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);
}
}
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();
}
}
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);
}
}
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);
}
}
}
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);
}
}
}
}
Aggregations