Package adams.gui.goe
Class AbstractBasicTypePropertyEditor
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- adams.gui.goe.AbstractPropertyEditorSupport
-
- adams.gui.goe.AbstractBasicTypePropertyEditor
-
- All Implemented Interfaces:
HelpProvider
,PropertyEditor
- Direct Known Subclasses:
AbstractNumberEditor
,BooleanEditor
,StringEditor
,TriStateEditor
public abstract class AbstractBasicTypePropertyEditor extends AbstractPropertyEditorSupport
A superclass for custom editor for basic Java types.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
-
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 AbstractBasicTypePropertyEditor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected JComponent
createCustomEditor()
Creates the custom editor to use.String
getAsText()
Gets the property value as text.protected void
initForDisplay()
Initializes the display of the value.boolean
isPaintable()
Determines whether this property editor is paintable.void
paintValue(Graphics gfx, Rectangle box)
Paint a representation of the value into a given area of screen real estate.protected abstract Object
parse(String text)
Parses the string and returns an object of the correct class.void
setAsText(String text)
Set the property value by parsing a given String.protected String
toString(Object obj)
Turns the object into a string representation.-
Methods inherited from class adams.gui.goe.AbstractPropertyEditorSupport
addWindowAdapter, cleanUp, closeDialog, createPopup, createTipText, createWindowAdapter, getChosenOption, getCustomEditor, getHelpDescription, getHelpIcon, getHelpTitle, getHelpURL, getParentDialog, getParentFrame, initialize, resetChosenOption, setValue, supportsCustomEditor
-
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getJavaInitializationString, getSource, getTags, getValue, removePropertyChangeListener, setSource
-
-
-
-
Method Detail
-
isPaintable
public boolean isPaintable()
Determines whether this property editor is paintable.- Specified by:
isPaintable
in interfacePropertyEditor
- Overrides:
isPaintable
in classAbstractPropertyEditorSupport
- Returns:
- True if the class will honor the paintValue method.
-
paintValue
public void paintValue(Graphics gfx, Rectangle box)
Paint a representation of the value into a given area of screen real estate. Note that the propertyEditor is responsible for doing its own clipping so that it fits into the given rectangle.If the PropertyEditor doesn't honor paint requests (see isPaintable) this method should be a silent noop.
The given Graphics object will have the default font, color, etc of the parent container. The PropertyEditor may change graphics attributes such as font and color and doesn't need to restore the old values.
- Specified by:
paintValue
in interfacePropertyEditor
- Overrides:
paintValue
in classPropertyEditorSupport
- Parameters:
gfx
- Graphics object to paint into.box
- Rectangle within graphics object into which we should paint.
-
getAsText
public String getAsText()
Gets the property value as text.- Specified by:
getAsText
in interfacePropertyEditor
- Overrides:
getAsText
in classPropertyEditorSupport
- Returns:
- The property value as a human editable string.
Returns null if the value can't be expressed as an editable string.
If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().
-
toString
protected String toString(Object obj)
Turns the object into a string representation.
Default implementation just uses the Object's toString() method.- Parameters:
obj
- the object to convert- Returns:
- the string representation
-
setAsText
public void setAsText(String text) throws IllegalArgumentException
Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.- Specified by:
setAsText
in interfacePropertyEditor
- Overrides:
setAsText
in classPropertyEditorSupport
- Parameters:
text
- The string to be parsed.- Throws:
IllegalArgumentException
- if parsing fails- See Also:
parse(String)
-
parse
protected abstract Object parse(String text) throws IllegalArgumentException
Parses the string and returns an object of the correct class.- Parameters:
text
- the string to parse- Returns:
- the generated object
- Throws:
IllegalArgumentException
- if parsing fails
-
createCustomEditor
protected JComponent createCustomEditor()
Creates the custom editor to use.- Specified by:
createCustomEditor
in classAbstractPropertyEditorSupport
- Returns:
- the custom editor
-
initForDisplay
protected void initForDisplay()
Initializes the display of the value.- Overrides:
initForDisplay
in classAbstractPropertyEditorSupport
-
-