Search in sources :

Example 1 with Task

use of edu.cmu.cs.hcii.cogtool.model.Task in project cogtool by cogtool.

the class ProjectController method addTask.

/**
     * Add a new task to a task group.  Assign its position based on the
     * given task, or at the beginning if the given task is <code>null</code>.
     * Returns the created task.
     * Also adds the appropriate undo/redo to the controller's undo manager.
     *
     * @param parent the task group where the task will be added
     * @param atIndex the index at which to place the task
     * @param newTaskName the name for the new task
     * @param lid the undo/redo command token
     * @param presentationName the undo/redo command label
     * @param editSeq the undo/redo sequence to hold the new edit
     */
protected Task addTask(TaskParent parent, int atIndex, String newTaskName, CogToolLID lid, String presentationName, IUndoableEditSequence editSeq) {
    // Create task and add to the task group
    Task newTask = new Task(newTaskName);
    parent.addUndertaking(atIndex, newTask);
    // Create undo/redo step and add to the undo manager
    editSeq.addEdit(createNewTaskUndo(parent, atIndex, newTask, lid, presentationName));
    return newTask;
}
Also used : Task(edu.cmu.cs.hcii.cogtool.model.Task)

Example 2 with Task

use of edu.cmu.cs.hcii.cogtool.model.Task in project cogtool by cogtool.

the class ProjectController method createNewTaskAction.

// Action for NewTask
protected IListenerAction createNewTaskAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return TaskSelectionState.class;
        }

        public boolean performAction(Object prms) {
            TaskSelectionState selection = (TaskSelectionState) prms;
            // Figure out what the selection is
            AUndertaking[] selectedTasks = selection.getSelectedTasks(TaskSelectionState.ORDER_SELECTION);
            Task newTask = null;
            if ((selectedTasks == null) || (selectedTasks.length == 0)) {
                // No task selection -- add a new root task
                String newTaskName = computeNewTaskName(project, DEFAULT_TASK_PREFIX);
                newTask = addTask(project, project.getUndertakings().size(), newTaskName);
            } else {
                // At least one selected task: add a new sibling after
                // Multiple selected tasks:
                //   if all tasks have same parent,
                //          add new sibling after last selection
                //   if tasks do not have same parent,
                //          add new root task after last selected root
                //          but, if no selected root, add new root at end
                // Get parent
                TaskGroup parent = selection.getSelectedTaskParent();
                if (parent == null) {
                    String newTaskName = computeNewTaskName(project, DEFAULT_TASK_PREFIX);
                    newTask = addTask(project, findLastSelectedRoot(selectedTasks), newTaskName);
                } else {
                    String newTaskName = computeNewTaskName(parent, DEFAULT_TASK_PREFIX);
                    AUndertaking last = selectedTasks[selectedTasks.length - 1];
                    newTask = addTask(parent, parent.getUndertakings().indexOf(last) + 1, newTaskName);
                }
            }
            // Task is automatically selected when added -- rename
            // Cannot put this into the ui because of undo/redo
            ui.initiateTaskRename(newTask);
            return true;
        }
    };
}
Also used : Task(edu.cmu.cs.hcii.cogtool.model.Task) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) TaskSelectionState(edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup)

Example 3 with Task

use of edu.cmu.cs.hcii.cogtool.model.Task in project cogtool by cogtool.

the class HCIPACmd method addHCIPATasks.

/**
     * Returns the created subtasks
     */
public static AUndertaking[] addHCIPATasks(Project project, AUndertaking task, String taskName, CognitiveModelGenerator modelGen, String undoRedoLabel, IUndoableEditSequence editSeq) {
    AUndertaking[] subtasks = new AUndertaking[6];
    String[] subtaskNames = new String[] { IDENTIFY_LABEL + taskName, FUNCTION_LABEL, L10N.get("HC.AccessLabel", "3) Access Step"), L10N.get("HC.EnterLabel", "4) Enter Step"), L10N.get("HC.ConfirmLabel", "5) Confirm & Save Step"), L10N.get("HC.MonitorLabel", "6) Monitor Step") };
    TaskGroup group = new TaskGroup(taskName, GroupNature.SUM);
    for (int i = 0; i < 6; i++) {
        subtasks[i] = new Task(subtaskNames[i]);
        subtasks[i].setSpawned(true);
        group.addUndertaking(i, subtasks[i]);
    }
    Iterator<Design> designs = project.getDesigns().iterator();
    while (designs.hasNext()) {
        initHCIPATaskDesign(project, taskName, subtasks, designs.next(), modelGen);
    }
    TaskParent parent = task.getTaskGroup();
    if (parent == null) {
        parent = project;
    }
    editSeq.addEdit(replaceTask(project, parent, task, group, undoRedoLabel));
    return subtasks;
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) Task(edu.cmu.cs.hcii.cogtool.model.Task) TaskParent(edu.cmu.cs.hcii.cogtool.model.TaskParent) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup)

Aggregations

Task (edu.cmu.cs.hcii.cogtool.model.Task)3 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)2 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)1 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)1 TaskParent (edu.cmu.cs.hcii.cogtool.model.TaskParent)1 TaskSelectionState (edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState)1 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)1