コード例 #1
0
 /** @generated */
 protected boolean provides(CreateDiagramViewOperation op) {
   return edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
           .ClassDiagramEditPart.MODEL_ID.equals(op.getSemanticHint())
       && edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part
               .NECSIS14_ClassDiagramVisualIDRegistry.getDiagramVisualID(
               getSemanticElement(op.getSemanticAdapter()))
           != -1;
 }
コード例 #2
0
 /** @generated */
 private void stampShortcut(View containerView, Node target) {
   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(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation
         .getDetails()
         .put(
             "modelID",
             edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.edit.parts
                 .ClassDiagramEditPart.MODEL_ID); //$NON-NLS-1$
     target.getEAnnotations().add(shortcutAnnotation);
   }
 }
コード例 #3
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;
 }