+ // Highlight style
+ Label label = new Label(content, SWT.NONE);
+ GridDataFactory.swtDefaults().applyTo(label);
+ label.setText("Highlight color");
+
+ colorCombo = new TableCombo(content, SWT.BORDER | SWT.READ_ONLY);
+ GridDataFactory.swtDefaults().hint(80, SWT.DEFAULT).applyTo(colorCombo);
+ Table colorTable = colorCombo.getTable();
+ colorCombo.getTextControl().setEnabled(false);
+ Display display = getShell().getDisplay();
+ colorTable.setFont(display.getSystemFont());
+ createColorItem(colorTable, "Red", SWT.COLOR_RED);
+ createColorItem(colorTable, "Green", SWT.COLOR_GREEN);
+ createColorItem(colorTable, "Blue", SWT.COLOR_BLUE);
+ createColorItem(colorTable, "Yellow", SWT.COLOR_YELLOW);
+ createColorItem(colorTable, "Cyan", SWT.COLOR_CYAN);
+ createColorItem(colorTable, "Magenta", SWT.COLOR_MAGENTA);
+ TableItem other = new TableItem(colorTable, SWT.NONE);
+ other.setText("Other...");
+
+ if (color != null) {
+ int i;
+ for (i = 0; i < 6; i++) {
+ if (colorTable.getItem(i).getBackground().getRGB().equals(color.getRgb())) {
+ colorCombo.select(i);
+ break;
+ }
+ }
+
+ if (i == 6) {
+ other.setBackground(resourceManager.createColor(color.getRgb()));
+ colorCombo.select(6);
+ }
+ }
+
+ colorCombo.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ int index = colorCombo.getSelectionIndex();
+ if (index == 6) {
+ org.simantics.utils.ui.color.ColorDialog colorDialog = new org.simantics.utils.ui.workbench.dialogs.ColorDialog(getParentShell());
+ int result = colorDialog.open();
+ if (result == Window.OK) {
+ other.setBackground(resourceManager.createColor(colorDialog.getColor().getRgb()));
+ colorCombo.clearSelection();
+ colorCombo.select(6);
+ colorTable.redraw();
+ }
+ }
+ }
+ });
+