org.eclipse.swt.nebula.widgets.cdatetime
Class CDateTime

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by org.eclipse.swt.nebula.widgets.cdatetime.AbstractCombo
                      extended by org.eclipse.swt.nebula.widgets.cdatetime.CDateTime
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class CDateTime
extends AbstractCombo

The CDateTime provides both textual and graphical means for setting the attributes of a java.util.Date class. As with other components having "combo" in their name, the base of this component is a text box which, if the DROP_DOWN style is set, is complimented by a down-arrow that will open / pop up / drop down a graphical component; for the CDateTime, the drop down component is a CDateTime (automatically set a style appropriate for date format of the text box). If the style DROP_DOWN is not set, then this combo will NOT show a drop down arrow button, but will instead show a spinner which can be used to increment / decrement the selected date field in the text box.

Styles:
BORDER, DROP_DOWN, FOOTER
Events:
Selection


Field Summary
 
Fields inherited from class org.eclipse.swt.nebula.widgets.cdatetime.AbstractCombo
carbon, gtk, win32
 
Fields inherited from class org.eclipse.swt.widgets.Composite
embeddedHandle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
handle
 
Constructor Summary
CDateTime(org.eclipse.swt.widgets.Composite parent, int style)
          Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
          Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface.
 java.util.Locale getLocale()
          The locale currently in use by this CDateTime.
 java.lang.String getPattern()
          Get the pattern of this CDateTime as used to set its format.
 java.util.Date getSelection()
          Get the java.util.Date that is currently selected by this CDateTime widget.
Note that if a field is being edited, and has not yet been committed, then this value may not represent what is displayed in the text box.
 java.lang.String getText()
           
 void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
          Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.
 void setFormat(int format)
          Set the date and time format of this CDateTime uses style constants which correspond to the various forms of DateFormat.getXxxInstance(int).
 void setLocale(java.util.Locale locale)
          Sets the Locale to be used by this CDateTime and causes all affected attributes to be updated
If the provided locale is the same as the current locale then this method simply returns.
 void setOpen(boolean open)
          If pop is true, then opens the popup shell (sets to visible)
If pop is false, closes the popup shell (sets to not visible)
If content == null this method simply returns.
If popup == null then popup will be created.
 void setPattern(java.lang.String pattern)
          Set the style of this CDateTime to work with dates and / or times as determined by the given pattern.
 void setSelection(java.util.Date date)
          Set the selection for this CDateTime to that of the provided Date object.
This method will update the text box and, if the DROP_DOWN style is set, the selection of the associated drop down CDateTime.
 
Methods inherited from class org.eclipse.swt.nebula.widgets.cdatetime.AbstractCombo
addModifyListener, addTraverseListener, getMenu, getStyle, isOpen, removeModifyListener, removeTraverseListener, setButtonVisibility, setButtonVisible, setEditable, setEnabled, setFocus, setFont, setHoldOpen, setMenu, setRedraw, setStretch
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, computeSize, getBackgroundMode, getChildren, getClientArea, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getBorderWidth, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, computeSize, forceFocus, getAccessible, getBackground, getBackgroundImage, getBounds, getCursor, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setForeground, setLayoutData, setLocation, setLocation, setParent, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, dispose, getData, getData, getDisplay, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CDateTime

public CDateTime(org.eclipse.swt.widgets.Composite parent,
                 int style)
Constructs a new instance of this class given its parent and a style value describing its behavior and appearance. The current date and the system's default locale are used.

Parameters:
parent - a widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
Method Detail

addSelectionListener

public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver's selection changes, by sending it one of the messages defined in the SelectionListener interface.

widgetSelected is called when the selection (date/time) changes. widgetDefaultSelected is when ENTER is pressed the text box.

The event's data field will contain the newly selected Date object.
The event's detail field will contain which Calendar Field was changed

Parameters:
listener - the listener which should be notified
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent

getPattern

public java.lang.String getPattern()
Get the pattern of this CDateTime as used to set its format. If the format was NOT set using setFormat(String) this will return null.

Returns:
the pattern, null if there isn't one
See Also:
SimpleDateFormat, setFormat(int), setPattern(String)

getLocale

public java.util.Locale getLocale()
The locale currently in use by this CDateTime.

Returns:
the locale
See Also:
setLocale(Locale), setLocale(Locale)

getSelection

public java.util.Date getSelection()
Get the java.util.Date that is currently selected by this CDateTime widget.
Note that if a field is being edited, and has not yet been committed, then this value may not represent what is displayed in the text box.

Returns:
the date
See Also:
setSelection(Date)

getText

public java.lang.String getText()
Overrides:
getText in class AbstractCombo

removeSelectionListener

public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver's selection changes.

Parameters:
listener - the listener which should no longer be notified
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
org.eclipse.swt.SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
SelectionListener, addSelectionListener(org.eclipse.swt.events.SelectionListener)

setFormat

public void setFormat(int format)
               throws java.lang.IllegalArgumentException
Set the date and time format of this CDateTime uses style constants which correspond to the various forms of DateFormat.getXxxInstance(int).
Valid Styles:
DATE_SHORT, DATE_MEDIUM, DATE_LONG, TIME_SHORT, TIME_MEDIUM

Styles are bitwise OR'ed together, but only one "DATE" and one "TIME" may be set at a time.

Examples:
setFormat(CDT.DATE_LONG);
setFormat(CDT.DATE_SHORT | CDT.TIME_MEDIUM);

Parameters:
format - the bitwise OR'ed Date and Time format to be set
Throws:
java.lang.IllegalArgumentException
See Also:
getPattern(), setPattern(String)

setOpen

public void setOpen(boolean open)
Description copied from class: AbstractCombo
If pop is true, then opens the popup shell (sets to visible)
If pop is false, closes the popup shell (sets to not visible)
If content == null this method simply returns.
If popup == null then popup will be created.

Overrides:
setOpen in class AbstractCombo

setPattern

public void setPattern(java.lang.String pattern)
                throws java.lang.IllegalArgumentException
Set the style of this CDateTime to work with dates and / or times as determined by the given pattern. This will set the fields shown in the text box and, if DROP_DOWN style is set, the fields of the drop down component.
This method is backed by an implementation of SimpleDateFormat, and as such, any string pattern which is valid for SimpleDateFormat may be used. Examples (US Locale):
setPattern("MM/dd/yyyy h:mm a");
setPattern("'Meeting @' h:mm a 'on' EEEE, MMM dd, yyyy");

Parameters:
pattern - the pattern to use, if it is invalid, the original is restored
Throws:
java.lang.IllegalArgumentException
See Also:
SimpleDateFormat, getPattern(), setFormat(int)

setLocale

public void setLocale(java.util.Locale locale)
Sets the Locale to be used by this CDateTime and causes all affected attributes to be updated
If the provided locale is the same as the current locale then this method simply returns. If the provided Locale is null then this CDateTime will use the system's default locale.
If this CDateTime is of style DROP_DOWN then the associated CDateTime will be set to the same locale.

Parameters:
locale - the Locale, or null to use the system's default
See Also:
getLocale()

setSelection

public void setSelection(java.util.Date date)
Set the selection for this CDateTime to that of the provided Date object.
This method will update the text box and, if the DROP_DOWN style is set, the selection of the associated drop down CDateTime.

Parameters:
date - the Date object to use for the new selection
See Also:
getSelection()