danger.ui
Class DateTimeEditor

java.lang.Object
  extended by danger.app.Listener
      extended by danger.ui.View
          extended by danger.ui.Container
              extended by danger.ui.Control
                  extended by danger.ui.DateTimeEditor
All Implemented Interfaces:
ToolTipOwner


public class DateTimeEditor
extends Control

A control to allow the user to edit a date or time.


Field Summary
static int FORMAT_DATE_LONG
          Specifies a long date format, such as December 25, 2005.
static int FORMAT_DATE_MEDIUM
          Specifies a medium date format, such as Dec 25, 2005.
static int FORMAT_DATE_SHORT
          Specifies a short date format, such as 12/25/2005.
static int FORMAT_NONE
          Deprecated. Not used.
static int FORMAT_TIME_LONG
          Specifies a long time format, such as 1:34 pm.
protected  Date mDate
          Deprecated. Use setDate(java.util.Date, java.util.TimeZone) and getDate() instead.
protected  String mFormat
          Deprecated. Use setFormat(int) instead.
protected  boolean mKeyEntry
          Deprecated. For internal use only.
protected  Alarm mKeyInputAlarm
          Deprecated. For internal use only.
protected  String mKeyString
          Deprecated. For internal use only.
protected  int mLastKeyTime
          Deprecated. For internal use only.
protected  Date mMaxDate
          Deprecated. Use max(danger.internal.Date) instead.
protected  Date mMinDate
          Deprecated. Use min(danger.internal.Date) instead.
protected  boolean mReflowAfterChange
          Deprecated. For internal use only.
protected  int[] mViewCounts
          Deprecated. For internal use only.
protected  StaticText[] mViews
          Deprecated. For internal use only.
protected  int[] mViewTypes
          Deprecated. For internal use only.
protected static int STD_HEIGHT
          Deprecated. For internal use only.
protected static int STD_WIDTH
          Deprecated. For internal use only.
 
Fields inherited from class danger.ui.Control
mValue
 
Fields inherited from class danger.ui.View
DEFAULT_SCROLL_FOCUS_MARGIN, FOCUS_DEFAULT, FOCUS_DOWNWARD, FOCUS_LEFTWARD, FOCUS_NONE, FOCUS_RIGHTWARD, FOCUS_UPWARD, mOriginX, mOriginY, mStyle, POSITION_ABOVE, POSITION_ALIGN_BASELINE, POSITION_ALIGN_BOTTOM, POSITION_ALIGN_HORIZONTALLY, POSITION_ALIGN_LEFT, POSITION_ALIGN_PARENT_BOTTOM, POSITION_ALIGN_PARENT_RIGHT, POSITION_ALIGN_RIGHT, POSITION_ALIGN_TOP, POSITION_ALIGN_VERTICALLY, POSITION_BELOW, POSITION_CENTER_HORIZONTALLY, POSITION_CENTER_VERTICALLY, POSITION_TO_LEFT, POSITION_TO_RIGHT, PREFER_DIRECTION_NONE, PREFER_HORIZONTAL_DIRECTION, PREFER_VERTICAL_DIRECTION, STATE_AT_AND_SPACE_PAGE, STATE_CAN_FOCUS, STATE_DEBUG_BOUNDS, STATE_ENABLED, STATE_FOCUSED, STATE_MAKE_DING, STATE_PARTIAL_FOCUS_OK, STATE_TRANSPARENT, STATE_VISIBLE, WIDTH_FILL_TO_RIGHT
 
Constructor Summary
DateTimeEditor()
          Construct an instance of a DateTimeEditor, defaulting to the current date and time.
DateTimeEditor(Date inDate)
          Construct an instance of a DateTimeEditor with the specified date.
DateTimeEditor(Date inDate, int inFormat)
          Construct an instance of a DateTimeEditor with the specified date and format.
DateTimeEditor(Date inDate, String inFormat)
          Construct an instance of a DateTimeEditor with the specified date and format.
DateTimeEditor(Date inDate, TimeZone inTimeZone)
          Construct an instance of a DateTimeEditor with the specified date and time zone.
 
Method Summary
protected  void adjustPickerWindow(PickerWindow pw, View inAlignView)
          Deprecated. For internal use only.
 void disable()
          Disables this container and all its children recursively.
protected  void drawBackground(Pen p, Rect inRect)
          Draw the background of the editor.
 void enable()
          Enables this container and all its children recursively.
 void enforceLimitsAndUpdate()
          Deprecated. For internal use only.
protected  void enforceMaxLimit()
          Deprecated. For internal use only.
protected  void enforceMinLimit()
          Deprecated. For internal use only.
 boolean eventKeyDown(char c, Event event)
          This method is called when the user presses a key.
 boolean eventKeyUp(char c, Event event)
          Processes key releases directed at this container.
 boolean eventWidgetDown(int widget, Event event)
          Handle the pressing of a device widget
 boolean eventWidgetUp(int widget, Event event)
          Handle the release of a device widget
 int getBaseline()
          Get the baseline of this Control's text or label.
 Date getDate()
          Get the current date value.
 Date getJavaDate()
          Get the current date value as a java.util.Date object.
protected  void layout()
          Deprecated. For internal use only.
 void limitToDangerEpoch()
          Set the minimum and maximum allowable dates to fit in the Danger epoch, which has a range of 2000-2068.
 void limitToUnixEpoch()
          Set the minimum and maximum allowable dates to fit in the Unix epoch, which has a range of 1970-2038.
 void max(Date inMaxDate)
          Set the maximum allowable date.
 void max(Date inDate, TimeZone inTimeZone)
          Set the maximum allowable date.
 void min(Date inMinDate)
          Set the minimum allowable date.
 void min(Date inDate, TimeZone inTimeZone)
          Set the minimum allowable date.
 void paint(Pen p)
          Draw the contents of this View.
 boolean receiveEvent(Event e)
          Entry point for event processing.
protected  void reflowDateLayout()
          Deprecated. For internal use only.
protected  void reflowDateLayout(int inAmount)
          Deprecated. For internal use only.
 void setDate(Date inDate)
          Set the date.
 void setDate(Date inDate, TimeZone inTimeZone)
          Set the date and time zone.
 void setFocusedChild(View newFocus, int direction)
          Set the focus for the view container to a specific child object.
 void setFormat(int inFormat)
          Set the format.
 void setFormat(String inFormat)
          Set the format.
 void setSize(int inWidth, int inHeight)
          Simultaneously set the width and height of this View.
protected  void showAMPMPicker()
          Deprecated. For internal use only.
protected  void showDayPicker()
          Deprecated. For internal use only.
protected  void showHourPicker()
          Deprecated. For internal use only.
protected  void showMinutePicker()
          Deprecated. For internal use only.
protected  void showMonthPicker()
          Deprecated. For internal use only.
protected  void showYearPicker()
          Deprecated. For internal use only.
protected  void update()
          Deprecated. For internal use only.
 
Methods inherited from class danger.ui.Control
drawFocusBox, drawIdleBox, drawIdleBox, getEvent, getEventListener, getEventType, getHasBorder, getMaxToolTipLines, getTitle, getTitleSequence, getToolTip, getValue, hasToolTip, loseFocus, onSetHasBorder, onSetTitle, sendEvent, setEvent, setEvent, setEvent, setEvent, setEvent, setEventArg, setEventListener, setHasBorder, setMaxToolTipLines, setTitle, setTitle, setToolTip, setValue, showToolTip, takeFocus
 
Methods inherited from class danger.ui.Container
addChild, addChild, addChildAt, addChildAt, addFromContainerResource, addFromContainerResource, addFromContainerResource, addFromDialogResource, addFromDialogResource, advanceFocus, advanceFocusInWindow, childCount, childIsOnScreen, eventKeyHeld, eventKeyRepeat, eventPeriodicPulse, eventRawKeyDown, eventRawKeyHeld, eventRawKeyRepeat, eventRawKeyUp, eventShortcut, eventWidgetHeld, focusedDescendantIsValid, getBottomChild, getBottomChild, getChildAt, getChildIndex, getChildWithID, getControlWithID, getDescendantWithID, getFirstChild, getFirstFocusableChild, getFocusableChildInWindow, getFocusedChild, getFocusedLeaf, getInterestingRect, getLastChild, getLastFocusableChild, getLeftMostChild, getNextFocusableChild, getNextFocusableChild, getPageHeight, getPrevFocusableChild, getPrevFocusableChild, getRightMostChild, getRightMostChild, handleButtonShortcut, hideAllChildren, isDescendant, keepRectInView, moveChildToIndex, onChildPositionChanged, onChildSizeChanged, onChildVisibilityChanged, pageToEnd, pageToHome, paintChildren, reflowChildren, removeAllChildren, removeChild, reverseFocus, setFocusedChild, setFocusedChild, setFocusedDescendant, setFocusedDescendant, setFocusedDescendant, setFocusToFirstDescendant, setFormatDateForControlWithID, setFormatDateForTextControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setFormatTextForTextControlWithID, setListenerForAllControls, setReflowAdjustHeight, setWindow, showAllChildren, snapHeightToChildren, snapHeightToChildren, snapToChildren, snapWidthToChildren, snapWidthToChildren, willFocusWithin, willFocusWithin
 
Methods inherited from class danger.ui.View
boundsIntersect, boundsIntersect, canLoseFocus, clear, clear, copyStyle, getAcceptFocus, getBackgroundColor, getBottom, getBounds, getBounds, getFocusTraversalDirection, getFocusTraversalFrom, getFocusTraversalPolicy, getFrame, getFrame, getGlobalBottom, getGlobalLeft, getGlobalRight, getGlobalTop, getHeight, getID, getInterestingRect, getLabelFont, getLabelFont, getLeft, getOrigin, getOrigin, getOriginX, getOriginY, getParent, getParentContainer, getPartialFocusOK, getRight, getScrollFocusMargin, getSibling, getState, getStyle, getStyleColor, getStyleFont, getTop, getWidth, getWindow, globalToLocal, globalToLocalH, globalToLocalV, hide, invalidate, invalidate, invalidate, invalidateIndependentOfOrigin, invalidateIndependentOfOrigin, isEnabled, isFocusable, isFocused, isOnScreen, isTransparent, isVisible, isVisibleInHierarchy, isVisibleOnScreen, justSetVisible, localToGlobal, localToGlobal, localToGlobalH, localToGlobalV, localToWindow, moveBy, notifyWhenParentSizeChanges, notifyWhenPositionChanges, notifyWhenSizeChanges, offsetOrigin, offsetOrigin, onAddedToParent, onDecoded, onEnabledStateChanged, onHide, onPeriodicPulse, onPositionChanged, onRemovedFromParent, onShortcut, onShortcut, onShortcutConsumed, onShow, onSizeChanged, onStyleChanged, onViewPositionChanged, onViewSizeChanged, onWindowPaint, playLimitSound, receiveEventInternal, resetOrigin, sendEventToWindow, setAcceptFocus, setAtAndSpacePage, setBackground, setBackgroundColor, setBottom, setDebugBounds, setDynamicPosition, setDynamicWidth, setEnabled, setFocusTraversalDirection, setFocusTraversalFrom, setFocusTraversalPolicy, setFrame, setHeight, setKeyedValue, setLabelFont, setLeft, setMakeLimitNoise, setOrigin, setOrigin, setPartialFocusOK, setPosition, setPreferredDirection, setRight, setScrollFocusMargin, setStyle, setStyleColor, setStyleFont, setStyleFrameColor, setTop, setTransparent, setVisible, setWidth, shouldDropEvent, show, showContextMenu, styleIsDefault, swapStyleColors, windowToLocal
 
Methods inherited from class danger.app.Listener
cancelEvents, childEventPump, childEventPumpDone, eventProblem, isDispatchingThread, sendEvent, sendEvent, sendEvent, sendEvent, sendEvent, sendLowPriorityEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mDate

protected Date mDate
Deprecated. Use setDate(java.util.Date, java.util.TimeZone) and getDate() instead.

mMaxDate

protected Date mMaxDate
Deprecated. Use max(danger.internal.Date) instead.

mMinDate

protected Date mMinDate
Deprecated. Use min(danger.internal.Date) instead.

mFormat

protected String mFormat
Deprecated. Use setFormat(int) instead.

mLastKeyTime

protected int mLastKeyTime
Deprecated. For internal use only.

mKeyString

protected String mKeyString
Deprecated. For internal use only.

mKeyEntry

protected boolean mKeyEntry
Deprecated. For internal use only.

mKeyInputAlarm

protected Alarm mKeyInputAlarm
Deprecated. For internal use only.

mViews

protected StaticText[] mViews
Deprecated. For internal use only.

mViewTypes

protected int[] mViewTypes
Deprecated. For internal use only.

mViewCounts

protected int[] mViewCounts
Deprecated. For internal use only.

mReflowAfterChange

protected boolean mReflowAfterChange
Deprecated. For internal use only.

FORMAT_NONE

public static final int FORMAT_NONE
Deprecated. Not used.
See Also:
Constant Field Values

FORMAT_DATE_SHORT

public static final int FORMAT_DATE_SHORT
Specifies a short date format, such as 12/25/2005. Used in DateTimeEditor(Date,int) and setFormat(int).

See Also:
Constant Field Values

FORMAT_DATE_MEDIUM

public static final int FORMAT_DATE_MEDIUM
Specifies a medium date format, such as Dec 25, 2005. Used in DateTimeEditor(Date,int) and setFormat(int).

See Also:
Constant Field Values

FORMAT_DATE_LONG

public static final int FORMAT_DATE_LONG
Specifies a long date format, such as December 25, 2005. Used in DateTimeEditor(Date,int) and setFormat(int).

See Also:
Constant Field Values

FORMAT_TIME_LONG

public static final int FORMAT_TIME_LONG
Specifies a long time format, such as 1:34 pm. Used in DateTimeEditor(Date,int) and setFormat(int).

See Also:
Constant Field Values

STD_HEIGHT

protected static final int STD_HEIGHT
Deprecated. For internal use only.
See Also:
Constant Field Values

STD_WIDTH

protected static final int STD_WIDTH
Deprecated. For internal use only.
See Also:
Constant Field Values
Constructor Detail

DateTimeEditor

public DateTimeEditor()
Construct an instance of a DateTimeEditor, defaulting to the current date and time. The FORMAT_DATE_MEDIUM format is used.


DateTimeEditor

public DateTimeEditor(Date inDate)
Construct an instance of a DateTimeEditor with the specified date. The FORMAT_DATE_MEDIUM format is used.


DateTimeEditor

public DateTimeEditor(Date inDate,
                      TimeZone inTimeZone)
Construct an instance of a DateTimeEditor with the specified date and time zone. The FORMAT_DATE_MEDIUM format is used.


DateTimeEditor

public DateTimeEditor(Date inDate,
                      int inFormat)
Construct an instance of a DateTimeEditor with the specified date and format.

Parameters:
inDate - the initial date
inFormat - the format to use. One of FORMAT_DATE_SHORT, FORMAT_DATE_MEDIUM, FORMAT_DATE_LONG, and FORMAT_TIME_LONG.

DateTimeEditor

public DateTimeEditor(Date inDate,
                      String inFormat)
Construct an instance of a DateTimeEditor with the specified date and format.

Parameters:
inDate - the initial date
inFormat - a string representation of the format to use. See DateFormat for more details.
Method Detail

setDate

public void setDate(Date inDate,
                    TimeZone inTimeZone)
Set the date and time zone.

Parameters:
inDate - the date
inTimeZone - the time zone

setDate

public void setDate(Date inDate)
Set the date.

Parameters:
inDate - the date

setFormat

public void setFormat(int inFormat)
Set the format.

Parameters:
inFormat - the format to use. One of FORMAT_DATE_SHORT, FORMAT_DATE_MEDIUM, FORMAT_DATE_LONG, and FORMAT_TIME_LONG.

setFormat

public void setFormat(String inFormat)
Set the format.

Parameters:
inFormat - a string representation of the format to use. See DateFormat for more details.

getDate

public Date getDate()

Get the current date value.


getJavaDate

public Date getJavaDate()

Get the current date value as a java.util.Date object.


enforceLimitsAndUpdate

public void enforceLimitsAndUpdate()
Deprecated. For internal use only.


enable

public void enable()
Description copied from class: Container
Enables this container and all its children recursively.

Overrides:
enable in class Container

disable

public void disable()
Description copied from class: Container
Disables this container and all its children recursively.

Overrides:
disable in class Container

layout

protected void layout()
Deprecated. For internal use only.


reflowDateLayout

protected void reflowDateLayout(int inAmount)
Deprecated. For internal use only.


reflowDateLayout

protected void reflowDateLayout()
Deprecated. For internal use only.


update

protected void update()
Deprecated. For internal use only.


setSize

public void setSize(int inWidth,
                    int inHeight)
Description copied from class: View
Simultaneously set the width and height of this View.

Overrides:
setSize in class View

receiveEvent

public boolean receiveEvent(Event e)
Description copied from class: Listener
Entry point for event processing. This method is called from a Dispatcher when it reads an Event in its queue that is targetted at this instance. The default behavior is to do nothing and return false. Subclasses are expected to override this method to do something more useful.

Overrides:
receiveEvent in class Container
Parameters:
e - non-null; the event to process
Returns:
whether (true) or not (false) this method actually handled the event to completion

adjustPickerWindow

protected void adjustPickerWindow(PickerWindow pw,
                                  View inAlignView)
Deprecated. For internal use only.


showMonthPicker

protected void showMonthPicker()
Deprecated. For internal use only.


showDayPicker

protected void showDayPicker()
Deprecated. For internal use only.


showYearPicker

protected void showYearPicker()
Deprecated. For internal use only.


showHourPicker

protected void showHourPicker()
Deprecated. For internal use only.


showMinutePicker

protected void showMinutePicker()
Deprecated. For internal use only.


showAMPMPicker

protected void showAMPMPicker()
Deprecated. For internal use only.


paint

public void paint(Pen p)
Description copied from class: View
Draw the contents of this View. This method is called by the graphics system when the View needs to be repainted. A Pen will be provided which is appropriately clipped and translated for drawing on this View.

The implementation of this method in this class will merely call clear() pen, if this View is opaque (not transparent), and will do nothing otherwise. If you don't need this behavior, then there is no point in calling super.paint() in an overriding method.

Overrides:
paint in class Container
Parameters:
p - non-null; the pen to use for drawing operations

getBaseline

public int getBaseline()
Description copied from class: Control
Get the baseline of this Control's text or label. The standard implementation just returns the same as View.getHeight(), but subclasses that display text should override it to return something more appropriate.

Overrides:
getBaseline in class Control

drawBackground

protected final void drawBackground(Pen p,
                                    Rect inRect)
Draw the background of the editor.


eventKeyUp

public boolean eventKeyUp(char c,
                          Event event)
Description copied from class: Container
Processes key releases directed at this container.

Overrides:
eventKeyUp in class Container
Parameters:
c - the character being released.

setFocusedChild

public void setFocusedChild(View newFocus,
                            int direction)
Description copied from class: Container
Set the focus for the view container to a specific child object. If the given view can't assume focus, or if it already has focus, then this method does nothing. If you pass null, then this indicates that whatever child currently has focus should lose focus. This throws an exception if you pass a non-null view that is not a child of this instance.

Overrides:
setFocusedChild in class Container
Parameters:
newFocus - null-ok; the child which should assume focus or null if no child should have focus
direction - the direction the focus moved; one of View.FOCUS_UPWARD, View.FOCUS_DOWNWARD, View.FOCUS_RIGHTWARD, or View.FOCUS_LEFTWARD.
See Also:
Container.getFocusedChild()

eventKeyDown

public boolean eventKeyDown(char c,
                            Event event)
Description copied from class: View
This method is called when the user presses a key. The default implementation turns space and @ into page-down and page-up events if you have View.setAtAndSpacePage(boolean).

Overrides:
eventKeyDown in class Container

eventWidgetUp

public boolean eventWidgetUp(int widget,
                             Event event)
Description copied from class: Container
Handle the release of a device widget

Overrides:
eventWidgetUp in class Container
Parameters:
widget - the widget that went down
Returns:
whether or not the event was consumed

eventWidgetDown

public boolean eventWidgetDown(int widget,
                               Event event)
Description copied from class: Container
Handle the pressing of a device widget

Overrides:
eventWidgetDown in class Container
Parameters:
widget - the widget that went up
Returns:
whether or not the event was consumed

max

public final void max(Date inMaxDate)

Set the maximum allowable date.

By default, the editor is unbounded.


max

public final void max(Date inDate,
                      TimeZone inTimeZone)

Set the maximum allowable date.

By default, the editor is unbounded.


min

public final void min(Date inMinDate)

Set the minimum allowable date.

By default, the editor is unbounded.


min

public final void min(Date inDate,
                      TimeZone inTimeZone)

Set the minimum allowable date.

By default, the editor is unbounded.


limitToUnixEpoch

public final void limitToUnixEpoch()

Set the minimum and maximum allowable dates to fit in the Unix epoch, which has a range of 1970-2038.

By default, the editor is unbounded.


limitToDangerEpoch

public final void limitToDangerEpoch()

Set the minimum and maximum allowable dates to fit in the Danger epoch, which has a range of 2000-2068.

By default, the editor is unbounded.


enforceMinLimit

protected final void enforceMinLimit()
Deprecated. For internal use only.


enforceMaxLimit

protected final void enforceMaxLimit()
Deprecated. For internal use only.