Class 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 class  CDateTime.EditField
      A simple class used for editing a field numerically.
      (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.
    • 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
      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.
      protected void addTextListener()
      Adds the textListener for the appropriate SWT events to handle incrementing fields.
      private boolean checkPicker()  
      private boolean commitEditField()
      If a field is being edited (via keyboard), set the edit value to the active field of the calendar.
      private static int convertStyle​(int style)  
      private void createPicker()
      If style is neither SIMPLE or DROP_DOWN, then this method simply returns, otherwise it creates the picker.
      private void createPickerToolbar​(VPanel parent)  
      private void disposePicker()  
      (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
      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
      (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
      private boolean fieldRoll​(int calendarField, int rollAmount, int style)  
      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.
      (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 changed
      org.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 versions
      java.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()  
      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 or null.
      java.util.Calendar getMinDate()
      Returns the minimum date or null.
      java.lang.String getNullText()
      Get the text which will be shown when the selection is set to null.
      (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.
      private boolean hasField​(int field)
      Determines if the given field number is backed by a real field.
      boolean hasSelection()
      Return true if this CDateTime has one or more dates selected;
      private void init​(int style)  
      (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.
      private void setActiveField​(int field)
      Sets the active field, which may or may not be a real field (it may also be FIELD_NONE)
      void setBackground​(org.eclipse.swt.graphics.Color color)  
      void setBuilder​(CDateTimeBuilder builder)
      WARNING: Experimental API - this method may be removed in future versions
      void 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)  
      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 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 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 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()  
      private boolean updateFields()
      inspects all of the calendar fields in the field array to determine what style is appropriate and then sets that style to the picker using the setPickerStyle method.
      private void updateNullText()  
      private void updatePicker()
      tell the picker to update its view of the selection and reference time
      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.
      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.
      (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.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
      • 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • 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
      • textListener

        org.eclipse.swt.widgets.Listener textListener
        Delegates events to their appropriate handler
      • textSelectionOffset

        private org.eclipse.swt.graphics.Point textSelectionOffset
      • 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
      • 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 the SelectionListener interface.

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

        The event's data field will contain the newly selected Date object.
        The event's detail field will contain which Calendar Field was changed
        Parameters:
        listener - the listener which should be notified
        Throws:
        java.lang.IllegalArgumentException -
        • ERROR_NULL_ARGUMENT - if the listener is null
        org.eclipse.swt.SWTException -
        • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
        • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
        See Also:
        SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent
      • 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 set
        value - the value to set it to
        style - 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 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 if setTime 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 class BaseCombo
        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 using setNullText(String)
        Returns:
        the text shown when the selection is null
        See Also:
        setNullText(String)
      • getPattern

        public java.lang.String getPattern()
        Get the pattern of this CDateTime as used to set its format. If the format was NOT set using setFormat(String) this will return null.
        Returns:
        the pattern, null if there isn't one
        See Also:
        SimpleDateFormat, setFormat(int), setPattern(String)
      • 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: BaseCombo
        Returns the text of this combo
        Overrides:
        getText in class BaseCombo
        Returns:
        the combo's text
      • getTextWidget

        VNative<org.eclipse.swt.widgets.Text> getTextWidget()
      • 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 the handleKey method.
        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
        the date picker provides the panels for selecting a day, month or year respectively. The panel should close itself and set the selection in the CDateTime field when the user selects the most precise field. The constants from the Calendar class may be used to determine the most precise field:
        • Calendar.YEAR -> 1
        • Calendar.MONTH -> 2
        • Calendar.DATE -> 5
        e.g. the highest constant is the closing field.
        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 class BaseCombo
        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 be FIELD_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: 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 class BaseCombo
      • 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 class BaseCombo
        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 class BaseCombo
        Parameters:
        editable - the new editable state
      • checkPicker

        private boolean checkPicker()
      • setFormat

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

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

        Examples:
        setFormat(CDT.DATE_LONG);
        setFormat(CDT.DATE_SHORT | CDT.TIME_MEDIUM);
        Parameters:
        format - the bitwise OR'ed Date and Time format to be set
        Throws:
        java.lang.IllegalArgumentException
        See Also:
        getPattern(), setPattern(String)
      • setLocale

        public void setLocale​(java.util.Locale locale)
        Sets the Locale to be used by this CDateTime and causes all affected attributes to be updated
        If the provided locale is the same as the current locale then this method simply returns. If the provided Locale is null then this CDateTime will use the system's default locale.
        If this CDateTime is of style DROP_DOWN then the associated CDateTime will be set to the same locale.
        Parameters:
        locale - the Locale, or null to use the system's default
        See Also:
        getLocale()
      • 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 class BaseCombo
      • 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 class BaseCombo
        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)
        If content == null or isOpen() == open this method simply returns.
        If contentShell == null then contentShell will be created.
        Overrides:
        setOpen in class BaseCombo
        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.IllegalArgumentException
        Set the style of this CDateTime to work with dates and / or times as determined by the given pattern. This will set the fields shown in the text box and, if DROP_DOWN style is set, the fields of the drop down component.
        This method is backed by an implementation of SimpleDateFormat, and as such, any string pattern which is valid for SimpleDateFormat may be used. Examples (US Locale):
        setPattern("MM/dd/yyyy h:mm a");

        setPattern("'Meeting @' h:mm a 'on' EEEE, MMM dd, yyyy");
        Parameters:
        pattern - the pattern to use, if it is invalid, the original is restored
        Throws:
        java.lang.IllegalArgumentException
        See Also:
        SimpleDateFormat, getPattern(), setFormat(int)
      • setScrollable

        void setScrollable​(boolean scrollable)
      • setSelection

        public void setSelection​(java.util.Date selection)
        Set the selection for this CDateTime to that of the provided Date 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 class org.eclipse.swt.widgets.Widget
      • updateFields

        private boolean updateFields()
        inspects all of the calendar fields in the field array 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. The getSelection property 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. The getSelection property 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 the updateText() 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 to this.editField without affecting the selection. Once this.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 of this.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 or null.
        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 or null.
        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 class BaseCombo
        See Also:
        Control.setBackground(org.eclipse.swt.graphics.Color)
      • setForeground

        public void setForeground​(org.eclipse.swt.graphics.Color color)
        Overrides:
        setForeground in class BaseCombo
        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