Exemple #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 line color to that in the model, or failing that, as per default */
 protected void setLineColor() {
   String val = fDiagramModelObject.getLineColor();
   Color c = ColorFactory.get(val);
   if (c != fLineColor) {
     fLineColor = c;
     repaint();
   }
 }
  /** Set the font to that in the model, or failing that, as per user's default */
  protected void setFont() {
    String fontName = fDiagramModelObject.getFont();
    setFont(FontFactory.get(fontName));

    // Need to do this after font change
    if (getTextControl() != null) {
      getTextControl().revalidate();
    }
  }
 /** Set the font color to that in the model, or failing that, as per default */
 protected void setFontColor() {
   String val = fDiagramModelObject.getFontColor();
   Color c = ColorFactory.get(val);
   if (c != fFontColor) {
     fFontColor = c;
     if (getTextControl() != null) {
       getTextControl().setForegroundColor(c);
     }
   }
 }
  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);
  }