Package org.eclipse.gef.commands

Examples of org.eclipse.gef.commands.CompoundCommand


   * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getAddCommand(org.eclipse.gef.Request)
   */
  protected Command getAddCommand(Request req) {
    ChangeBoundsRequest request = (ChangeBoundsRequest) req;
    List editParts = request.getEditParts();
    CompoundCommand command = new CompoundCommand();
    for (int i = 0; i < editParts.size(); i++) {
      EditPart child = (EditPart) editParts.get(i);
      if (child.getModel() instanceof IActionElement) {
        IActionElement ae = (IActionElement) child.getModel();
        IState state = (IState) getHost().getModel();
        if ((ae.getType() == IActionElement.ACTION_TYPE.ACTION && state instanceof IActionState)
            || (ae.getType() == IActionElement.ACTION_TYPE.RENDER_ACTION && state instanceof IViewState)
            || (ae.getType() == IActionElement.ACTION_TYPE.ENTRY_ACTION && state instanceof IState)
            || (ae.getType() == IActionElement.ACTION_TYPE.EXIT_ACTION && state instanceof ITransitionableFrom)) {
          command.add(createAddActionCommand(child));
        }
      }
      else if (child.getModel() instanceof IExceptionHandler) {
        IState state = (IState) getHost().getModel();
        if (!(state instanceof IWebflowState) && !(state instanceof IInlineFlowState)) {
          command.add(createAddExceptionHandlerCommand(child));
        }
      }
      else if (child.getModel() instanceof IAttributeMapper
          && getHost().getModel() instanceof ISubflowState
          && ((ISubflowState) getHost().getModel()).getAttributeMapper() == null) {
        command.add(createAddAttributeMapperCommand(child));
      }
      else if (child.getModel() instanceof IIf
          && getHost().getModel() instanceof IDecisionState) {
        command.add(createAddIfCommand(child));
      }
    }
    return command.unwrap();
  }
View Full Code Here


     */
    /* (non-Javadoc)
     * @see org.eclipse.gef.editpolicies.TreeContainerEditPolicy#getAddCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
     */
    protected Command getAddCommand(ChangeBoundsRequest request) {
        CompoundCommand command = new CompoundCommand();
        List editparts = request.getEditParts();
        int index = findIndexOfTreeItemAt(request.getLocation());

        for (int i = 0; i < editparts.size(); i++) {
            EditPart child = (EditPart) editparts.get(i);
            if (isAncestor(child, getHost()))
                command.add(UnexecutableCommand.INSTANCE);
            else {
                if (child.getModel() instanceof IActionElement
                        && getHost().getModel() instanceof IActionState) {
                    IActionElement childModel = (IActionElement) child.getModel();
                    command.add(createDeleteActionCommand(childModel));
                    command.add(createCreateActionCommand(childModel, index));//$NON-NLS-1$
                }
                else if (child.getModel() instanceof IAttributeMapper
                        && getHost().getModel() instanceof ISubflowState) {
                    IAttributeMapper childModel = (IAttributeMapper) child
                            .getModel();
                    command.add(createDeleteAttributeMapperCommand(childModel));
                    command.add(createCreateAttributeMapperCommand(childModel,
                            index)); //$NON-NLS-1$
                }
                else if (child.getModel() instanceof IAttribute
                        && (getHost().getModel() instanceof IActionElement || getHost()
                                .getModel() instanceof IState)) {
                    IAttribute childModel = (IAttribute) child.getModel();
                    command.add(createDeletePropertyCommand(childModel));
                    command.add(createCreatePropertyCommand(childModel, index));
                }
                else if (child.getModel() instanceof IIf
                        && getHost().getModel() instanceof IDecisionState) {
                    IIf childModel = (IIf) child.getModel();
                    command.add(createDeleteIfCommand(childModel));
                    command.add(createCreateIfCommand(childModel, index));
                }
                else if ((child.getModel() instanceof IInputMapper || child.getModel() instanceof IOutputMapper)
                        && getHost().getModel() instanceof IAttributeMapper) {
                    //command.add(createDeleteInputOutputCommand(child.getModel()));
                    //command.add(createCreateInputOutputCommand(child.getModel()));
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.gef.editpolicies.TreeContainerEditPolicy#getMoveChildrenCommand(org.eclipse.gef.requests.ChangeBoundsRequest)
     */
    protected Command getMoveChildrenCommand(ChangeBoundsRequest request) {
        CompoundCommand command = new CompoundCommand();
        List editparts = request.getEditParts();
        List children = getHost().getChildren();
        int newIndex = findIndexOfTreeItemAt(request.getLocation());

        for (int i = 0; i < editparts.size(); i++) {
            EditPart child = (EditPart) editparts.get(i);
            int tempIndex = newIndex;
            int oldIndex = children.indexOf(child);
            if (oldIndex == tempIndex || oldIndex + 1 == tempIndex) {
                command.add(UnexecutableCommand.INSTANCE);
                return command;
            }
            else if (oldIndex < tempIndex) {
                tempIndex--;
            }
            if (child.getModel() instanceof IState && tempIndex >= 0) {
                command.add(new ReorderStateCommand((IState) child.getModel(),
                        (IWebflowState) getHost().getModel(), oldIndex,
                        tempIndex));
            }
            else if (child.getModel() instanceof IIf && tempIndex >= 0) {
                command.add(new ReorderIfCommand((IIf) child.getModel(),
                        (IDecisionState) getHost().getModel(), oldIndex,
                        tempIndex));
            }
        }
        return command;
View Full Code Here

  /**
   * @return
   */
  private CompoundCommand getCommand() {
    List editparts = getSelectedObjects();
    CompoundCommand cc = new CompoundCommand();
    for (int i = 0; i < editparts.size(); i++) {
      EditPart part = (EditPart) editparts.get(i);
      cc.add(part.getCommand(request));
    }
    return cc;
  }
View Full Code Here

  /*
   * (non-Javadoc)
   * @see org.eclipse.jface.action.Action#run()
   */
  public void run() {
    CompoundCommand cc = getCommand();

    for (int i = 0; i < cc.getCommands().size(); i++) {
      if (cc.getCommands().get(i) instanceof EditPropertiesCommand) {
        EditPropertiesCommand command = (EditPropertiesCommand) cc
            .getCommands().get(i);
        this.openDialog = true;
        runWithCommand(command);
      }
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getAddCommand(org.eclipse.gef.requests.GroupRequest)
     */
    protected Command getAddCommand(GroupRequest request) {
        CompoundCommand cmd = new CompoundCommand();
        for (int i = 0; i < request.getEditParts().size(); i++) {
            if (getHost().getModel() instanceof ITransitionableFrom) {
                AddAndAssignSourceCommand add = new AddAndAssignSourceCommand();
                add.setParent((IWebflowState) getHost().getParent().getModel());
                add.setSource((ITransitionableFrom) getHost().getModel());
                add.setChild(((ITransitionableTo) ((EditPart) request
                        .getEditParts().get(i)).getModel()));
                cmd.add(add);
            }
        }
        return cmd;
    }
View Full Code Here

   * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getOrphanChildrenCommand(org.eclipse.gef.requests.GroupRequest)
   */
  @Override
  protected Command getOrphanChildrenCommand(GroupRequest request) {
    List parts = request.getEditParts();
    CompoundCommand result = new CompoundCommand();
    for (int i = 0; i < parts.size(); i++) {
      Activity child = (Activity) ((EditPart) parts.get(i)).getModel();
      OrphanChildCommand orphan = new OrphanChildCommand(child.getDiagram().getTextEditor());
      orphan.setChild(child);
      orphan.setParent((StructuredActivity) getHost().getModel());
      result.add(orphan);
    }
    return result.unwrap();
  }
View Full Code Here

  @Override
  protected Command getAddCommand(Request req) {
    ChangeBoundsRequest request = (ChangeBoundsRequest) req;
    List editParts = request.getEditParts();
    CompoundCommand command = new CompoundCommand();
    for (int i = 0; i < editParts.size(); i++) {
      EditPart child = (EditPart) editParts.get(i);
      command.add(createAddCommand(child));
    }
    return command.unwrap();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.gef.commands.CompoundCommand

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.