/** @generated */
  public Node createPersistentTable_2003(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Node node = NotationFactory.eINSTANCE.createNode();
    node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
    node.getStyles().add(NotationFactory.eINSTANCE.createLineStyle());
    node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle());

    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(SqlmodelVisualIDRegistry.getType(PersistentTable2EditPart.VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    org.eclipse.swt.graphics.RGB fillRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getFillStyle_FillColor(),
        FigureUtilities.RGBToInteger(fillRGB));
    return node;
  }
  /** @generated */
  public Edge createAssociation_4001(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Connector edge = NotationFactory.eINSTANCE.createConnector();
    edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
    RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
    ArrayList<RelativeBendpoint> points = new ArrayList<RelativeBendpoint>(2);
    points.add(new RelativeBendpoint());
    points.add(new RelativeBendpoint());
    bendpoints.setPoints(points);
    edge.setBendpoints(bendpoints);
    ViewUtil.insertChildView(containerView, edge, index, persisted);
    edge.setType(
        edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
            .NECSIS14_ClassDiagramVisualIDRegistry.getType(
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                .AssociationEditPart.VISUAL_ID));
    edge.setElement(domainElement);
    // initializePreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        edge,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (edgeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      edgeFontStyle.setFontName(fontData.getName());
      edgeFontStyle.setFontHeight(fontData.getHeight());
      edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE));
    if (routing != null) {
      ViewUtil.setStructuralFeatureValue(
          edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
    }
    Node label6001 =
        createLabel(
            edge,
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
                .NECSIS14_ClassDiagramVisualIDRegistry.getType(
                edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                    .AssociationNameEditPart.VISUAL_ID));
    label6001.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
    Location location6001 = (Location) label6001.getLayoutConstraint();
    location6001.setX(0);
    location6001.setY(40);
    return edge;
  }
  /**
   * initialize the background for a graphical element
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initBackgroundFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    if (!usePreferenceInitializer(view)) {
      return;
    }

    String fillColorConstant =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FILL);
    String gradientColorConstant =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_GRADIENT);
    String gradientPolicyConstant =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.GRADIENT_POLICY);
    String shadowConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.SHADOW);
    String elementIcon = getpreferenceKey(view, elementName, PreferenceConstantHelper.ELEMENTICON);
    String qualifiedName =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.QUALIFIEDNAME);

    org.eclipse.swt.graphics.RGB fillRGB = PreferenceConverter.getColor(store, fillColorConstant);
    ViewUtil.setStructuralFeatureValue(
        view,
        NotationPackage.eINSTANCE.getFillStyle_FillColor(),
        FigureUtilities.RGBToInteger(fillRGB));

    FillStyle fillStyle = (FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE);
    fillStyle.setFillColor(FigureUtilities.RGBToInteger(fillRGB).intValue());

    if (store.getBoolean(gradientPolicyConstant)) {
      GradientPreferenceConverter gradientPreferenceConverter =
          new GradientPreferenceConverter(store.getString(gradientColorConstant));
      fillStyle.setGradient(gradientPreferenceConverter.getGradientData());
      fillStyle.setTransparency(gradientPreferenceConverter.getTransparency());
    }

    EditingDomain domain = EMFHelper.resolveEditingDomain(view);
    if (domain instanceof TransactionalEditingDomain) {
      TransactionalEditingDomain editingDomain = (TransactionalEditingDomain) domain;
      // shadow
      RecordingCommand shadowcommand =
          AnnotationStyleProvider.getSetShadowCommand(
              editingDomain, view, store.getBoolean(shadowConstant));
      if (shadowcommand.canExecute()) {
        shadowcommand.execute();
      }
      // icon label
      RecordingCommand namelabelIconCommand =
          AnnotationStyleProvider.getSetElementIconCommand(
              editingDomain, view, store.getBoolean(elementIcon));
      if (namelabelIconCommand.canExecute()) {
        namelabelIconCommand.execute();
      }
      // qualified name
      if (!store.getBoolean(qualifiedName)) {
        RecordingCommand qualifiedNameCommand =
            AnnotationStyleProvider.getSetQualifiedNameDepthCommand(editingDomain, view, 1000);
        if (qualifiedNameCommand.canExecute()) {
          qualifiedNameCommand.execute();
        }
      }
    }
  }
  /** @generated */
  public Node createViewTable_1002(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Node node = NotationFactory.eINSTANCE.createNode();
    node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
    node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());

    FillStyle fillStyle = NotationFactory.eINSTANCE.createFillStyle();
    Color color = ViewTableEditPart.getDeclaredBackgroundColor();
    fillStyle.setFillColor(FigureUtilities.colorToInteger(color));
    node.getStyles().add(fillStyle);
    LineStyle lineStyle = NotationFactory.eINSTANCE.createLineStyle();
    lineStyle.setLineColor(FigureUtilities.RGBToInteger(new org.eclipse.swt.graphics.RGB(0, 0, 0)));
    node.getStyles().add(lineStyle);

    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(SqlmodelVisualIDRegistry.getType(ViewTableEditPart.VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    stampShortcut(containerView, node);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
    FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (nodeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      nodeFontStyle.setFontName(fontData.getName());
      nodeFontStyle.setFontHeight(fontData.getHeight());
      nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    Node label4002 =
        createLabel(node, SqlmodelVisualIDRegistry.getType(ViewTableNameEditPart.VISUAL_ID));
    createCompartment(
        node,
        SqlmodelVisualIDRegistry.getType(ViewTableViewedColumnsEditPart.VISUAL_ID),
        false,
        false,
        true,
        true);
    createCompartment(
        node,
        SqlmodelVisualIDRegistry.getType(ViewTableViewedTablesEditPart.VISUAL_ID),
        false,
        false,
        true,
        true);
    return node;
  }
  /** @generated */
  public Node createAttribute_3001(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Shape node = NotationFactory.eINSTANCE.createShape();
    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(
        edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
            .NECSIS14_ClassDiagramVisualIDRegistry.getType(
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.AttributeEditPart
                .VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (nodeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      nodeFontStyle.setFontName(fontData.getName());
      nodeFontStyle.setFontHeight(fontData.getHeight());
      nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    org.eclipse.swt.graphics.RGB fillRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getFillStyle_FillColor(),
        FigureUtilities.RGBToInteger(fillRGB));
    Node label5001 =
        createLabel(
            node,
            edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
                .NECSIS14_ClassDiagramVisualIDRegistry.getType(
                edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                    .AttributeNameEditPart.VISUAL_ID));
    return node;
  }
  /** @generated */
  @Override
  protected void handleNotificationEvent(Notification notification) {
    super.handleNotificationEvent(notification);

    if (notification.getNotifier() instanceof de.uni_mannheim.informatik.swt.models.plm.PLM.Feature
        && ((EStructuralFeature) notification.getFeature()).getName().equals("expressed")) {
      IGraphicalEditPart parent = (IGraphicalEditPart) getParent();
      de.uni_mannheim.informatik.swt.models.plm.PLM.Element self =
          (de.uni_mannheim.informatik.swt.models.plm.PLM.Element) resolveSemanticElement();

      // Check is visible
      if (parent.resolveSemanticElement()
          instanceof de.uni_mannheim.informatik.swt.models.plm.PLM.Context) {
        de.uni_mannheim.informatik.swt.models.plm.PLM.Context container =
            (de.uni_mannheim.informatik.swt.models.plm.PLM.Context) parent.resolveSemanticElement();
        if ((container.getOrigin().equalsIgnoreCase("computed") && self.isExpressed())
            || (container.getOrigin().equalsIgnoreCase("expressed") && !self.isExpressed())) {
          getNotationView().setVisible(false);
        }
      } else {
        getNotationView().setVisible(true);
      }

      de.uni_mannheim.informatik.swt.models.plm.PLM.Feature f =
          (de.uni_mannheim.informatik.swt.models.plm.PLM.Feature) resolveSemanticElement();
      if (f.isExpressed()) {
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView()).setItalic(false);
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView()).setFontColor(0);
      } else {
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView()).setItalic(true);
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView())
            .setFontColor(FigureUtilities.colorToInteger(DiagramColorConstants.diagramGray));
      }
    }
  }
 /** @generated */
 public Edge createViewTableViewedTables_3002(
     View containerView, int index, boolean persisted, PreferencesHint preferencesHint) {
   Edge edge = NotationFactory.eINSTANCE.createEdge();
   edge.getStyles().add(NotationFactory.eINSTANCE.createRoutingStyle());
   edge.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
   RelativeBendpoints bendpoints = NotationFactory.eINSTANCE.createRelativeBendpoints();
   ArrayList points = new ArrayList(2);
   points.add(new RelativeBendpoint());
   points.add(new RelativeBendpoint());
   bendpoints.setPoints(points);
   edge.setBendpoints(bendpoints);
   ViewUtil.insertChildView(containerView, edge, index, persisted);
   edge.setType(SqlmodelVisualIDRegistry.getType(ViewTableViewedTables2EditPart.VISUAL_ID));
   edge.setElement(null);
   // initializePreferences
   final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
   FontStyle edgeFontStyle = (FontStyle) edge.getStyle(NotationPackage.Literals.FONT_STYLE);
   if (edgeFontStyle != null) {
     FontData fontData =
         PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
     edgeFontStyle.setFontName(fontData.getName());
     edgeFontStyle.setFontHeight(fontData.getHeight());
     edgeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
     edgeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
     org.eclipse.swt.graphics.RGB fontRGB =
         PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
     edgeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
   }
   Routing routing = Routing.get(prefStore.getInt(IPreferenceConstants.PREF_LINE_STYLE));
   if (routing != null) {
     ViewUtil.setStructuralFeatureValue(
         edge, NotationPackage.eINSTANCE.getRoutingStyle_Routing(), routing);
   }
   return edge;
 }
  protected Declaration handleStyleFeature(Style style, EStructuralFeature feature) {
    Declaration declaration = CssFactory.eINSTANCE.createDeclaration();
    declaration.setProperty(feature.getName());

    GMFToCSSConverter converter = GMFToCSSConverter.instance;

    if (isString(feature)) {
      declaration.setExpression(converter.convert((String) style.eGet(feature)));
    }

    if (isInteger(feature)) {
      if (feature.getName().endsWith("Color")) {
        Color color = FigureUtilities.integerToColor((Integer) style.eGet(feature));
        declaration.setExpression(converter.convert(color));
        color.dispose();
      } else {
        declaration.setExpression(converter.convert((Integer) style.eGet(feature)));
      }
    }

    if (feature.getEType() == NotationPackage.eINSTANCE.getGradientData()) {
      declaration.setExpression(converter.convert((GradientData) style.eGet(feature)));
    }

    if (feature.getEType() instanceof EEnum) {
      declaration.setExpression(converter.convert((Enumerator) style.eGet(feature)));
    }

    if (isBoolean(feature)) {
      declaration.setExpression(converter.convert((Boolean) style.eGet(feature)));
    }

    return declaration;
  }
Exemple #9
0
  /** @generated */
  public Node createStakeHolder_2011(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Shape node = NotationFactory.eINSTANCE.createShape();
    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(RdalVisualIDRegistry.getType(StakeHolderEditPart.VISUAL_ID));
    ViewUtil.insertChildView(containerView, node, index, persisted);
    node.setElement(domainElement);
    stampShortcut(containerView, node);
    // initializeFromPreferences
    final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();

    org.eclipse.swt.graphics.RGB lineRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_LINE_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
    FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (nodeFontStyle != null) {
      FontData fontData =
          PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
      nodeFontStyle.setFontName(fontData.getName());
      nodeFontStyle.setFontHeight(fontData.getHeight());
      nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
      org.eclipse.swt.graphics.RGB fontRGB =
          PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
      nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
    org.eclipse.swt.graphics.RGB fillRGB =
        PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
    ViewUtil.setStructuralFeatureValue(
        node,
        NotationPackage.eINSTANCE.getFillStyle_FillColor(),
        FigureUtilities.RGBToInteger(fillRGB));
    Node label5018 =
        createLabel(node, RdalVisualIDRegistry.getType(StakeHolderNameEditPart.VISUAL_ID));
    label5018.setLayoutConstraint(NotationFactory.eINSTANCE.createLocation());
    Location location5018 = (Location) label5018.getLayoutConstraint();
    location5018.setX(0);
    location5018.setY(5);
    return node;
  }
Exemple #10
0
 /** @generated */
 public Node createRequirementsGroup_2007(
     EObject domainElement,
     View containerView,
     int index,
     boolean persisted,
     PreferencesHint preferencesHint) {
   Node node = NotationFactory.eINSTANCE.createNode();
   node.getStyles().add(NotationFactory.eINSTANCE.createDescriptionStyle());
   node.getStyles().add(NotationFactory.eINSTANCE.createFontStyle());
   node.getStyles().add(NotationFactory.eINSTANCE.createFillStyle());
   node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
   node.setType(RdalVisualIDRegistry.getType(RequirementsGroupEditPart.VISUAL_ID));
   ViewUtil.insertChildView(containerView, node, index, persisted);
   node.setElement(domainElement);
   stampShortcut(containerView, node);
   // initializeFromPreferences
   final IPreferenceStore prefStore = (IPreferenceStore) preferencesHint.getPreferenceStore();
   FontStyle nodeFontStyle = (FontStyle) node.getStyle(NotationPackage.Literals.FONT_STYLE);
   if (nodeFontStyle != null) {
     FontData fontData =
         PreferenceConverter.getFontData(prefStore, IPreferenceConstants.PREF_DEFAULT_FONT);
     nodeFontStyle.setFontName(fontData.getName());
     nodeFontStyle.setFontHeight(fontData.getHeight());
     nodeFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
     nodeFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);
     org.eclipse.swt.graphics.RGB fontRGB =
         PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FONT_COLOR);
     nodeFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
   }
   org.eclipse.swt.graphics.RGB fillRGB =
       PreferenceConverter.getColor(prefStore, IPreferenceConstants.PREF_FILL_COLOR);
   ViewUtil.setStructuralFeatureValue(
       node,
       NotationPackage.eINSTANCE.getFillStyle_FillColor(),
       FigureUtilities.RGBToInteger(fillRGB));
   Node label5013 =
       createLabel(node, RdalVisualIDRegistry.getType(RequirementsGroupNameEditPart.VISUAL_ID));
   createCompartment(
       node,
       RdalVisualIDRegistry.getType(RequirementsGroupRequirementsCompartmentEditPart.VISUAL_ID),
       true,
       false,
       false,
       false);
   return node;
 }
  @Override
  protected void initializeFromPreferences(View view) {
    super.initializeFromPreferences(view);
    IPreferenceStore store = (IPreferenceStore) getPreferencesHint().getPreferenceStore();
    if (store == null) {
      return;
    }

    // Create region default styles
    ShapeStyle style = (ShapeStyle) view.getStyle(NotationPackage.Literals.SHAPE_STYLE);
    RGB fillRGB =
        PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_REGION_BACKGROUND);
    style.setFillColor(FigureUtilities.RGBToInteger(fillRGB));
    RGB lineRGB =
        PreferenceConverter.getColor(store, StatechartPreferenceConstants.PREF_REGION_LINE);
    style.setLineColor(FigureUtilities.RGBToInteger(lineRGB));
  }
 /**
  * Updates the contents of this cell editor, i.e. the value of gradientLabel with the given value.
  * Parameter value is a string if this method is called when user selects the editor. Parameter
  * value is GradientData if this method is called after user changed gradient (after opening
  * GradientSelectionDialog from this cell editor)
  *
  * @see org.eclipse.jface.viewers.DialogCellEditor#updateContents(java.lang.Object)
  */
 protected void updateContents(Object value) {
   if (value == null) {
     gradientLabel.setText(StringStatics.BLANK);
   } else if (value instanceof String) {
     gradientLabel.setText((String) value);
   } else {
     // format GradientData to string:
     //  RGB {x,x,x),RGB {x,x,x},style
     // (the same as in NotationPropertyDescriptor.getPropertyValue())
     GradientData gradient = (GradientData) value;
     StringBuffer sf = new StringBuffer();
     sf.append(FigureUtilities.integerToRGB(gradient.getGradientColor1()));
     sf.append(',');
     sf.append(FigureUtilities.integerToRGB(gradient.getGradientColor2()));
     sf.append(',');
     sf.append(GradientStyle.get(gradient.getGradientStyle()));
     gradientLabel.setText(sf.toString());
   }
 }
  /**
   * initialize the foreground for a graphical element
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initForegroundFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    if (!usePreferenceInitializer(view)) {
      return;
    }

    String lineColorConstant =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_LINE);
    org.eclipse.swt.graphics.RGB lineRGB = PreferenceConverter.getColor(store, lineColorConstant);
    ViewUtil.setStructuralFeatureValue(
        view,
        NotationPackage.eINSTANCE.getLineStyle_LineColor(),
        FigureUtilities.RGBToInteger(lineRGB));
  }
  /** @generated */
  @Override
  public Object getPreferredValue(EStructuralFeature feature) {
    IPreferenceStore preferenceStore =
        (IPreferenceStore) getDiagramPreferencesHint().getPreferenceStore();
    Object result = null;

    if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()
        || feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()
        || feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) {
      String prefColor = null;
      if (feature == NotationPackage.eINSTANCE.getLineStyle_LineColor()) {
        prefColor =
            PreferenceConstantHelper.getElementConstant(
                "Metaclass", PreferenceConstantHelper.COLOR_LINE);
      } else if (feature == NotationPackage.eINSTANCE.getFontStyle_FontColor()) {
        prefColor =
            PreferenceConstantHelper.getElementConstant(
                "Metaclass", PreferenceConstantHelper.COLOR_FONT);
      } else if (feature == NotationPackage.eINSTANCE.getFillStyle_FillColor()) {
        prefColor =
            PreferenceConstantHelper.getElementConstant(
                "Metaclass", PreferenceConstantHelper.COLOR_FILL);
      }
      result =
          FigureUtilities.RGBToInteger(
              PreferenceConverter.getColor((IPreferenceStore) preferenceStore, prefColor));
    } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()
        || feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) {
      String prefGradient =
          PreferenceConstantHelper.getElementConstant(
              "Metaclass", PreferenceConstantHelper.COLOR_GRADIENT);
      GradientPreferenceConverter gradientPreferenceConverter =
          new GradientPreferenceConverter(preferenceStore.getString(prefGradient));
      if (feature == NotationPackage.eINSTANCE.getFillStyle_Transparency()) {
        result = new Integer(gradientPreferenceConverter.getTransparency());
      } else if (feature == NotationPackage.eINSTANCE.getFillStyle_Gradient()) {
        result = gradientPreferenceConverter.getGradientData();
      }
    }

    if (result == null) {
      result = getStructuralFeatureValue(feature);
    }
    return result;
  }
  /**
   * initialize the font for a graphical element
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initFontStyleFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    if (!usePreferenceInitializer(view)) {
      return;
    }

    String fontConstant = getpreferenceKey(view, elementName, PreferenceConstantHelper.FONT);
    String fontColorConstant =
        getpreferenceKey(view, elementName, PreferenceConstantHelper.COLOR_FONT);

    FontStyle viewFontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE);
    if (viewFontStyle != null) {
      FontData fontData = PreferenceConverter.getFontData(store, fontConstant);
      viewFontStyle.setFontName(fontData.getName());
      viewFontStyle.setFontHeight(fontData.getHeight());
      viewFontStyle.setBold((fontData.getStyle() & SWT.BOLD) != 0);
      viewFontStyle.setItalic((fontData.getStyle() & SWT.ITALIC) != 0);

      org.eclipse.swt.graphics.RGB fontRGB = PreferenceConverter.getColor(store, fontColorConstant);
      viewFontStyle.setFontColor(FigureUtilities.RGBToInteger(fontRGB).intValue());
    }
  }
 /** @generated NOT */
 protected void initializeFromPreferences(View view) {
   super.initializeFromPreferences(view);
   ((FillStyle) view.getStyle(NotationPackage.Literals.FILL_STYLE))
       .setFillColor(FigureUtilities.colorToInteger(DEFAULT_COLOR));
 }
 /**
  * Opens GradientSelectionDialog without transparency setting available, receives the return
  * values and uses them to create the resulting GradientData object.
  *
  * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
  */
 protected Object openDialogBox(Control cellEditorWindow) {
   String value = (String) getValue();
   RGB color1 = null, color2 = null;
   int gradientStyle = -1;
   // value is in format: RGB {x, x, x},RGB {x, x, x},style
   // parse it
   if (value != null) {
     StringTokenizer st = new StringTokenizer(value, ",{}"); // $NON-NLS-1$
     try {
       int red, green, blue;
       st.nextToken().trim(); // RGB string			
       // color1
       red = Integer.parseInt(st.nextToken().trim());
       green = Integer.parseInt(st.nextToken().trim());
       blue = Integer.parseInt(st.nextToken().trim());
       if (red > -1 && green > -1 && blue > -1) {
         color1 = new RGB(red, green, blue);
       }
       st.nextToken().trim(); // RGB string			
       // color2
       red = Integer.parseInt(st.nextToken().trim());
       green = Integer.parseInt(st.nextToken().trim());
       blue = Integer.parseInt(st.nextToken().trim());
       if (red > -1 && green > -1 && blue > -1) {
         color2 = new RGB(red, green, blue);
       }
       // style
       GradientStyle gradientStyleObj =
           GradientStyle.get(value.substring(value.lastIndexOf(',') + 1).trim());
       if (gradientStyleObj != null) {
         gradientStyle = gradientStyleObj.getValue();
       }
     } finally {
       if (color1 == null || color2 == null || gradientStyle == -1) {
         value = null;
       }
     }
   }
   if (value == null) {
     // use default
     GradientData def = GradientData.getDefaultGradientData();
     color1 = FigureUtilities.integerToRGB(def.getGradientColor1());
     color2 = FigureUtilities.integerToRGB(def.getGradientColor2());
     gradientStyle = def.getGradientStyle();
   }
   GradientSelectionDialog dialog =
       new GradientSelectionDialog(
           cellEditorWindow.getShell(), SWT.APPLICATION_MODAL, color1, color2, gradientStyle, 0);
   int result = dialog.open();
   if (result == SWT.OK) {
     return new GradientData(
         FigureUtilities.RGBToInteger(dialog.getGradientColor1()),
         FigureUtilities.RGBToInteger(dialog.getGradientColor2()),
         dialog.getGradientStyle());
   } else if (result == -1) { // user selected Clear button
     // make the calls here, since parent ignores null, and we need to clear gradient
     markDirty();
     doSetValue(null);
     fireApplyEditorValue();
   }
   return null;
 }