コード例 #1
0
ファイル: InheritedDecorator.java プロジェクト: go2zo/ju4pa
  /**
   * Creates the appropriate review decoration if all the criteria is satisfied by the view passed
   * in.
   */
  public void refresh() {
    removeDecoration();

    Node node = getDecoratorTargetNode(getDecoratorTarget());
    IGraphicalEditPart gep =
        (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);

    if (node != null) {
      DescriptionStyle descStyle = getDescriptionStyle(node);

      if (descStyle != null) {
        if (isInherited(node)) {
          // if(Util.isAffixedChildNode(gep)) {

          // setDecoration(getDecoratorTarget().addDecoration(figure,
          // locator, false));
          // } else {
          // setDecoration(getDecoratorTarget().addShapeDecoration(figure,
          // getDirection(node), -1, false));
          // }

          if (gep != null && gep.getRoot() != null) { // if the gep has
            // no parent, we
            // can't test if
            // the container
            // is a
            // compartment
            // list
            // (because, we
            // call the
            // method
            // DiagramEditPartsUtil.getEditPartFromView((View)container,
            // gep);
            IFigure figure = getFigure(ICON_HYPERLINK);
            if (isInCompartmentList(node) && !Util.isAffixedChildNode(gep)) {
              setDecoration(
                  getDecoratorTarget().addShapeDecoration(figure, getDirection(node), -1, false));
            } else {
              Locator locator = new OverlayLocator(gep.getFigure(), getDirection(node));
              setDecoration(getDecoratorTarget().addDecoration(figure, locator, false));
            }
          }
        }
      }
    }
  }
コード例 #2
0
ファイル: InheritedDecorator.java プロジェクト: go2zo/ju4pa
 /**
  * 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;
 }
コード例 #3
0
 /** @generated */
 protected EObject selectExistingElement(IAdaptable host, Collection types) {
   if (types.isEmpty()) {
     return null;
   }
   IGraphicalEditPart editPart = (IGraphicalEditPart) host.getAdapter(IGraphicalEditPart.class);
   if (editPart == null) {
     return null;
   }
   Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel();
   HashSet<EObject> elements = new HashSet<EObject>();
   for (Iterator<EObject> it = diagram.getElement().eAllContents(); it.hasNext(); ) {
     EObject element = it.next();
     if (isApplicableElement(element, types)) {
       elements.add(element);
     }
   }
   if (elements.isEmpty()) {
     return null;
   }
   return selectElement((EObject[]) elements.toArray(new EObject[elements.size()]));
 }