Search in sources :

Example 41 with AUndertaking

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

the class ProjectUIModel method populateRow.

protected void populateRow(AUndertaking undertaking, final TreeItem row) {
    taskTreeItems.put(undertaking, row);
    row.addListener(SWT.Dispose, onDisposeRow);
    // TODO: This is creating a new handler instance for each row
    // TODO: reuse a single instance by looking up TreeItem in taskTreeItems?
    AlertHandler handler = new AlertHandler() {

        public void handleAlert(EventObject alert) {
            AUndertaking task = (AUndertaking) row.getData();
            row.setText(0, SWTStringUtil.insertEllipsis(task.getName(), 300, StringUtil.EQUAL, tree.getFont()));
            setRowBackground(task, row);
        }
    };
    row.setData(undertaking);
    undertaking.addHandler(this, NameChangeAlert.class, handler);
    row.setText(getTaskRowStrings(undertaking));
    Color bkg = setRowBackground(undertaking, row);
    int numCols = tree.getColumnCount();
    for (int i = 0; i < numCols; i++) {
        row.setBackground(i, bkg);
    }
    if (undertaking.isTaskGroup()) {
        TaskGroup group = (TaskGroup) undertaking;
        setGroupAlertHandlers(group, row);
        addTasks(group.getUndertakings().iterator(), row);
    }
    row.setExpanded(true);
    if (rowHook != null) {
        rowHook.onRowCreation(row);
    }
}
Also used : AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) Color(org.eclipse.swt.graphics.Color) AlertHandler(edu.cmu.cs.hcii.cogtool.util.AlertHandler) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup) EventObject(java.util.EventObject)

Example 42 with AUndertaking

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

the class ProjectUIModel method redisplayResults.

// For task represented by row and all parent task groups!
protected void redisplayResults(TreeItem row) {
    // Propagate changes to parent items
    while (row != null) {
        AUndertaking task = (AUndertaking) row.getData();
        row.setText(getTaskRowStrings(task));
        setRowBackground(task, row);
        row = row.getParentItem();
    }
}
Also used : AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking)

Example 43 with AUndertaking

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

the class ProjectUIModel method installUndertakings.

// setGroupAlertHandlers
protected void installUndertakings() {
    Iterator<AUndertaking> undertakings = project.getUndertakings().iterator();
    while (undertakings.hasNext()) {
        AUndertaking undertaking = undertakings.next();
        TreeItem row = new TreeItem(tree, SWT.NONE);
        populateRow(undertaking, row);
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking)

Example 44 with AUndertaking

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

the class GenerateDictEntriesWorkThread method generateEntries.

protected void generateEntries(Iterator<AUndertaking> tasks, DictEntryGenerator generator, ITermSimilarity alg) {
    while (tasks.hasNext() && !isCanceled() && !isStopped()) {
        AUndertaking t = tasks.next();
        if (t instanceof TaskGroup) {
            SNIFACTExecContext context = (SNIFACTExecContext) t.getAttribute(WidgetAttributes.SNIFACT_CONTEXT_ATTR);
            if (!NullSafe.equals(context, WidgetAttributes.NO_CONTEXT)) {
                generator.generateEntries(context.getParameters().taskName, alg, this, this, requestData.computeAll, computeErrors, progressCallback);
            } else {
                Iterator<AUndertaking> subTasks = ((TaskGroup) t).getUndertakings().iterator();
                generateEntries(subTasks, generator, alg);
            }
        } else if (!t.isSpawned()) {
            generator.generateEntries(t.getName(), alg, this, this, requestData.computeAll, computeErrors, progressCallback);
        }
    }
}
Also used : AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) SNIFACTExecContext(edu.cmu.cs.hcii.cogtool.model.SNIFACTExecContext) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup)

Example 45 with AUndertaking

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

the class HCIPACmd method checkStartFrame.

public static void checkStartFrame(Project project, TaskApplication ta, CognitiveModelGenerator modelGen) {
    Demonstration demo = ta.getDemonstration();
    // If start frame is already chosen, fine.
    if ((demo.getStartFrame() != null) && (demo.isStartFrameChosen())) {
        return;
    }
    AUndertaking selectedTask = ta.getTask();
    // then don't try to determine based on previous sibling's target frame
    if (selectedTask.getTaskGroup() == null) {
        return;
    }
    // Try to find the previous sibling
    List<AUndertaking> tasks = selectedTask.getTaskGroup().getUndertakings();
    int index = tasks.indexOf(selectedTask);
    // If no previous sibling, can't do anything
    if (index > 1) {
        AUndertaking prevTask = tasks.get(index - 1);
        TaskApplication prevTA = project.getTaskApplication(prevTask, ta.getDesign());
        // can't do anything
        if (prevTA != null) {
            Demonstration prevDemo = prevTA.getDemonstration();
            if (prevDemo != null) {
                demo.setStartFrame(prevDemo.getResultFrame());
                demo.setStartFrameChosen(prevDemo.isStartFrameChosen());
                // In HCIPA, the last state in the previous script should be
                // the same as the first state in the new script
                Script s = prevTA.getScript(modelGen);
                copyState(s, demo);
            }
        }
    }
}
Also used : Script(edu.cmu.cs.hcii.cogtool.model.Script) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration)

Aggregations

AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)89 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)38 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)35 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)30 Design (edu.cmu.cs.hcii.cogtool.model.Design)28 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)24 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)18 ProjectSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)17 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)14 Script (edu.cmu.cs.hcii.cogtool.model.Script)13 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)13 IOException (java.io.IOException)12 TaskSelectionState (edu.cmu.cs.hcii.cogtool.ui.TaskSelectionState)11 IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)10 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)10 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)10 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)9 TaskParent (edu.cmu.cs.hcii.cogtool.model.TaskParent)9 TreeItem (org.eclipse.swt.widgets.TreeItem)9 ArrayList (java.util.ArrayList)7