コード例 #1
0
 /** @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 =
         edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
             .NECSIS14_ClassDiagramVisualIDRegistry.getNodeVisualID(containerView, domainElement);
   } else {
     visualID =
         edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
             .NECSIS14_ClassDiagramVisualIDRegistry.getVisualID(semanticHint);
   }
   switch (visualID) {
     case edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.ClassEditPart
         .VISUAL_ID:
       return createClass_2001(domainElement, containerView, index, persisted, preferencesHint);
     case edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.AttributeEditPart
         .VISUAL_ID:
       return createAttribute_3001(
           domainElement, containerView, index, persisted, preferencesHint);
   }
   // can't happen, provided #provides(CreateNodeViewOperation) is correct
   return null;
 }
コード例 #2
0
 /** @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 =
         edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
             .NECSIS14_ClassDiagramVisualIDRegistry.getNodeVisualID(
             op.getContainerView(), domainElement);
   } else {
     visualID =
         edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
             .NECSIS14_ClassDiagramVisualIDRegistry.getVisualID(op.getSemanticHint());
     if (elementType != null) {
       if (!edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.providers
               .NECSIS14_ClassDiagramElementTypes.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
               != edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
                   .NECSIS14_ClassDiagramVisualIDRegistry.getNodeVisualID(
                   op.getContainerView(), domainElement)) {
         return false; // visual id for node EClass should match visual id from element type
       }
     } else {
       if (!edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
           .ClassDiagramEditPart.MODEL_ID.equals(
           edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
               .NECSIS14_ClassDiagramVisualIDRegistry.getModelID(op.getContainerView()))) {
         return false; // foreign diagram
       }
       switch (visualID) {
         case edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.ClassEditPart
             .VISUAL_ID:
         case edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
             .AttributeEditPart.VISUAL_ID:
           if (domainElement == null
               || visualID
                   != edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
                       .NECSIS14_ClassDiagramVisualIDRegistry.getNodeVisualID(
                       op.getContainerView(), domainElement)) {
             return false; // visual id in semantic hint should match visual id for domain element
           }
           break;
         default:
           return false;
       }
     }
   }
   return edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.ClassEditPart
               .VISUAL_ID
           == visualID
       || edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts.AttributeEditPart
               .VISUAL_ID
           == visualID;
 }