use of edu.cmu.cs.hcii.cogtool.model.AUndertaking 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.model.AUndertaking in project cogtool by cogtool.
the class ProjectController method createGenerateDictionaryAction.
protected IListenerAction createGenerateDictionaryAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return ProjectSelectionState.class;
}
public boolean performAction(Object prms) {
ProjectSelectionState seln = (ProjectSelectionState) prms;
AUndertaking[] tasks = seln.getSelectedTasks(TaskSelectionState.ORDER_SELECTION);
Design d = seln.getSelectedDesign();
boolean hasDict = false;
ITermSimilarity defaultAlg = ISimilarityDictionary.DEFAULT_ALG;
if (d != null) {
ISimilarityDictionary dict = (ISimilarityDictionary) d.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
if (!NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
hasDict = true;
defaultAlg = dict.getCurrentAlgorithm();
}
} else {
// No design selected, so just show the compute options
hasDict = true;
}
ProjectInteraction.GenerateEntriesData requestData = requestGenerateParms(generateEntriesMessage, defaultAlg, hasDict);
if (requestData == null) {
return false;
}
GenerateDictEntriesWorkThread workThread = new GenerateDictEntriesWorkThread(interaction, d, tasks, project, undoMgr, requestData);
CogTool.logger.info(String.format("Generating dictionary for design %s in project %s.", d.getName(), getProject().getName()));
ThreadManager.startNewThread(workThread);
return true;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.AUndertaking in project cogtool by cogtool.
the class ProjectController method createDeleteTaskAction.
// createDeleteDesignAction
// Action for DeleteTask
protected IListenerAction createDeleteTaskAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return TaskSelectionState.class;
}
public boolean performAction(Object prms) {
TaskSelectionState selection = (TaskSelectionState) prms;
AUndertaking[] selectedTasks = selection.getSelectedTasks(TaskSelectionState.PRUNE_SELECTION);
// Can only delete if one or more tasks are currently selected.
if ((selectedTasks != null) && (selectedTasks.length > 0)) {
if (interaction.confirmDeleteTasks(selectedTasks)) {
// Delete tasks without copying to the clipboard.
deleteTasks(selectedTasks, null, undoMgr);
return true;
}
} else {
interaction.protestNoSelection();
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.AUndertaking 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