You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/client/coding/Adding-a-Button-to-the-Perspective-Switcher.md
+40-1
Original file line number
Diff line number
Diff line change
@@ -347,6 +347,45 @@ by default this value is set to true and so perspectives are displayed.
347
347
348
348
To subsequently display the perspective run IBEX and go to the perspective window (CTRL + ALT + P) then enable the checkbox in ISIS Perspectives. On the next restart of the GUI your perspective should be displayed.
349
349
350
-
### Troubleshooting
350
+
## Adding a button to the E4 Perspective switcher
351
+
352
+
### Migrating an E3 perspective to E4
353
+
354
+
1. Open the Application.e4xmi from `uk.ac.stfc.isis.ibex.e4.client`
355
+
1. Go to `Snippets`
356
+
1. Click `Add` to add a new perspective
357
+
1. Set the perspective up using an existing migrated perspective as a template
358
+
1. Set a sensible ID
359
+
1. Give it a label
360
+
1. If you want your perspective to be invisible toggle the visible checkbox
361
+
1. Set the icon
362
+
1. Add controls. This should be a hierarchy of part sash containers. You can see how it should be set up from the existing perspectives. Don't forget to set the container data where appropriate; it sets the relative size of sibling components.
363
+
1. Add the perspective-specific parts
364
+
1. In the alarms perspective, you'll see one part in the final part sash container called alarms. Do the same thing in your new perspective, but give it an appropriate name
365
+
1. Change the ID of your new part to the ID of the view class you want the perspective to open
366
+
1. Add the dependency of the view you've added to the `plugin.xml` in the `...e4.client` plugin
367
+
1. Add the new dependency to `...feature.xml` (in `uk.ac.stfc.isis.ibex.feature.base`)
368
+
1. Synchronize `ibex.product` (in `...e4.client.product`)
369
+
1. Open IBEX
370
+
1. Check the new perspective scales appropriately and change the layout accordingly if needed
371
+
372
+
### Creating a brand new E4 perspective
373
+
374
+
Making a brand new E4 perspective would probably look similar to the steps above, minus the E3 steps. However, a new E4 perspective has yet to been attempted.
375
+
376
+
### Hiding Perspectives
377
+
378
+
Perspectives can be hidden by adding perspective IDs to the Eclipse preference store at the preference key `uk.ac.stfc.isis.ibex.preferences/perspectives_not_shown` (at `/uk.ac.stfc.isis.ibex.e4.client/plugin_customization.ini`). e.g.
If the perspective is not being shown in the switcher at the side it may be Eclipse being silly or you may not be running the right product. Be sure to re-run by going selecting the client product, rather than using the drop-down (which will run the same product as you used previously) Finally, try clearing the workspace and resetting the target platform etc.
Copy file name to clipboardExpand all lines: doc/client/coding/Adding-a-Plugin-or-Feature-to-Maven-Build.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Adding a plugin or feature to Maven
1
+
# Adding a plugin or feature
2
2
3
3
The steps for adding a plug-in (one small part of IBEX, such as the blocks view) or feature (a larger collection of plug-ins, such as CSS) to the maven build are below:
`ListViewer` is a wrapper around the List control that provides extra functionality and `ObservableListContentProvider` make the databinding work.
387
+
`ListViewer` is a wrapper around the List control that provides extra functionality and `ObservableListContentProvider` make the databinding work.
388
+
389
+
## Troubleshooting
390
+
391
+
### Missing getter or setter (or incorrectly named)
392
+
393
+
The getter and setters (if the value can be set from the UI) must exist and be named correctly. For example: `getName` and `setName` for `BeanProperties.value("name")`.
394
+
395
+
Behind the scenes the databinding library automatically changes the first character to upper-case and then prepends "get" and "set".
396
+
397
+
### Incorrectly cased string in binding
398
+
399
+
With something like the following it is import that the name of the property to bind to is cased correctly:
The 'f' of "fedId" is lower-case. It will not work if it is upper-case.
416
+
:::
417
+
418
+
### The getter or setter "silently" throws an exception
419
+
420
+
If any code in the getter throws an unhandled exception then the binding won't work because the value cannot be read.
421
+
If a setter throws an unhandled exception before the firing the property change then the listeners will not receive the change signal. Both result in the binding being broken.
422
+
423
+
If a binding seems to work intermittently then there might be something in the getter or setter causing this, e.g. an object used in a getter that switches between being null and initialised based on something else.
424
+
425
+
The exceptions will appear in the console inside Eclipse and IBEX, but won't cause an error pop-up to appear.
426
+
427
+
### The binding works but the initial value is not put in the widget
428
+
429
+
When the binding first happens it will call the getter to set the widget properties to whatever is in the model.
430
+
If this doesn't happen, the getter is probably non-existent or not implemented correctly.
int seconds_per_hour =60*60; // Magic numbers and a bad variable name
113
-
return hours * seconds_per_hour;
114
-
}
115
-
```
116
-
## Naming conventions ##
117
-
118
-
### General ###
119
-
120
-
In general we use the standard Java naming conventions, e.g.:
121
-
122
-
* Class names are CamelCase and usually nouns, e.g. `FileReader` not `ReadsFile`
123
-
124
-
* Method names are Mixed Case (also known as Lower CamelCase), e.g. `sayHello`
125
-
126
-
* Package names are lowercase, e.g. `uk.ac.stfc.isis.dae`
127
-
128
-
* Variable names are Mixed Case, e.g. `calculateMeanSpeed`
129
-
130
-
* Constants are uppercase spaced by underscores, e.g. `SECONDS_PER_FORTNIGHT`
131
-
132
-
### Getters and Setters ###
100
+
### Getters and Setters
133
101
134
102
Getters and Setters should follow the JavaBeans convention, namely:
135
103
@@ -163,45 +131,34 @@ class Point {
163
131
}
164
132
```
165
133
166
-
## Coding Conventions ##
134
+
## Coding Conventions
167
135
168
-
A mix of IBEX specific and general Java coding conventions.
169
-
170
-
### GUI code must use a View Model ###
136
+
### GUI code should use a model-view-viewmodel (MVVM) pattern
171
137
172
138
This maintains a separation between pure GUI code and the back-end. It also makes it easier for us to test our code.
173
-
See the previous GUI Chat slides for more information.
174
-
175
-
Some legacy code does not have a View Model, this is on the list to fix.
139
+
See the [previous GUI Chat slides](/processes/meetings/Code-Chats-and-Lightning-Talks) for more information.
176
140
177
-
### Use data-binding for GUI items ###
141
+
### Use data-binding for GUI items
178
142
179
-
~~For connecting UI elements to data from the View Model use data-binding.
180
-
It seems that if a mix of data-binding and more traditional SWT wiring up is used (e.g. AddPropertyChangeListener) then the data-binding will stop working*, so always using data-binding should avoid this problem.~~
143
+
For connecting UI elements to data from the View Model, prefer to use [databinding](Databinding) where possible.
181
144
182
-
~~*This does need more investigation to find out why it occurs.~~
145
+
### Don't mess with finalizers
183
146
184
-
This no longer seems to apply.
185
-
186
-
### Don't mess with finalizers ###
187
-
From the Google Java Style Guide:
188
-
189
-
```
190
-
It is extremely rare to override Object.finalize.
191
-
192
-
Tip: Don't do it. If you absolutely must, first read and understand Effective Java Item 7, "Avoid Finalizers," very carefully, and then don't do it.
193
-
```
194
-
195
-
As of Java 9, `finalize` is officially deprecated in java. The IBEX checkstyle configuration is configured to disallow finalizers - this check should not be disabled or overridden.
147
+
In Java versions >=9, `finalize` is deprecated and marked for removal from Java. The IBEX checkstyle configuration
148
+
is configured to disallow finalizers - this check must not be disabled or overridden.
196
149
197
150
The remaining options for supported clean-up mechanisms (in preference order) are:
198
-
- Implement `autocloseable` and use the class in a try-with-resources statement to ensure the relevant resource is closed
199
-
- Use a `closeable` and manually call `close` to ensure the relevant resource is closed
151
+
- Implement `AutoCloseable` and use the class in a try-with-resources statement to ensure the relevant resource is closed
152
+
- Use a `Closeable` and manually call `close` to ensure the relevant resource is closed
200
153
- Refactor to avoid needing to close the resource at all
201
-
- Use a *supported* automatic clean-up mechanism such as `PhantomReference` or `Cleaner` only as a last resort. While these are *better* than finalizers, they still suffer from high complexity and are tricky to get right. In particular it is easy to accidentally create reference loops meaning that objects will never be cleaned.
154
+
- Use a *supported* automatic clean-up mechanism such as `PhantomReference` or `Cleaner` only as a last resort.
155
+
While these are *better* than finalizers, they still suffer from high complexity and are tricky to get right.
156
+
In particular, it is easy to accidentally create reference loops meaning that objects will never be cleaned.
157
+
158
+
### Return a empty collection or stream, not null
202
159
203
-
### Return a empty collection or stream, not null ###
204
-
For methods that return arrays/lists/maps/sets/streams etc. don't return null. It is cleaner to return an empty instance as the calling code does not need to check for null.
160
+
For methods that return arrays/lists/maps/sets/streams etc. don't return null. It is cleaner to return an empty
161
+
instance as the calling code does not need to check for null.
Using `+` is fine for, say, joining two or three short strings but it is inefficient for larger numbers of strings and longer strings. UseStringBuilder instead.
171
+
### PreferStringBuilderfor string concatenation
172
+
173
+
Using `+` is fine for, say, joining two or three short strings, but it is inefficient for larger numbers of strings and
174
+
longer strings. Use `StringBuilder` instead.
216
175
217
176
SeeEffectiveJavaItem51"Beware the performance of string concatenation"
218
177
219
178
### Prefer `Optional` over `null`
220
179
221
-
NewAPIs should not returnnull to indicate a missing value. Instead, return an Optional wrapping the value which may not exist. Where external code returns null to indicate a missing value, this should be wrapped in an optional as soon as reasonable.
180
+
NewAPIs should not returnnull to indicate a missing value. Instead, return an `Optional` wrapping the value which may
181
+
not exist. Where external code returns null to indicate a missing value, this should be wrapped in an optional as soon
182
+
as reasonable.
222
183
223
184
To convert a maybe-null value to an optional, use:
0 commit comments