Search in sources :

Example 21 with DefaultModelGeneratorState

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

the class SEDemoUI method setViewEnabledState.

/**
     * Enables or disables LIDs as appropriate
     *
     * Primarily used to enable Edit Think Duration or edit Delay Duration.
     *
     * @param selnState the selection state on which to base enabling/disabling
     * @param availability NORMAL or CONTEXT
     * @see ListenerIdentifierMap
     */
protected void setViewEnabledState(SEDemoSelectionState selnState, Boolean availability) {
    Demonstration demo = taskApp.getDemonstration();
    boolean isValid = !demo.isInvalid();
    boolean isObsolete = isValid && demo.isObsolete();
    String label = isObsolete ? SEDemoView.REGENERATE_THEN_COMPUTE : SEDemoView.COMPUTE;
    setEnabled(SEDemoLID.RecomputeScript, availability, isValid && editable, label);
    setEnabled(SEDemoLID.RegenerateScript, availability, isObsolete);
    label = "";
    // Anything selected?
    DefaultModelGeneratorState selectedState = selnState.getSelectedState();
    if (selectedState != null) {
        AScriptStep scriptStep = selectedState.getScriptStep();
        label = MenuFactory.DELETE_STRING + " " + STEP_LABEL;
        if (scriptStep instanceof ThinkScriptStep) {
            if (!scriptStep.isInsertedByUser()) {
                label = MenuFactory.DELETE_STRING + " " + THINK_LABEL;
            }
            setEnabled(SEDemoLID.ChangeThinkProperties, availability, true);
            setEnabled(SEDemoLID.ChangeWaitProperties, availability, false);
            setEnabled(SEDemoLID.Edit, availability, editable, EDIT_THINK_LABEL);
        } else {
            setEnabled(SEDemoLID.ChangeThinkProperties, availability, false);
            setEnabled(SEDemoLID.ChangeWaitProperties, availability, scriptStep instanceof DelayScriptStep);
            setEnabled(SEDemoLID.Edit, availability, editable && ((scriptStep instanceof DelayScriptStep) || isEditable(scriptStep)), EDIT_STEP_LABEL);
        }
    } else {
        setEnabled(SEDemoLID.ChangeWaitProperties, availability, false);
        setEnabled(SEDemoLID.ChangeThinkProperties, availability, false);
        if (script.getStepStateCount() > 0) {
            label = MenuFactory.DELETE_STRING + " " + LAST_STEP_LABEL;
            setEnabled(SEDemoLID.Edit, availability, false, EDIT_STEP_LABEL + " " + LAST_STEP_LABEL);
        } else {
            label = CHANGE_START_FRAME_LABEL;
            setEnabled(SEDemoLID.Edit, availability, false, EDIT_STEP_LABEL);
        }
    }
    String deleteString = label;
    setEnabled(CogToolLID.Delete, availability, editable, deleteString);
    setEnabled(CogToolLID.ShowModelVisualization, availability, taskApp.hasComputedResult() && taskApp.hasResultSteps());
}
Also used : DelayScriptStep(edu.cmu.cs.hcii.cogtool.model.DelayScriptStep) Demonstration(edu.cmu.cs.hcii.cogtool.model.Demonstration) AScriptStep(edu.cmu.cs.hcii.cogtool.model.AScriptStep) DefaultModelGeneratorState(edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState) ThinkScriptStep(edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep)

Aggregations

DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)21 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)9 ThinkScriptStep (edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep)7 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)7 AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)6 TableItem (org.eclipse.swt.widgets.TableItem)6 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)5 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)5 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)5 DelayScriptStep (edu.cmu.cs.hcii.cogtool.model.DelayScriptStep)4 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)4 HandLocation (edu.cmu.cs.hcii.cogtool.model.HandLocation)4 Script (edu.cmu.cs.hcii.cogtool.model.Script)4 EventObject (java.util.EventObject)4 Table (org.eclipse.swt.widgets.Table)3 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)2 CognitiveModelGenerator (edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)2 SEDemoInteraction (edu.cmu.cs.hcii.cogtool.ui.SEDemoInteraction)2 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)2