public class CDateTime extends BaseCombo
Styles are set using the constants provided in the CDT class.
CDT
Constructor | Description |
---|---|
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.
|
Modifier and Type | Method | Description |
---|---|---|
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.Calendar |
getCalendarInstance(long date) |
WARNING: Experimental API - this method may be removed in future
versions
|
java.util.Calendar |
getCalendarInstance(java.util.Date date) |
WARNING: Experimental API - this method may be removed in future
versions
|
boolean |
getEditable() |
Returns the editable state.
|
java.util.Locale |
getLocale() |
The locale currently in use by this CDateTime.
|
java.lang.String |
getNullText() |
Get the text which will be shown when the selection is set to null.
|
java.lang.String |
getPattern() |
Get the pattern of this CDateTime as used to set its format.
|
java.util.Date |
getSelection() |
Get the current selection of this CDateTime widget, or null if there is
no selection.
|
int |
getStyle() |
|
java.lang.String |
getText() |
Returns the text of this combo
|
java.util.TimeZone |
getTimeZone() |
The timezone currently in use by this CDateTime.
|
boolean |
hasSelection() |
Return true if this CDateTime has one or more dates selected;
|
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 |
setBuilder(CDateTimeBuilder builder) |
WARNING: Experimental API - this method may be removed in future
versions
|
void |
setButtonImage(org.eclipse.swt.graphics.Image image) |
Set the custom image for the drop down button.
|
void |
setEditable(boolean editable) |
Sets the editable state.
|
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 |
setNullText(java.lang.String text) |
Set the text to be shown when the selection is null.
|
void |
setOpen(boolean open) |
Convenience method for BaseCombo:setOpen(boolean, Runnable), omitting optional runnable.
|
void |
setOpen(boolean open,
java.lang.Runnable callback) |
If 'open' is true, then open the popup shell (time/date picker) (set to visible)
If 'open' is false, close the popup shell (set to not visible) If content == null or isOpen() == open this
method simply returns.If contentShell == null then contentShell will be created. |
void |
setPainter(CDateTimePainter painter) |
WARNING: Experimental API - this method may be removed in future
versions
|
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 |
setPattern(java.lang.String pattern,
java.util.TimeZone[] allowedTimeZones) |
|
void |
setSelection(java.util.Date selection) |
Set the selection for this CDateTime to that of the provided
Date object. |
void |
setTimeZone(java.lang.String zoneID) |
Sets the timezone to the timezone specified by the given zoneID, or to
the system default if the given zoneID is null.
|
void |
setTimeZone(java.util.TimeZone zone) |
Sets the timezone to the given timezone, or to the system's default
timezone if the given timezone is null.
|
void |
show(java.util.Date date) |
Shows the given date if it can be shown by the selector.
|
void |
showSelection() |
Show the selection if it can be shown by the selector.
|
java.lang.String |
toString() |
getEnabled, getMenu, isOpen, setEnabled, setFocus, setFont, setMenu, setToolTipText
drawBackground, getCaret, getIME, scroll, setCaret, setIME
changed, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getFont, getForeground, getLayoutData, getLocation, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setForeground, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
public CDateTime(org.eclipse.swt.widgets.Composite parent, int style)
parent
- a widget which will be the parent of the new instance (cannot
be null)style
- the style of widget to constructpublic void addSelectionListener(org.eclipse.swt.events.SelectionListener listener)
SelectionListener
interface.
widgetSelected
is called when the selection (date/time)
changes. widgetDefaultSelected
is when ENTER is pressed the
text box.
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- SelectionListener
,
removeSelectionListener(org.eclipse.swt.events.SelectionListener)
,
SelectionEvent
public java.util.Calendar getCalendarInstance(java.util.Date date)
WARNING: Experimental API - this method may be removed in future versions
Get a new instance of Calendar that is initialized with the timezone and locale of this CDateTime, and set to the given date.date
- the date that the Calendar will be set to, or null for the
current system timepublic java.util.Calendar getCalendarInstance(long date)
WARNING: Experimental API - this method may be removed in future versions
Get a new instance of Calendar that is initialized with the timezone and locale of this CDateTime, and set to the given date.date
- the date, in millis, that the Calendar will be set topublic boolean getEditable()
BaseCombo
getEditable
in class BaseCombo
public java.util.Locale getLocale()
setLocale(Locale)
public java.lang.String getNullText()
setNullText(String)
setNullText(String)
public java.lang.String getPattern()
setFormat(String)
this will return
null
.SimpleDateFormat
,
setFormat(int)
,
setPattern(String)
public java.util.Date getSelection()
public java.lang.String getText()
BaseCombo
public java.util.TimeZone getTimeZone()
setTimeZone(String)
,
setTimeZone(TimeZone)
public boolean hasSelection()
public void removeSelectionListener(org.eclipse.swt.events.SelectionListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- SelectionListener
,
addSelectionListener(org.eclipse.swt.events.SelectionListener)
public void setBuilder(CDateTimeBuilder builder)
WARNING: Experimental API - this method may be removed in future versions
Sets the builder that this CDateTime widget will use to build its graphical selector to the given builder, or to a default builder if the given builder is null.builder
- the builder to use, or null to use a default builderpublic void setButtonImage(org.eclipse.swt.graphics.Image image)
BaseCombo
public void setEditable(boolean editable)
BaseCombo
setEditable
in class BaseCombo
editable
- the new editable statepublic void setFormat(int format) throws java.lang.IllegalArgumentException
Styles are bitwise OR'ed together, but only one "DATE" and one "TIME" may be set at a time.
Examples:format
- the bitwise OR'ed Date and Time format to be setjava.lang.IllegalArgumentException
getPattern()
,
setPattern(String)
public void setLocale(java.util.Locale locale)
CDateTime
is of style DROP_DOWN
then
the associated CDateTime
will be set to the same locale.locale
- the Locale, or null to use the system's defaultgetLocale()
public void setNullText(java.lang.String text)
text
- public void setOpen(boolean open)
BaseCombo
open
- true to open the popup (date/time picker) shell, false to close it.
BaseCombo.setOpen(boolean, Runnable)
public void setOpen(boolean open, java.lang.Runnable callback)
BaseCombo
content == null
or isOpen() == open
this
method simply returns.contentShell == null
then contentShell
will be created.open
- true to open the popup (date/time picker) shell, false to close it.callback
- an optional runnable to be run when the operation completes.
BaseCombo.setOpen(boolean)
public void setPainter(CDateTimePainter painter)
WARNING: Experimental API - this method may be removed in future versions
Sets the painter that this CDateTime widget will use to paint its graphical selector to the given painter, or to a default painter if the given painter is null.painter
- the painter to use, or null to use a default painterpublic void setPattern(java.lang.String pattern) throws java.lang.IllegalArgumentException
DROP_DOWN
style is set, the fields of the
drop down component.pattern
- the pattern to use, if it is invalid, the original is restoredjava.lang.IllegalArgumentException
SimpleDateFormat
,
getPattern()
,
setFormat(int)
public void setSelection(java.util.Date selection)
Date
object.selection
- the new selection, or null to clear the selectionpublic void setTimeZone(java.lang.String zoneID)
zoneID
- the id of the timezone to use, or null to use the system
defaultsetTimeZone(TimeZone)
public void setTimeZone(java.util.TimeZone zone)
zone
- the timezone to use, or null to use the system defaultsetTimeZone(String)
public void show(java.util.Date date)
date
- the date to showpublic void showSelection()
show(Date)
public java.lang.String toString()
toString
in class org.eclipse.swt.widgets.Widget
public void setPattern(java.lang.String pattern, java.util.TimeZone[] allowedTimeZones) throws java.lang.IllegalArgumentException
pattern
- allowedTimeZones
- java.lang.IllegalArgumentException