Package adams.gui.goe
Class AbstractBaseDateTypeEditor<B extends BaseObject & DateValueSupporter & GrammarSupplier,P extends DateProvider>
- java.lang.Object
-
- java.beans.PropertyEditorSupport
-
- adams.gui.goe.AbstractPropertyEditorSupport
-
- adams.gui.goe.AbstractBaseDateTypeEditor<B,P>
-
- Type Parameters:
B
- the base object type in useP
- the panel in use for selecting the date type
- All Implemented Interfaces:
HelpProvider
,CustomStringRepresentationHandler
,InlineEditorSupport
,MultiSelectionEditor
,PropertyEditor
- Direct Known Subclasses:
BaseDateEditor
,BaseDateTimeEditor
,BaseDateTimeMsecEditor
,BaseTimeEditor
,BaseTimeMsecEditor
public abstract class AbstractBaseDateTypeEditor<B extends BaseObject & DateValueSupporter & GrammarSupplier,P extends DateProvider> extends AbstractPropertyEditorSupport implements CustomStringRepresentationHandler, MultiSelectionEditor, InlineEditorSupport
Ancestor property editors that handle base date types.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractBaseDateTypeEditor.Placeholder
The supported placeholders.
-
Field Summary
Fields Modifier and Type Field Description protected BaseButton
m_ButtonCustomHelp
the button for the bringing up the help for the custom format.protected BaseButton
m_ButtonNow
The NOW button.protected BaseButton
m_ButtonOK
The OK button.protected BaseButtonWithDropDownMenu
m_ButtonTemplates
the template button.protected P
m_Calendar
The calendar component for editing the date.protected BaseComboBox<String>
m_ComboBoxPlaceholders
For specific date placeholders.protected B
m_Date
for parsing the date type.protected BaseTextField
m_TextCustom
For entering a custom date string.-
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 AbstractBaseDateTypeEditor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected JComponent
createCustomEditor()
Gets the custom editor component.Object
fromCustomStringRepresentation(String str)
Returns an object created from the custom string representation.String
getInlineValue()
Returns the current value.String
getJavaInitializationString()
Returns a representation of the current property value as java source.protected abstract String
getNowButtonText()
Returns the text to use for the "now" button.protected abstract String
getPlaceholder(AbstractBaseDateTypeEditor.Placeholder ph)
Returns the string equivalent of the placeholder.Object[]
getSelectedObjects(Container parent)
Returns the selected objects.protected void
initForDisplay()
Initializes the display of the value.protected void
initialize()
Initializes the members.boolean
isInlineEditingAvailable()
Checks whether inline editing is available.boolean
isInlineValueValid(String value)
Checks whether the value id valid.protected B
newDateType()
Returns a new instance of the date type used for parsing.protected abstract B
newDateType(String s)
Returns a new instance of the date type.protected abstract B
newDateType(Date d)
Returns a new instance of the date type.protected abstract P
newPanel()
Instantiates a new panel for picking the date type.void
paintValue(Graphics gfx, Rectangle box)
Paints a representation of the current Object.void
setInlineValue(String value)
Sets the value to use.protected void
showHelp()
Displays the help for theString
toCustomStringRepresentation(Object obj)
Returns a custom string representation of the object.protected void
updateButtons()
Sets the enabled state of the buttons.-
Methods inherited from class adams.gui.goe.AbstractPropertyEditorSupport
addWindowAdapter, cleanUp, closeDialog, createPopup, createTipText, createWindowAdapter, getChosenOption, getCustomEditor, getHelpDescription, getHelpIcon, getHelpTitle, getHelpURL, getParentDialog, getParentFrame, isPaintable, resetChosenOption, setValue, supportsCustomEditor
-
Methods inherited from class java.beans.PropertyEditorSupport
addPropertyChangeListener, firePropertyChange, getAsText, getSource, getTags, getValue, removePropertyChangeListener, setAsText, setSource
-
-
-
-
Field Detail
-
m_Calendar
protected P extends DateProvider m_Calendar
The calendar component for editing the date.
-
m_ComboBoxPlaceholders
protected BaseComboBox<String> m_ComboBoxPlaceholders
For specific date placeholders.
-
m_TextCustom
protected BaseTextField m_TextCustom
For entering a custom date string.
-
m_ButtonCustomHelp
protected BaseButton m_ButtonCustomHelp
the button for the bringing up the help for the custom format.
-
m_ButtonNow
protected BaseButton m_ButtonNow
The NOW button.
-
m_ButtonTemplates
protected BaseButtonWithDropDownMenu m_ButtonTemplates
the template button.
-
m_ButtonOK
protected BaseButton m_ButtonOK
The OK button.
-
m_Date
protected B extends BaseObject & DateValueSupporter & GrammarSupplier m_Date
for parsing the date type.
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractPropertyEditorSupport
-
newDateType
protected B newDateType()
Returns a new instance of the date type used for parsing.- Returns:
- the instance
-
newDateType
protected abstract B newDateType(String s)
Returns a new instance of the date type.- Parameters:
s
- the string to instantiate with, can be null- Returns:
- the instance
-
newDateType
protected abstract B newDateType(Date d)
Returns a new instance of the date type.- Parameters:
d
- the date to initialize with- Returns:
- the instance
-
toCustomStringRepresentation
public String toCustomStringRepresentation(Object obj)
Returns a custom string representation of the object.- Specified by:
toCustomStringRepresentation
in interfaceCustomStringRepresentationHandler
- 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:
fromCustomStringRepresentation
in interfaceCustomStringRepresentationHandler
- 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:
getJavaInitializationString
in interfacePropertyEditor
- Overrides:
getJavaInitializationString
in classPropertyEditorSupport
- Returns:
- a value of type 'String'
-
paintValue
public void paintValue(Graphics gfx, Rectangle box)
Paints a representation of the current Object.- Specified by:
paintValue
in interfacePropertyEditor
- Overrides:
paintValue
in classPropertyEditorSupport
- Parameters:
gfx
- the graphics context to usebox
- the area we are allowed to paint into
-
newPanel
protected abstract P newPanel()
Instantiates a new panel for picking the date type.- Returns:
- the panel
-
getPlaceholder
protected abstract String getPlaceholder(AbstractBaseDateTypeEditor.Placeholder ph)
Returns the string equivalent of the placeholder.- Parameters:
ph
- the placeholder to get the string representation for- Returns:
- the string representation
-
getNowButtonText
protected abstract String getNowButtonText()
Returns the text to use for the "now" button.- Returns:
- the button text
-
createCustomEditor
protected JComponent createCustomEditor()
Gets the custom editor component.- Specified by:
createCustomEditor
in classAbstractPropertyEditorSupport
- Returns:
- the editor
-
updateButtons
protected void updateButtons()
Sets the enabled state of the buttons.
-
showHelp
protected void showHelp()
Displays the help for the
-
initForDisplay
protected void initForDisplay()
Initializes the display of the value.- Overrides:
initForDisplay
in classAbstractPropertyEditorSupport
-
getSelectedObjects
public Object[] getSelectedObjects(Container parent)
Returns the selected objects.- Specified by:
getSelectedObjects
in interfaceMultiSelectionEditor
- Parameters:
parent
- the parent container- Returns:
- the objects
-
isInlineEditingAvailable
public boolean isInlineEditingAvailable()
Checks whether inline editing is available.- Specified by:
isInlineEditingAvailable
in interfaceInlineEditorSupport
- Returns:
- true if editing available
-
setInlineValue
public void setInlineValue(String value)
Sets the value to use.- Specified by:
setInlineValue
in interfaceInlineEditorSupport
- Parameters:
value
- the value to use
-
getInlineValue
public String getInlineValue()
Returns the current value.- Specified by:
getInlineValue
in interfaceInlineEditorSupport
- Returns:
- the current value
-
isInlineValueValid
public boolean isInlineValueValid(String value)
Checks whether the value id valid.- Specified by:
isInlineValueValid
in interfaceInlineEditorSupport
- Parameters:
value
- the value to check- Returns:
- true if valid
-
-