Package org.eclipse.gef.commands

Examples of org.eclipse.gef.commands.CompoundCommand


  return null;
}

public Command getOrphanChildrenCommand(GroupRequest request) {
  List parts = request.getEditParts();
  CompoundCommand result =
    new CompoundCommand(LogicMessages.LogicContainerEditPolicy_OrphanCommandLabelText);
  for (int i = 0; i < parts.size(); i++) {
    OrphanChildCommand orphan = new OrphanChildCommand();
    orphan.setChild((LogicSubpart)((EditPart)parts.get(i)).getModel());
    orphan.setParent((LogicDiagram)getHost().getModel());
    orphan.setLabel(LogicMessages.LogicElementEditPolicy_OrphanCommandLabelText);
    result.add(orphan);
  }
  return result.unwrap();
}
View Full Code Here


    cmd.setIndex(index);
  return cmd;
}

protected Command getAddCommand(ChangeBoundsRequest request){
  CompoundCommand command = new CompoundCommand();
  command.setDebugLabel("Add in LogicTreeContainerEditPolicy");//$NON-NLS-1$
  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 {
      LogicSubpart childModel = (LogicSubpart)child.getModel();
      command.add(createCreateCommand(
            childModel,
            new Rectangle(new org.eclipse.draw2d.geometry.Point(),
              childModel.getSize()),
            index, "Reparent LogicSubpart"));//$NON-NLS-1$
    }
View Full Code Here

  int index = findIndexOfTreeItemAt(request.getLocation());
  return createCreateCommand(child, null, index, "Create LogicSubpart");//$NON-NLS-1$
}

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--;
    }
    command.add(new ReorderPartCommand(
          (LogicSubpart)child.getModel(),
          (LogicDiagram)getHost().getModel(),
          tempIndex));
  }
  return command;
View Full Code Here

  return true;
}

private Command getCommand() {
  List editparts = getSelectedObjects();
  CompoundCommand cc = new CompoundCommand();
  cc.setDebugLabel("Increment/Decrement LEDs");//$NON-NLS-1$
  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

}

protected Command getAddCommand(Request generic) {
  ChangeBoundsRequest request = (ChangeBoundsRequest)generic;
  List editParts = request.getEditParts();
  CompoundCommand command = new CompoundCommand();
  command.setDebugLabel("Add in ConstrainedLayoutEditPolicy");//$NON-NLS-1$
  GraphicalEditPart childPart;
  Rectangle r;
  Object constraint;

  for (int i = 0; i < editParts.size(); i++) {
    childPart = (GraphicalEditPart)editParts.get(i);
    r = childPart.getFigure().getBounds().getCopy();
    //convert r to absolute from childpart figure
    childPart.getFigure().translateToAbsolute(r);
    r = request.getTransformedRectangle(r);
    //convert this figure to relative
    getLayoutContainer().translateToRelative(r);
    getLayoutContainer().translateFromParent(r);
    r.translate(getLayoutOrigin().getNegated());
    constraint = getConstraintFor(r);
    command.add(createAddCommand(generic, childPart,
      translateToModelConstraint(constraint)));
  }
  return command.unwrap();
}
View Full Code Here

  /**
   * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getAddCommand(org.eclipse.gef.requests.GroupRequest)
   */
  @Override
  protected Command getAddCommand(GroupRequest request) {
    CompoundCommand cmd = new CompoundCommand();
    for (int i = 0; i < request.getEditParts().size(); i++) {
      StructuredActivity parent = (StructuredActivity) getHost().getParent().getModel();
      AddAndAssignSourceCommand add = new AddAndAssignSourceCommand(parent.getDiagram().getTextEditor());
      add.setParent(parent);
      add.setSource((Activity) getHost().getModel());
      add.setChild(((Activity) ((EditPart) request.getEditParts().get(i)).getModel()));
      cmd.add(add);
    }
    return cmd;
  }
View Full Code Here

    return true;
  }

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

   * (non-Javadoc)
   * @see org.eclipse.gef.editpolicies.ContainerEditPolicy#getOrphanChildrenCommand(org.eclipse.gef.requests.GroupRequest)
   */
  protected Command getOrphanChildrenCommand(GroupRequest request) {
    List parts = request.getEditParts();
    CompoundCommand result = new CompoundCommand();
    for (int i = 0; i < parts.size(); i++) {
      EditPart part = (EditPart) parts.get(i);
      if (part.getModel() instanceof IActionElement) {
        ActionOrphanChildCommand orphan = new ActionOrphanChildCommand();
        orphan.setChild((IActionElement) ((EditPart) parts.get(i))
            .getModel());
        result.add(orphan);
      }
      else if (part.getModel() instanceof IExceptionHandler) {
        ExceptionHandlerOrphanChildCommand orphan = new ExceptionHandlerOrphanChildCommand();
        orphan.setChild((IExceptionHandler) ((EditPart) parts.get(i))
            .getModel());
        result.add(orphan);
      }
      else if (part.getModel() instanceof IAttributeMapper) {
        AttributeMapperOrphanChildCommand orphan = new AttributeMapperOrphanChildCommand();
        orphan.setChild((IAttributeMapper) ((EditPart) parts.get(i))
            .getModel());
        orphan.setParent((ISubflowState) getHost().getModel());
        result.add(orphan);
      }
      else if (part.getModel() instanceof IIf) {
        IfOrphanChildCommand orphan = new IfOrphanChildCommand();
        orphan.setChild((IIf) ((EditPart) parts.get(i)).getModel());
        orphan.setParent((IDecisionState) getHost().getModel());
        result.add(orphan);
      }
    }
    return result.unwrap();
  }
View Full Code Here

   * @param request the clone request
   * @return the command contribution to the clone
   */
  protected Command getCloneCommand(ChangeBoundsRequest request) {
    List parts = request.getEditParts();
    CompoundCommand result = new CompoundCommand();
    for (int i = 0; i < parts.size(); i++) {
      EditPart part = (EditPart) parts.get(i);
      if (part.getModel() instanceof IActionElement) {
        IActionElement ae = (IActionElement) part.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)) {
          ActionCloneCommand orphan = new ActionCloneCommand();
          orphan.setChild((IActionElement) ((EditPart) parts.get(i))
              .getModel());
          orphan.setNewState((IWebflowModelElement) getHost()
              .getModel());
          result.add(orphan);
        }
      }
      else if (part.getModel() instanceof IExceptionHandler) {
        IState state = (IState) getHost().getModel();
        if (!(state instanceof IWebflowState)
            && !(state instanceof IInlineFlowState)) {
          ExceptionHandlerCloneCommand orphan = new ExceptionHandlerCloneCommand();
          orphan.setChild((IExceptionHandler) ((EditPart) parts.get(i))
              .getModel());
          orphan.setNewState((IWebflowModelElement) getHost()
              .getModel());
          result.add(orphan);
        }
      }
      else if (part.getModel() instanceof IAttributeMapper) {
        IState state = (IState) getHost().getModel();
        if (state instanceof SubflowState
            && ((SubflowState) state).getAttributeMapper() == null) {
          AttributeMapperCloneCommand orphan = new AttributeMapperCloneCommand();
          orphan.setChild((IAttributeMapper) ((EditPart) parts.get(i))
              .getModel());
          orphan.setNewState((IWebflowModelElement) getHost()
              .getModel());
          result.add(orphan);
        }
      }
    }
    return result.unwrap();
  }
View Full Code Here

     *
     * @return
     */
    private Command 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

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.