EchoPoint
1.0

echopoint
Class TimeField

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.text.TextComponent
          extended bynextapp.echo.TextField
              extended byechopoint.TextField
                  extended byechopoint.AbstractDateTimeField
                      extended byechopoint.TimeField
All Implemented Interfaces:
Borderable, MouseCursorable, ReflectionSetter, java.io.Serializable, ToolTipPopUpSupport, nextapp.echo.ToolTipSupport, Validateable

public class TimeField
extends AbstractDateTimeField

The TimeField class is a TextField component that can be used to allow a user to enter in a time value.

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

The TimeField also contains a list if time values that can be popped down by the user. This allows the user to navigate to a valid time without having to enter it in the right format.

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

Author:
Brad Baker
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class echopoint.AbstractDateTimeField
AbstractDateTimeField.NestedStyleInfo
 
Field Summary
static java.lang.String MINUTE_INTERVAL_PROPRTY_CHANGED
           
 
Fields inherited from class echopoint.AbstractDateTimeField
AUTO_COLLAPSE_CHANGED_PROPERTY, DATE_FORMAT_CHANGED_PROPERTY, DEFAULT_DROP_DOWN_ICON, DROP_DOWN_BUTTON_BACKGROUND_CHANGED_PROPERTY, DROP_DOWN_ICON_CHANGED_PROPERTY, EXPANSION_MODEL_CHANGED_PROPERTY, INVALID_COLOR_CHANGED_PROPERTY, STYLE_DROP_DOWN_BUTTON_BACKGROUND, STYLE_DROP_DOWN_ICON, STYLE_INVALID_COLOR
 
Fields inherited from class nextapp.echo.TextField
ACTION_COMMAND_CHANGED_PROPERTY, COLUMN_UNITS_CHANGED_PROPERTY, COLUMNS_CHANGED_PROPERTY, MAXIMUM_LENGTH_CHANGED_PROPERTY, STYLE_MAXIMUM_LENGTH
 
Fields inherited from class nextapp.echo.text.TextComponent
BORDER_COLOR_CHANGED_PROPERTY, BORDER_DEFAULT, BORDER_INSET, BORDER_NONE, 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 class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_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
 
Constructor Summary
TimeField()
          Creates a TimeField
TimeField(java.util.Calendar cal)
          Creates a TimeField with cal as the initial time value.
TimeField(java.util.Calendar cal, int columns)
          Creates a TimeField with cal as the initial value and a given column size.
TimeField(java.util.Calendar cal, int columns, java.util.Locale locale)
          Creates a TimeField with cal as the initial value and a given column size and the specified Locale.
TimeField(java.util.Calendar cal, java.util.Locale locale)
          Creates a TimeField with cal as the initial time value and the specified Locale.
TimeField(int columns)
          Creates a TimeField that is columns wide.
TimeField(java.lang.String text)
          Creates a TimeField with text as the initial value.
TimeField(java.lang.String text, int columns)
          Creates a TimeField with text as the initial value and that is columns wide.
 
Method Summary
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
protected  java.text.DateFormat getDefaultDateFormat(java.util.Locale locale)
          Returns new SimpleDateFormat("HH:mm", locale);
 int getMinuteInterval()
          Return the minute interval used in the pop down list of valid times
 java.util.Calendar getTime()
          This method will return a Calendar object created by parsing the current text in the TimeField with the current DateFormat.
protected  void onConstruction(java.util.Calendar cal)
          Called at construction time to add extra bits to the TimeField
 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 setMinuteInterval(int newValue)
          Return the minute interval used in the pop down list of valid times.
 void setTime(java.util.Calendar newValue)
          Sets the text of the TimeField according to the current DateFormat obhject in effect.
 
Methods inherited from class echopoint.AbstractDateTimeField
_reRegisterComponents, getDate, getDateFormat, getDropDownButtonBackground, getDropDownIcon, getExpansionModel, getInvalidColor, isAutoCollapse, isExpanded, isValidDateTime, localeChanged, setAutoCollapse, setDateFormat, setDropDownButtonBackground, setDropDownIcon, setEnabled, setExpanded, setExpansionModel, setInvalidColor
 
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, fireActionEvent, getActionCommand, getColumns, getColumnUnits, getMaximumLength, hasActionListeners, removeActionListener, setActionCommand, setColumns, setColumnUnits, setMaximumLength
 
Methods inherited from class nextapp.echo.text.TextComponent
getDocument, getHorizontalAlignment, getText, isEditable, setDocument, setEditable, setHorizontalAlignment, setText
 
Methods inherited from class nextapp.echo.Component
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getLocale, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setFont, setForeground, setIdentifier, setLocale, 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

MINUTE_INTERVAL_PROPRTY_CHANGED

public static final java.lang.String MINUTE_INTERVAL_PROPRTY_CHANGED
See Also:
Constant Field Values
Constructor Detail

TimeField

public TimeField()
Creates a TimeField


TimeField

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


TimeField

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


TimeField

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


TimeField

public TimeField(java.util.Calendar cal)
Creates a TimeField with cal as the initial time value.


TimeField

public TimeField(java.util.Calendar cal,
                 java.util.Locale locale)
Creates a TimeField with cal as the initial time value and the specified Locale.


TimeField

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


TimeField

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

Method Detail

getDefaultDateFormat

protected java.text.DateFormat getDefaultDateFormat(java.util.Locale locale)
Returns new SimpleDateFormat("HH:mm", locale);

Specified by:
getDefaultDateFormat in class AbstractDateTimeField
See Also:
AbstractDateTimeField.getDefaultDateFormat(Locale)

onConstruction

protected void onConstruction(java.util.Calendar cal)
Called at construction time to add extra bits to the TimeField

Specified by:
onConstruction in class AbstractDateTimeField

applyStyle

public void applyStyle(nextapp.echo.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
Overrides:
applyStyle in class AbstractDateTimeField

getTime

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

Note that this method is a simple synonymn for getDate()

Returns:
Calendar - a calendar object if the current text is a valid time

setTime

public void setTime(java.util.Calendar newValue)
Sets the text of the TimeField according to the current DateFormat obhject in effect.

Parameters:
newValue -

getMinuteInterval

public int getMinuteInterval()
Return the minute interval used in the pop down list of valid times

Returns:
the minute interval

setMinuteInterval

public void setMinuteInterval(int newValue)
Return the minute interval used in the pop down list of valid times. The entries in the pop down list will be created by dividing a 24 hour period by the minuteInterval.

A sensible value might be 15, 30 or 60 minutes.

Parameters:
newValue - - the minute interval
Throws:
java.lang.IllegalArgumentException - - 1440 > the minute interval is < 1

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 AbstractDateTimeField
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0