Search in sources :

Example 6 with ISimilarityDictionary

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

the class DictEntryGenerator method insertEntries.

public void insertEntries(final DictionaryEditorController dec, final boolean computeAll, final ITermSimilarity oldAlg, final ITermSimilarity alg, Project project, IUndoableEditSequence editSequence) {
    final ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
    if ((newDictEntries.size() > 0) || (updatedDictEntries.size() > 0)) {
        dict.insertEntries(newDictEntries, computeAll);
        dict.insertEntries(updatedDictEntries, computeAll);
        IUndoableEdit edit = new AUndoableEdit(ProjectLID.GenerateDictionary) {

            @Override
            public String getPresentationName() {
                return GENERATE_DICTIONARY;
            }

            @Override
            public void redo() {
                super.redo();
                dict.insertEntries(newDictEntries, computeAll);
                dict.insertEntries(updatedDictEntries, computeAll);
                dec.setCurrentAlgorithm(alg);
            }

            @Override
            public void undo() {
                super.undo();
                dict.removeEntries(newDictEntries);
                dict.insertEntries(oldDictEntries, computeAll);
                dec.setCurrentAlgorithm(oldAlg);
            }
        };
        editSequence.addEdit(edit);
        UndoManager.getUndoManager(dict, project).addEdit(edit);
    } else {
        dec.interaction.setStatusMessage("No entries to compute.");
    }
}
Also used : AUndoableEdit(edu.cmu.cs.hcii.cogtool.util.AUndoableEdit) IUndoableEdit(edu.cmu.cs.hcii.cogtool.util.IUndoableEdit) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)

Example 7 with ISimilarityDictionary

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

the class ProjectController method createExportDictionaryAction.

protected IListenerAction createExportDictionaryAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return ProjectSelectionState.class;
        }

        public boolean performAction(Object actionParms) {
            ProjectSelectionState seln = (ProjectSelectionState) actionParms;
            Design design = seln.getSelectedDesign();
            if (design == null) {
                interaction.reportProblem("Export Dictionary", "No design is selected");
                return false;
            }
            ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
            if (dict == null) {
                interaction.reportProblem("Export Dictionary", "No dictionary exists for the selected design");
                return false;
            }
            return DictionaryEditorCmd.exportDictionaryToCSV(dict, interaction);
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) ProjectSelectionState(edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)

Example 8 with ISimilarityDictionary

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

the class UndoManagerRecovery method recoverManagers.

/**
     * Recover UndoManagers for the given design and its associated
     * task applications.  Also recovers for the design's frames and widgets.
     *
     * @param project the project containing the model objects
     * @param design design whose ITaskApplications to recover managers for
     * @param associatedTAs maps ITaskDesign to TaskApplication
     */
public static void recoverManagers(Project project, Design design, Map<ITaskDesign, TaskApplication> associatedTAs) {
    DemoStateManager.removeStateManager(project, design);
    // Recover UndoManagers for design's frames
    // (used by FrameEditorControllers)
    Iterator<Frame> frames = design.getFrames().iterator();
    while (frames.hasNext()) {
        Frame frame = frames.next();
        recoverManagers(project, frame);
    }
    recoverScriptManagers(project, associatedTAs, false);
    // Recover UndoManager for design's dictionary, if one exists
    ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
    if (!NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
        recoverManagers(project, dict);
    }
    // Recover UndoManager for design (used by DesignEditorController)
    recoverManagers(project, design);
}
Also used : Frame(edu.cmu.cs.hcii.cogtool.model.Frame) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)

Example 9 with ISimilarityDictionary

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

the class ProjectController method createGenerateDictionaryAction.

protected IListenerAction createGenerateDictionaryAction() {
    return new IListenerAction() {

        public Class<?> getParameterClass() {
            return ProjectSelectionState.class;
        }

        public boolean performAction(Object prms) {
            ProjectSelectionState seln = (ProjectSelectionState) prms;
            AUndertaking[] tasks = seln.getSelectedTasks(TaskSelectionState.ORDER_SELECTION);
            Design d = seln.getSelectedDesign();
            boolean hasDict = false;
            ITermSimilarity defaultAlg = ISimilarityDictionary.DEFAULT_ALG;
            if (d != null) {
                ISimilarityDictionary dict = (ISimilarityDictionary) d.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
                if (!NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
                    hasDict = true;
                    defaultAlg = dict.getCurrentAlgorithm();
                }
            } else {
                // No design selected, so just show the compute options
                hasDict = true;
            }
            ProjectInteraction.GenerateEntriesData requestData = requestGenerateParms(generateEntriesMessage, defaultAlg, hasDict);
            if (requestData == null) {
                return false;
            }
            GenerateDictEntriesWorkThread workThread = new GenerateDictEntriesWorkThread(interaction, d, tasks, project, undoMgr, requestData);
            CogTool.logger.info(String.format("Generating dictionary for design %s in project %s.", d.getName(), getProject().getName()));
            ThreadManager.startNewThread(workThread);
            return true;
        }
    };
}
Also used : Design(edu.cmu.cs.hcii.cogtool.model.Design) ITaskDesign(edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign) IListenerAction(edu.cmu.cs.hcii.cogtool.util.IListenerAction) ITermSimilarity(edu.cmu.cs.hcii.cogtool.model.ITermSimilarity) ProjectSelectionState(edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState) AUndertaking(edu.cmu.cs.hcii.cogtool.model.AUndertaking) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary) ProjectInteraction(edu.cmu.cs.hcii.cogtool.ui.ProjectInteraction)

Example 10 with ISimilarityDictionary

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

the class ProjectController method openDictionaryEditor.

protected void openDictionaryEditor(Design design) {
    ISimilarityDictionary dict = (ISimilarityDictionary) design.getAttribute(WidgetAttributes.DICTIONARY_ATTR);
    if (NullSafe.equals(dict, WidgetAttributes.NO_DICTIONARY)) {
        dict = new SimilarityDictionary();
        design.setAttribute(WidgetAttributes.DICTIONARY_ATTR, dict);
    }
    DictionaryEditorController.openController(dict, design, project);
}
Also used : ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary) SimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.SimilarityDictionary) ISimilarityDictionary(edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)

Aggregations

ISimilarityDictionary (edu.cmu.cs.hcii.cogtool.model.ISimilarityDictionary)11 Design (edu.cmu.cs.hcii.cogtool.model.Design)5 ITaskDesign (edu.cmu.cs.hcii.cogtool.model.Project.ITaskDesign)4 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)4 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)3 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)3 ITermSimilarity (edu.cmu.cs.hcii.cogtool.model.ITermSimilarity)3 SimilarityDictionary (edu.cmu.cs.hcii.cogtool.model.SimilarityDictionary)3 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)3 ProjectSelectionState (edu.cmu.cs.hcii.cogtool.ui.ProjectSelectionState)3 TaskGroup (edu.cmu.cs.hcii.cogtool.model.TaskGroup)2 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)2 CogToolLID (edu.cmu.cs.hcii.cogtool.CogToolLID)1 DoublePoint (edu.cmu.cs.hcii.cogtool.model.DoublePoint)1 FrameElementGroup (edu.cmu.cs.hcii.cogtool.model.FrameElementGroup)1 GroupNature (edu.cmu.cs.hcii.cogtool.model.GroupNature)1 IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)1 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)1 SNIFACTExecContext (edu.cmu.cs.hcii.cogtool.model.SNIFACTExecContext)1 SNIFACTPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.SNIFACTPredictionAlgo)1