use of edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit in project cogtool by cogtool.
the class ProjectController method createDuplicateTaskFullAction.
protected IListenerAction createDuplicateTaskFullAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return ProjectUI.ChangeTaskPositionParms.class;
}
public boolean performAction(Object actionParms) {
ProjectUI.ChangeTaskPositionParms prms = (ProjectUI.ChangeTaskPositionParms) actionParms;
if ((prms.tasks == null) || (prms.tasks.getSelectedTaskCount() == 0)) {
interaction.protestNoSelection();
return false;
}
AUndertaking[] selectedTasks = prms.tasks.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION | TaskSelectionState.ORDER_SELECTION);
TaskParent placeBeforeTaskParent = (prms.placeBeforeTask != null) ? project.getTaskParent(prms.placeBeforeTask) : project;
List<AUndertaking> siblings = placeBeforeTaskParent.getUndertakings();
int atIndex = (prms.placeBeforeTask != null) ? siblings.indexOf(prms.placeBeforeTask) : siblings.size();
String presentationName = (selectedTasks.length > 1) ? DUPLICATE_TASKS : DUPLICATE_TASK;
CompoundUndoableEdit editSeq = new CompoundUndoableEdit(presentationName, ProjectLID.DuplicateTaskFull);
AUndertaking lastDuplicate = null;
for (int i = 0; i < selectedTasks.length; i++) {
lastDuplicate = duplicateTask(selectedTasks[i], atIndex + i, placeBeforeTaskParent, siblings, ProjectLID.DuplicateTaskFull, presentationName, editSeq);
}
// Done with undo/redo steps; add the compound change
// to the undo manager.
editSeq.end();
undoMgr.addEdit(editSeq);
if (selectedTasks.length == 1) {
ui.initiateTaskRename(lastDuplicate);
}
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit in project cogtool by cogtool.
the class ProjectController method createUngroupAction.
protected IListenerAction createUngroupAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return TaskSelectionState.class;
}
public boolean performAction(Object prms) {
TaskSelectionState seln = (TaskSelectionState) prms;
AUndertaking[] tasks = seln.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION | TaskSelectionState.ORDER_SELECTION | TaskSelectionState.TASK_GROUPS_ONLY);
if ((tasks == null) || (tasks.length == 0)) {
interaction.protestNoSelection();
return false;
}
CompoundUndoableEdit editSeq = new CompoundUndoableEdit(L10N.get("PC.Ungroup", "Ungroup"), ProjectLID.Ungroup);
for (AUndertaking task : tasks) {
if (task.isTaskGroup()) {
TaskGroup group = (TaskGroup) task;
List<AUndertaking> childTasks = group.getUndertakings();
int numChildTasks = childTasks.size();
if (numChildTasks > 0) {
AUndertaking[] promoteTasks = new AUndertaking[numChildTasks];
childTasks.toArray(promoteTasks);
for (int j = numChildTasks - 1; j >= 0; j--) {
promoteTask(promoteTasks[j], ProjectLID.Ungroup, editSeq);
}
}
}
}
deleteTasks(tasks, null, editSeq);
if (editSeq.isSignificant()) {
editSeq.end();
undoMgr.addEdit(editSeq);
}
return true;
}
};
}
Aggregations