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 buttonprotected boolean
footerVisible
Flag to set footer visible or not in the popupprotected FormattedText
formattedText
FormattedText widget for edition of the dateprotected int
gridVisible
Flag to set grid visible or not in the popupprotected static java.lang.String
IMAGE
Default image filenameprotected java.util.Locale
locale
Locale used for localized names and formatsprotected DateChooserTheme
theme
Calendar themeprotected boolean
weeksVisible
Flag to set weeks numbers visible or notFields inherited from class org.eclipse.nebula.widgets.datechooser.AbstractCombo
_shell, button, createOnDrop, filter, GTK, hasFocus, listener, popup, popupContent, showButtonOnFocus, text, WIN32
-
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 currentDate
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 newDateFormatter
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 newDate
value.void
setWeeksVisible(boolean weeksVisible)
Sets the weeks numbers visible or not.Methods inherited from class org.eclipse.nebula.widgets.datechooser.AbstractCombo
addModifyListener, addSelectionListener, addVerifyListener, buttonEvent, checkStyle, comboEvent, contentEvent, copy, createPopup, cut, getEditable, getPopupVisible, getSelection, getShell, getStyle, getText, getTextHeight, getTextLimit, handleFocus, isDropped, isFocusControl, isShowButtonOnFocus, paste, popupEvent, redraw, redraw, removeModifyListener, removeSelectionListener, removeVerifyListener, selectAll, setBackground, setCreateOnDrop, setEditable, setEnabled, setFocus, setFont, setForeground, setLayout, setMenu, setPopupLocation, setSelection, setShowButtonOnFocus, setTextLimit, setToolTipText, setVisible, textEvent, updateButtonDisplay
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
-
Field Details
-
IMAGE
protected static final java.lang.String IMAGEDefault image filename- See Also:
- Constant Field Values
-
buttonImage
protected static org.eclipse.swt.graphics.Image buttonImageDefault image for the button -
formattedText
FormattedText widget for edition of the date -
footerVisible
protected boolean footerVisibleFlag to set footer visible or not in the popup -
gridVisible
protected int gridVisibleFlag to set grid visible or not in the popup -
weeksVisible
protected boolean weeksVisibleFlag to set weeks numbers visible or not -
theme
Calendar theme -
locale
protected java.util.Locale localeLocale 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 classorg.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 classAbstractCombo
- 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 classorg.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, andfalse
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 classAbstractCombo
- 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 aDateChooser
.- Specified by:
createPopupContent
in classAbstractCombo
- 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 aFormattedText
with the default formatter forDate
values. The formatter is provided byDefaultFormatterFactory
. By default aDateFormatter
is returned. This can be changed by registering a new formatter for Date class.- Overrides:
createTextControl
in classAbstractCombo
- 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 classAbstractCombo
- 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 classAbstractCombo
- 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 currentDate
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, elsefalse
-
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 classorg.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, elsefalse
-
setFormatter
Associates a newDateFormatter
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, elsefalse
-
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
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 newDate
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, elsefalse
-