Package adams.gui.goe
Class TriStateEditor
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- adams.gui.goe.AbstractPropertyEditorSupport
-
- adams.gui.goe.AbstractBasicTypePropertyEditor
-
- adams.gui.goe.TriStateEditor
-
- All Implemented Interfaces:
HelpProvider,PropertyEditor
public class TriStateEditor extends AbstractBasicTypePropertyEditor
A custom editor for TriState enums.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected TriStatem_Currentthe current value.static StringSTATE_FALSEthe false state.static StringSTATE_TRUEthe true state.static StringSTATE_UNSETthe unset state.-
Fields inherited from class adams.gui.goe.AbstractPropertyEditorSupport
APPROVE_OPTION, CANCEL_OPTION, EMPTY, m_ChosenOption, m_CustomEditor, m_WindowAdapter, NULL
-
-
Constructor Summary
Constructors Constructor Description TriStateEditor()Initializes the editor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static TriStatecomboBoxToTriState(BaseComboBox<String> comboBox)Turns the state of the combobox intoTriStateenum.protected JComponentcreateCustomEditor()Creates the custom editor to use.ObjectgetValue()Gets the property value.protected voidinitForDisplay()Initializes the display of the value.protected Objectparse(String text)Parses the string and returns an object of the correct class.static voidselectComboBoxIndex(BaseComboBox<String> comboBox, TriState state)Sets the state of a combobox based on theTriStateenum.voidsetValue(Object value)Set (or change) the object that is to be edited.-
Methods inherited from class adams.gui.goe.AbstractBasicTypePropertyEditor
getAsText, isPaintable, paintValue, setAsText, toString
-
Methods inherited from class adams.gui.goe.AbstractPropertyEditorSupport
addWindowAdapter, cleanUp, closeDialog, createPopup, createTipText, createWindowAdapter, getChosenOption, getCustomEditor, getHelpDescription, getHelpIcon, getHelpTitle, getHelpURL, getParentDialog, getParentFrame, initialize, resetChosenOption, supportsCustomEditor
-
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getJavaInitializationString, getSource, getTags, removePropertyChangeListener, setSource
-
-
-
-
Field Detail
-
STATE_UNSET
public static final String STATE_UNSET
the unset state.- See Also:
- Constant Field Values
-
STATE_TRUE
public static final String STATE_TRUE
the true state.- See Also:
- Constant Field Values
-
STATE_FALSE
public static final String STATE_FALSE
the false state.- See Also:
- Constant Field Values
-
m_Current
protected TriState m_Current
the current value.
-
-
Method Detail
-
createCustomEditor
protected JComponent createCustomEditor()
Creates the custom editor to use.- Overrides:
createCustomEditorin classAbstractBasicTypePropertyEditor- Returns:
- the custom editor
-
setValue
public void setValue(Object value)
Set (or change) the object that is to be edited. Primitive types such as "int" must be wrapped as the corresponding object type such as "java.lang.Boolean".- Specified by:
setValuein interfacePropertyEditor- Overrides:
setValuein classAbstractPropertyEditorSupport- Parameters:
value- The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.
-
getValue
public Object getValue()
Gets the property value.- Specified by:
getValuein interfacePropertyEditor- Overrides:
getValuein classPropertyEditorSupport- Returns:
- The value of the property. Primitive types such as "int" will be wrapped as the corresponding object type such as "java.lang.Boolean".
-
parse
protected Object parse(String text) throws IllegalArgumentException
Parses the string and returns an object of the correct class.- Specified by:
parsein classAbstractBasicTypePropertyEditor- Parameters:
text- the string to parse- Returns:
- the generated object
- Throws:
IllegalArgumentException- if parsing fails
-
initForDisplay
protected void initForDisplay()
Initializes the display of the value.- Overrides:
initForDisplayin classAbstractBasicTypePropertyEditor
-
comboBoxToTriState
public static TriState comboBoxToTriState(BaseComboBox<String> comboBox)
Turns the state of the combobox intoTriStateenum.- Parameters:
comboBox- the checkbox to convert- Returns:
- the state
-
selectComboBoxIndex
public static void selectComboBoxIndex(BaseComboBox<String> comboBox, TriState state)
Sets the state of a combobox based on theTriStateenum.- Parameters:
comboBox- the combobox to updatestate- the state to set
-
-