Search in sources :

Example 26 with ColorDialog

use of org.eclipse.swt.widgets.ColorDialog in project portfolio by buchen.

the class DefinitionViewer method doEditColor.

private void doEditColor(TaxonomyNode node) {
    RGB oldColor = Colors.toRGB(node.getClassification().getColor());
    ColorDialog colorDialog = new ColorDialog(getNodeViewer().getControl().getShell());
    colorDialog.setRGB(oldColor);
    RGB newColor = colorDialog.open();
    if (newColor != null && !newColor.equals(oldColor)) {
        String hex = Colors.toHex(newColor);
        node.getClassification().setColor(hex);
        // use same color for virtual and classification root nodes
        if (node.getParent().isRoot())
            node.getParent().getClassification().setColor(hex);
        getModel().fireTaxonomyModelChange(node);
        getModel().markDirty();
    }
}
Also used : ColorDialog(org.eclipse.swt.widgets.ColorDialog) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

ColorDialog (org.eclipse.swt.widgets.ColorDialog)26 RGB (org.eclipse.swt.graphics.RGB)22 Button (org.eclipse.swt.widgets.Button)12 Composite (org.eclipse.swt.widgets.Composite)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 Color (org.eclipse.swt.graphics.Color)9 GridData (org.eclipse.swt.layout.GridData)9 GridLayout (org.eclipse.swt.layout.GridLayout)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)8 Label (org.eclipse.swt.widgets.Label)8 Shell (org.eclipse.swt.widgets.Shell)8 Text (org.eclipse.swt.widgets.Text)8 FontData (org.eclipse.swt.graphics.FontData)7 FontDialog (org.eclipse.swt.widgets.FontDialog)7 Combo (org.eclipse.swt.widgets.Combo)5 Command (org.eclipse.gef.commands.Command)4 FileDialog (org.eclipse.swt.widgets.FileDialog)4 Group (org.eclipse.swt.widgets.Group)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3