Пример #1
0
  @Override
  public void run() {
    List<?> selection = getSelectedObjects();

    IDiagramModelObject model = (IDiagramModelObject) getFirstValidSelectedModelObject(selection);
    if (model == null) {
      return;
    }

    ColorDialog colorDialog = new ColorDialog(getWorkbenchPart().getSite().getShell());

    // Set default RGB on first selected object
    RGB defaultRGB = null;

    String s = model.getFillColor();
    if (s == null) {
      defaultRGB = ColorFactory.getDefaultFillColor(model).getRGB();
    } else {
      defaultRGB = ColorFactory.convertStringToRGB(s);
    }

    if (defaultRGB != null) {
      colorDialog.setRGB(defaultRGB);
    }

    RGB newColor = colorDialog.open();
    if (newColor != null) {
      execute(createCommand(selection, newColor));
    }
  }
 /** Set the fill color to that in the model, or failing that, as per default */
 protected void setFillColor() {
   String val = fDiagramModelObject.getFillColor();
   Color c = ColorFactory.get(val);
   if (c != fFillColor) {
     fFillColor = c;
     repaint();
   }
 }
Пример #3
0
  protected void refreshControls() {
    String colorValue = fDiagramModelObject.getFillColor();
    RGB rgb = ColorFactory.convertStringToRGB(colorValue);
    if (rgb == null) {
      rgb = ColorFactory.getDefaultFillColor(fDiagramModelObject).getRGB();
    }

    fColorChooser.setColorValue(rgb);

    boolean enabled =
        fDiagramModelObject instanceof ILockable
            ? !((ILockable) fDiagramModelObject).isLocked()
            : true;
    fColorChooser.setEnabled(enabled);

    // If user pref is to save the color then it's a different meaning of default
    boolean isDefaultColor = (colorValue == null);
    if (Preferences.STORE.getBoolean(IPreferenceConstants.SAVE_USER_DEFAULT_COLOR)) {
      isDefaultColor =
          (colorValue != null)
              && rgb.equals(ColorFactory.getDefaultFillColor(fDiagramModelObject).getRGB());
    }
    fColorChooser.setIsDefaultColor(isDefaultColor);
  }