use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class SEDemoController method createInsertSelfTransitionAction.
protected IListenerAction createInsertSelfTransitionAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return SEDemoUI.SelfTransition.class;
}
public boolean performAction(Object actionParms) {
SEDemoUI.SelfTransition prms = (SEDemoUI.SelfTransition) actionParms;
if (prms.target != null) {
TaskApplication taskApp = script.getDemonstration().getTaskApplication();
Set<DeviceType> deviceTypeSet = taskApp.getDesign().getDeviceTypes();
int deviceTypes = DeviceType.buildDeviceSet(deviceTypeSet);
int limitMode = ActionProperties.determineChangeActionMode(prms.target);
AAction action = prms.action;
if (prms.action == null) {
properties.resetValues();
properties.setInitialActionType(prms.target, deviceTypeSet);
if (!interaction.determineNewAction(properties, deviceTypes, limitMode, L10N.get("DE.SetActionType", "Set Action Type"))) {
return false;
}
action = EditActionCmd.buildActionFromProperties(properties, deviceTypes, limitMode, interaction);
if (action == null) {
return false;
}
}
action = EditActionCmd.ensureActionIsUnique(prms.target, action, properties, deviceTypes, limitMode, null, interaction);
if (action == null) {
return false;
}
return performSelfTransition(prms.selection, prms.target, action, properties.delayInSecs, properties.delayLabel);
}
return false;
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class SNIFACTCmd method addTasksToGroup.
/**
* Creates an undoable edit for the action of adding the list of tasks
* stored in the execution context to the given task group.
*/
protected static IUndoableEdit addTasksToGroup(final Project project, final TaskGroup group, final SNIFACTExecContext context, final String undoLabel) {
return new AUndoableEdit(ProjectLID.RecomputeScript) {
protected Map<ITaskDesign, TaskApplication>[] associatedTAs = null;
protected boolean recoverMgrs = false;
@Override
public String getPresentationName() {
return undoLabel;
}
@Override
public void redo() {
super.redo();
recoverMgrs = false;
List<AUndertaking> tasks = context.getTasks();
for (int i = 0; i < tasks.size(); i++) {
AUndertaking curTask = tasks.get(i);
group.addUndertaking(curTask);
project.restoreRemovedTaskApplications(associatedTAs[i]);
}
}
@Override
@SuppressWarnings("unchecked")
public void undo() {
super.undo();
recoverMgrs = true;
List<AUndertaking> tasks = context.getTasks();
int size = tasks.size();
if (associatedTAs == null) {
associatedTAs = new Map[size];
}
// delete children; IMPORTANT: reverse order!
for (int i = tasks.size() - 1; 0 <= i; i--) {
AUndertaking curTask = tasks.get(i);
associatedTAs[i] = project.taskApplicationsForRemovedTask(curTask);
group.removeUndertaking(curTask);
}
}
@Override
public void die() {
super.die();
if (recoverMgrs) {
for (Map<ITaskDesign, TaskApplication> associatedTA : associatedTAs) {
UndoManagerRecovery.recoverScriptManagers(project, associatedTA, true);
}
}
}
};
}
use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class ScriptViewerController method createEditScriptAction.
protected IListenerAction createEditScriptAction() {
return new IListenerAction() {
public Class<?> getParameterClass() {
return Script.class;
}
public boolean performAction(Object actionParms) {
Script s = (Script) actionParms;
TaskApplication ta = s.getDemonstration().getTaskApplication();
try {
SEDemoController.openController(ta, s.getModelGenerator(), project);
} catch (GraphicsUtil.ImageException ex) {
//interaction.protestInvalidImageFile();
}
return true;
}
};
}
Aggregations