Search in sources :

Example 6 with DelayScriptStep

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

DelayScriptStep (edu.cmu.cs.hcii.cogtool.model.DelayScriptStep)6 AScriptStep (edu.cmu.cs.hcii.cogtool.model.AScriptStep)5 ThinkScriptStep (edu.cmu.cs.hcii.cogtool.model.ThinkScriptStep)5 DefaultModelGeneratorState (edu.cmu.cs.hcii.cogtool.model.DefaultModelGeneratorState)4 SEDemoInteraction (edu.cmu.cs.hcii.cogtool.ui.SEDemoInteraction)3 ComputationUndoRedo (edu.cmu.cs.hcii.cogtool.controller.DemoScriptCmd.ComputationUndoRedo)1 ActionScriptStep (edu.cmu.cs.hcii.cogtool.model.ActionScriptStep)1 Demonstration (edu.cmu.cs.hcii.cogtool.model.Demonstration)1 Frame (edu.cmu.cs.hcii.cogtool.model.Frame)1 HearScriptStep (edu.cmu.cs.hcii.cogtool.model.HearScriptStep)1 SEDemoSelectionState (edu.cmu.cs.hcii.cogtool.ui.SEDemoSelectionState)1 SEDemoUI (edu.cmu.cs.hcii.cogtool.ui.SEDemoUI)1 AUndoableEdit (edu.cmu.cs.hcii.cogtool.util.AUndoableEdit)1 AlertHandler (edu.cmu.cs.hcii.cogtool.util.AlertHandler)1 GraphicsUtil (edu.cmu.cs.hcii.cogtool.util.GraphicsUtil)1 IListenerAction (edu.cmu.cs.hcii.cogtool.util.IListenerAction)1 IUndoableEdit (edu.cmu.cs.hcii.cogtool.util.IUndoableEdit)1 RcvrImageException (edu.cmu.cs.hcii.cogtool.util.RcvrImageException)1 SWTList (edu.cmu.cs.hcii.cogtool.view.SWTList)1 EventObject (java.util.EventObject)1