echopoint
Class AbstractDateTimeField

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by nextapp.echo.text.TextComponent
          extended by nextapp.echo.TextField
              extended by echopoint.TextField
                  extended by echopoint.AbstractDateTimeField
All Implemented Interfaces:
Borderable, MouseCursorable, ToolTipPopUpSupport, ReflectionSetter, Validateable, java.io.Serializable, java.util.EventListener, Component, ChangeListener, ToolTipSupport
Direct Known Subclasses:
DateField, TimeField

public abstract class AbstractDateTimeField
extends TextField
implements ReflectionSetter, ChangeListener

The AbstractDateTimeField class is an abstract Component that can be used as the baisis for allowing a user to enter in a date or time.

The AbstractDateTimeField has a DateFormat that is used to parse and sets its current value (remember it is derived from TextField).

Remember that at any one time the text value can be an invalid date/time. You must check the date/time in you code before accepting it as valid.

See Also:
Serialized Form

Nested Class Summary
static class AbstractDateTimeField.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static java.lang.String AUTO_COLLAPSE_CHANGED_PROPERTY
          Auto Collapse Property
static java.lang.String CSS_CLASS_CHANGED_PROPERTY
          Css Class Property
static java.lang.String DATE_FORMAT_CHANGED_PROPERTY
          DateFormat Property
static ImageReference DEFAULT_DROP_DOWN_ICON
          Default Drop Down Icon
static java.lang.String DROP_DOWN_BUTTON_BACKGROUND_CHANGED_PROPERTY
           
static java.lang.String DROP_DOWN_ICON_CHANGED_PROPERTY
           
static java.lang.String EXPANSION_MODEL_CHANGED_PROPERTY
          Model Property
static java.lang.String INVALID_COLOR_CHANGED_PROPERTY
           
static java.lang.String STYLE_DROP_DOWN_BUTTON_BACKGROUND
          Drop Down Button Color Property
static java.lang.String STYLE_DROP_DOWN_ICON
          Drop Down Icon Property
static java.lang.String STYLE_INVALID_COLOR
          Invalid Date Color Property
 
Fields inherited from class nextapp.echo.TextField
ACTION_COMMAND_CHANGED_PROPERTY, COLUMN_UNITS_CHANGED_PROPERTY, COLUMNS_CHANGED_PROPERTY, KEY_ACTION_COMMAND_CHANGED_PROPERTY, MAXIMUM_LENGTH_CHANGED_PROPERTY, RETURN_KEY_ACTION_COMMAND_CHANGED_PROPERTY, STYLE_MAXIMUM_LENGTH
 
Fields inherited from class nextapp.echo.text.TextComponent
BORDER_COLOR_CHANGED_PROPERTY, BORDER_DEFAULT, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_SIZE_CHANGED_PROPERTY, BORDER_SOLID, BORDER_STYLE_CHANGED_PROPERTY, CHARACTER_UNITS, DOCUMENT_CHANGED_PROPERTY, EDITABLE_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, PERCENT_UNITS, PIXEL_UNITS, STYLE_BORDER_COLOR, STYLE_BORDER_SIZE, STYLE_BORDER_STYLE, STYLE_COLUMNS, STYLE_HORIZONTAL_ALIGNMENT, STYLE_LINE_WRAP, STYLE_ROWS, TEXT_CHANGED_PROPERTY
 
Fields inherited from interface echopoint.positionable.Borderable
BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_GROOVE, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_RIDGE, BORDER_SOLID, borderStyleSymbolics, STYLE_BORDER_COLOR, STYLE_BORDER_SIZE, STYLE_BORDER_STYLE, STYLE_BOTTOM_BORDER_COLOR, STYLE_BOTTOM_BORDER_SIZE, STYLE_BOTTOM_BORDER_STYLE, STYLE_LEFT_BORDER_COLOR, STYLE_LEFT_BORDER_SIZE, STYLE_LEFT_BORDER_STYLE, STYLE_RIGHT_BORDER_COLOR, STYLE_RIGHT_BORDER_SIZE, STYLE_RIGHT_BORDER_STYLE, STYLE_TOP_BORDER_COLOR, STYLE_TOP_BORDER_SIZE, STYLE_TOP_BORDER_STYLE
 
Fields inherited from interface echopoint.positionable.MouseCursorable
borderStyleSymbolics, CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, STYLE_MOUSE_CURSOR, STYLE_MOUSE_CURSOR_URI
 
Fields inherited from interface nextapp.echo.ToolTipSupport
TOOL_TIP_TEXT_CHANGED_PROPERTY
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
AbstractDateTimeField()
          Creates a AbstractDateTimeField
AbstractDateTimeField(java.util.Calendar cal)
          Creates a AbstractDateTimeField with cal as the initial Date value.
AbstractDateTimeField(java.util.Calendar cal, int columns)
          Creates a AbstractDateTimeField with cal as the initial value and a given column size.
AbstractDateTimeField(java.util.Calendar cal, int columns, java.util.Locale locale)
          Creates a AbstractDateTimeField with cal as the initial value and a given column size as well as a specific Locale.
AbstractDateTimeField(java.util.Calendar cal, java.util.Locale locale)
          Creates a AbstractDateTimeField with cal as the initial Date value and a specific Locale.
AbstractDateTimeField(int columns)
          Creates a AbstractDateTimeField that is columns wide.
AbstractDateTimeField(java.lang.String text)
          Creates a AbstractDateTimeField with text as the initial value.
AbstractDateTimeField(java.lang.String text, int columns)
          Creates a AbstractDateTimeField with text as the initial value and that is columns wide.
 
Method Summary
protected  void _reRegisterComponents(Component oldValue, Component newValue)
          adds and removes an Component from the current hierarchy tree
 void applyStyle(Style style)
          Applies the provided style to the component.
 java.lang.String getCssClass()
           
 java.util.Calendar getDate()
          This method will return a Calendar object created by parsing the current text in the AbstractDateTimeField with the current DateFormat.
 java.text.DateFormat getDateFormat()
          Returns the DateFormat in use.
protected abstract  java.text.DateFormat getDefaultDateFormat(java.util.Locale locale)
          Implementing classes must return a default DateFormat that is used during object contruction.
 Color getDropDownButtonBackground()
          Returns the background Color of the drop down button
 ImageReference getDropDownIcon()
          Gets the icon to be used as the drop down image
 ExpandableModel getExpansionModel()
           
 Color getInvalidColor()
          Returns the color used by the AbstractDateTimeField when an invalid date/time value is currently entered.
 boolean isAutoCollapse()
          Returns TRUE if the AbstractDateTimeField will revert to a collapsed state when a date/time is selected.
 boolean isExpanded()
           
 boolean isValidDateTime()
          This method returns TRUE if the text of the AbstractDateTimeField can be parsed into a valid date/time with the current DateFormat.
protected  void localeChanged()
          Called when the Locale properly has changed.
protected abstract  void onConstruction(java.util.Calendar cal)
          Implementing classes can implement this to do extra object construction.
 java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue)
          Called to save the old value of a field, set in a new value and return the old value of a field.
 void setAutoCollapse(boolean newAutoCollapse)
          Sets whether the AbstractDateTimeField will revert to a collapsed state when a date/time is selected from its drop down.
 void setCssClass(java.lang.String newValue)
           
 void setDateFormat(java.text.DateFormat newDateFormat)
          Sets the DateFormat to be used by the AbstractDateTimeField for displaying and parsing entered data.
 void setDropDownButtonBackground(Color newValue)
          Sets the background Color of the drop down button
 void setDropDownIcon(ImageReference dropDownIcon)
          Sets the icon to be used as the drop down image
 void setEnabled(boolean newValue)
          Sets whether the component is enabled.
 void setExpanded(boolean isExpanded)
          Sets whether the AbstractDateTimeField is expanded or not and hence whether its contained DatePicker is showing.
 void setExpansionModel(ExpandableModel newExpansionModel)
          Sets the ExpandableModel model used by the AbstractDateTimeField.
 void setInvalidColor(Color newInvalidColor)
          Sets the color used by the AbstractDateTimeField when an invalid date/time value is currently entered.
 void stateChanged(ChangeEvent e)
          Invoked when a state change occurs.
 
Methods inherited from class echopoint.TextField
getBorderColor, getBorderSize, getBorderStyle, getBottomBorderColor, getBottomBorderSize, getBottomBorderStyle, getLeftBorderColor, getLeftBorderSize, getLeftBorderStyle, getMouseCursor, getMouseCursorURI, getRightBorderColor, getRightBorderSize, getRightBorderStyle, getRuleSet, getToolTipPopUp, getToolTipText, getTopBorderColor, getTopBorderSize, getTopBorderStyle, setBorderColor, setBorderSize, setBorderStyle, setBottomBorderColor, setBottomBorderSize, setBottomBorderStyle, setLeftBorderColor, setLeftBorderSize, setLeftBorderStyle, setMouseCursor, setMouseCursorURI, setRightBorderColor, setRightBorderSize, setRightBorderStyle, setRuleSet, setToolTipText, setTopBorderColor, setTopBorderSize, setTopBorderStyle, validate
 
Methods inherited from class nextapp.echo.TextField
addActionListener, addKeyActionListener, addReturnActionListener, fireActionEvent, fireKeyActionEvent, fireReturnActionEvent, getActionCommand, getColumns, getColumnUnits, getKeyActionCommand, getMaximumLength, getReturnActionCommand, hasActionListeners, hasKeyActionListeners, hasReturnActionListeners, isAsync, isConvertToLowerCase, isConvertToUpperCase, removeActionListener, removeKeyActionListener, removeReturnActionListener, setActionCommand, setAsync, setColumns, setColumnUnits, setConvertToLowerCase, setConvertToUpperCase, setKeyActionCommand, setMaximumLength, setReturnActionCommand
 
Methods inherited from class nextapp.echo.text.TextComponent
getDocument, getHorizontalAlignment, getText, isEditable, setDocument, setEditable, setHorizontalAlignment, setText
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface echopoint.validation.Validateable
getIdentifier, getLocale, getText
 

Field Detail

EXPANSION_MODEL_CHANGED_PROPERTY

public static final java.lang.String EXPANSION_MODEL_CHANGED_PROPERTY
Model Property

See Also:
Constant Field Values

DATE_FORMAT_CHANGED_PROPERTY

public static final java.lang.String DATE_FORMAT_CHANGED_PROPERTY
DateFormat Property

See Also:
Constant Field Values

STYLE_INVALID_COLOR

public static final java.lang.String STYLE_INVALID_COLOR
Invalid Date Color Property

See Also:
Constant Field Values

INVALID_COLOR_CHANGED_PROPERTY

public static final java.lang.String INVALID_COLOR_CHANGED_PROPERTY
See Also:
Constant Field Values

STYLE_DROP_DOWN_BUTTON_BACKGROUND

public static final java.lang.String STYLE_DROP_DOWN_BUTTON_BACKGROUND
Drop Down Button Color Property

See Also:
Constant Field Values

DROP_DOWN_BUTTON_BACKGROUND_CHANGED_PROPERTY

public static final java.lang.String DROP_DOWN_BUTTON_BACKGROUND_CHANGED_PROPERTY
See Also:
Constant Field Values

DEFAULT_DROP_DOWN_ICON

public static final ImageReference DEFAULT_DROP_DOWN_ICON
Default Drop Down Icon


STYLE_DROP_DOWN_ICON

public static final java.lang.String STYLE_DROP_DOWN_ICON
Drop Down Icon Property

See Also:
Constant Field Values

DROP_DOWN_ICON_CHANGED_PROPERTY

public static final java.lang.String DROP_DOWN_ICON_CHANGED_PROPERTY
See Also:
Constant Field Values

AUTO_COLLAPSE_CHANGED_PROPERTY

public static final java.lang.String AUTO_COLLAPSE_CHANGED_PROPERTY
Auto Collapse Property

See Also:
Constant Field Values

CSS_CLASS_CHANGED_PROPERTY

public static final java.lang.String CSS_CLASS_CHANGED_PROPERTY
Css Class Property

See Also:
Constant Field Values
Constructor Detail

AbstractDateTimeField

public AbstractDateTimeField()
Creates a AbstractDateTimeField


AbstractDateTimeField

public AbstractDateTimeField(int columns)
Creates a AbstractDateTimeField that is columns wide.


AbstractDateTimeField

public AbstractDateTimeField(java.lang.String text)
Creates a AbstractDateTimeField with text as the initial value.


AbstractDateTimeField

public AbstractDateTimeField(java.lang.String text,
                             int columns)
Creates a AbstractDateTimeField with text as the initial value and that is columns wide.


AbstractDateTimeField

public AbstractDateTimeField(java.util.Calendar cal)
Creates a AbstractDateTimeField with cal as the initial Date value.


AbstractDateTimeField

public AbstractDateTimeField(java.util.Calendar cal,
                             java.util.Locale locale)
Creates a AbstractDateTimeField with cal as the initial Date value and a specific Locale.


AbstractDateTimeField

public AbstractDateTimeField(java.util.Calendar cal,
                             int columns)
Creates a AbstractDateTimeField with cal as the initial value and a given column size.


AbstractDateTimeField

public AbstractDateTimeField(java.util.Calendar cal,
                             int columns,
                             java.util.Locale locale)
Creates a AbstractDateTimeField with cal as the initial value and a given column size as well as a specific Locale.

Method Detail

localeChanged

protected void localeChanged()
Called when the Locale properly has changed. This will get a new DateFormat for the locale and then reparse the current text.


getDefaultDateFormat

protected abstract java.text.DateFormat getDefaultDateFormat(java.util.Locale locale)
Implementing classes must return a default DateFormat that is used during object contruction.


onConstruction

protected abstract void onConstruction(java.util.Calendar cal)
Implementing classes can implement this to do extra object construction.


_reRegisterComponents

protected void _reRegisterComponents(Component oldValue,
                                     Component newValue)
adds and removes an Component from the current hierarchy tree


applyStyle

public void applyStyle(Style style)
Applies the provided style to the component. The base nextapp.echo.Component style names can be used as well.

Specified by:
applyStyle in interface Borderable
Specified by:
applyStyle in interface MouseCursorable
Specified by:
applyStyle in interface Component
Overrides:
applyStyle in class TextField
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Borderable.applyStyle(nextapp.echo.Style)

getDate

public java.util.Calendar getDate()
This method will return a Calendar object created by parsing the current text in the AbstractDateTimeField with the current DateFormat. If this parse is successful then a Calendar object will be returned, otherwise null will be returned.


getDateFormat

public java.text.DateFormat getDateFormat()
Returns the DateFormat in use.

Returns:
java.text.DateFormat

getExpansionModel

public ExpandableModel getExpansionModel()
Returns:
the ExpandableModel model of the AbstractDateTimeField.

getInvalidColor

public Color getInvalidColor()
Returns the color used by the AbstractDateTimeField when an invalid date/time value is currently entered.

Returns:
nextapp.echo.Color

isAutoCollapse

public boolean isAutoCollapse()
Returns TRUE if the AbstractDateTimeField will revert to a collapsed state when a date/time is selected.

Returns:
boolean

isExpanded

public boolean isExpanded()
Returns:
whether AbstractDateTimeField is expanded or not, and hence whether it is showing its underlying drop down component.

isValidDateTime

public boolean isValidDateTime()
This method returns TRUE if the text of the AbstractDateTimeField can be parsed into a valid date/time with the current DateFormat.


setAutoCollapse

public void setAutoCollapse(boolean newAutoCollapse)
Sets whether the AbstractDateTimeField will revert to a collapsed state when a date/time is selected from its drop down.

Parameters:
newAutoCollapse - boolean

setDateFormat

public void setDateFormat(java.text.DateFormat newDateFormat)
Sets the DateFormat to be used by the AbstractDateTimeField for displaying and parsing entered data.

Parameters:
newDateFormat - java.text.DateFormat

setExpanded

public void setExpanded(boolean isExpanded)
Sets whether the AbstractDateTimeField is expanded or not and hence whether its contained DatePicker is showing.


setExpansionModel

public void setExpansionModel(ExpandableModel newExpansionModel)
Sets the ExpandableModel model used by the AbstractDateTimeField.


setInvalidColor

public void setInvalidColor(Color newInvalidColor)
Sets the color used by the AbstractDateTimeField when an invalid date/time value is currently entered. If this value is null then no special invalid coloring will take place.

Parameters:
newInvalidColor - nextapp.echo.Color

getDropDownButtonBackground

public Color getDropDownButtonBackground()
Returns the background Color of the drop down button

Returns:
the background Color of the drop down button

setDropDownButtonBackground

public void setDropDownButtonBackground(Color newValue)
Sets the background Color of the drop down button

Parameters:
newValue - - the new background color

setEnabled

public void setEnabled(boolean newValue)
Description copied from interface: Component
Sets whether the component is enabled.

Specified by:
setEnabled in interface Component
Overrides:
setEnabled in class AbstractComponent
Parameters:
newValue - True if the component is enabled.
See Also:
Component.setEnabled(boolean)

getDropDownIcon

public ImageReference getDropDownIcon()
Gets the icon to be used as the drop down image

Returns:
- the icon to be used as the drop down image

setDropDownIcon

public void setDropDownIcon(ImageReference dropDownIcon)
Sets the icon to be used as the drop down image

Parameters:
dropDownIcon - - the new drop down icon

set

public java.lang.Object set(java.lang.reflect.Field field,
                            java.lang.Object newValue)
                     throws java.lang.Exception
Description copied from interface: ReflectionSetter
Called to save the old value of a field, set in a new value and return the old value of a field. This interface allows a field set operation to be "delegated" back into the class that has permission to perform the field set.

 public Object set(Field f, Object newValue) throws Exception {
      Object oldValue = f.get(this);
      f.set(this,newValue);
      return oldValue;
 }
 

Specified by:
set in interface ReflectionSetter
Overrides:
set in class TextField
Parameters:
field - - the field to be set
newValue - - the new value to be set
Returns:
the oldValue of the field
Throws:
java.lang.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.NullPointerException
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

stateChanged

public void stateChanged(ChangeEvent e)
Description copied from interface: ChangeListener
Invoked when a state change occurs.

Specified by:
stateChanged in interface ChangeListener
Parameters:
e - The event describing the state change.

getCssClass

public java.lang.String getCssClass()
Overrides:
getCssClass in class TextComponent

setCssClass

public void setCssClass(java.lang.String newValue)
Overrides:
setCssClass in class TextComponent