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());
}
Aggregations