- colorSizeCombo.setItems(Stream.of(ColorBarsSize.values()).map(size -> size.toString()).toArray(String[]::new));
-
- Button applyButton = new Button(parent, SWT.NONE);
- applyButton.setText("Apply");
-
- applyButton.addSelectionListener(new SelectionAdapter() {
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- // persist changes
- IEditorPart activeEditor = WorkbenchUtils.getActiveEditor();
- if (activeEditor instanceof IResourceEditorPart) {
-
- String colorLocation = colorLocationCombo.getItem(colorLocationCombo.getSelectionIndex());
- String colorSize = colorSizeCombo.getItem(colorSizeCombo.getSelectionIndex());
-
- ColorBarOptions options = new ColorBarOptions()
- .showColorBars(showColorButton.getSelection())
- .showColorBarsTicks(colorTicksButton.getSelection())
- .withLocation(ColorBarsLocation.valueOf(colorLocation))
- .withSize(ColorBarsSize.valueOf(colorSize));
-
- Simantics.getSession().asyncRequest(new WriteRequest() {
-
- @Override
- public void perform(WriteGraph graph) throws DatabaseException {
- DistrictNetworkUtil.setColorBarOptions(graph, visualisation.getVisualisationResource(), options);
- }
- });
- }
- }
- });
+ String[] colorSizeItems = Stream.of(ColorBarsSize.values()).map(size -> size.toString()).toArray(String[]::new);
+ colorSizeCombo.setItems(colorSizeItems);
+ if (colorSizeItems.length > 0) {
+ colorSizeCombo.select(0);
+ }