ecologylab.appframework.types.prefs
Class MetaPref<T>

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.xml.ElementState
          extended by ecologylab.appframework.types.prefs.MetaPref<T>
All Implemented Interfaces:
WidgetTypes, FieldTypes, XMLTranslationExceptionTypes
Direct Known Subclasses:
MetaPrefBoolean, MetaPrefColor, MetaPrefFile, MetaPrefFloat, MetaPrefInt, MetaPrefString

public abstract class MetaPref<T>
extends ElementState
implements WidgetTypes

Metadata about a Preference. Defines information to enable editing the Preference.

Author:
andruid

Nested Class Summary
 
Nested classes/interfaces inherited from class ecologylab.xml.ElementState
ElementState.DeclarationStyle, ElementState.xml_attribute, ElementState.xml_bind_from, ElementState.xml_bind_to, ElementState.xml_class, ElementState.xml_classes, ElementState.xml_collection, ElementState.xml_format, ElementState.xml_leaf, ElementState.xml_map, ElementState.xml_nested, ElementState.xml_nowrap, ElementState.xml_other_tags, ElementState.xml_scope, ElementState.xml_tag, ElementState.xml_text
 
Field Summary
 
Fields inherited from class ecologylab.xml.ElementState
CDATA, NORMAL, UTF16, UTF16_LE, UTF8
 
Fields inherited from interface ecologylab.appframework.types.prefs.WidgetTypes
CHECK_BOX, COLOR_CHOOSER, DROP_DOWN, FILE_CHOOSER, RADIO_BUTTONS, SLIDER, SPINNER, TEXT_AREA, TEXT_FIELD
 
Fields inherited from interface ecologylab.xml.FieldTypes
ATTRIBUTE, AWFUL_OLD_NESTED_ELEMENT, BAD_FIELD, COLLECTION_ELEMENT, COLLECTION_SCALAR, IGNORED_ATTRIBUTE, IGNORED_ELEMENT, LEAF, MAP_ELEMENT, MAP_SCALAR, NAME_SPACE_ATTRIBUTE, NAME_SPACE_LEAF_NODE, NAME_SPACE_MASK, NAME_SPACE_NESTED_ELEMENT, NAMESPACE_IGNORED_ELEMENT, NAMESPACE_TRIAL_ELEMENT, NESTED_ELEMENT, PSEUDO_FIELD_DESCRIPTOR, ROOT, TEXT_ELEMENT, TEXT_NODE_VALUE, UNSET_TYPE, WRAPPER, XMLNS_ATTRIBUTE, XMLNS_IGNORED
 
Fields inherited from interface ecologylab.xml.XMLTranslationExceptionTypes
FILE_NOT_FOUND, IO_EXCEPTION, NULL_PURL, UNKNOWN
 
Constructor Summary
MetaPref(ScalarType scalarType)
          Instantiate.
 
Method Summary
 Pref<T> getAssociatedPref()
          Get the Pref object associated with this.
 java.lang.String getCategory()
          Gets the category for a MetaPref.
 Choice<T> getChoiceByIndex(int index)
          Get the Choice at the given index.
 Choice<T> getChoiceByValue(java.lang.String value)
          Get a Choice from the list of choices, whose value matches the value passed in.
 java.lang.String getChoiceNameByIndex(int index)
          Get Choice's name, for the choice at the given index.
 java.lang.String getChoiceNameByValue(java.lang.String value)
          Get Choice's name, for a choice whose value that matches the given value.
 java.util.ArrayList<Choice<T>> getChoices()
          Gets the Choices of a MetaPref.
 Pref<T> getDefaultPrefInstance()
          Construct a new instance of the Pref that matches this.
abstract  T getDefaultValue()
          Gets the default value of a MetaPref; type-specific behavior.
 java.lang.String getDescription()
          Gets the description for a MetaPref.
 java.lang.String getHelpText()
          Gets the help text for a MetaPref.
 java.lang.String getID()
          Gets the ID of a MetaPref.
 int getIndexByChoice(Choice<T> choice)
          Get the index of a given Choice.
 int getIndexByValue(java.lang.String value)
          Get the index of a Choice with the given value.
 T getInstance(java.lang.String string)
          Create an instance of our associated type, from a String.
 T getInstance(T value)
           
abstract  T getMaxValue()
          Gets the max value of the range of a MetaPref.
abstract  T getMinValue()
          Gets the min value of the range of a MetaPref.
 ValueChangedListener getValueChangedListener()
           
 boolean hasChoices()
          Returns true if the metaPref has choices.
static MetaPref lookup(java.lang.String id)
          Look up a MetaPref by name in the map of all MetaPrefs
 void print()
          Gives printed output showing id, description, category, helpText, widget, default value, and choices for a MetaPref.
static void setValueChangedListener(java.lang.String metaPrefId, ValueChangedListener valueChangedListener)
          Set object that receives a callback when the value of a Pref is changed through the PrefsEditor.
 void setValueChangedListener(ValueChangedListener valueChangedListener)
          Set object that receives a callback when the value of a Pref is changed through the PrefsEditor.
 boolean widgetIsCheckBox()
          Returns whether or not a widget uses check boxes.
 boolean widgetIsColorChooser()
          Returns whether or not a widget uses a color chooser.
 boolean widgetIsDropDown()
          Returns whether or not a widget uses a drop down menu.
 boolean widgetIsFileChooser()
          Returns whether or not a widget uses a file chooser.
 boolean widgetIsRadio()
          Returns whether or not a widget uses radio buttons.
 boolean widgetIsSlider()
          Returns whether or not a widget uses a slider.
 boolean widgetIsSpinner()
          Returns whether or not a widget uses a spinner.
 boolean widgetIsTextField()
          Returns whether or not a widget uses one or more text fields.
 
Methods inherited from class ecologylab.xml.ElementState
buildDOM, buildDOM, buildDOM, buildDOM, buildDOM, buildDOMFromXMLCharSequence, buildDOMFromXMLString, checkAnnotation, classDescriptor, createParentDirs, getChildFieldAccessors, getElementStateById, getFieldDescriptors, getNestedNameSpace, getTextNodeString, hasScalarTextField, lookupNestedNameSpace, parent, recycle, setDeclarationStyle, setParent, setUseDOMForTranslateTo, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXML, translateFromXMLCharSequence, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOM, translateFromXMLDOMCharSequence, translateFromXMLDOMCharSequence, translateFromXMLRootNode, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateFromXMLSAX, translateToDOM, translateToXML, translateToXML, translateToXML, translateToXML, writePrettyXML, writePrettyXML, writePrettyXML
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MetaPref

public MetaPref(ScalarType scalarType)
Instantiate.

Parameters:
scalarType - TODO
Method Detail

getDefaultValue

public abstract T getDefaultValue()
Gets the default value of a MetaPref; type-specific behavior.

Returns:
Default value of MetaPref

getMinValue

public abstract T getMinValue()
Gets the min value of the range of a MetaPref.

Returns:
Min value of a MetaPref

getMaxValue

public abstract T getMaxValue()
Gets the max value of the range of a MetaPref.

Returns:
Max value of a MetaPref

getCategory

public java.lang.String getCategory()
Gets the category for a MetaPref.

Returns:
Category of MetaPref

getDescription

public java.lang.String getDescription()
Gets the description for a MetaPref.

Returns:
Description of MetaPref

getHelpText

public java.lang.String getHelpText()
Gets the help text for a MetaPref.

Returns:
Help Text of MetaPref

getID

public java.lang.String getID()
Gets the ID of a MetaPref. This is a unique identifier.

Returns:
ID (unique) of MetaPref.

getChoices

public java.util.ArrayList<Choice<T>> getChoices()
Gets the Choices of a MetaPref. This is optional and may be null.

Returns:
ID (unique) of MetaPref.

hasChoices

public boolean hasChoices()
Returns true if the metaPref has choices. False otherwise

Returns:

getChoiceByValue

public Choice<T> getChoiceByValue(java.lang.String value)
Get a Choice from the list of choices, whose value matches the value passed in.

Parameters:
value - Value to find
Returns:
Choice whose value equals the passed in value

getChoiceNameByValue

public java.lang.String getChoiceNameByValue(java.lang.String value)
Get Choice's name, for a choice whose value that matches the given value.

Parameters:
value -
Returns:
Name of choice

getChoiceNameByIndex

public java.lang.String getChoiceNameByIndex(int index)
Get Choice's name, for the choice at the given index.

Parameters:
index -
Returns:
Name of choice

getChoiceByIndex

public Choice<T> getChoiceByIndex(int index)
Get the Choice at the given index.

Parameters:
index -
Returns:
Name of choice

getIndexByChoice

public int getIndexByChoice(Choice<T> choice)
Get the index of a given Choice.

Parameters:
choice - Given choice
Returns:
Index of Choice in choices

getIndexByValue

public int getIndexByValue(java.lang.String value)
Get the index of a Choice with the given value.

Parameters:
value -
Returns:
index of Choice with given value

print

public void print()
Gives printed output showing id, description, category, helpText, widget, default value, and choices for a MetaPref.


widgetIsRadio

public boolean widgetIsRadio()
Returns whether or not a widget uses radio buttons.

Returns:
True = Uses radio buttons. False = Doesn't.

widgetIsSlider

public boolean widgetIsSlider()
Returns whether or not a widget uses a slider.

Returns:
True = Uses a slider. False = Doesn't.

widgetIsSpinner

public boolean widgetIsSpinner()
Returns whether or not a widget uses a spinner.

Returns:
True = Uses a spinner. False = Doesn't.

widgetIsTextField

public boolean widgetIsTextField()
Returns whether or not a widget uses one or more text fields.

Returns:
True = Uses text field(s). False = Doesn't.

widgetIsCheckBox

public boolean widgetIsCheckBox()
Returns whether or not a widget uses check boxes.

Returns:
True = Uses check boxes. False = Doesn't.

widgetIsDropDown

public boolean widgetIsDropDown()
Returns whether or not a widget uses a drop down menu.

Returns:
True = Uses a drop down menu. False = Doesn't.

widgetIsColorChooser

public boolean widgetIsColorChooser()
Returns whether or not a widget uses a color chooser.

Returns:
True = Uses a color chooser. False = Doesn't.

widgetIsFileChooser

public boolean widgetIsFileChooser()
Returns whether or not a widget uses a file chooser.

Returns:
True = Uses a file chooser. False = Doesn't.

getInstance

public T getInstance(java.lang.String string)
Create an instance of our associated type, from a String.

Parameters:
string -
Returns:

getInstance

public T getInstance(T value)

getDefaultPrefInstance

public Pref<T> getDefaultPrefInstance()
Construct a new instance of the Pref that matches this. Use this to fill-in the default value.

Returns:

getAssociatedPref

public Pref<T> getAssociatedPref()
Get the Pref object associated with this. That is, look for one in the registry. Return it if there is one. Otherwise, get a default Pref based on this, register it, and return it.

Returns:
The Pref object associated with this MetaPref.

setValueChangedListener

public void setValueChangedListener(ValueChangedListener valueChangedListener)
Set object that receives a callback when the value of a Pref is changed through the PrefsEditor.

Parameters:
valueChangedListener -

setValueChangedListener

public static void setValueChangedListener(java.lang.String metaPrefId,
                                           ValueChangedListener valueChangedListener)
Set object that receives a callback when the value of a Pref is changed through the PrefsEditor.

Parameters:
valueChangedListener -

lookup

public static MetaPref lookup(java.lang.String id)
Look up a MetaPref by name in the map of all MetaPrefs

Parameters:
id - Name of MetaPref
Returns:
MetaPref with the given id

getValueChangedListener

public ValueChangedListener getValueChangedListener()