Class CDateTime
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Control
-
- org.eclipse.swt.widgets.Scrollable
-
- org.eclipse.swt.widgets.Composite
-
- org.eclipse.swt.widgets.Canvas
-
- org.eclipse.nebula.cwt.base.BaseCombo
-
- org.eclipse.nebula.widgets.cdatetime.CDateTime
-
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
public class CDateTime extends BaseCombo
The CDateTime provides both textual and graphical means selecting a date.
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 private classCDateTime.EditFieldA simple class used for editing a field numerically.(package private) classCDateTime.SpinnerLayoutThe 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) intactiveFieldprivate java.util.TimeZone[]allowedTimezonesprivate static intBLOCK(package private) CDateTimeBuilderbuilder(package private) org.eclipse.swt.graphics.ColorbuttonHoverBackgroundColor(package private) org.eclipse.swt.graphics.ColorbuttonHoverBorderColor(package private) org.eclipse.swt.graphics.ColorbuttonSelectedBackgroundColor(package private) org.eclipse.swt.graphics.ColorbuttonSelectedBorderColorprivate java.util.Calendarcalendarprivate int[]calendarFieldsprivate java.util.DatecancelDateprivate booleandefaultNullTextprivate java.text.DateFormatdfprivate static intDISCARDprivate CDateTime.EditFieldeditField(package private) java.text.DateFormat.Field[]fieldprivate static intFIELD_NONE(package private) intformat(package private) booleaninternalFocusShiftprivate booleanisDateprivate booleanisTime(package private) java.util.Localelocaleprivate java.util.CalendarmaxDateprivate java.util.CalendarminDateprivate java.lang.StringnullTextprivate CDateTimePainterpainter(package private) java.lang.Stringpattern(package private) VPanelpicker(package private) org.eclipse.swt.graphics.ColorpickerActiveDayColor(package private) org.eclipse.swt.graphics.ColorpickerBackgroundColor(package private) org.eclipse.swt.graphics.FontpickerFont(package private) org.eclipse.swt.graphics.ColorpickerForegroundColor(package private) org.eclipse.swt.graphics.ColorpickerInactiveDayColor(package private) org.eclipse.swt.graphics.ColorpickerMinutesBackgroundColor(package private) org.eclipse.swt.graphics.ColorpickerMinutesColor(package private) VPanelpickerPanel(package private) org.eclipse.swt.graphics.ColorpickerTodayColor(package private) booleanrightClickprivate booleanscrollableprivate java.util.Date[]selectionprivate java.lang.String[]separatorprivate booleansingleSelection(package private) VNative<org.eclipse.swt.widgets.Spinner>spinner(package private) intstyleprivate booleantabStops(package private) org.eclipse.swt.widgets.ListenertextListenerDelegates events to their appropriate handlerprivate org.eclipse.swt.graphics.PointtextSelectionOffset(package private) java.util.TimeZonetimezoneprivate static intWRAP-
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSelectionListener(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 theSelectionListenerinterface.protected voidaddTextListener()Adds the textListener for the appropriate SWT events to handle incrementing fields.private booleancheckPicker()private booleancommitEditField()If a field is being edited (via keyboard), set the edit value to the active field of the calendar.private static intconvertStyle(int style)private voidcreatePicker()If style is neither SIMPLE or DROP_DOWN, then this method simply returns, otherwise it creates the picker.private voidcreatePickerToolbar(VPanel parent)private voiddisposePicker()(package private) voidfieldAdjust(int amount)Adds the given amount to the x² field, if there is one(package private) voidfieldFirst()(package private) voidfieldFromTextSelection()Sets the active field from the select of the text box(package private) voidfieldLast()(package private) voidfieldNext()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) voidfieldNext(boolean async)Sets the active field to the next field; wraps if necessary and sets to last field if there is no current active fieldprivate voidfieldPrev()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) voidfieldPrev(boolean async)Sets the active field to the previous field; wraps if necessary and sets to first field if there is no current active fieldprivate booleanfieldRoll(int calendarField, int rollAmount, int style)private booleanfieldSet(int calendarField, int value, int style)Sets the given calendar field to the given value.
NOTE: This is NOT the active field but a field in the "calendar" variable.(package private) voidfireSelectionChanged()Notifies listeners that the selection for this CDateTime has changed(package private) voidfireSelectionChanged(boolean defaultSelection)(package private) voidfireSelectionChanged(int field)Notifies listeners that a field of the selected date for this CDateTime has changedorg.eclipse.swt.graphics.ColorgetButtonHoverBackgroundColor()org.eclipse.swt.graphics.ColorgetButtonHoverBorderColor()org.eclipse.swt.graphics.ColorgetButtonSelectedBackgroundColor()org.eclipse.swt.graphics.ColorgetButtonSelectedBorderColor()(package private) VButtongetButtonWidget()(package private) intgetCalendarField()Gets the calendar field corresponding to the active field, if there is one.(package private) intgetCalendarField(java.text.DateFormat.Field field)(package private) java.util.CalendargetCalendarInstance()java.util.CalendargetCalendarInstance(long date)WARNING: Experimental API - this method may be removed in future versionsjava.util.CalendargetCalendarInstance(java.util.Date date)WARNING: Experimental API - this method may be removed in future versions(package private) java.util.DategetCalendarTime()(package private) longgetCalendarTimeInMillis()booleangetEditable()Returns the editable state.java.util.LocalegetLocale()The locale currently in use by this CDateTime.java.util.CalendargetMaxDate()Returns the maximum date ornull.java.util.CalendargetMinDate()Returns the minimum date ornull.java.lang.StringgetNullText()Get the text which will be shown when the selection is set to null.(package private) CDateTimePaintergetPainter()java.lang.StringgetPattern()Get the pattern of this CDateTime as used to set its format.org.eclipse.swt.graphics.ColorgetPickerActiveDayColor()org.eclipse.swt.graphics.ColorgetPickerBackgroundColor()org.eclipse.swt.graphics.FontgetPickerFont()org.eclipse.swt.graphics.ColorgetPickerForegroundColor()org.eclipse.swt.graphics.ColorgetPickerInactiveDayColor()org.eclipse.swt.graphics.ColorgetPickerMinutesBackgroundColor()org.eclipse.swt.graphics.ColorgetPickerMinutesColor()org.eclipse.swt.graphics.ColorgetPickerTodayColor()java.util.DategetSelection()Get the current selection of this CDateTime widget, or null if there is no selection.intgetStyle()java.lang.StringgetText()Returns the text of this combo(package private) VNative<org.eclipse.swt.widgets.Text>getTextWidget()java.util.TimeZonegetTimeZone()The timezone currently in use by this CDateTime.(package private) voidhandleKey(org.eclipse.swt.widgets.Event event)The Key event handler(package private) voidhandleTraverse(org.eclipse.swt.widgets.Event event)The Travers event handler.private booleanhasField(int field)Determines if the given field number is backed by a real field.booleanhasSelection()Return true if this CDateTime has one or more dates selected;private voidinit(int style)(package private) booleanisClosingField(int calendarField)Determine whether the provided field is the most precise field.(package private) booleanisSelected(java.util.Date date)(package private) booleanisSingleSelection()protected voidpostClose(org.eclipse.swt.widgets.Shell popup)called just after the content shell is set not-visible and has "closed"voidremoveSelectionListener(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 voidremoveTextListener()Removes the textListener for the appropriate SWT events to handle incrementing fields.private voidsetActiveField(int field)Sets the active field, which may or may not be a real field (it may also beFIELD_NONE)voidsetBackground(org.eclipse.swt.graphics.Color color)voidsetBuilder(CDateTimeBuilder builder)WARNING: Experimental API - this method may be removed in future versionsvoidsetButtonHoverBackgroundColor(org.eclipse.swt.graphics.Color color)voidsetButtonHoverBorderColor(org.eclipse.swt.graphics.Color color)voidsetButtonImage(org.eclipse.swt.graphics.Image image)Set the custom image for the drop down button.voidsetButtonSelectedBackgroundColor(org.eclipse.swt.graphics.Color color)voidsetButtonSelectedBorderColor(org.eclipse.swt.graphics.Color color)protected booleansetContentFocus()Called when the popup shell has been open, this method provides a location for subclasses to set the focus to the content.voidsetEditable(boolean editable)Sets the editable state.voidsetForeground(org.eclipse.swt.graphics.Color color)voidsetFormat(int format)Set the date and time format of this CDateTime uses style constants which correspond to the various forms of DateFormat.getXxxInstance(int).voidsetLocale(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 voidsetModifyEventProperties(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.voidsetNullText(java.lang.String text)Set the text to be shown when the selection is null.voidsetOpen(boolean open)Convenience method for BaseCombo:setOpen(boolean, Runnable), omitting optional runnable.voidsetOpen(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 == nullorisOpen() == openthis method simply returns.
IfcontentShell == nullthencontentShellwill be created.voidsetPainter(CDateTimePainter painter)WARNING: Experimental API - this method may be removed in future versionsvoidsetPattern(java.lang.String pattern)Set the style of this CDateTime to work with dates and / or times as determined by the given pattern.voidsetPattern(java.lang.String pattern, java.util.TimeZone[] allowedTimeZones)voidsetPickerActiveDayColor(org.eclipse.swt.graphics.Color pickerActiveDayColor)voidsetPickerBackgroundColor(org.eclipse.swt.graphics.Color pickerBackgroundColor)voidsetPickerFont(org.eclipse.swt.graphics.Font pickerFont)voidsetPickerForegroundColor(org.eclipse.swt.graphics.Color pickerForegroundColor)voidsetPickerInactiveDayColor(org.eclipse.swt.graphics.Color pickerInactiveDayColor)voidsetPickerMinutesBackgroundColor(org.eclipse.swt.graphics.Color pickerMinutesBackgroundColor)voidsetPickerMinutesColor(org.eclipse.swt.graphics.Color pickerMinutesColor)voidsetPickerTodayColor(org.eclipse.swt.graphics.Color pickerTodayColor)(package private) voidsetScrollable(boolean scrollable)voidsetSelection(java.util.Date selection)Set the selection for this CDateTime to that of the providedDateobject.voidsetTimeZone(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.voidsetTimeZone(java.util.TimeZone zone)Sets the timezone to the given timezone, or to the system's default timezone if the given timezone is null.voidshow(java.util.Date date)Shows the given date if it can be shown by the selector.voidshowSelection()Show the selection if it can be shown by the selector.java.lang.StringtoString()private booleanupdateFields()inspects all of the calendar fields in thefieldarray to determine what style is appropriate and then sets that style to the picker using the setPickerStyle method.private voidupdateNullText()private voidupdatePicker()tell the picker to update its view of the selection and reference timeprivate voidupdateText()This is the only way that text is set to the text box.
The selection of the text in the text box is also set here (the active field is selected) as well as if a field is being edited, it's "edit text" is inserted for display.private voidupdateText(boolean async)This is the only way that text is set to the text box.
The selection of the text in the text box is also set here (the active field is selected) as well as if a field is being edited, it's "edit text" is inserted for display.(package private) voidverify(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, isAutoScalable, 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
-
-
-
-
Field Detail
-
FIELD_NONE
private static final int FIELD_NONE
- See Also:
- Constant Field Values
-
DISCARD
private static final int DISCARD
- See Also:
- Constant Field Values
-
WRAP
private static final int WRAP
- See Also:
- Constant Field Values
-
BLOCK
private static final int BLOCK
- See Also:
- Constant Field Values
-
picker
VPanel picker
-
spinner
VNative<org.eclipse.swt.widgets.Spinner> spinner
-
internalFocusShift
boolean internalFocusShift
-
rightClick
boolean rightClick
-
cancelDate
private java.util.Date cancelDate
-
calendar
private java.util.Calendar calendar
-
minDate
private java.util.Calendar minDate
-
maxDate
private java.util.Calendar maxDate
-
df
private java.text.DateFormat df
-
locale
java.util.Locale locale
-
timezone
java.util.TimeZone timezone
-
field
java.text.DateFormat.Field[] field
-
activeField
int activeField
-
tabStops
private boolean tabStops
-
style
int style
-
pattern
java.lang.String pattern
-
format
int format
-
painter
private CDateTimePainter painter
-
textListener
org.eclipse.swt.widgets.Listener textListener
Delegates events to their appropriate handler
-
textSelectionOffset
private org.eclipse.swt.graphics.Point textSelectionOffset
-
editField
private CDateTime.EditField editField
-
separator
private java.lang.String[] separator
-
calendarFields
private int[] calendarFields
-
isTime
private boolean isTime
-
isDate
private boolean isDate
-
nullText
private java.lang.String nullText
-
defaultNullText
private boolean defaultNullText
-
singleSelection
private boolean singleSelection
-
selection
private java.util.Date[] selection
-
scrollable
private boolean scrollable
-
builder
CDateTimeBuilder builder
-
pickerPanel
VPanel pickerPanel
-
allowedTimezones
private java.util.TimeZone[] allowedTimezones
-
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
-
-
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
-
convertStyle
private static int convertStyle(int style)
-
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 theSelectionListenerinterface.
The event's data field will contain the newly selected Date object.widgetSelectedis called when the selection (date/time) changes.widgetDefaultSelectedis 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.
-
commitEditField
private boolean commitEditField()
If a field is being edited (via keyboard), set the edit value to the active field of the calendar. Reset the count of the EditField so that a subsequent key press will overwrite its contents;- Returns:
- true if the commit was successfull (the value was valid for the field) or there was no commit to be made (editField is null), false otherwise
-
createPicker
private void createPicker()
If style is neither SIMPLE or DROP_DOWN, then this method simply returns, otherwise it creates the picker.
-
createPickerToolbar
private void createPickerToolbar(VPanel parent)
-
disposePicker
private void disposePicker()
-
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
private void fieldPrev()
Sets the active field to the previous field; wraps if necessary and sets to first field if there is no current active field
-
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)
-
fieldRoll
private boolean fieldRoll(int calendarField, int rollAmount, int style)
-
fieldSet
private boolean fieldSet(int calendarField, int value, int style)Sets the given calendar field to the given value.
NOTE: This is NOT the active field but a field in the "calendar" variable.- Parameters:
calendarField- the field of calendar to setvalue- the value to set it tostyle- the of set to perform; if the value is valid for the given calendarField then this has no affect, otherwise it will take an action according to this style int:- DISCARD: the value will be discarded and the method returns without performing and action
- WRAP: if value is higher than its maximum it will be set to its minimum, and visa versa
- BLOCK: if value is higher than its maximum it will be set to its maximum, and visa versa
- Returns:
- true if the field was set, false otherwise (as is possible with a DISCARD style)
-
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
singleSelectionis 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 ifsetTimewas 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:BaseComboReturns the editable state.- Overrides:
getEditablein 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
-
getText
public java.lang.String getText()
Description copied from class:BaseComboReturns 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 thehandleKeymethod.- Parameters:
event- the event
-
hasField
private boolean hasField(int field)
Determines if the given field number is backed by a real field.- Parameters:
field- the field number to check- Returns:
- true if the given field number corresponds to a field in the field array
-
hasSelection
public boolean hasSelection()
Return true if this CDateTime has one or more dates selected;- Returns:
- true if a date is selected, false otherwise
-
init
private void init(int style)
-
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
Calendarclass 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:BaseCombocalled 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:
postClosein 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.
-
setActiveField
private void setActiveField(int field)
Sets the active field, which may or may not be a real field (it may also beFIELD_NONE)- Parameters:
field- the field to be set active- See Also:
hasField(int)
-
setBuilder
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.- 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:BaseComboSet 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:
setButtonImagein classBaseCombo
-
setContentFocus
protected boolean setContentFocus()
Description copied from class:BaseComboCalled when the popup shell has been open, this method provides a location for subclasses to set the focus to the content.- Specified by:
setContentFocusin classBaseCombo- Returns:
- true if the focus was set, false otherwise
-
setEditable
public void setEditable(boolean editable)
Description copied from class:BaseComboSets the editable state.- Overrides:
setEditablein classBaseCombo- Parameters:
editable- the new editable state
-
checkPicker
private boolean checkPicker()
-
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 thisCDateTimeis of styleDROP_DOWNthen the associatedCDateTimewill 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:BaseComboProvides 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:
setModifyEventPropertiesin 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:BaseComboConvenience method for BaseCombo:setOpen(boolean, Runnable), omitting optional runnable.- Overrides:
setOpenin 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:BaseComboIf '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 == nullorisOpen() == openthis method simply returns.
IfcontentShell == nullthencontentShellwill be created.- Overrides:
setOpenin 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
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.- 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_DOWNstyle 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 providedDateobject.- 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:
toStringin classorg.eclipse.swt.widgets.Widget
-
updateFields
private boolean updateFields()
inspects all of the calendar fields in thefieldarray to determine what style is appropriate and then sets that style to the picker using the setPickerStyle method.
-
updateNullText
private void updateNullText()
-
updatePicker
private void updatePicker()
tell the picker to update its view of the selection and reference time
-
updateText
private void updateText()
This is the only way that text is set to the text box.
The selection of the text in the text box is also set here (the active field is selected) as well as if a field is being edited, it's "edit text" is inserted for display. ThegetSelectionproperty of CDateTime remains unchanged.
-
updateText
private void updateText(boolean async)
This is the only way that text is set to the text box.
The selection of the text in the text box is also set here (the active field is selected) as well as if a field is being edited, it's "edit text" is inserted for display. ThegetSelectionproperty of CDateTime remains unchanged.- Parameters:
async- If true, this operation will be performed asynchronously (for changes to text selection)
-
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.editFieldwithout affecting the selection. Oncethis.editFieldreaches 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.editFieldare 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
nullif not set. - Since:
- 1.4
-
getMaxDate
public java.util.Calendar getMaxDate()
Returns the maximum date ornull.- Returns:
- Returns a clone of the maxDate or
nullif not set. - Since:
- 1.4
-
setBackground
public void setBackground(org.eclipse.swt.graphics.Color color)
- Overrides:
setBackgroundin classBaseCombo- See Also:
Control.setBackground(org.eclipse.swt.graphics.Color)
-
setForeground
public void setForeground(org.eclipse.swt.graphics.Color color)
- Overrides:
setForegroundin 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
-
-