/** @generated */
 protected boolean provides(CreateNodeViewOperation op) {
   if (op.getContainerView() == null) {
     return false;
   }
   IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
   EObject domainElement = getSemanticElement(op.getSemanticAdapter());
   int visualID;
   if (op.getSemanticHint() == null) {
     // Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
     // In this situation there should be NO elementType, visualID will be determined
     // by VisualIDRegistry.getNodeVisualID() for domainElement.
     if (elementType != null || domainElement == null) {
       return false;
     }
     visualID = GeometryVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement);
   } else {
     visualID = GeometryVisualIDRegistry.getVisualID(op.getSemanticHint());
     if (elementType != null) {
       if (!GeometryElementTypes.isKnownElementType(elementType)
           || (!(elementType instanceof IHintedType))) {
         return false; // foreign element type
       }
       String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
       if (!op.getSemanticHint().equals(elementTypeHint)) {
         return false; // if semantic hint is specified it should be the same as in element type
       }
       if (domainElement != null
           && visualID
               != GeometryVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
         return false; // visual id for node EClass should match visual id from element type
       }
     } else {
       if (!GeometryEditPart.MODEL_ID.equals(
           GeometryVisualIDRegistry.getModelID(op.getContainerView()))) {
         return false; // foreign diagram
       }
       switch (visualID) {
         case PointEditPart.VISUAL_ID:
           if (domainElement == null
               || visualID
                   != GeometryVisualIDRegistry.getNodeVisualID(
                       op.getContainerView(), domainElement)) {
             return false; // visual id in semantic hint should match visual id for domain element
           }
           break;
         default:
           return false;
       }
     }
   }
   return PointEditPart.VISUAL_ID == visualID;
 }
 /** @generated */
 private void stampShortcut(View containerView, Node target) {
   if (!GeometryEditPart.MODEL_ID.equals(GeometryVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation.getDetails().put("modelID", GeometryEditPart.MODEL_ID); // $NON-NLS-1$
     target.getEAnnotations().add(shortcutAnnotation);
   }
 }
 /** @generated */
 protected boolean provides(CreateEdgeViewOperation op) {
   IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
   if (!GeometryElementTypes.isKnownElementType(elementType)
       || (!(elementType instanceof IHintedType))) {
     return false; // foreign element type
   }
   String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
   if (elementTypeHint == null
       || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
     return false; // our hint is visual id and must be specified, and it should be the same as in
                   // element type
   }
   int visualID = GeometryVisualIDRegistry.getVisualID(elementTypeHint);
   EObject domainElement = getSemanticElement(op.getSemanticAdapter());
   if (domainElement != null
       && visualID != GeometryVisualIDRegistry.getLinkWithClassVisualID(domainElement)) {
     return false; // visual id for link EClass should match visual id from element type
   }
   return true;
 }
 /** @generated */
 public Node createNode(
     IAdaptable semanticAdapter,
     View containerView,
     String semanticHint,
     int index,
     boolean persisted,
     PreferencesHint preferencesHint) {
   final EObject domainElement = getSemanticElement(semanticAdapter);
   final int visualID;
   if (semanticHint == null) {
     visualID = GeometryVisualIDRegistry.getNodeVisualID(containerView, domainElement);
   } else {
     visualID = GeometryVisualIDRegistry.getVisualID(semanticHint);
   }
   switch (visualID) {
     case PointEditPart.VISUAL_ID:
       return createPoint_2001(domainElement, containerView, index, persisted, preferencesHint);
   }
   // can't happen, provided #provides(CreateNodeViewOperation) is correct
   return null;
 }
 /** @generated */
 public Edge createEdge(
     IAdaptable semanticAdapter,
     View containerView,
     String semanticHint,
     int index,
     boolean persisted,
     PreferencesHint preferencesHint) {
   IElementType elementType = getSemanticElementType(semanticAdapter);
   String elementTypeHint = ((IHintedType) elementType).getSemanticHint();
   switch (GeometryVisualIDRegistry.getVisualID(elementTypeHint)) {
     case LineEditPart.VISUAL_ID:
       return createLine_4001(
           getSemanticElement(semanticAdapter), containerView, index, persisted, preferencesHint);
   }
   // can never happen, provided #provides(CreateEdgeViewOperation) is correct
   return null;
 }
  /** @generated */
  public Edge createLine_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(GeometryVisualIDRegistry.getType(LineEditPart.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);
    }
    return edge;
  }
  /** @generated */
  public Node createPoint_2001(
      EObject domainElement,
      View containerView,
      int index,
      boolean persisted,
      PreferencesHint preferencesHint) {
    Shape node = NotationFactory.eINSTANCE.createShape();
    node.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
    node.setType(GeometryVisualIDRegistry.getType(PointEditPart.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));
    return node;
  }
 /** @generated */
 protected boolean provides(CreateDiagramViewOperation op) {
   return GeometryEditPart.MODEL_ID.equals(op.getSemanticHint())
       && GeometryVisualIDRegistry.getDiagramVisualID(getSemanticElement(op.getSemanticAdapter()))
           != -1;
 }