Package adams.gui.goe
Class StringEditor
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- adams.gui.goe.AbstractPropertyEditorSupport
-
- adams.gui.goe.StringEditor
-
- All Implemented Interfaces:
HelpProvider,InlineEditorSupport,MultiSelectionEditor,PropertyEditorWithConstraint,PropertyEditor
public class StringEditor extends AbstractPropertyEditorSupport implements MultiSelectionEditor, InlineEditorSupport, PropertyEditorWithConstraint
A PropertyEditor for strings.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
BaseObject
-
-
Field Summary
Fields Modifier and Type Field Description protected BaseButtonm_ButtonHelpthe help button for bringing up a browser with the Java Pattern class.protected AbstractOptionConstraintm_Constraintthe constraint to use.protected JTextComponentm_TextValueThe text field with the value.-
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 StringEditor()
-
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.AbstractOptionConstraintgetConstraint()Return the constraint in use.StringgetInlineValue()Returns the current value.StringgetJavaInitializationString()Returns a representation of the current property value as java source.Object[]getSelectedObjects(Container parent)Returns the selected objects.protected StringgetStringToPaint()Returns the string to paint.protected voidinitForDisplay()Initializes the display of the value.booleanisInlineEditingAvailable()Checks whether inline editing is available.booleanisInlineValueValid(String value)Checks whether the value id valid.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 Stringparse(String s)Parses the given string and returns the generated object.voidsetConstraint(AbstractOptionConstraint value)The constraint to use.voidsetInlineValue(String value)Sets the value to use.-
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
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.beans.PropertyEditor
addPropertyChangeListener, getAsText, getCustomEditor, getTags, getValue, isPaintable, removePropertyChangeListener, setAsText, setValue, supportsCustomEditor
-
-
-
-
Field Detail
-
m_TextValue
protected JTextComponent m_TextValue
The text field with the value.
-
m_ButtonHelp
protected BaseButton m_ButtonHelp
the help button for bringing up a browser with the Java Pattern class.
-
m_Constraint
protected AbstractOptionConstraint m_Constraint
the constraint to use.
-
-
Method Detail
-
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 String 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
-
createCustomEditor
protected JComponent createCustomEditor()
Gets the custom editor component.- Specified by:
createCustomEditorin classAbstractPropertyEditorSupport- Returns:
- always null
-
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.
-
initForDisplay
protected void initForDisplay()
Initializes the display of the value.- Overrides:
initForDisplayin classAbstractPropertyEditorSupport
-
getSelectedObjects
public Object[] getSelectedObjects(Container parent)
Returns the selected objects.- Specified by:
getSelectedObjectsin interfaceMultiSelectionEditor- Parameters:
parent- the parent container- Returns:
- the objects
-
isInlineEditingAvailable
public boolean isInlineEditingAvailable()
Checks whether inline editing is available.- Specified by:
isInlineEditingAvailablein interfaceInlineEditorSupport- Returns:
- true if editing available
-
setInlineValue
public void setInlineValue(String value)
Sets the value to use.- Specified by:
setInlineValuein interfaceInlineEditorSupport- Parameters:
value- the value to use
-
getInlineValue
public String getInlineValue()
Returns the current value.- Specified by:
getInlineValuein interfaceInlineEditorSupport- Returns:
- the current value
-
isInlineValueValid
public boolean isInlineValueValid(String value)
Checks whether the value id valid.- Specified by:
isInlineValueValidin interfaceInlineEditorSupport- Parameters:
value- the value to check- Returns:
- true if valid
-
setConstraint
public void setConstraint(AbstractOptionConstraint value)
The constraint to use.- Specified by:
setConstraintin interfacePropertyEditorWithConstraint- Parameters:
value- the constraint, null to remove
-
getConstraint
public AbstractOptionConstraint getConstraint()
Return the constraint in use.- Specified by:
getConstraintin interfacePropertyEditorWithConstraint- Returns:
- the constraint, null if none set
-
-