org.rhq.enterprise.communications.util.prefs
Class PromptIfEnabledSetupInstruction

java.lang.Object
  extended by org.rhq.enterprise.communications.util.prefs.SetupInstruction
      extended by org.rhq.enterprise.communications.util.prefs.DefaultSetupInstruction
          extended by org.rhq.enterprise.communications.util.prefs.PromptIfEnabledSetupInstruction

public class PromptIfEnabledSetupInstruction
extends DefaultSetupInstruction

This setup instruction will perform preprocessing to determine if the user should be prompted for the preference value or not. If a given boolean preference (called the "enablement preference") is true, then this instruction will leave the prompt message as-is thus prompting the user for a new value. If that enablement preference is false, then the prompt message will be set to null forcing this instruction's new preference value to be the default value.

Use this when there are a set of preferences that are configuration settings for a particular feature that can be enabled or disabled. If that feature is disabled (via the enablement preference), then the user should not be asked to configure that feature any further. If that feature is enabled, then it makes sense to ask the user to configure the rest of that feature's settings.

This class derives from DefaultSetupInstruction so it will default to the existing preference value if one exists; otherwise, the original SetupInstruction.getDefaultValue() is used.

Author:
John Mazzitelli

Constructor Summary
PromptIfEnabledSetupInstruction(String preference_name, String default_value, SetupValidityChecker validity_checker, String prompt_message, String help_message, String enablement_preference, boolean enablement_preference_default)
          The enablement_preference is the name of the boolean preference that will determine if this instruction will or will not prompt the user.
 
Method Summary
 void preProcess()
          If the enablement preference's value is true, then this method does nothing, but if it is false, this method will set the prompt to null so the user isn't bothered to ask to configure this setting.
 
Methods inherited from class org.rhq.enterprise.communications.util.prefs.SetupInstruction
getDefaultValue, getHelpMessage, getPreferenceName, getPreferences, getPromptMessage, getValidityChecker, isUsingNoEchoPrompt, postProcess, setDefaultValue, setHelpMessage, setPreferences, setPromptMessage, setUsingNoEchoPrompt, setValidityChecker, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PromptIfEnabledSetupInstruction

public PromptIfEnabledSetupInstruction(String preference_name,
                                       String default_value,
                                       SetupValidityChecker validity_checker,
                                       String prompt_message,
                                       String help_message,
                                       String enablement_preference,
                                       boolean enablement_preference_default)
                                throws IllegalArgumentException
The enablement_preference is the name of the boolean preference that will determine if this instruction will or will not prompt the user. The enablement_preference_default is the default value of the enablement preference if it is not defined (that is, if it is not set in the set of preferences given to this instruction via SetupInstruction.setPreferences(java.util.prefs.Preferences)).

Throws:
IllegalArgumentException
See Also:
SetupInstruction#SetupInstruction(String, String, SetupValidityChecker, String, String)
Method Detail

preProcess

public void preProcess()
If the enablement preference's value is true, then this method does nothing, but if it is false, this method will set the prompt to null so the user isn't bothered to ask to configure this setting.

Overrides:
preProcess in class DefaultSetupInstruction
See Also:
SetupInstruction.preProcess()


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.