Package adams.gui.goe
Class RatReferenceEditor
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- adams.gui.goe.AbstractPropertyEditorSupport
-
- adams.gui.goe.RatReferenceEditor
-
- All Implemented Interfaces:
adams.core.HelpProvider,adams.gui.goe.CustomStringRepresentationHandler,PropertyEditor
public class RatReferenceEditor extends adams.gui.goe.AbstractPropertyEditorSupport implements adams.gui.goe.CustomStringRepresentationHandlerA PropertyEditor for RatReference objects.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.gui.core.BaseTextFieldm_TextValueThe text field with the value.protected RatsTreem_TreeThe tree displaying all the callable actors.
-
Constructor Summary
Constructors Constructor Description RatReferenceEditor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidacceptInput()Accepts the input and closes the dialog.protected JComponentcreateCustomEditor()Gets the custom editor component.protected voiddiscardInput()Discards the input and closes the dialog.protected List<String>findRats()Locates all the callable actors for the node.ObjectfromCustomStringRepresentation(String str)Returns an object created from the custom string representation.StringgetJavaInitializationString()Returns a representation of the current property value as java source.protected StringgetStringToPaint()Returns the string to paint.protected voidinitForDisplay()Initializes the display of the value.protected booleanisUnchanged(String s)Checks whether the string is the same as the currently used one.protected booleanisValid(String s)Checks whether the string is valid.voidpaintValue(Graphics gfx, Rectangle box)Paints a representation of the current Object.protected RatReferenceparse(String s)Parses the given string and returns the generated object.StringtoCustomStringRepresentation(Object obj)Returns a custom string representation of the object.protected booleanupdateValue(TreePath path)Updates the value of the text field if possble, using the last component on the given tree path.-
Methods inherited from class adams.gui.goe.AbstractPropertyEditorSupport
addWindowAdapter, cleanUp, closeDialog, createPopup, createTipText, createWindowAdapter, getChosenOption, getCustomEditor, getHelpDescription, getHelpIcon, getHelpTitle, getHelpURL, getParentDialog, getParentFrame, initialize, isPaintable, resetChosenOption, setValue, supportsCustomEditor
-
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getAsText, getSource, getTags, getValue, removePropertyChangeListener, setAsText, setSource
-
-
-
-
Field Detail
-
m_TextValue
protected adams.gui.core.BaseTextField m_TextValue
The text field with the value.
-
m_Tree
protected RatsTree m_Tree
The tree displaying all the callable actors.
-
-
Method Detail
-
toCustomStringRepresentation
public String toCustomStringRepresentation(Object obj)
Returns a custom string representation of the object.- Specified by:
toCustomStringRepresentationin interfaceadams.gui.goe.CustomStringRepresentationHandler- Parameters:
obj- the object to turn into a string- Returns:
- the string representation
-
fromCustomStringRepresentation
public Object fromCustomStringRepresentation(String str)
Returns an object created from the custom string representation.- Specified by:
fromCustomStringRepresentationin interfaceadams.gui.goe.CustomStringRepresentationHandler- Parameters:
str- the string to turn into an object- Returns:
- the object
-
getJavaInitializationString
public String getJavaInitializationString()
Returns a representation of the current property value as java source.- Specified by:
getJavaInitializationStringin interfacePropertyEditor- Overrides:
getJavaInitializationStringin classPropertyEditorSupport- Returns:
- a value of type 'String'
-
getStringToPaint
protected String getStringToPaint()
Returns the string to paint.- Returns:
- the string
- See Also:
paintValue(Graphics, Rectangle)
-
paintValue
public void paintValue(Graphics gfx, Rectangle box)
Paints a representation of the current Object.- Specified by:
paintValuein interfacePropertyEditor- Overrides:
paintValuein classPropertyEditorSupport- Parameters:
gfx- the graphics context to usebox- the area we are allowed to paint into- See Also:
getStringToPaint()
-
parse
protected RatReference parse(String s)
Parses the given string and returns the generated object. The string has to be a valid one, i.e., the isValid(String) check has been performed already and succeeded.- Parameters:
s- the string to parse- Returns:
- the generated object, or null in case of an error
-
updateValue
protected boolean updateValue(TreePath path)
Updates the value of the text field if possble, using the last component on the given tree path.- Parameters:
path- the path to use for updating the value- Returns:
- true if the text field got updated
-
createCustomEditor
protected JComponent createCustomEditor()
Gets the custom editor component.- Specified by:
createCustomEditorin classadams.gui.goe.AbstractPropertyEditorSupport- Returns:
- the editor
-
isValid
protected boolean isValid(String s)
Checks whether the string is valid.- Parameters:
s- the string to check- Returns:
- true if the string is valid
-
isUnchanged
protected boolean isUnchanged(String s)
Checks whether the string is the same as the currently used one.- Parameters:
s- the string to check- Returns:
- true if the strings are the same
-
acceptInput
protected void acceptInput()
Accepts the input and closes the dialog.
-
discardInput
protected void discardInput()
Discards the input and closes the dialog.
-
findRats
protected List<String> findRats()
Locates all the callable actors for the node.- Returns:
- the located callable actors (including Rats nodes)
-
initForDisplay
protected void initForDisplay()
Initializes the display of the value.- Overrides:
initForDisplayin classadams.gui.goe.AbstractPropertyEditorSupport
-
-