Пример #1
0
  private Control createToolBar(Composite parent) {
    toolBar = new ToolBarManager();

    picker = new ColorPicker(configurer.getPopupStyle(), configurer.getPalette());
    configureColorPicker(picker);

    toolBar.add(picker);
    toolBar.createControl(parent);
    return toolBar.getControl();
  }
Пример #2
0
 private void setValueToPicker(Object value) {
   ISelection selection;
   if (configurer.isNoneValueSet()
       && (configurer.getNoneValue() == value
           || (configurer.getNoneValue() != null && configurer.getNoneValue().equals(value)))) {
     selection = new ColorSelection(ColorSelection.NONE);
   } else if (configurer.isAutoValueSet()
       && (configurer.getAutoValue() == value
           || (configurer.getAutoValue() != null && configurer.getAutoValue().equals(value)))) {
     selection = new ColorSelection(ColorSelection.AUTO);
   } else if (value instanceof String) {
     RGB color = ColorUtils.toRGB((String) value);
     selection = color == null ? ColorSelection.EMPTY : new ColorSelection(color);
   } else if (value instanceof RGB) {
     selection = new ColorSelection((RGB) value);
   } else {
     selection = ColorSelection.EMPTY;
   }
   picker.setSelection(selection);
 }
Пример #3
0
 /** @param picker */
 private void configureColorPicker(ColorPicker picker) {
   picker.setAutoColor(configurer.getAutoColor());
   picker.addOpenListener(
       new IOpenListener() {
         public void open(OpenEvent event) {
           ColorSelection selection = (ColorSelection) event.getSelection();
           Object value;
           if (selection.isNone()) {
             value = configurer.getNoneValue();
           } else if (selection.isAutomatic()) {
             value = configurer.getAutoValue();
           } else {
             RGB color = selection.getColor();
             value = color == null ? null : ColorUtils.toString(color);
           }
           setValueToText(value);
           changeValue(value);
           fireApplyEditorValue();
         }
       });
 }