/**
   * @see
   *     org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand#doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor,
   *     org.eclipse.core.runtime.IAdaptable)
   * @param arg0
   * @param arg1
   * @return
   * @throws ExecutionException
   */
  @SuppressWarnings("unchecked")
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor arg0, IAdaptable arg1)
      throws ExecutionException {
    Object createdElement = elementAdapter.getAdapter(EObject.class);
    if (createdElement instanceof EObject) {
      EObject eObjectCreatedElement = (EObject) createdElement;
      for (IGraphicalEditPart parent : graphicalParent) {
        EObject eObjectSourceReference = parent.resolveSemanticElement();
        AbstractContainerNodeDescriptor desc =
            GroupContainmentRegistry.getContainerDescriptor(parent);
        List<EReference> refs = desc.getReferenceFor(eObjectCreatedElement.eClass());
        for (EReference ref : refs) {
          if (ref != null && ref.isMany()) {
            Collection<EObject> collection = (Collection<EObject>) eObjectSourceReference.eGet(ref);
            if (!collection.contains(eObjectCreatedElement)) {
              collection.add(eObjectCreatedElement);
            }
          } else if (ref != null && !ref.isMany()) {
            eObjectSourceReference.eSet(ref, eObjectCreatedElement);
          }
        }
      }
    }

    return CommandResult.newOKCommandResult();
  }
  /** Erases the guide and the feedback shown by the container of the elements. */
  protected void eraseSourceFeedback() {
    if (guideline.getParent() != null) {
      guideline.getParent().remove(guideline);
    }

    if (_container != null) {
      _container.eraseSourceFeedback(getSourceRequest());
    }

    ChangeBoundsRequest request = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
    request.setEditParts(Collections.emptyList());
    request.setSizeDelta(new Dimension(0, 0));
    request.setMoveDelta(new Point(0, 0));
    for (IGraphicalEditPart part : _movingShapes) {
      part.eraseSourceFeedback(request);
    }

    ChangeBoundsRequest spRequest = new ChangeBoundsRequest(RequestConstants.REQ_RESIZE);
    spRequest.setEditParts(Collections.emptyList());
    spRequest.setSizeDelta(new Dimension(0, 0));
    spRequest.setMoveDelta(new Point(0, 0));
    for (IGraphicalEditPart sp : _subProcesses) {
      sp.eraseSourceFeedback(spRequest);
    }
  }
Exemplo n.º 3
0
  /** Runs the operation, basically invert the value of isDefault property on the sequence edge. */
  @Override
  protected void doRun(IProgressMonitor progressMonitor) {
    IStructuredSelection selection = getStructuredSelection();
    if (selection == null || (selection.isEmpty())) {
      return;
    }
    if (selection.getFirstElement() instanceof IGraphicalEditPart) {
      IGraphicalEditPart part = (IGraphicalEditPart) selection.getFirstElement();
      final EObject object =
          ((IGraphicalEditPart) selection.getFirstElement()).getNotationView().getElement();
      if (object instanceof Activity) {
        part.getDiagramEditDomain()
            .getDiagramCommandStack()
            .execute(
                new ICommandProxy(
                    new MyCommand(object) {

                      @Override
                      protected CommandResult doExecuteWithResult(
                          IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
                        if (object instanceof Activity) {
                          ((Activity) object).setLooping(!(((Activity) object).isLooping()));
                        }
                        return CommandResult.newOKCommandResult();
                      }
                    }),
                progressMonitor);
      }
    }
  }
  /**
   * Complete the given composite command with RegionContainer specific resize commands: the
   * commands to report the RegionContainer resize on its regions.
   */
  @Override
  protected void completeResizeCommand(
      CompositeTransactionalCommand ctc, ChangeBoundsRequest request) {
    if (request.getEditParts().size() > 1 && !request.isConstrainedResize()) {
      ctc.add(UnexecutableCommand.INSTANCE);
      return;
    }

    Collection<ChangeBoundsRequest> siblingRequests = getConstrainedRegionRequests(request);
    if (!siblingRequests.isEmpty()) {
      for (ChangeBoundsRequest siblingRequest : siblingRequests) {
        if (siblingRequest.getEditParts() != null) {
          for (IGraphicalEditPart constrainedPart :
              Iterables.filter(siblingRequest.getEditParts(), IGraphicalEditPart.class)) {
            Command constrainedCommand = constrainedPart.getCommand(siblingRequest);
            if (constrainedCommand == null) {
              ctc.add(UnexecutableCommand.INSTANCE);
            } else {
              ctc.add(new CommandProxy(constrainedCommand));
            }
          }
        }
      }
    } else if (!(request.isConstrainedMove() || request.isConstrainedResize())) {
      // Deactivate the manual resize of RegionContainer when there are no
      // regions.
      ctc.add(UnexecutableCommand.INSTANCE);
    }

    // Adjust border nodes and edges.
    ctc.add(new ChildrenAdjustmentCommand((IGraphicalEditPart) getHost(), request, true, false));
  }
Exemplo n.º 5
0
  /** @generated */
  @Override
  protected void handleNotificationEvent(Notification notification) {
    super.handleNotificationEvent(notification);

    if (notification.getNotifier() instanceof de.uni_mannheim.informatik.swt.models.plm.PLM.Feature
        && ((EStructuralFeature) notification.getFeature()).getName().equals("expressed")) {
      IGraphicalEditPart parent = (IGraphicalEditPart) getParent();
      de.uni_mannheim.informatik.swt.models.plm.PLM.Element self =
          (de.uni_mannheim.informatik.swt.models.plm.PLM.Element) resolveSemanticElement();

      // Check is visible
      if (parent.resolveSemanticElement()
          instanceof de.uni_mannheim.informatik.swt.models.plm.PLM.Context) {
        de.uni_mannheim.informatik.swt.models.plm.PLM.Context container =
            (de.uni_mannheim.informatik.swt.models.plm.PLM.Context) parent.resolveSemanticElement();
        if ((container.getOrigin().equalsIgnoreCase("computed") && self.isExpressed())
            || (container.getOrigin().equalsIgnoreCase("expressed") && !self.isExpressed())) {
          getNotationView().setVisible(false);
        }
      } else {
        getNotationView().setVisible(true);
      }

      de.uni_mannheim.informatik.swt.models.plm.PLM.Feature f =
          (de.uni_mannheim.informatik.swt.models.plm.PLM.Feature) resolveSemanticElement();
      if (f.isExpressed()) {
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView()).setItalic(false);
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView()).setFontColor(0);
      } else {
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView()).setItalic(true);
        ((org.eclipse.gmf.runtime.notation.Shape) this.getNotationView())
            .setFontColor(FigureUtilities.colorToInteger(DiagramColorConstants.diagramGray));
      }
    }
  }
Exemplo n.º 6
0
 /**
  * Returns the direction to set the decorator for the node
  *
  * @param node the node
  * @return the direction to set the decorator for the node direction can be :
  *     <ul>
  *       <li>{@link PositionConstants#NORTH_WEST} or {@link PositionConstants#SOUTH_EAST} if the
  *           node is an Affixed Child Node
  *       <li>{@link PositionConstants#EAST} if the node is in a compartment list
  *       <li>{@link PositionConstants#SOUTH_EAST} in other cases
  *     </ul>
  */
 protected Direction getDirection(Node node) {
   IGraphicalEditPart gep =
       (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
   assert gep != null;
   // test if its an affixed ChildNode
   // if(Util.isAffixedChildNode(gep)) {
   //
   // IBorderItemLocator loc =
   // ((BorderNamedElementEditPart)gep).getBorderItemLocator();
   // int location = loc.getCurrentSideOfParent();
   // if(PositionConstants.NONE == location) { //sometimes
   // getBorderItemLocator doesn't work correctly!
   // location = PositionConstants.NORTH_WEST;
   // }
   // switch(location) {
   // case PositionConstants.NORTH:
   // case PositionConstants.NORTH_WEST:
   // case PositionConstants.WEST:
   // case PositionConstants.SOUTH_WEST:
   // // return IDecoratorTarget.Direction.NORTH_WEST;
   // default:
   // return IDecoratorTarget.Direction.SOUTH_EAST;
   // }
   // }
   if (gep.getParent() != null) {
     if (isInCompartmentList(node) && !Util.isAffixedChildNode(gep)) {
       return IDecoratorTarget.Direction.EAST;
     }
   }
   return IDecoratorTarget.Direction.SOUTH_WEST;
 }
Exemplo n.º 7
0
 public boolean select(Object object) {
   if (object instanceof IGraphicalEditPart) {
     IGraphicalEditPart editPart = (IGraphicalEditPart) object;
     Object model = editPart.resolveSemanticElement();
     return model instanceof Widget;
   }
   return false;
 }
Exemplo n.º 8
0
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.gmf.runtime.diagram.ui.services.decorator.IDecorator#activate()
  */
 public void activate() {
   final IGraphicalEditPart gep = getTargetEditPart();
   DiagramEventBroker.getInstance(gep.getEditingDomain())
       .addNotificationListener(
           gep.getNotationView(),
           NotationPackage.eINSTANCE.getNode_LayoutConstraint(),
           notificationListener);
 }
 @Override
 protected boolean shouldDecorate(State state) {
   IGraphicalEditPart adapter =
       (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
   BooleanValueStyle style =
       GMFNotationUtil.getBooleanValueStyle(
           adapter.getNotationView(), DiagramPartitioningUtil.INLINE_STYLE);
   return style == null ? false : !style.isBooleanValue();
 }
 public boolean select(Object object) {
   if (object instanceof IGraphicalEditPart) {
     IGraphicalEditPart editPart = (IGraphicalEditPart) object;
     Object model = editPart.resolveSemanticElement();
     if (model instanceof MainProcess) return false;
     return model instanceof ConnectableElement;
   }
   return false;
 }
  protected void setUp() throws Exception {
    super.setUp();

    List children = getTestFixture().getDiagramEditPart().getChildren();
    if (children.isEmpty()) assertFalse(true);

    EditPart firstEP = (EditPart) children.get(0);
    if (firstEP instanceof CircuitEditPart) {
      CircuitEditPart circuitEditPart = (CircuitEditPart) firstEP;

      IElementType typeLED = ElementTypeRegistry.getInstance().getType("logic.led"); // $NON-NLS-1$
      Point pos = circuitEditPart.getFigure().getBounds().getBottomRight();
      circuitEditPart.getFigure().translateToAbsolute(pos);
      pos.translate(100, 100);
      LEDEditPart ledEP2 =
          (LEDEditPart)
              getLogicTestFixture().createShapeUsingTool(typeLED, pos, getDiagramEditPart());

      Terminal term1 =
          (Terminal)
              ((Circuit) circuitEditPart.getNotationView().getElement())
                  .getOutputTerminals()
                  .get(0);
      TerminalEditPart tep1 = null;
      ListIterator li = circuitEditPart.getChildren().listIterator();
      while (li.hasNext()) {
        IGraphicalEditPart gep = (IGraphicalEditPart) li.next();
        if (gep.getNotationView().getElement().equals(term1)) tep1 = (TerminalEditPart) gep;
      }

      Terminal term2 =
          (Terminal) ((LED) ledEP2.getNotationView().getElement()).getInputTerminals().get(0);
      TerminalEditPart tep2 = null;
      li = ledEP2.getChildren().listIterator();
      while (li.hasNext()) {
        IGraphicalEditPart gep = (IGraphicalEditPart) li.next();
        if (gep.getNotationView().getElement().equals(term2)) tep2 = (TerminalEditPart) gep;
      }

      IElementType typeWire =
          ElementTypeRegistry.getInstance().getType("logic.wire"); // $NON-NLS-1$

      getLogicTestFixture().createConnectorUsingTool(tep1, tep2, typeWire);

      IGraphicalEditPart logicCompartment =
          circuitEditPart.getChildBySemanticHint(LogicConstants.LOGIC_SHAPE_COMPARTMENT);

      Rectangle rect = new Rectangle(logicCompartment.getFigure().getBounds());
      logicCompartment.getFigure().translateToAbsolute(rect);

      CreateRequest request = getLogicTestFixture().getCreationRequest(typeLED);
      request.setLocation(rect.getCenter());
      Command cmd = logicCompartment.getCommand(request);

      getCommandStack().execute(cmd);

      assertEquals(
          "Unexpected LED count.", 1, logicCompartment.getChildren().size()); // $NON-NLS-1$
    }
  }
 public void setBoundsForOverlapComputation(IGraphicalEditPart ep, Rectangle result) {
   if (ep.resolveSemanticElement() instanceof FlowElement) {
     IFigure fig = ((IGraphicalEditPart) ep).getContentPane();
     result.setBounds(fig.getBounds());
     fig.translateToAbsolute(result);
     return;
   } else {
     result.setBounds(ep.getFigure().getBounds());
     ep.getFigure().translateToAbsolute(result);
   }
 }
 /** @return the bordered node edit part. */
 private IBorderedShapeEditPart getContainerBorderedNodeEditpart() {
   IGraphicalEditPart current = this;
   IBorderedShapeEditPart borderedNodeEditPart = null;
   while (current != null && borderedNodeEditPart == null) {
     if (current instanceof AbstractBorderedShapeEditPart) {
       borderedNodeEditPart = (IBorderedShapeEditPart) current;
     }
     current = (IGraphicalEditPart) current.getParent();
   }
   return borderedNodeEditPart;
 }
  /** Moved to public so that it may be called programmatically by an other tool. */
  public boolean handleButtonDown(int button) {
    Object underMouse = getCurrentViewer().findObjectAt(getCurrentInput().getMouseLocation());
    if (!(underMouse instanceof IGraphicalEditPart)) {
      return true;
    }
    stateTransition(STATE_INITIAL, STATE_DRAG_IN_PROGRESS);
    _initialPosition = getCurrentPosition();
    _initPosNoZoom = getCurrentPositionZoomed();

    // calculate the initial selection
    // of shapes that should move
    _container = (IGraphicalEditPart) findPool(underMouse);

    // the children that will be moved around
    List<IGraphicalEditPart> bottomChildren = new ArrayList<IGraphicalEditPart>();
    List<IGraphicalEditPart> subProcesses = new ArrayList<IGraphicalEditPart>();

    if (_container != null && _container.resolveSemanticElement() instanceof Container) {
      List children = null;
      if (_container.resolveSemanticElement() instanceof Container) {
        children = _container.getChildren();
      } else if (_container instanceof ShapeCompartmentEditPart) {
        children = ((ShapeCompartmentEditPart) _container).getChildren();
      }
      if (children == null) {
        throw new IllegalArgumentException(
            "The part " + _container + " did not contain elements"); // $NON-NLS-1$ //$NON-NLS-2$
      }
      // now iterate over the compartment children
      // and take those that are on the right.
      for (Object child : children) {
        if (child instanceof ShapeNodeEditPart) {
          setBoundsForOverlapComputation((IGraphicalEditPart) child, SINGLETON);
          ((DiagramEditPart) getCurrentViewer().getContents())
              .getFigure()
              .translateToRelative(SINGLETON);
          if (SINGLETON.y > _initPosNoZoom) {
            bottomChildren.add((IGraphicalEditPart) child);
          }
        }
      }
    }
    _movingShapes = bottomChildren;
    _subProcesses = subProcesses;

    updateSourceRequest();
    showSourceFeedback();

    return true;
  }
  public InlineTextInputDialog(final IGraphicalEditPart graphicalEditPart, final String value) {
    super(graphicalEditPart.getViewer().getControl().getShell());
    final IFigure theFigure = graphicalEditPart.getFigure();

    final org.eclipse.draw2d.geometry.Rectangle r = theFigure.getBounds().getCopy();
    theFigure.translateToAbsolute(r);

    final Control theCanvas = graphicalEditPart.getViewer().getControl();
    labelBounds =
        theCanvas.getDisplay().map(theCanvas, null, new Rectangle(r.x, r.y, r.width, r.height));

    this.value = value;
    setShellStyle(SWT.NO_TRIM | SWT.APPLICATION_MODAL);
  }
  public void initGenModel(Object target, IGenModel genModel) {

    IGraphicalEditPart editpart = (IGraphicalEditPart) target;
    Automaton automaton = (Automaton) editpart.getNotationView().getElement();

    // The automaton name is used as a default project name.
    String projectName = automaton.getName() == null ? "myautomaton" : automaton.getName();

    genModel.setProperty(IGenModel.PROJECT_NAME, projectName);
    genModel.setProperty(CodegenUtils.PROPERTY_DEPTH, CodegenUtils.DEFAULT_DEPTH);
    genModel.setProperty(CodegenUtils.PROPERTY_RANGE, CodegenUtils.DEFAULT_RANGE);
    genModel.setProperty(CodegenUtils.PROPERTY_FILENAME, projectName + ".msat");
    genModel.setProperty("targetlang", mathsat); // mathsat is default
    genModel.setTarget(automaton);
  }
 public List getRelTypesOnSource(IAdaptable source) {
   IGraphicalEditPart sourceEditPart =
       (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
   if (sourceEditPart != null) {
     EObject element = sourceEditPart.resolveSemanticElement();
     if (element instanceof Constraint
         || element instanceof Observation
         || element instanceof Comment) {
       ArrayList<IElementType> types = new ArrayList<IElementType>(1);
       types.add(UMLElementTypes.CommentAnnotatedElement_4010);
       return types;
     }
   }
   return super.getRelTypesOnSource(source);
 }
  /**
   * initialize the status of the compartment for the node (Showed or hidden)
   *
   * @param view the element to initialize
   * @param store the preference store
   * @param elementName the name to the element
   */
  public static void initCompartmentsStatusFromPrefs(
      View view, final IPreferenceStore store, String elementName) {
    EList<?> children = view.getPersistedChildren();
    if (children != null) {
      for (Object object : children) {

        // we look for the name of the compartment for this view
        EditPart dummyEP = EditPartService.getInstance().createGraphicEditPart((View) object);
        IGraphicalEditPart epp = (IGraphicalEditPart) dummyEP;
        IFigure fig1 = epp.getFigure();

        if (fig1 instanceof ResizableCompartmentFigure) {
          String compartmentName = ((ResizableCompartmentFigure) fig1).getCompartmentTitle();
          if (compartmentName != null) {
            String diagramKind = view.getDiagram().getType();
            String preferenceKey =
                PreferenceConstantHelper.getCompartmentElementConstant(
                    diagramKind + "_" + elementName,
                    compartmentName,
                    PreferenceConstantHelper.COMPARTMENT_VISIBILITY); // $NON-NLS-1$
            boolean value = store.getBoolean(preferenceKey);

            if (!value) { // the default value is true : nothing to
              // do
              ENamedElement namedElement =
                  PackageUtil.getElement("notation.View.visible"); // $NON-NLS-1$
              ViewUtil.setStructuralFeatureValue(
                  (View) object, (EStructuralFeature) namedElement, value);
            }

            String compartmentNameVisibilityPreference =
                PreferenceConstantHelper.getCompartmentElementConstant(
                    diagramKind + "_" + elementName,
                    compartmentName,
                    PreferenceConstantHelper.COMPARTMENT_NAME_VISIBILITY); // $NON-NLS-1$
            boolean showCompartmentName = store.getBoolean(compartmentNameVisibilityPreference);
            View childView = (View) object;
            TitleStyle style =
                (TitleStyle) childView.getStyle(NotationPackage.eINSTANCE.getTitleStyle());
            if (style != null) {
              style.setShowTitle(showCompartmentName);
            }
          }
        }
        dummyEP = null;
      }
    }
  }
Exemplo n.º 19
0
  public static void increaseLaneHeight(final SWTBotGefEditor editor, final String laneName) {
    final SWTBotGefEditPart lanePart = editor.getEditPart(laneName).parent();
    lanePart.select();

    final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) lanePart.part();
    final UpdateSizePoolSelectionEditPolicy addPoolSizeElementEditPolicy =
        (UpdateSizePoolSelectionEditPolicy)
            graphicalEditPart.getEditPolicy(
                UpdateSizePoolSelectionEditPolicy.UPDATE_POOL_SIZE_SELECTION_FEEDBACK_ROLE);

    final IFigure toolbarFigure =
        addPoolSizeElementEditPolicy.getFigure(UpdateSizePoolSelectionEditPolicy.ADD_BOTTOM);
    final Point location = toolbarFigure.getBounds().getCenter().getCopy();
    toolbarFigure.translateToAbsolute(location);
    editor.click(location.x, location.y);
  }
Exemplo n.º 20
0
  /** {@inheritDoc} */
  @Override
  protected void initAction() {
    super.initAction();

    visibleRepresentations = new ArrayList<CompartmentEditPartRepresentation>();

    for (IGraphicalEditPart current : this.selectedElements) {
      if (((View) current.getModel()).getElement() != null) {
        this.representations.add(
            new RootEditPartRepresentation(current, ((View) current.getModel()).getElement()));
      }
    }
    setContentProvider(new ContentProvider());
    // setEditorLabelProvider(new EditorLabelProvider());
    // this.domain = ((IGraphicalEditPart)this.selectedElements.get(0)).getEditingDomain();
    // this.initialSelection = getInitialSelection();
  }
Exemplo n.º 21
0
  /**
   * 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));
            }
          }
        }
      }
    }
  }
Exemplo n.º 22
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;
 }
 private IFigure getTargetFigure(IGraphicalEditPart editPart) {
   IFigure figure = editPart.getFigure();
   if (figure instanceof BorderedNodeFigure) {
     figure = (IFigure) figure.getChildren().get(0);
   }
   if (figure instanceof DefaultSizeNodeFigure) {
     figure = (IFigure) figure.getChildren().get(0);
   }
   return figure;
 }
  @Override
  protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
      throws ExecutionException {
    parentTreeNodeEditPart.getParent().refresh();
    final List<IGraphicalEditPart> treeChildren =
        TreeLayoutUtil.getOrderedTreeChildren(parentTreeNodeEditPart);
    treeChildren.remove(UIUtils.getEditPart(request.getElementToDestroy()));
    TreeLayoutUtil.setTreeNodesPositionAnnotation(TreeLayoutUtil.getViews(treeChildren));

    return CommandResult.newOKCommandResult();
  }
Exemplo n.º 25
0
        /**
         * @see
         *     org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener#notifyChanged(org.eclipse.emf.common.notify.Notification)
         * @param notification
         */
        public void notifyChanged(Notification notification) {

          if (notification.getEventType() == Notification.REMOVE) {
            if (notification.getNotifier() instanceof Classifier) {
              IGraphicalEditPart gep =
                  (IGraphicalEditPart) getDecoratorTarget().getAdapter(IGraphicalEditPart.class);
              assert gep != null;
              // we remove the listener on the container (because it's
              // changing
              DiagramEventBroker.getInstance(gep.getEditingDomain())
                  .removeNotificationListener(
                      (EObject) notification.getNotifier(), notificationListener);
            }
          }
          // we update the listeners It's useful when an Element with overlay
          // changes of parent
          deactivate();
          activate();
          refresh();
        }
 /** @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()]));
 }
 /**
  * Get the {@link IGraphicalEditPart} from view adapter
  *
  * @param any
  * @return
  */
 private Boolean getEditPartFromViewAdapter(IGraphicalEditPart any) {
   Object view = adapter.getAdapter(View.class);
   Map<?, ?> registery = any.getViewer().getEditPartRegistry();
   if (view instanceof View) {
     View childView = (View) view;
     Object auxPart = registery.get(childView);
     if (auxPart instanceof IGraphicalEditPart) {
       mainEditPart = (IGraphicalEditPart) auxPart;
       return true;
     }
   }
   return false;
 }
Exemplo n.º 28
0
  private boolean checkNewLocation(
      final SWTBotSiriusDiagramEditor editordiagram,
      final SWTBotGefEditPart botPart,
      final int x,
      final int y) {
    if (botPart == null) System.out.println("NULL");
    final EditPart rawPart = botPart.part();
    if (rawPart == null) System.out.println("rawPart NULL");
    if (rawPart instanceof IDiagramElementEditPart && !(rawPart instanceof DiagramEditPart)) {
      final IGraphicalEditPart gep = (IGraphicalEditPart) rawPart;
      final Rectangle r = gep.getFigure().getBounds().getCopy();
      System.out.println("REAL");
      System.out.println(r.x);
      System.out.println(r.y);
      System.out.println("EXPECTED");
      System.out.println(x);
      System.out.println(y);

      return (r.x == x) && (r.y == y);
    }
    return false;
  }
 /**
  * @return the current diagram or null if not found. TODO : throw appropriate exception if not
  *     found ?
  */
 protected Diagram getCurrentDiagram() {
   IEditorPart editorPart =
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
   if (editorPart instanceof IMultiDiagramEditor) {
     editorPart = ((IMultiDiagramEditor) editorPart).getActiveEditor();
     if (editorPart instanceof DiagramEditor) {
       host = ((DiagramEditor) editorPart).getDiagramEditPart();
       View view = (View) host.getModel();
       Diagram diagram = view.getDiagram();
       return diagram;
     }
   }
   return null;
 }
  /** creates the command to move the shapes left or right. */
  protected Command getCommand() {
    if (_container == null) {
      return null;
    }
    CompoundCommand command = new CompoundCommand("Multiple Shape Move");
    TransactionalEditingDomain editingDomain = _container.getEditingDomain();

    Point moveDelta = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
    Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
    ZoomManager zoomManager =
        ((DiagramRootEditPart) getCurrentViewer().getRootEditPart()).getZoomManager();
    spSizeDelta.scale(1 / zoomManager.getZoom());
    command.add(_container.getCommand(getSourceRequest()));

    for (IGraphicalEditPart sp : _subProcesses) {
      Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
      spDim.expand(spSizeDelta);
      SetBoundsCommand setBounds =
          new SetBoundsCommand(editingDomain, "MultipleShape Move", sp, spDim);
      command.add(new ICommandProxy(setBounds));
    }
    return command;
  }