Search in sources :

Example 16 with AScriptStep

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

AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)16 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)8 ThinkScriptStep (edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep)8 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)6 DelayScriptStep (edu.cmu.cs.hcii.cogtool.model.DelayScriptStep)5 TaskApplication (edu.cmu.cs.hcii.cogtool.model.TaskApplication)5 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)3 AUndertaking (edu.cmu.cs.hcii.cogtool.model.AUndertaking)3 Design (edu.cmu.cs.hcii.cogtool.model.Design)3 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)3 IWidget (edu.cmu.cs.hcii.cogtool.model.IWidget)3 CompoundUndoableEdit (edu.cmu.cs.hcii.cogtool.util.CompoundUndoableEdit)3 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)3 LinkedHashSet (java.util.LinkedHashSet)3 ActionScriptStep (edu.cmu.cs.hcii.cogtool.model.ActionScriptStep)2 LookAtScriptStep (edu.cmu.cs.hcii.cogtool.model.LookAtScriptStep)2 Script (edu.cmu.cs.hcii.cogtool.model.Script)2 TransitionSource (edu.cmu.cs.hcii.cogtool.model.TransitionSource)2 SEDemoInteraction (edu.cmu.cs.hcii.cogtool.ui.SEDemoInteraction)2 BufferedWriter (java.io.BufferedWriter)2