/** @generated */ protected boolean provides(CreateEdgeViewOperation op) { IElementType elementType = getSemanticElementType(op.getSemanticAdapter()); 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 (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 = edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getVisualID(elementTypeHint); EObject domainElement = getSemanticElement(op.getSemanticAdapter()); if (domainElement != null && visualID != edu.toronto.cs.se.modelepedia.necsis14_classdiagram.diagram.part .NECSIS14_ClassDiagramVisualIDRegistry.getLinkWithClassVisualID(domainElement)) { return false; // visual id for link EClass should match visual id from element type } return true; }
/** @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; }