Ejemplo n.º 1
0
 @Override
 public void execute() {
   // Ensure fIndex is stored just before execute because if this is part of a composite delete
   // action
   // then the index positions will have changed
   fIndex = fFolder.getElements().indexOf(fElement);
   if (fIndex != -1) { // might be already be deleted from Command in CompoundCommand
     fFolder.getElements().remove(fElement);
   }
 }
Ejemplo n.º 2
0
  @Override
  public void redo() {
    fParent.getFolders().add(fFolder);

    // Select
    UIRequestManager.INSTANCE.fireRequest(
        new TreeSelectionRequest(this, new StructuredSelection(fFolder), true));
  }
Ejemplo n.º 3
0
  @Override
  public void undo() {
    fParent.getFolders().remove(fFolder);

    // Select the parent node if no node is selected (this happens when the node is deleted)
    TreeSelectionRequest request =
        new TreeSelectionRequest(this, new StructuredSelection(fParent), true) {
          @Override
          public boolean shouldSelect(Viewer viewer) {
            return viewer.getSelection().isEmpty();
          }
        };
    UIRequestManager.INSTANCE.fireRequest(request);
  }
Ejemplo n.º 4
0
 @Override
 public void undo() {
   if (fIndex != -1) { // might be already be deleted from Command in CompoundCommand
     fFolder.getElements().add(fIndex, fElement);
   }
 }