Search in sources :

Example 11 with ThinkScriptStep

use of edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep 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

ThinkScriptStep (edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep)11 AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)8 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)7 DelayScriptStep (edu.cmu.cs.hcii.cogtool.model.DelayScriptStep)5 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)4 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)4 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)3 SEDemoInteraction (edu.cmu.cs.hcii.cogtool.ui.SEDemoInteraction)3 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)3 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)3 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)2 Design (edu.cmu.cs.hcii.cogtool.model.Design)2 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)2 APredictionResult (edu.cmu.cs.hcii.cogtool.model.APredictionResult)1 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)1 ActionScriptStep (edu.cmu.cs.hcii.cogtool.model.ActionScriptStep)1 CognitiveModelGenerator (edu.cmu.cs.hcii.cogtool.model.CognitiveModelGenerator)1 HearScriptStep (edu.cmu.cs.hcii.cogtool.model.HearScriptStep)1 IPredictionAlgo (edu.cmu.cs.hcii.cogtool.model.IPredictionAlgo)1 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)1