@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); } }
@Override public void undo() { if (fIndex != -1) { // might be already be deleted from Command in CompoundCommand fFolder.getElements().add(fIndex, fElement); } }