Package org.eclipse.gef.commands

Examples of org.eclipse.gef.commands.CompoundCommand


      return false;
    return true;
  }

  public Command createAllRelabelCommands() {
    CompoundCommand compoundCmd = new CompoundCommand(ACTION_ID);
    for (int iterator = 0; iterator < getSelectedObjects().size(); iterator++) {
      Object selectedObject = getSelectedObjects().get(iterator);
      if (selectedObject instanceof MusicTreeEditPart
          && ((MusicTreeEditPart) selectedObject).getModel() instanceof MeasureForm)
        compoundCmd
            .add(createRelabelCommand((MusicTreeEditPart) selectedObject, iterator));
    }
    compoundCmd.add(new RefreshScreenCommand());
    LogService.info(MusicMessages.RelabelMeasuresAction_1 + compoundCmd.size() + MusicMessages.RelabelMeasuresAction_2);
    return compoundCmd;
  }
View Full Code Here


  protected boolean calculateEnabled() {
    return true;
  }

  public Command createMassInsertCommand() {
    this.compoundCmd = new CompoundCommand(getCompoundCommandName());
    massInsertStaffdefs();
    compoundCmd.add(new RefreshScreenCommand());
    return compoundCmd;
  }
View Full Code Here

}

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

}

@Override
@SuppressWarnings("rawtypes")
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(
          (BasicElement)child.getModel(),
          (MusicContainerForm)getHost().getModel(),
          tempIndex));
  }
  return command;
View Full Code Here

  protected boolean calculateEnabled() {
    return true;
  }

  public Command createMassInsertCommand() {
    this.compoundCmd = new CompoundCommand(getCompoundCommandName());
    massInsertMeasures();
    compoundCmd.add(new RefreshScreenCommand());
    return compoundCmd;
  }
View Full Code Here

  @Override
  @SuppressWarnings("rawtypes")
  public Command getOrphanChildrenCommand(GroupRequest request) {
    List parts = request.getEditParts();
    CompoundCommand result = new CompoundCommand(
        MusicMessages.MusicContainerEditPolicy_OrphanCommandLabelText);
    for (int i = 0; i < parts.size(); i++) {
      OrphanChildCommand orphan = new OrphanChildCommand();
      orphan.setChild((BasicElement) ((EditPart) parts.get(i)).getModel());
      orphan.setParent((MusicContainerForm) getHost().getModel());
      orphan.setLabel(MusicMessages.MusicElementEditPolicy_OrphanCommandLabelText);
      result.add(orphan);
    }
    return result.unwrap();
  }
View Full Code Here

    if (getHost() instanceof VertexEditPart) {
      VertexEditPart part = (VertexEditPart) getHost();
      List<?> incoming = part.getSourceConnections();
      List<?> outgoing = part.getTargetConnections();
      if (!incoming.isEmpty() || !outgoing.isEmpty()) {
        CompoundCommand compound = new CompoundCommand();
        for (Object obj : incoming) {
          DeleteCommand command = new DeleteCommand(
              ((EdgeEditPart) obj).getModel());
          compound.add(command);
        }

        for (Object obj : outgoing) {
          DeleteCommand command = new DeleteCommand(
              ((EdgeEditPart) obj).getModel());
          compound.add(command);
        }

        DeleteCommand command = new DeleteCommand(getHost().getModel());
        compound.add(command);

        return compound;
      }
    }
View Full Code Here

  public static Resource[] getResources(Command command) {
    if (command instanceof IEditModelCommand) {
      return ((IEditModelCommand)command).getResources();
    }
    if (command instanceof CompoundCommand) {
      CompoundCommand ccmd = (CompoundCommand) command;
     
      Set<Resource> set = new HashSet<Resource>();     
      for (Object n : ccmd.getChildren() ) {
        for (Resource r : getResources((Command)n)) {
          set.add(r);
        }               
      }
      if (set.isEmpty()) {
View Full Code Here

   
    if (command instanceof IEditModelCommand) {
      return ((IEditModelCommand)command).getModifiedResources();
    }
    if (command instanceof CompoundCommand) {
      CompoundCommand ccmd = (CompoundCommand) command;
     
      Set<Resource> set = new HashSet<Resource>();     
      for (Object n : ccmd.getChildren() ) {
        for (Resource r : getModifiedResources((Command)n)) {
          set.add(r);
        }               
      }
      if (set.isEmpty()) {
View Full Code Here

    EditPart indexPart = (EditPart)condemned.get(0);
    int index = getModelChildren().indexOf(indexPart.getModel());
   
    // remove all the valid selected edit parts
    GroupRequest request = new GroupRequest(RequestConstants.REQ_DELETE);
    CompoundCommand deletions = new CompoundCommand();
    for (Iterator iter = condemned.iterator(); iter.hasNext();) {
      EditPart part = (EditPart) iter.next();
      deletions.add(part.getCommand(request));
    }
    getCommandStack().execute(deletions);
   
    // Select the next edit part if one is available
    int size = getModelChildren().size();
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.