Example #1
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 = RdalVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement);
   } else {
     visualID = RdalVisualIDRegistry.getVisualID(op.getSemanticHint());
     if (elementType != null) {
       if (!RdalElementTypes.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
               != RdalVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
         return false; // visual id for node EClass should match visual id from element type
       }
     } else {
       if (!SpecificationEditPart.MODEL_ID.equals(
           RdalVisualIDRegistry.getModelID(op.getContainerView()))) {
         return false; // foreign diagram
       }
       switch (visualID) {
         case RequirementsGroupEditPart.VISUAL_ID:
         case StakeHolderEditPart.VISUAL_ID:
         case VerificationActivityEditPart.VISUAL_ID:
         case RequirementEditPart.VISUAL_ID:
         case AssumptionEditPart.VISUAL_ID:
           if (domainElement == null
               || visualID
                   != RdalVisualIDRegistry.getNodeVisualID(op.getContainerView(), domainElement)) {
             return false; // visual id in semantic hint should match visual id for domain element
           }
           break;
         default:
           return false;
       }
     }
   }
   return RequirementsGroupEditPart.VISUAL_ID == visualID
       || StakeHolderEditPart.VISUAL_ID == visualID
       || VerificationActivityEditPart.VISUAL_ID == visualID
       || RequirementEditPart.VISUAL_ID == visualID
       || AssumptionEditPart.VISUAL_ID == visualID;
 }
Example #2
0
 /** @generated */
 private void stampShortcut(View containerView, Node target) {
   if (!SpecificationEditPart.MODEL_ID.equals(RdalVisualIDRegistry.getModelID(containerView))) {
     EAnnotation shortcutAnnotation = EcoreFactory.eINSTANCE.createEAnnotation();
     shortcutAnnotation.setSource("Shortcut"); // $NON-NLS-1$
     shortcutAnnotation.getDetails().put("modelID", SpecificationEditPart.MODEL_ID); // $NON-NLS-1$
     target.getEAnnotations().add(shortcutAnnotation);
   }
 }