Class CDateTime
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class CDateTime extends BaseCombo
As with other combo type widgets, there are three basic styles:
- Text only (default)
- Graphical only (CDT.SIMPLE)
- Combo - a text selector with a drop-down graphical selector (CDT.DROP_DOWN)
Styles are set using the constants provided in the CDT class.
- Since:
- 1.5
- See Also:
CDT
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) class
CDateTime.SpinnerLayout
The layout used for a "basic" CDateTime - when it is neither of style SIMPLE or DROP_DOWN - with style of SPINNER.
Note that there is a spinner, but no button for this style.Nested classes/interfaces inherited from class org.eclipse.nebula.cwt.base.BaseCombo
BaseCombo.DropComboLayout
-
Field Summary
Fields Modifier and Type Field Description (package private) int
activeField
(package private) CDateTimeBuilder
builder
(package private) org.eclipse.swt.graphics.Color
buttonHoverBackgroundColor
(package private) org.eclipse.swt.graphics.Color
buttonHoverBorderColor
(package private) org.eclipse.swt.graphics.Color
buttonSelectedBackgroundColor
(package private) org.eclipse.swt.graphics.Color
buttonSelectedBorderColor
(package private) org.eclipse.swt.graphics.Color
cancelButtonColor
(package private) org.eclipse.swt.graphics.Font
clearButtonFont
(package private) org.eclipse.swt.graphics.Color
clearButtonForegroundColor
(package private) java.text.DateFormat.Field[]
field
(package private) int
format
(package private) boolean
internalFocusShift
(package private) java.util.Locale
locale
(package private) org.eclipse.swt.graphics.Color
okButtonColor
(package private) java.lang.String
pattern
(package private) VPanel
picker
(package private) org.eclipse.swt.graphics.Color
pickerActiveDayColor
(package private) org.eclipse.swt.graphics.Color
pickerBackgroundColor
(package private) org.eclipse.swt.graphics.Font
pickerFont
(package private) org.eclipse.swt.graphics.Color
pickerForegroundColor
(package private) org.eclipse.swt.graphics.Color
pickerInactiveDayColor
(package private) org.eclipse.swt.graphics.Color
pickerMinutesBackgroundColor
(package private) org.eclipse.swt.graphics.Color
pickerMinutesColor
(package private) VPanel
pickerPanel
(package private) org.eclipse.swt.graphics.Color
pickerTodayColor
(package private) boolean
rightClick
(package private) VNative<org.eclipse.swt.widgets.Spinner>
spinner
(package private) int
style
(package private) org.eclipse.swt.widgets.Listener
textListener
Delegates events to their appropriate handler(package private) java.util.TimeZone
timezone
Fields inherited from class org.eclipse.nebula.cwt.base.BaseCombo
button, BUTTON_ALWAYS, BUTTON_AUTO, BUTTON_NEVER, BUTTON_ONLY, carbon, content, contentShell, defaultButtonImage, gtk, leftAlign, panel, simple, text, textMarginHeight, win32
-
Constructor Summary
Constructors 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. -
Method Summary
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 theSelectionListener
interface.protected void
addTextListener()
Adds the textListener for the appropriate SWT events to handle incrementing fields.(package private) void
fieldAdjust(int amount)
Adds the given amount to the x² field, if there is one(package private) void
fieldFirst()
(package private) void
fieldFromTextSelection()
Sets the active field from the select of the text box(package private) void
fieldLast()
(package private) void
fieldNext()
Sets the active field to the next field; wraps if necessary and sets to last field if there is no current active field(package private) void
fieldNext(boolean async)
Sets the active field to the next field; wraps if necessary and sets to last field if there is no current active field(package private) void
fieldPrev(boolean async)
Sets the active field to the previous field; wraps if necessary and sets to first field if there is no current active field(package private) void
fireSelectionChanged()
Notifies listeners that the selection for this CDateTime has changed(package private) void
fireSelectionChanged(boolean defaultSelection)
(package private) void
fireSelectionChanged(int field)
Notifies listeners that a field of the selected date for this CDateTime has changedorg.eclipse.swt.graphics.Color
getButtonHoverBackgroundColor()
org.eclipse.swt.graphics.Color
getButtonHoverBorderColor()
org.eclipse.swt.graphics.Color
getButtonSelectedBackgroundColor()
org.eclipse.swt.graphics.Color
getButtonSelectedBorderColor()
(package private) VButton
getButtonWidget()
(package private) int
getCalendarField()
Gets the calendar field corresponding to the active field, if there is one.(package private) int
getCalendarField(java.text.DateFormat.Field field)
(package private) java.util.Calendar
getCalendarInstance()
java.util.Calendar
getCalendarInstance(long date)
WARNING: Experimental API - this method may be removed in future versionsjava.util.Calendar
getCalendarInstance(java.util.Date date)
WARNING: Experimental API - this method may be removed in future versions(package private) java.util.Date
getCalendarTime()
(package private) long
getCalendarTimeInMillis()
org.eclipse.swt.graphics.Color
getCancelButtonColor()
org.eclipse.swt.graphics.Font
getClearButtonFont()
org.eclipse.swt.graphics.Color
getClearButtonForegroundColor()
boolean
getEditable()
Returns the editable state.java.util.Locale
getLocale()
The locale currently in use by this CDateTime.java.util.Calendar
getMaxDate()
Returns the maximum date ornull
.java.util.Calendar
getMinDate()
Returns the minimum date ornull
.java.lang.String
getNullText()
Get the text which will be shown when the selection is set to null.org.eclipse.swt.graphics.Color
getOkButtonColor()
(package private) CDateTimePainter
getPainter()
java.lang.String
getPattern()
Get the pattern of this CDateTime as used to set its format.org.eclipse.swt.graphics.Color
getPickerActiveDayColor()
org.eclipse.swt.graphics.Color
getPickerBackgroundColor()
org.eclipse.swt.graphics.Font
getPickerFont()
org.eclipse.swt.graphics.Color
getPickerForegroundColor()
org.eclipse.swt.graphics.Color
getPickerInactiveDayColor()
org.eclipse.swt.graphics.Color
getPickerMinutesBackgroundColor()
org.eclipse.swt.graphics.Color
getPickerMinutesColor()
org.eclipse.swt.graphics.Color
getPickerTodayColor()
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(package private) VNative<org.eclipse.swt.widgets.Text>
getTextWidget()
java.util.TimeZone
getTimeZone()
The timezone currently in use by this CDateTime.(package private) void
handleKey(org.eclipse.swt.widgets.Event event)
The Key event handler(package private) void
handleTraverse(org.eclipse.swt.widgets.Event event)
The Travers event handler.boolean
hasSelection()
Return true if this CDateTime has one or more dates selected;(package private) boolean
isClosingField(int calendarField)
Determine whether the provided field is the most precise field.(package private) boolean
isSelected(java.util.Date date)
(package private) boolean
isSingleSelection()
protected void
postClose(org.eclipse.swt.widgets.Shell popup)
called just after the content shell is set not-visible and has "closed"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.protected void
removeTextListener()
Removes the textListener for the appropriate SWT events to handle incrementing fields.void
setBackground(org.eclipse.swt.graphics.Color color)
void
setBuilder(CDateTimeBuilder builder)
WARNING: Experimental API - this method may be removed in future versionsvoid
setButtonHoverBackgroundColor(org.eclipse.swt.graphics.Color color)
void
setButtonHoverBorderColor(org.eclipse.swt.graphics.Color color)
void
setButtonImage(org.eclipse.swt.graphics.Image image)
Set the custom image for the drop down button.void
setButtonSelectedBackgroundColor(org.eclipse.swt.graphics.Color color)
void
setButtonSelectedBorderColor(org.eclipse.swt.graphics.Color color)
void
setCancelButtonColor(org.eclipse.swt.graphics.Color cancelButtonColor)
void
setClearButtonFont(org.eclipse.swt.graphics.Font clearButtonFont)
void
setClearButtonForegroundColor(org.eclipse.swt.graphics.Color clearButtonForegroundColor)
protected boolean
setContentFocus()
Called when the popup shell has been open, this method provides a location for subclasses to set the focus to the content.void
setEditable(boolean editable)
Sets the editable state.void
setForeground(org.eclipse.swt.graphics.Color color)
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.protected void
setModifyEventProperties(org.eclipse.swt.widgets.Event e)
Provides a chance for subclasses to set the properties of the modify event called when the text is modified.void
setNullText(java.lang.String text)
Set the text to be shown when the selection is null.void
setOkButtonColor(org.eclipse.swt.graphics.Color okButtonColor)
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)
Ifcontent == null
orisOpen() == open
this method simply returns.
IfcontentShell == null
thencontentShell
will be created.void
setPainter(CDateTimePainter painter)
WARNING: Experimental API - this method may be removed in future versionsvoid
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
setPickerActiveDayColor(org.eclipse.swt.graphics.Color pickerActiveDayColor)
void
setPickerBackgroundColor(org.eclipse.swt.graphics.Color pickerBackgroundColor)
void
setPickerFont(org.eclipse.swt.graphics.Font pickerFont)
void
setPickerForegroundColor(org.eclipse.swt.graphics.Color pickerForegroundColor)
void
setPickerInactiveDayColor(org.eclipse.swt.graphics.Color pickerInactiveDayColor)
void
setPickerMinutesBackgroundColor(org.eclipse.swt.graphics.Color pickerMinutesBackgroundColor)
void
setPickerMinutesColor(org.eclipse.swt.graphics.Color pickerMinutesColor)
void
setPickerTodayColor(org.eclipse.swt.graphics.Color pickerTodayColor)
(package private) void
setScrollable(boolean scrollable)
void
setSelection(java.util.Date selection)
Set the selection for this CDateTime to that of the providedDate
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()
(package private) void
verify(org.eclipse.swt.widgets.Event e)
The Verify Event handler.
EVERYTHING is blocked via this handler (Event.doit is set to false).Methods inherited from class org.eclipse.nebula.cwt.base.BaseCombo
addKeyListener, addModifyListener, addTraverseListener, checkButton, checkContent, checkContentShell, checkText, containsControl, doSetButtonImage, getContent, getContentShell, getEnabled, getHoldOpen, getMenu, getStretchControl, isDropDown, isOpen, isRTL, isSimple, postOpen, preClose, preOpen, removeKeyListener, removeModifyListener, removeTraverseListener, setButtonAlignment, setButtonText, setButtonVisibility, setButtonVisible, setContent, setEnabled, setFocus, setFont, setHoldOpen, setMenu, setPositionControl, setStretch, setToolTipText
Methods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setIME
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, 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, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData
-
Field Details
-
picker
VPanel picker -
spinner
VNative<org.eclipse.swt.widgets.Spinner> spinner -
internalFocusShift
boolean internalFocusShift -
rightClick
boolean rightClick -
locale
java.util.Locale locale -
timezone
java.util.TimeZone timezone -
field
java.text.DateFormat.Field[] field -
activeField
int activeField -
style
int style -
pattern
java.lang.String pattern -
format
int format -
textListener
org.eclipse.swt.widgets.Listener textListenerDelegates events to their appropriate handler -
builder
CDateTimeBuilder builder -
pickerPanel
VPanel pickerPanel -
buttonHoverBackgroundColor
org.eclipse.swt.graphics.Color buttonHoverBackgroundColor -
buttonHoverBorderColor
org.eclipse.swt.graphics.Color buttonHoverBorderColor -
buttonSelectedBackgroundColor
org.eclipse.swt.graphics.Color buttonSelectedBackgroundColor -
buttonSelectedBorderColor
org.eclipse.swt.graphics.Color buttonSelectedBorderColor -
pickerForegroundColor
org.eclipse.swt.graphics.Color pickerForegroundColor -
pickerBackgroundColor
org.eclipse.swt.graphics.Color pickerBackgroundColor -
pickerFont
org.eclipse.swt.graphics.Font pickerFont -
pickerActiveDayColor
org.eclipse.swt.graphics.Color pickerActiveDayColor -
pickerInactiveDayColor
org.eclipse.swt.graphics.Color pickerInactiveDayColor -
pickerTodayColor
org.eclipse.swt.graphics.Color pickerTodayColor -
pickerMinutesColor
org.eclipse.swt.graphics.Color pickerMinutesColor -
pickerMinutesBackgroundColor
org.eclipse.swt.graphics.Color pickerMinutesBackgroundColor -
okButtonColor
org.eclipse.swt.graphics.Color okButtonColor -
cancelButtonColor
org.eclipse.swt.graphics.Color cancelButtonColor -
clearButtonForegroundColor
org.eclipse.swt.graphics.Color clearButtonForegroundColor -
clearButtonFont
org.eclipse.swt.graphics.Font clearButtonFont
-
-
Constructor Details
-
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 Details
-
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 theSelectionListener
interface.widgetSelected
is called when the selection (date/time) changes.widgetDefaultSelected
is when ENTER is pressed the text box.
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
-
addTextListener
protected void addTextListener()Adds the textListener for the appropriate SWT events to handle incrementing fields. -
fieldAdjust
void fieldAdjust(int amount)Adds the given amount to the x² field, if there is one -
fieldFirst
void fieldFirst() -
fieldFromTextSelection
void fieldFromTextSelection()Sets the active field from the select of the text box -
fieldLast
void fieldLast() -
fieldNext
void fieldNext()Sets the active field to the next field; wraps if necessary and sets to last field if there is no current active field -
fieldNext
void fieldNext(boolean async)Sets the active field to the next field; wraps if necessary and sets to last field if there is no current active field- Parameters:
If
- true, the text update will be asynchronous (for changes to text selection)
-
fieldPrev
void fieldPrev(boolean async)Sets the active field to the previous field; wraps if necessary and sets to first field if there is no current active field- Parameters:
If
- true, the text update will be asynchronous (for changes to text selection)
-
fireSelectionChanged
void fireSelectionChanged()Notifies listeners that the selection for this CDateTime has changed
This will fire both a regular selection event, and a default selection event.
The data field is populated by
#getSelectedDates()
. -
fireSelectionChanged
void fireSelectionChanged(boolean defaultSelection) -
fireSelectionChanged
void fireSelectionChanged(int field)Notifies listeners that a field of the selected date for this CDateTime has changed
Note that this is only valid when
singleSelection
is true, and will only fire a regular selection event (not a default selection event)The data field is populated by
getSelection()
and the detail field holds the field which was changed.- Parameters:
field
- the Calendar Field which caused the change, or -1 ifsetTime
was called (thus setting all Calendar Fields)
-
getButtonWidget
VButton getButtonWidget() -
getCalendarField
int getCalendarField()Gets the calendar field corresponding to the active field, if there is one.- Returns:
- an int representing the calendar field, -1 if there isn't one.
-
getCalendarField
int getCalendarField(java.text.DateFormat.Field field) -
getCalendarInstance
java.util.Calendar getCalendarInstance() -
getCalendarInstance
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.- Parameters:
date
- the date that the Calendar will be set to, or null for the current system time- Returns:
- a new instance of Calendar
-
getCalendarInstance
public 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.- Parameters:
date
- the date, in millis, that the Calendar will be set to- Returns:
- a new instance of Calendar
-
getCalendarTime
java.util.Date getCalendarTime() -
getCalendarTimeInMillis
long getCalendarTimeInMillis() -
getEditable
public boolean getEditable()Description copied from class:BaseCombo
Returns the editable state.- Overrides:
getEditable
in classBaseCombo
- Returns:
- whether or not the receiver is editable
-
getLocale
public java.util.Locale getLocale()The locale currently in use by this CDateTime.- Returns:
- the locale
- See Also:
setLocale(Locale)
-
getNullText
public java.lang.String getNullText()Get the text which will be shown when the selection is set to null. Note that this will be equal to the default null text for the given locale unless the null text has been explicitly set usingsetNullText(String)
- Returns:
- the text shown when the selection is null
- See Also:
setNullText(String)
-
getPainter
CDateTimePainter getPainter() -
getPattern
public java.lang.String getPattern()Get the pattern of this CDateTime as used to set its format. If the format was NOT set usingsetFormat(String)
this will returnnull
.- Returns:
- the pattern, null if there isn't one
- See Also:
SimpleDateFormat
,setFormat(int)
,setPattern(String)
-
getSelection
public java.util.Date getSelection()Get the current selection of this CDateTime widget, or null if there is no selection.- Returns:
- the current selection
-
getStyle
public int getStyle() -
getText
public java.lang.String getText()Description copied from class:BaseCombo
Returns the text of this combo -
getTextWidget
VNative<org.eclipse.swt.widgets.Text> getTextWidget() -
getTimeZone
public java.util.TimeZone getTimeZone()The timezone currently in use by this CDateTime.- Returns:
- the timezone
- See Also:
setTimeZone(String)
,setTimeZone(TimeZone)
-
handleKey
void handleKey(org.eclipse.swt.widgets.Event event)The Key event handler- Parameters:
event
- the event
-
handleTraverse
void handleTraverse(org.eclipse.swt.widgets.Event event)The Travers event handler. Note that ARROW_UP and ARROW_DOWN are handled in thehandleKey
method.- Parameters:
event
- the event
-
hasSelection
public boolean hasSelection()Return true if this CDateTime has one or more dates selected;- Returns:
- true if a date is selected, false otherwise
-
isSelected
boolean isSelected(java.util.Date date) -
isSingleSelection
boolean isSingleSelection() -
isClosingField
boolean isClosingField(int calendarField)Determine whether the provided field is the most precise field. According to the used pattern, e.g.- dd.mm.yyyy
- MMMM yyyy
- yyyy
Calendar
class may be used to determine the most precise field:Calendar.YEAR
-> 1Calendar.MONTH
-> 2Calendar.DATE
-> 5
- Parameters:
calendarField
- The calendar field identifying a pattern field- Returns:
- true if the highest pattern field
-
postClose
protected void postClose(org.eclipse.swt.widgets.Shell popup)Description copied from class:BaseCombo
called just after the content shell is set not-visible and has "closed"override if you want to do something with the shell just after becoming not visible
- Overrides:
postClose
in classBaseCombo
- See Also:
BaseCombo.preClose(Shell)
-
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)
-
removeTextListener
protected void removeTextListener()Removes the textListener for the appropriate SWT events to handle incrementing fields. -
setBuilder
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.- Parameters:
builder
- the builder to use, or null to use a default builder
-
setButtonImage
public void setButtonImage(org.eclipse.swt.graphics.Image image)Description copied from class:BaseCombo
Set the custom image for the drop down button. Only valid if style is DROP_DOWN. Passing null in will set the image to its default value.- Overrides:
setButtonImage
in classBaseCombo
-
setContentFocus
protected boolean setContentFocus()Description copied from class:BaseCombo
Called when the popup shell has been open, this method provides a location for subclasses to set the focus to the content.- Specified by:
setContentFocus
in classBaseCombo
- Returns:
- true if the focus was set, false otherwise
-
setEditable
public void setEditable(boolean editable)Description copied from class:BaseCombo
Sets the editable state.- Overrides:
setEditable
in classBaseCombo
- Parameters:
editable
- the new editable state
-
setFormat
public void setFormat(int format) throws java.lang.IllegalArgumentExceptionSet 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)
-
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 thisCDateTime
is of styleDROP_DOWN
then the associatedCDateTime
will be set to the same locale.- Parameters:
locale
- the Locale, or null to use the system's default- See Also:
getLocale()
-
setModifyEventProperties
protected void setModifyEventProperties(org.eclipse.swt.widgets.Event e)Description copied from class:BaseCombo
Provides a chance for subclasses to set the properties of the modify event called when the text is modified. Not valid if style is SIMPLE.For example, CDateTime overrides this method to set the data field to the current time:
e.data = calendar.getTime();
- Overrides:
setModifyEventProperties
in classBaseCombo
-
setNullText
public void setNullText(java.lang.String text)Set the text to be shown when the selection is null. Passing null into this method will cause the CDateTime widget to use a default null text for the given locale.- Parameters:
text
-
-
setOpen
public void setOpen(boolean open)Description copied from class:BaseCombo
Convenience method for BaseCombo:setOpen(boolean, Runnable), omitting optional runnable.- Overrides:
setOpen
in classBaseCombo
- Parameters:
open
- true to open the popup (date/time picker) shell, false to close it.
- See Also:
BaseCombo.setOpen(boolean, Runnable)
-
setOpen
public void setOpen(boolean open, java.lang.Runnable callback)Description copied from class:BaseCombo
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)
Ifcontent == null
orisOpen() == open
this method simply returns.
IfcontentShell == null
thencontentShell
will be created.- Overrides:
setOpen
in classBaseCombo
- Parameters:
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.
- See Also:
BaseCombo.setOpen(boolean)
-
setPainter
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.- Parameters:
painter
- the painter to use, or null to use a default painter
-
setPattern
public void setPattern(java.lang.String pattern) throws java.lang.IllegalArgumentExceptionSet 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, ifDROP_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)
-
setScrollable
void setScrollable(boolean scrollable) -
setSelection
public void setSelection(java.util.Date selection)Set the selection for this CDateTime to that of the providedDate
object.- Parameters:
selection
- the new selection, or null to clear the selection
-
setTimeZone
public 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. If the give zoneID cannot be understood, then the timezone will be set to GMT.- Parameters:
zoneID
- the id of the timezone to use, or null to use the system default- See Also:
setTimeZone(TimeZone)
-
setTimeZone
public 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.- Parameters:
zone
- the timezone to use, or null to use the system default- See Also:
setTimeZone(String)
-
show
public void show(java.util.Date date)Shows the given date if it can be shown by the selector. In other words, for graphical selectors such as a calendar, the visible range of time is moved so that the given date is visible.- Parameters:
date
- the date to show
-
showSelection
public void showSelection()Show the selection if it can be shown by the selector. Has no affect if there is no selection.- See Also:
show(Date)
-
toString
public java.lang.String toString()- Overrides:
toString
in classorg.eclipse.swt.widgets.Composite
-
verify
void verify(org.eclipse.swt.widgets.Event e)The Verify Event handler.
EVERYTHING is blocked via this handler (Event.doit is set to false). Depending upon the input, a course of action is determined and the displayed text is updated via theupdateText()
method.
This method implements the following logic: If the event is a paste, the pasted text is parsed for the entire date/time selection; if this parse is successful, the result is committed to the selection property and is displayed; otherwise, it is discarded. One-character pastes are discarded without parsing. When user types characters one by one, all non-digits are discarded (if they have effects, they have already been processed by other event handlers) while digits are added tothis.editField
without affecting the selection. Oncethis.editField
reaches its capacity for the active field, its contents are attempted to be committed. If the commit is successful, focus switches to the next field of CDateTime. Otherwise, the contents ofthis.editField
are discarded and the previous value of the selection (before user started typing in this field) is restored; focus stays in the same field. Example: if the seconds field contains "23", and user types 8 in the seconds field, "08" is shown on screen while getSelection still returns 23. If user types 9 after that, the field reaches its capacity, the attempt to commit 89 seconds fails, and 23 gets restored on screen.- Parameters:
e
- the event- See Also:
updateText()
-
setPattern
public void setPattern(java.lang.String pattern, java.util.TimeZone[] allowedTimeZones) throws java.lang.IllegalArgumentException- Parameters:
pattern
-allowedTimeZones
-- Throws:
java.lang.IllegalArgumentException
-
getMinDate
public java.util.Calendar getMinDate()Returns the minimum date ornull
.- Returns:
- Returns a clone of the minDate or
null
if not set. - Since:
- 1.4
-
getMaxDate
public java.util.Calendar getMaxDate()Returns the maximum date ornull
.- Returns:
- Returns a clone of the maxDate or
null
if not set. - Since:
- 1.4
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color)- Overrides:
setBackground
in classBaseCombo
- See Also:
Control.setBackground(org.eclipse.swt.graphics.Color)
-
setForeground
public void setForeground(org.eclipse.swt.graphics.Color color)- Overrides:
setForeground
in classBaseCombo
- See Also:
Control.setForeground(org.eclipse.swt.graphics.Color)
-
setButtonHoverBackgroundColor
public void setButtonHoverBackgroundColor(org.eclipse.swt.graphics.Color color)- Parameters:
color
-- Since:
- 1.5
-
setButtonHoverBorderColor
public void setButtonHoverBorderColor(org.eclipse.swt.graphics.Color color)- Parameters:
color
-- Since:
- 1.5
-
setButtonSelectedBackgroundColor
public void setButtonSelectedBackgroundColor(org.eclipse.swt.graphics.Color color)- Parameters:
color
-- Since:
- 1.5
-
setButtonSelectedBorderColor
public void setButtonSelectedBorderColor(org.eclipse.swt.graphics.Color color)- Parameters:
color
-- Since:
- 1.5
-
getPickerForegroundColor
public org.eclipse.swt.graphics.Color getPickerForegroundColor()- Returns:
- the picker foreground color
- Since:
- 1.5
-
setPickerForegroundColor
public void setPickerForegroundColor(org.eclipse.swt.graphics.Color pickerForegroundColor)- Parameters:
pickerForegroundColor
-- Since:
- 1.5
-
getPickerBackgroundColor
public org.eclipse.swt.graphics.Color getPickerBackgroundColor()- Returns:
- the picker background color
- Since:
- 1.5
-
setPickerBackgroundColor
public void setPickerBackgroundColor(org.eclipse.swt.graphics.Color pickerBackgroundColor)- Parameters:
pickerBackgroundColor
-- Since:
- 1.5
-
getPickerFont
public org.eclipse.swt.graphics.Font getPickerFont()- Returns:
- the picker font
- Since:
- 1.5
-
setPickerFont
public void setPickerFont(org.eclipse.swt.graphics.Font pickerFont)- Parameters:
pickerFont
-- Since:
- 1.5
-
getButtonHoverBackgroundColor
public org.eclipse.swt.graphics.Color getButtonHoverBackgroundColor()- Returns:
- the bg color of the button hover
- Since:
- 1.5
-
getButtonHoverBorderColor
public org.eclipse.swt.graphics.Color getButtonHoverBorderColor()- Returns:
- the border color of the button hover
- Since:
- 1.5
-
getButtonSelectedBackgroundColor
public org.eclipse.swt.graphics.Color getButtonSelectedBackgroundColor()- Returns:
- the selected background of the button
- Since:
- 1.5
-
getButtonSelectedBorderColor
public org.eclipse.swt.graphics.Color getButtonSelectedBorderColor()- Returns:
- the border color of the selected button
- Since:
- 1.5
-
getPickerActiveDayColor
public org.eclipse.swt.graphics.Color getPickerActiveDayColor()- Returns:
- the color of the active day
- Since:
- 1.5
-
setPickerActiveDayColor
public void setPickerActiveDayColor(org.eclipse.swt.graphics.Color pickerActiveDayColor)- Parameters:
pickerActiveDayColor
-- Since:
- 1.5
-
getPickerInactiveDayColor
public org.eclipse.swt.graphics.Color getPickerInactiveDayColor()- Returns:
- the color of the inactive day
- Since:
- 1.5
-
setPickerInactiveDayColor
public void setPickerInactiveDayColor(org.eclipse.swt.graphics.Color pickerInactiveDayColor)- Parameters:
pickerInactiveDayColor
-- Since:
- 1.5
-
getPickerTodayColor
public org.eclipse.swt.graphics.Color getPickerTodayColor()- Returns:
- the color of the "today" section
- Since:
- 1.5
-
setPickerTodayColor
public void setPickerTodayColor(org.eclipse.swt.graphics.Color pickerTodayColor)- Parameters:
pickerTodayColor
-- Since:
- 1.5
-
getPickerMinutesColor
public org.eclipse.swt.graphics.Color getPickerMinutesColor()- Returns:
- the color of the minutes
- Since:
- 1.5
-
setPickerMinutesColor
public void setPickerMinutesColor(org.eclipse.swt.graphics.Color pickerMinutesColor)- Parameters:
pickerMinutesColor
-- Since:
- 1.5
-
getPickerMinutesBackgroundColor
public org.eclipse.swt.graphics.Color getPickerMinutesBackgroundColor()- Returns:
- the minutes background
- Since:
- 1.5
-
setPickerMinutesBackgroundColor
public void setPickerMinutesBackgroundColor(org.eclipse.swt.graphics.Color pickerMinutesBackgroundColor)- Parameters:
pickerMinutesBackgroundColor
-- Since:
- 1.5
-
getOkButtonColor
public org.eclipse.swt.graphics.Color getOkButtonColor()- Returns:
- the foreground color of the "Ok" button
-
setOkButtonColor
public void setOkButtonColor(org.eclipse.swt.graphics.Color okButtonColor)- Parameters:
okButtonColor
- the new foreground color of the "ok" button
-
getCancelButtonColor
public org.eclipse.swt.graphics.Color getCancelButtonColor()- Returns:
- the foreground color of the "Cancel" button
-
setCancelButtonColor
public void setCancelButtonColor(org.eclipse.swt.graphics.Color cancelButtonColor)- Parameters:
cancelButtonColor
- the new foreground color of the "cancel" button
-
getClearButtonForegroundColor
public org.eclipse.swt.graphics.Color getClearButtonForegroundColor()- Returns:
- the foreground color of the "clear" button
-
setClearButtonForegroundColor
public void setClearButtonForegroundColor(org.eclipse.swt.graphics.Color clearButtonForegroundColor)- Parameters:
clearButtonForegroundColor
- the new foreground color of the "clear" button
-
getClearButtonFont
public org.eclipse.swt.graphics.Font getClearButtonFont()- Returns:
- the font of the "clear" button
-
setClearButtonFont
public void setClearButtonFont(org.eclipse.swt.graphics.Font clearButtonFont)- Parameters:
clearButtonFont
- the new font of the "clear" button
-