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.ImagebuttonImageDefault image for the buttonprotected booleanfooterVisibleFlag to set footer visible or not in the popupprotected FormattedTextformattedTextFormattedText widget for edition of the dateprotected intgridVisibleFlag to set grid visible or not in the popupprotected static java.lang.StringIMAGEDefault image filenameprotected java.util.LocalelocaleLocale used for localized names and formatsprotected DateChooserThemethemeCalendar themeprotected booleanweeksVisibleFlag 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 voidaddKeyListener(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 voidbeforeDrop()Called just before the popup is dropped.org.eclipse.swt.graphics.PointcomputeSize(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.ButtoncreateButtonControl(int style)Creates the button widget.protected org.eclipse.swt.widgets.ControlcreatePopupContent(org.eclipse.swt.widgets.Composite parent)Creates the popup content.protected org.eclipse.swt.widgets.TextcreateTextControl(int style)Creates the text widget.protected booleandoSelection()This method is called when a SWT.Selection is notify in the popup content, allowing to update the Text widget content.protected voiddropDown(boolean drop)Manages drop down of the popup.intgetGridVisible()Returns the grid visibility status.java.util.DategetValue()Returns the currentDatevalue of the widget.booleanisFooterVisible()Returns true if footer is visible in the popup calendar.booleanisGridVisible()Deprecated.booleanisWeeksVisible()Returns true if weeks numbers are visible.voidremoveKeyListener(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.voidsetFooterVisible(boolean footerVisible)Sets the footer of popup calendar visible or not.voidsetFormatter(DateFormatter formatter)Associates a newDateFormatterto the text widget, replacing the default one.voidsetGridVisible(boolean gridVisible)Deprecated.voidsetGridVisible(int gridVisible)Sets the grid visible or not.voidsetImage(org.eclipse.swt.graphics.Image image)Sets a new image to display on the button, replacing the default one.voidsetLocale(java.util.Locale locale)Sets the locale used both by the input mask and the calendar.voidsetTheme(DateChooserTheme theme)Sets the theme to apply to the calendar popup.voidsetValue(java.util.Date value)Sets a newDatevalue.voidsetWeeksVisible(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, updateButtonDisplayMethods 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, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods 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, updateMethods 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:
addKeyListenerin 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:
beforeDropin 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:
computeSizein classorg.eclipse.swt.widgets.Control- Parameters:
wHint- the width hint (can be SWT.DEFAULT)hHint- the height hint (can be SWT.DEFAULT)changed-trueif the control's contents have changed, andfalseotherwise- 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:
createButtonControlin 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:
createPopupContentin 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 aFormattedTextwith the default formatter forDatevalues. The formatter is provided byDefaultFormatterFactory. By default aDateFormatteris returned. This can be changed by registering a new formatter for Date class.- Overrides:
createTextControlin 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:
doSelectionin classAbstractCombo- Returns:
- true if the SWT.Selection event must be propagated, else false
-
dropDown
protected void dropDown(boolean drop)Description copied from class:AbstractComboManages drop down of the popup.- Overrides:
dropDownin classAbstractCombo- Parameters:
drop-trueto drop the popup,falseto 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 currentDatevalue of the widget.- Returns:
- Current value
-
isFooterVisible
public boolean isFooterVisible()Returns true if footer is visible in the popup calendar.- Returns:
trueif 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:
removeKeyListenerin 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-trueto set footer visible, elsefalse
-
setFormatter
Associates a newDateFormatterto 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-trueto 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 newDatevalue.- 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-trueto set weeks visible, elsefalse
-