Exemple #1
0
 /**
  * Tests if the node is an inherited element
  *
  * @param node a node
  * @return <code>true</code> if the node is an inherited element <code>false</code> if not
  */
 protected boolean isInherited(Node node) {
   EObject element = node.getElement();
   if (element instanceof Element) {
     EObject container = node.eContainer();
     EObject graphicalParent = null;
     if (container instanceof DecorationNode) {
       graphicalParent = ((DecorationNode) container).getElement();
     } else if (container instanceof View) {
       graphicalParent = ((View) container).getElement();
     }
     if (graphicalParent instanceof Property || graphicalParent instanceof Classifier) {
       Classifier classifier = null;
       if (graphicalParent instanceof Property) {
         Type type = ((Property) graphicalParent).getType();
         if (type instanceof Classifier) {
           classifier = (Classifier) type;
         }
       } else {
         classifier = (Classifier) graphicalParent;
       }
       if (classifier != null) {
         EList<NamedElement> inheritedMembers = classifier.getInheritedMembers();
         return inheritedMembers.contains(element);
       }
     }
   }
   return false;
 }
Exemple #2
0
 /**
  * Tests if the compartment is a compartment list
  *
  * @param node the node on which we want add an Overlay
  * @return <code>true</code> if the compartment is managed by an {@link XYLayoutEditPolicy}
  */
 protected boolean isInCompartmentList(Node node) {
   IGraphicalEditPart gep =
       (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
   if (gep != null && gep.getRoot() != null) {
     EObject container = node.eContainer();
     if (container instanceof View) {
       EditPart EP = DiagramEditPartsUtil.getEditPartFromView((View) container, gep);
       EditPolicy editPolicy = EP.getEditPolicy(EditPolicy.LAYOUT_ROLE);
       if (!(editPolicy instanceof XYLayoutEditPolicy)) { // we are in a
         // compartment
         // list
         return true;
       }
     }
   }
   return false;
 }