Search in sources :

Example 31 with TaskApplication

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;
}
Also used : Script(edu.cmu.cs.hcii.cogtool.model.Script) ArrayList(java.util.ArrayList) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) CognitiveModelGenerator(edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator)

Example 32 with TaskApplication

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());
        }
    }
}
Also used : TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication)

Example 33 with TaskApplication

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;
}
Also used : TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication)

Example 34 with TaskApplication

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();
}
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) TaskGroup(edu.cmu.cs.hcii.cogtool.model.TaskGroup)

Example 35 with TaskApplication

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;
        }
    };
}
Also used : RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) AListenerAction(edu.cmu.cs.hcii.cogtool.util.AListenerAction) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) RcvrIOException(edu.cmu.cs.hcii.cogtool.util.RcvrIOException) IOException(java.io.IOException) RcvrIOSaveException(edu.cmu.cs.hcii.cogtool.util.RcvrIOSaveException) RcvrClipboardException(edu.cmu.cs.hcii.cogtool.util.RcvrClipboardException) RcvrImageException(edu.cmu.cs.hcii.cogtool.util.RcvrImageException) RcvrOutOfMemoryException(edu.cmu.cs.hcii.cogtool.util.RcvrOutOfMemoryException) RcvrIOException(edu.cmu.cs.hcii.cogtool.util.RcvrIOException) SAXException(org.xml.sax.SAXException) RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) RcvrUIException(edu.cmu.cs.hcii.cogtool.util.RcvrUIException) IOException(java.io.IOException) RecoverableException(edu.cmu.cs.hcii.cogtool.util.RecoverableException) RcvrIOSaveException(edu.cmu.cs.hcii.cogtool.util.RcvrIOSaveException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) BufferedWriter(java.io.BufferedWriter) RcvrIllegalStateException(edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) TaskApplication(edu.cmu.cs.hcii.cogtool.model.TaskApplication) File(java.io.File) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) BufferedWriter(java.io.BufferedWriter) RecoverableException(edu.cmu.cs.hcii.cogtool.util.RecoverableException)

Aggregations

TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)63 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)38 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)22 Design (edu.cmu.cs.hcii.cogtool.model.Design)20 Script (edu.cmu.cs.hcii.cogtool.model.Script)20 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)17 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)16 IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)15 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)14 ProjectSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)12 IOException (java.io.IOException)12 CognitiveModelGenerator (edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator)11 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)11 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)10 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)10 RcvrIOException (edu.cmu.cs.hcii.cogtool.util.RcvrIOException)10 APredictionResult (edu.cmu.cs.hcii.cogtool.model.APredictionResult)8 File (java.io.File)8 RcvrIllegalStateException (edu.cmu.cs.hcii.cogtool.util.RcvrIllegalStateException)7 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)5