Package org.eclipse.gef.commands

Examples of org.eclipse.gef.commands.CompoundCommand


  @Override
  public Command chain(Command command) {
    if (command == null)
      return this;
    if (command instanceof SXECommand) {
      CompoundCommand result = new SXECompoundCommand();
      result.setDebugLabel("chained SXECommands");
      result.add(this);
      result.add(command);
      return result;
    } else
      return super.chain(command);
  }
View Full Code Here


   */
  protected CompoundCommand getSXECompoundCommand(CompoundCommand cc) {
    if (cc instanceof SXECompoundCommand)
      return cc;

    CompoundCommand r = new CompoundCommand();
    r.setLabel(cc.getLabel());

    SXECompoundCommand sxeCommand = new SXECompoundCommand();
    sxeCommand.setLabel(cc.getLabel());

    for (Object o : cc.getCommands()) {
      if (o instanceof SXECommand)
        sxeCommand.add((SXECommand) o);
      else
        r.add((Command) o);
    }

    if (r.getCommands().size() == 0)
      return sxeCommand;

    r.add(sxeCommand);

    return r;
  }
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");
    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());

      // Because of the scaling and not using double type in size,
      // nodes size was getting bigger. this bug is fixed.
      r.setSize(childPart.getFigure().getSize().getCopy());
      r.setLocation(r.getLocation().translate(1, 1));

      constraint = getConstraintFor(r);
      command.add(createAddCommand(generic,
        childPart,
        translateToModelConstraint(constraint)));
    }

    return command.unwrap();
  }
View Full Code Here

  }

  public Command getOrphanChildrenCommand(GroupRequest request)
  {
    List parts = request.getEditParts();
    CompoundCommand result =
      new CompoundCommand("MyContainerEditPolicy_OrphanCommandLabelText");

    for (int i = 0; i < parts.size(); i++) {
      OrphanChildCommand orphan = new OrphanChildCommand();
      orphan.setChild((NodeModel)((EditPart)parts.get(i)).getModel());
      orphan.setParent((CompoundModel)getHost().getModel());
      result.add(orphan);
    }

    return result.unwrap();
  }
View Full Code Here

        if (event.stateMask == SWT.MOD1 && event.keyCode == SWT.DEL) {
          final List<? extends EditorPart> objects = viewer.getSelectedEditParts();
          if (objects == null || objects.isEmpty())
            return true;
          final GroupRequest deleteReq = new GroupRequest(RequestConstants.REQ_DELETE);
          final CompoundCommand compoundCmd = new CompoundCommand("Delete"); //$NON-NLS-1$
          for (int i = 0; i < objects.size(); i++) {
            final EditPart object = (EditPart) objects.get(i);
            deleteReq.setEditParts(object);
            final Command cmd = object.getCommand(deleteReq);
            if (cmd != null)
              compoundCmd.add(cmd);
          }
          getCommandStack().execute(compoundCmd);
          return true;
        }
        if (event.stateMask == SWT.MOD3
          && (event.keyCode == SWT.ARROW_DOWN || event.keyCode == SWT.ARROW_LEFT
            || event.keyCode == SWT.ARROW_RIGHT || event.keyCode == SWT.ARROW_UP)) {
          final List<? extends EditorPart> objects = viewer.getSelectedEditParts();
          if (objects == null || objects.isEmpty())
            return true;
          // move request
          final GroupRequest moveReq = new ChangeBoundsRequest(RequestConstants.REQ_MOVE);
          final CompoundCommand compoundCmd = new CompoundCommand("Move"); //$NON-NLS-1$
          for (int i = 0; i < objects.size(); i++) {
            final EditPart object = (EditPart) objects.get(i);
            moveReq.setEditParts(object);
            final LocationCommand cmd = (LocationCommand) object.getCommand(moveReq);
            if (cmd != null) {
              cmd.setLocation(new Point(event.keyCode == SWT.ARROW_LEFT ? -1
                : event.keyCode == SWT.ARROW_RIGHT ? 1 : 0,
                event.keyCode == SWT.ARROW_DOWN ? 1
                  : event.keyCode == SWT.ARROW_UP ? -1 : 0));
              cmd.setRelative(true);
              compoundCmd.add(cmd);
            }
          }
          getCommandStack().execute(compoundCmd);
          return true;
        }
View Full Code Here

    }
    return false;
  }
 
  public Command createAddPossibleChildrenCommand() {
    CompoundCommand compoundCmd = new CompoundCommand(getCompoundCommandName());
    CreateCommand createCmd = new CreateCommand();
    createCmd.setParent(this.parent);
    createCmd.setChild(this.child);
    compoundCmd.add(createCmd);
    return compoundCmd;
  }
View Full Code Here

    redo();
  }
 
  @Override
  public void redo(){
    CompoundCommand compoundCommand = new CompoundCommand(COMMAND_ID);
    MusicDiagram activeDiagram = MusicPlugin.getDefault().getActiveDiagram();
    SectionForm child = new SectionForm();
    CreateCommand createCmd = new CreateCommand();
    createCmd.setParent(activeDiagram);
    createCmd.setChild(child);
    compoundCommand.add(createCmd);
    DeleteCommand cleanupCommand = new DeleteCommand();
    cleanupCommand.setParent(activeDiagram);
    cleanupCommand.setChild(child);
    compoundCommand.add(cleanupCommand);
    compoundCommand.execute();   
  }
View Full Code Here

      return false;
    return true;
  }

  public Command createCloneCommand(BasicElement child, MusicContainerForm parent) {
    CompoundCommand compoundCmd = new CompoundCommand(ACTION_ID);
    CreateCommand createCmd = new CreateCommand();
    createCmd.setParent(parent);
    try {
      createCmd.setChild(child.getClass().newInstance());
      createCmd.setMeiNode((MeiNode) child.getMeiNode().clone());
    } catch (InstantiationException e) {
      LogService.error(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      LogService.error(e.getMessage(), e);
    }
    compoundCmd.add(createCmd);
    LogService.info(MusicMessages.CloneFormAction_4 + compoundCmd.size());
    return compoundCmd;
  }
View Full Code Here

    return true;
  }

  @SuppressWarnings("unchecked")
  public Command createManageSourcesCommand() {
    CompoundCommand compoundCmd = new CompoundCommand(ACTION_ID);
    ManageSourcesCommand manageSourcesCmd = new ManageSourcesCommand();
    manageSourcesCmd.setMusicDiagram(MusicPlugin.getDefault().getActiveDiagram());
    manageSourcesCmd.setPostList((List<SourceBindingWrapper>) Display.getCurrent().getData(StringConstants.MUSIC_DIAGRAM_DIRTY));
    manageSourcesCmd.setPreList(MusicPlugin.getDefault().getActiveDiagram().getSourceList());
    compoundCmd.add(manageSourcesCmd);
    return compoundCmd;
  }
View Full Code Here

@Override
@SuppressWarnings("rawtypes")
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

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.