use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class DemoScriptCmd method regenerateScripts.
public static Collection<ComputationUndoRedo> regenerateScripts(Demonstration demo, int atStepIndex, AScriptStep oldDemoStep, Interaction interaction) {
Collection<ComputationUndoRedo> scriptsUndoRedoData = new ArrayList<ComputationUndoRedo>();
if (!demo.isEditable()) {
return scriptsUndoRedoData;
}
TaskApplication taskApp = demo.getTaskApplication();
Iterator<CognitiveModelGenerator> modelGens = taskApp.getModelGenerators();
while (modelGens.hasNext()) {
CognitiveModelGenerator modelGen = modelGens.next();
Script script = taskApp.getScript(modelGen);
if (script != null) {
scriptsUndoRedoData.add(new ScriptUndoRedo(script, interaction, atStepIndex, oldDemoStep));
}
}
return scriptsUndoRedoData;
}
use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class DemoStateManager method removeStateManager.
public static void removeStateManager(Project project, Design design) {
DemoStateManager mgr = stateMgrRegistry.remove(design);
if (mgr != null) {
Iterator<TaskApplication> designTAs = project.taskApplicationsForDesign(design).values().iterator();
while (designTAs.hasNext()) {
TaskApplication ta = designTAs.next();
mgr.stopTrackingEdits(ta.getDemonstration());
}
}
}
use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class DemoStateManager method getStateManager.
public static DemoStateManager getStateManager(Project project, Design design) {
DemoStateManager mgr = stateMgrRegistry.get(design);
if (mgr == null) {
mgr = new DemoStateManager(project, design);
stateMgrRegistry.put(design, mgr);
Iterator<TaskApplication> designTAs = project.taskApplicationsForDesign(design).values().iterator();
while (designTAs.hasNext()) {
TaskApplication ta = designTAs.next();
mgr.trackEdits(ta.getDemonstration());
}
}
return mgr;
}
use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class ScriptViewerUIModel method dispose.
/**
* Dispose: clear the currentFrame of the window, and remove all handlers
*/
@Override
public void dispose() {
TaskGroup group = (TaskGroup) taskDesign.getTask();
Iterator<AUndertaking> tasks = group.getUndertakings().iterator();
while (tasks.hasNext()) {
AUndertaking childTask = tasks.next();
TaskApplication tApp = project.getTaskApplication(childTask, design);
if (tApp != null) {
Script script = tApp.getOnlyScript();
script.removeAllHandlers(this);
script.getDemonstration().removeAllHandlers(this);
}
}
super.dispose();
}
use of edu.cmu.cs.hcii.cogtool.model.TaskApplication in project cogtool by cogtool.
the class DesignEditorController method createExportDesignToXMLAction.
protected IListenerAction createExportDesignToXMLAction() {
return new AListenerAction() {
public boolean performAction(Object actionParms) {
String defaultFilename = design.getName() + ".xml";
File exportFile = interaction.selectXMLFile(false, defaultFilename);
if (exportFile == null) {
return false;
}
OutputStream oStream = null;
try {
try {
oStream = new FileOutputStream(exportFile);
Writer xmlWriter = new BufferedWriter(new OutputStreamWriter(oStream, "UTF-8"));
Map<ITaskDesign, TaskApplication> designTAs = project.taskApplicationsForDesign(design);
ExportCogToolXML.exportXML(design, designTAs, xmlWriter, "UTF-8");
xmlWriter.flush();
} finally {
if (oStream != null) {
oStream.close();
}
}
} catch (IllegalArgumentException e) {
throw new RcvrIllegalStateException("Invalid argument exporting to XML", e);
} catch (IllegalStateException e) {
throw new RcvrIllegalStateException("Exporting to XML", e);
} catch (IOException e) {
throw new RcvrIOSaveException("Exporting to XML", e);
} catch (Exception e) {
throw new RecoverableException("Exporting to XML", e);
}
interaction.setStatusMessage(L10N.get("PC.DesignExportedToXML", "Design exported to XML:") + " " + exportFile.getName());
return true;
}
};
}
Aggregations