Search in sources :

Example 1 with ColorChooser

use of org.polymap.core.style.ui.ColorChooser in project polymap4-core by Polymap4.

the class ConstantColorEditor method createContents.

@Override
public Composite createContents(Composite parent) {
    Composite contents = super.createContents(parent);
    final Button button = new Button(parent, SWT.FLAT | SWT.LEFT);
    button.setText(i18n.get("choose"));
    button.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            ColorChooser cc = new ColorChooser(new RGB(prop.get().r.get(), prop.get().g.get(), prop.get().b.get()));
            UIService.instance().openDialog(cc.title(), dialogParent -> {
                cc.createContents(dialogParent);
            }, () -> {
                RGB rgb = cc.getRGB();
                prop.get().r.set(rgb.red);
                prop.get().b.set(rgb.blue);
                prop.get().g.set(rgb.green);
                updateButtonColor(button, rgb);
                return true;
            });
        }
    });
    updateButtonColor(button, new RGB(prop.get().r.get(), prop.get().g.get(), prop.get().b.get()));
    return contents;
}
Also used : Color(java.awt.Color) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StylePropertyFieldSite(org.polymap.core.style.ui.StylePropertyFieldSite) Button(org.eclipse.swt.widgets.Button) StylePropertyEditor(org.polymap.core.style.ui.StylePropertyEditor) ValueInitializer(org.polymap.model2.runtime.ValueInitializer) ConstantColor(org.polymap.core.style.model.feature.ConstantColor) IMessages(org.polymap.core.runtime.i18n.IMessages) ColorChooser(org.polymap.core.style.ui.ColorChooser) UIService(org.polymap.core.style.ui.UIService) Composite(org.eclipse.swt.widgets.Composite) SWT(org.eclipse.swt.SWT) UIUtils(org.polymap.core.ui.UIUtils) RGB(org.eclipse.swt.graphics.RGB) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Messages(org.polymap.core.style.Messages) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ColorChooser(org.polymap.core.style.ui.ColorChooser) SelectionEvent(org.eclipse.swt.events.SelectionEvent) RGB(org.eclipse.swt.graphics.RGB)

Aggregations

Color (java.awt.Color)1 SWT (org.eclipse.swt.SWT)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 RGB (org.eclipse.swt.graphics.RGB)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 IMessages (org.polymap.core.runtime.i18n.IMessages)1 Messages (org.polymap.core.style.Messages)1 ConstantColor (org.polymap.core.style.model.feature.ConstantColor)1 ColorChooser (org.polymap.core.style.ui.ColorChooser)1 StylePropertyEditor (org.polymap.core.style.ui.StylePropertyEditor)1 StylePropertyFieldSite (org.polymap.core.style.ui.StylePropertyFieldSite)1 UIService (org.polymap.core.style.ui.UIService)1 UIUtils (org.polymap.core.ui.UIUtils)1 ValueInitializer (org.polymap.model2.runtime.ValueInitializer)1