ca.nengo.config.handlers
Class EnumHandler
java.lang.Object
ca.nengo.config.handlers.BaseHandler
ca.nengo.config.handlers.EnumHandler
- All Implemented Interfaces:
- ConfigurationHandler
public class EnumHandler
- extends BaseHandler
ConfigurationHandler for SimulationMode values.
- Author:
- Bryan Tripp
|
Constructor Summary |
EnumHandler()
Defaults to type Enum with null default value. |
EnumHandler(java.lang.Class type,
java.lang.Enum defaultValue)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnumHandler
public EnumHandler()
- Defaults to type Enum with null default value.
EnumHandler
public EnumHandler(java.lang.Class type,
java.lang.Enum defaultValue)
- Parameters:
type - Type handled by this handlerdefaultValue - Default value for this handler
getEditor
public java.awt.Component getEditor(java.lang.Object o,
ConfigurationChangeListener listener)
- Description copied from class:
BaseHandler
- Returns a JTextField. An object is built from the text using fromString().
- Specified by:
getEditor in interface ConfigurationHandler- Overrides:
getEditor in class BaseHandler
- Parameters:
o - An object for which canHandle(o.getClass()) == truelistener - An ActionListener. The returned editor component must 1) add this listener
to the part of itself that produces an event when editing is complete, and 2) call
setProxy() with an EditorProxy through which the listener can retrieve a
new object value when editing is complete
- Returns:
- A UI component (eg JTextField) that allows the user to change the
object's value. If null, the calling property editor will attempt
to create a default editor, possibly using fromString(...).
- See Also:
ConfigurationHandler.getEditor(java.lang.Object, ConfigurationChangeListener)
fromString
public java.lang.Object fromString(java.lang.String s)
- Specified by:
fromString in interface ConfigurationHandler- Overrides:
fromString in class BaseHandler
- Parameters:
s - A String representation of an object, eg from toString(o) or user
input
- Returns:
- myClass.getConstructor(new Class[]{String.class}).newInstance(new Object[]{s})
- See Also:
ConfigurationHandler.fromString(java.lang.String)
getDefaultValue
public java.lang.Object getDefaultValue(java.lang.Class c)
- Parameters:
c - A class for which canHandle(c) == true
- Returns:
- A default value of the given class
- See Also:
ConfigurationHandler.getDefaultValue(java.lang.Class)