Class DateChooserCombo

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.nebula.widgets.datechooser.AbstractCombo
org.eclipse.nebula.widgets.datechooser.DateChooserCombo
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class DateChooserCombo
extends AbstractCombo
DateChooserCombo widget. This class represents a date field editor that combines a text field and a calendar. Implementation is based on FormattedText and DateChooser.

Issues notification when the text content is modified or when a date is selected in the calendar.

Styles:
BORDER, READ_ONLY, FLAT
Events:
Modify
Selection
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static org.eclipse.swt.graphics.Image buttonImage
    Default image for the button
    protected boolean footerVisible
    Flag to set footer visible or not in the popup
    protected FormattedText formattedText
    FormattedText widget for edition of the date
    protected int gridVisible
    Flag to set grid visible or not in the popup
    protected static java.lang.String IMAGE
    Default image filename
    protected java.util.Locale locale
    Locale used for localized names and formats
    protected DateChooserTheme theme
    Calendar theme
    protected boolean weeksVisible
    Flag to set weeks numbers visible or not

    Fields inherited from class org.eclipse.nebula.widgets.datechooser.AbstractCombo

    _shell, button, createOnDrop, filter, GTK, hasFocus, listener, popup, popupContent, showButtonOnFocus, text, WIN32

    Fields inherited from class org.eclipse.swt.widgets.Control

    handle
  • Constructor Summary

    Constructors 
    Constructor Description
    DateChooserCombo​(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 addKeyListener​(org.eclipse.swt.events.KeyListener listener)
    Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in the KeyListener interface. The listener is set on the Text widget, as there is no sense to have it on the Composite.
    protected void beforeDrop()
    Called just before the popup is dropped.
    org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)
    Returns the preferred size of the receiver.
    If wHint == SWT.DEFAULT, the preferred size is computed to adjust the width to display a date in the MM/dd/yyyy format.
    protected org.eclipse.swt.widgets.Button createButtonControl​(int style)
    Creates the button widget.
    protected org.eclipse.swt.widgets.Control createPopupContent​(org.eclipse.swt.widgets.Composite parent)
    Creates the popup content.
    protected org.eclipse.swt.widgets.Text createTextControl​(int style)
    Creates the text widget.
    protected boolean doSelection()
    This method is called when a SWT.Selection is notify in the popup content, allowing to update the Text widget content.
    protected void dropDown​(boolean drop)
    Manages drop down of the popup.
    int getGridVisible()
    Returns the grid visibility status.
    java.util.Date getValue()
    Returns the current Date value of the widget.
    boolean isFooterVisible()
    Returns true if footer is visible in the popup calendar.
    boolean isGridVisible()
    Deprecated. 
    boolean isWeeksVisible()
    Returns true if weeks numbers are visible.
    void removeKeyListener​(org.eclipse.swt.events.KeyListener listener)
    Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.
    void setFooterVisible​(boolean footerVisible)
    Sets the footer of popup calendar visible or not.
    void setFormatter​(DateFormatter formatter)
    Associates a new DateFormatter to the text widget, replacing the default one.
    void setGridVisible​(boolean gridVisible)
    Deprecated. 
    void setGridVisible​(int gridVisible)
    Sets the grid visible or not.
    void setImage​(org.eclipse.swt.graphics.Image image)
    Sets a new image to display on the button, replacing the default one.
    void setLocale​(java.util.Locale locale)
    Sets the locale used both by the input mask and the calendar.
    void setTheme​(DateChooserTheme theme)
    Sets the theme to apply to the calendar popup.
    void setValue​(java.util.Date value)
    Sets a new Date value.
    void setWeeksVisible​(boolean weeksVisible)
    Sets the weeks numbers visible or not.

    Methods inherited from class org.eclipse.swt.widgets.Composite

    changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayoutDeferred, setTabList, toString

    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, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, 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

    Methods inherited from interface org.eclipse.swt.graphics.Drawable

    isAutoScalable
  • Field Details

    • IMAGE

      protected static final java.lang.String IMAGE
      Default image filename
      See Also:
      Constant Field Values
    • buttonImage

      protected static org.eclipse.swt.graphics.Image buttonImage
      Default image for the button
    • formattedText

      protected FormattedText formattedText
      FormattedText widget for edition of the date
    • footerVisible

      protected boolean footerVisible
      Flag to set footer visible or not in the popup
    • gridVisible

      protected int gridVisible
      Flag to set grid visible or not in the popup
    • weeksVisible

      protected boolean weeksVisible
      Flag to set weeks numbers visible or not
    • theme

      protected DateChooserTheme theme
      Calendar theme
    • locale

      protected java.util.Locale locale
      Locale used for localized names and formats
  • Constructor Details

    • DateChooserCombo

      public DateChooserCombo​(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 widget is initialized with a default image for the button, and a default DateFormatter.

      Parameters:
      parent - a composite control which will be the parent of the new instance (cannot be null)
      style - the style of control to construct
  • Method Details

    • addKeyListener

      public void addKeyListener​(org.eclipse.swt.events.KeyListener listener)
      Adds the listener to the collection of listeners who will be notified when keys are pressed and released on the system keyboard, by sending it one of the messages defined in the KeyListener interface. The listener is set on the Text widget, as there is no sense to have it on the Composite.
      Overrides:
      addKeyListener in class org.eclipse.swt.widgets.Control
      Parameters:
      listener - the listener which should be notified
    • beforeDrop

      protected void beforeDrop()
      Called just before the popup is dropped. The selected date of the calendar is set to the current date present in the formatted text.
      Overrides:
      beforeDrop in class AbstractCombo
      See Also:
      AbstractCombo.beforeDrop()
    • computeSize

      public org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)
      Returns the preferred size of the receiver.
      If wHint == SWT.DEFAULT, the preferred size is computed to adjust the width to display a date in the MM/dd/yyyy format. If a DateFormatter with more larger edit or display patterns is used, the width of the combo must be set programmatically.
      Overrides:
      computeSize in class org.eclipse.swt.widgets.Control
      Parameters:
      wHint - the width hint (can be SWT.DEFAULT)
      hHint - the height hint (can be SWT.DEFAULT)
      changed - true if the control's contents have changed, and false otherwise
      Returns:
      the preferred size of the control.
    • createButtonControl

      protected org.eclipse.swt.widgets.Button createButtonControl​(int style)
      Creates the button widget. The default appearance with an arrow is replaced by a button with an image.
      Overrides:
      createButtonControl in class AbstractCombo
      Parameters:
      style - button style
      Returns:
      the created Button control
      See Also:
      AbstractCombo.createButtonControl(int)
    • createPopupContent

      protected org.eclipse.swt.widgets.Control createPopupContent​(org.eclipse.swt.widgets.Composite parent)
      Creates the popup content. The content is a DateChooser.
      Specified by:
      createPopupContent in class AbstractCombo
      Parameters:
      parent - The parent Composite that will contain the control
      Returns:
      The created Control for the popup content
    • createTextControl

      protected org.eclipse.swt.widgets.Text createTextControl​(int style)
      Creates the text widget. Overrides the default implementation to create a FormattedText with the default formatter for Date values. The formatter is provided by DefaultFormatterFactory. By default a DateFormatter is returned. This can be changed by registering a new formatter for Date class.
      Overrides:
      createTextControl in class AbstractCombo
      Parameters:
      style - text style
      Returns:
      the created Text control
      See Also:
      AbstractCombo.createTextControl(int)
    • doSelection

      protected boolean doSelection()
      This method is called when a SWT.Selection is notify in the popup content, allowing to update the Text widget content.
      Specified by:
      doSelection in class AbstractCombo
      Returns:
      true if the SWT.Selection event must be propagated, else false
    • dropDown

      protected void dropDown​(boolean drop)
      Description copied from class: AbstractCombo
      Manages drop down of the popup.
      Overrides:
      dropDown in class AbstractCombo
      Parameters:
      drop - true to drop the popup, false to close
      See Also:
      AbstractCombo.dropDown(boolean)
    • getGridVisible

      public int getGridVisible()
      Returns the grid visibility status.
      Returns:
      Returns the grid visible status.
    • getValue

      public java.util.Date getValue()
      Returns the current Date value of the widget.

      Returns:
      Current value
    • isFooterVisible

      public boolean isFooterVisible()
      Returns true if footer is visible in the popup calendar.
      Returns:
      true if footer visible, else false
    • isGridVisible

      public boolean isGridVisible()
      Deprecated.
      Returns true if grid is visible in the calendar popup.
      Returns:
      Returns the grid visible status.
    • isWeeksVisible

      public boolean isWeeksVisible()
      Returns true if weeks numbers are visible.
      Returns:
      Returns the weeks numbers visible status.
    • removeKeyListener

      public void removeKeyListener​(org.eclipse.swt.events.KeyListener listener)
      Removes the listener from the collection of listeners who will be notified when keys are pressed and released on the system keyboard.
      Overrides:
      removeKeyListener in class org.eclipse.swt.widgets.Control
      Parameters:
      listener - the listener which should no longer be notified
    • setFooterVisible

      public void setFooterVisible​(boolean footerVisible)
      Sets the footer of popup calendar visible or not. The footer displays the today date. It is not visible by default.
      Parameters:
      footerVisible - true to set footer visible, else false
    • setFormatter

      public void setFormatter​(DateFormatter formatter)
      Associates a new DateFormatter to the text widget, replacing the default one.
      Parameters:
      formatter - date formatter
    • setGridVisible

      public void setGridVisible​(boolean gridVisible)
      Deprecated.
      Sets the grid visible or not in the calendar popup. By default, the grid is visible.
      Parameters:
      gridVisible - true to set grid visible, else false
    • setGridVisible

      public void setGridVisible​(int gridVisible)
      Sets the grid visible or not. By default, the grid is visible. The possible values are GRID_FULL, GRID_LINES and GRID_NONE.
      Parameters:
      gridVisible - grid visibility flag
    • setImage

      public void setImage​(org.eclipse.swt.graphics.Image image)
      Sets a new image to display on the button, replacing the default one.
      Parameters:
      image - new image
    • setLocale

      public void setLocale​(java.util.Locale locale)
      Sets the locale used both by the input mask and the calendar.
      Parameters:
      locale - locale
    • setTheme

      public void setTheme​(DateChooserTheme theme)
      Sets the theme to apply to the calendar popup.
      Parameters:
      theme - new theme (must not be null)
    • setValue

      public void setValue​(java.util.Date value)
      Sets a new Date value.
      Parameters:
      value - new date value
    • setWeeksVisible

      public void setWeeksVisible​(boolean weeksVisible)
      Sets the weeks numbers visible or not. By default, the weeks are NOT visible.
      Parameters:
      weeksVisible - true to set weeks visible, else false