|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.swt.widgets.Widget org.eclipse.swt.widgets.Control org.eclipse.swt.widgets.Scrollable org.eclipse.swt.widgets.Composite de.jaret.util.ui.datechooser.DateChooser
public class DateChooser
A date field with an attached datechooser in a combobox style. The date chooser used is
The popup is displayed using a shell. The creation of the shell
and the chooserpanel is lazy. The control offers three strategies for dealing with unparsable input in the textfield:
KEEP_AND_MARK: keep the unparsable input, do not modify the date value and mark the field. This is the default
behaviour allowing the user to step back and correct the input without slowing down the input process.
RESET_TO_LASTVALID: reset the input to the last valid date entered or given RESET_TO_NULL: reset the value to null
The DateFieldCombo features
- selectable locale which is used for the determination of the first day of the week and the weekday/months
abbreviations
- display of week of the year selectable
- keyboard control (cursor keys navigate in the day panel, SHIFT-Cursor-left/right navigate month, ESC cancels, t
sets the date to the current date), ctrl-space will open dropdown, RETURN selects
- roll fields in the edited field with cursor up/down (if a FieldIdentfier is supplied)
- mousewheel on textfieled. roll field if field identifier is set and feature is enabled (default:true)
- mousewheel on panel. roll day; use shift+wheel to roll months
- optional a
,
can be set for highlighting holidays in the day panel
- can be wired with a time chooser to keep date and time in sync
Field Summary | |
---|---|
protected DateChooserPanel |
_chooserPanel
DateChooserPanel in the dropdown. |
protected java.util.Date |
_date
the date value manipulated by the control. |
protected java.text.DateFormat |
_dateformat
dateformat used to format the date in the textfield. |
protected IAdditionalDayInformationProvider |
_dayInformationProvider
Provier for additional day information. |
protected org.eclipse.swt.widgets.Button |
_dropdownButton
dropdown button. |
protected org.eclipse.swt.widgets.Shell |
_dropDownShell
shell for the drop down. |
protected boolean |
_dropped
dropped state. |
protected boolean |
_editable
if true: editable. |
protected IFieldIdentifier |
_fieldIdentifier
FieldIdentifier used for field rolling. |
protected boolean |
_hasValidInput
true if th einput is valid. |
protected de.jaret.util.date.holidayenumerator.HolidayEnumerator |
_holidayEnumerator
Enumerator for identifying holidays. |
protected int |
_invalidInputBehaviour
behaviour on invalid input. |
protected java.util.List<IDateChooserListener> |
_listenerList
listener list of interestedlisteners. |
protected java.util.Locale |
_locale
locale used by the control. |
protected org.eclipse.swt.widgets.Text |
_textField
text field widgets used. |
protected TimeChooser |
_timeChooser
timechooser to sync time of the handled date with. |
static int |
KEEP_AND_MARK
Invalid input behaviour: keep the textual input and mark the field. |
static org.eclipse.swt.graphics.Color |
MARKER_COLOR
Color used to mark invalid input. |
protected static int |
MOUSEWHEEL_DIVISOR
divisor for the mousewheel ticks. |
static int |
RESET_TO_LASTVALID
Invalid input behaviour: reset the date to the last valid input. |
static int |
RESET_TO_NULL
Invalid input behaviour: reset the date to null . |
Fields inherited from class org.eclipse.swt.widgets.Control |
---|
handle |
Constructor Summary | |
---|---|
DateChooser(org.eclipse.swt.widgets.Composite parent,
int style)
Constructor using the default locale. |
|
DateChooser(org.eclipse.swt.widgets.Composite parent,
int style,
java.util.Locale locale)
Constructor for the datefieldcombo. |
Method Summary | |
---|---|
void |
addDateChooserListener(IDateChooserListener listener)
Add a DateChooserListener to be informed about changes. |
void |
choosingCanceled()
Called when the user decided not to choose any date. |
void |
clearSelection()
Clear selection on the textfield. |
void |
copy()
Copy operation of the textfield. |
void |
cut()
Cut operation of the textfield. |
void |
dateChosen(java.util.Date date)
Called when the user selected a date. |
void |
dateIntermediateChange(java.util.Date date)
Called on intermediate changes in the date chooser. |
protected void |
fireChoosingCanceled()
Inform listeners that the choosing has been cancelled. |
protected void |
fireDateChosen(java.util.Date date)
Inform listeners that a date has been chosen. |
protected void |
fireInputInvalid()
Inform listeners that the current input has become invalid. |
protected void |
fireIntermediateChange(java.util.Date date)
Inform listeners about an intermediate change of the date. |
void |
focusGained(org.eclipse.swt.events.FocusEvent evt)
On gaining focus on the textfield, select its content. |
void |
focusLost(org.eclipse.swt.events.FocusEvent evt)
On loosing focus validate the input and check whether the focus will be going to the dropdown. |
boolean |
forceFocus()
The textfield will get the focus. |
IAdditionalDayInformationProvider |
getAdditionalDayInformationProvider()
Retrieve the additional information provider. |
java.util.Date |
getDate()
Retrieve the current selected date. |
DateChooserPanel |
getDateChooserPanel()
Return the chooser panel used by the DateChooser. |
java.text.DateFormat |
getDateFormat()
Retrieve the used dateformat. |
protected java.util.Date |
getDateInternal()
Retrieve the current date without syncing with a time chooser. |
IFieldIdentifier |
getFieldIdentifier()
|
de.jaret.util.date.holidayenumerator.HolidayEnumerator |
getHolidayEnumerator()
Retrieve he holiday enumerator used. |
int |
getInvalidInputBehaviour()
|
org.eclipse.swt.widgets.Text |
getTextField()
Access to the embedded textfield widget. |
TimeChooser |
getTimeChooser()
Get the timechooser set for time synchronization. |
void |
inputInvalid()
Called when the user input becomes invalid. |
boolean |
isDropped()
Check whether the drop down is dropped down. |
boolean |
isEditable()
|
boolean |
isEnabled()
|
boolean |
isOneClickSelection()
Get the oneClick property of the date chooser panel. |
boolean |
isSelectAllOnFocusGained()
|
boolean |
isTextfieldMouseWheelEnable()
Retrieve state of mousewheel support on textfield. |
void |
onDispose()
dispose has to take care of some additional disposals. |
void |
paste()
Paste operation of the textfield. |
void |
remDateChooserListener(IDateChooserListener listener)
Remove a DateChooserListener. |
void |
selectAll()
Select the text fields contents. |
void |
setAdditionalDayInformationProvider(IAdditionalDayInformationProvider dayInformationProvider)
Set an additional information provider for days. |
void |
setDate(java.util.Date date)
Set the date. |
void |
setDateFormat(java.text.DateFormat dateformat)
Set the dateformat used to parse and format the date in the text field. |
void |
setDropped(boolean dropped)
Set the state of the dropdown. |
void |
setEditable(boolean editable)
Set the editable state. |
void |
setEnabled(boolean enabled)
Set the enabled state of the widget. |
void |
setFieldIdentifier(IFieldIdentifier fieldIdentifier)
|
boolean |
setFocus()
The textfield will get the focus. |
void |
setHolidayEnumerator(de.jaret.util.date.holidayenumerator.HolidayEnumerator holidayEnumerator)
Set a HolidayEnumerator for marking holidays in the day panel. |
void |
setInvalidInputBehaviour(int invalidInputBehaviour)
|
void |
setOneClickSelection(boolean oneClick)
Set the onClick property of the date chooser panel. |
void |
setSelectAllOnFocusGained(boolean selectAllOnFocusGained)
|
void |
setSelection(int pos)
Set the selection on the textfield. |
void |
setText(java.lang.String text)
Set the input in the textfield direct. |
void |
setTextfieldMouseWheelEnable(boolean mouseWheelEnable)
Enable/Disable mousewheel for rolling on text field. |
void |
setTimeChooser(TimeChooser timeChooser)
Set a timechoser to synchronize the time of the chosen date with. |
boolean |
validateInput()
Validate the input currently present in the textfield. |
Methods inherited from class org.eclipse.swt.widgets.Composite |
---|
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList |
Methods inherited from class org.eclipse.swt.widgets.Scrollable |
---|
computeTrim, getClientArea, getHorizontalBar, getVerticalBar |
Methods inherited from class org.eclipse.swt.widgets.Control |
---|
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, setToolTipText, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, update |
Methods inherited from class org.eclipse.swt.widgets.Widget |
---|
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int KEEP_AND_MARK
public static final int RESET_TO_LASTVALID
public static final int RESET_TO_NULL
null
.
public static final org.eclipse.swt.graphics.Color MARKER_COLOR
protected static final int MOUSEWHEEL_DIVISOR
protected int _invalidInputBehaviour
protected boolean _editable
protected java.util.List<IDateChooserListener> _listenerList
protected java.util.Date _date
protected java.text.DateFormat _dateformat
protected java.util.Locale _locale
protected org.eclipse.swt.widgets.Text _textField
protected org.eclipse.swt.widgets.Button _dropdownButton
protected org.eclipse.swt.widgets.Shell _dropDownShell
protected boolean _dropped
protected DateChooserPanel _chooserPanel
protected de.jaret.util.date.holidayenumerator.HolidayEnumerator _holidayEnumerator
protected IAdditionalDayInformationProvider _dayInformationProvider
protected IFieldIdentifier _fieldIdentifier
protected TimeChooser _timeChooser
protected boolean _hasValidInput
Constructor Detail |
---|
public DateChooser(org.eclipse.swt.widgets.Composite parent, int style, java.util.Locale locale)
parent
- Composite parentstyle
- stylelocale
- locale to be usedpublic DateChooser(org.eclipse.swt.widgets.Composite parent, int style)
parent
- Composite parentstyle
- styleMethod Detail |
---|
public java.text.DateFormat getDateFormat()
public void setDateFormat(java.text.DateFormat dateformat)
dateformat
- dateformat to use.public void onDispose()
public boolean isDropped()
public void setDropped(boolean dropped)
dropped
- if true the dropdowbn will be displayed.public java.util.Date getDate()
protected java.util.Date getDateInternal()
public void setDate(java.util.Date date)
date
- The date to set.public void setText(java.lang.String text)
text
- new text of the textfieldpublic void selectAll()
public void setSelection(int pos)
pos
- positionpublic void clearSelection()
public void cut()
public void copy()
public void paste()
public boolean setFocus()
setFocus
in class org.eclipse.swt.widgets.Composite
public boolean forceFocus()
forceFocus
in class org.eclipse.swt.widgets.Control
public org.eclipse.swt.widgets.Text getTextField()
public de.jaret.util.date.holidayenumerator.HolidayEnumerator getHolidayEnumerator()
public void setHolidayEnumerator(de.jaret.util.date.holidayenumerator.HolidayEnumerator holidayEnumerator)
null
is valid indicating
no HolidayEnumerator to be used.
holidayEnumerator
- HolidayEnumerator to be used.public IAdditionalDayInformationProvider getAdditionalDayInformationProvider()
public void setAdditionalDayInformationProvider(IAdditionalDayInformationProvider dayInformationProvider)
dayInformationProvider
- the information providerpublic void dateChosen(java.util.Date date)
dateChosen
in interface IDateChooserListener
date
- chosen datepublic void choosingCanceled()
choosingCanceled
in interface IDateChooserListener
public void dateIntermediateChange(java.util.Date date)
dateIntermediateChange
in interface IDateChooserListener
date
- current date selectionpublic void inputInvalid()
inputInvalid
in interface IDateChooserListener
public void focusGained(org.eclipse.swt.events.FocusEvent evt)
focusGained
in interface org.eclipse.swt.events.FocusListener
public void focusLost(org.eclipse.swt.events.FocusEvent evt)
focusLost
in interface org.eclipse.swt.events.FocusListener
public boolean validateInput()
public int getInvalidInputBehaviour()
public void setInvalidInputBehaviour(int invalidInputBehaviour)
invalidInputBehaviour
- The invalidInputBehaviour to set.public boolean isEditable()
public void setEditable(boolean editable)
editable
- The editable state to be set.public boolean isEnabled()
isEnabled
in class org.eclipse.swt.widgets.Control
public void setEnabled(boolean enabled)
setEnabled
in class org.eclipse.swt.widgets.Control
enabled
- the enabled state to setpublic void setOneClickSelection(boolean oneClick)
oneClick
- if set to true a single click will selct the date.public boolean isOneClickSelection()
public DateChooserPanel getDateChooserPanel()
public void addDateChooserListener(IDateChooserListener listener)
listener
- the DateChooserListener to be addedpublic void remDateChooserListener(IDateChooserListener listener)
listener
- the DateChooserListener to be removedprotected void fireDateChosen(java.util.Date date)
date
- chosen dateprotected void fireIntermediateChange(java.util.Date date)
date
- current dateprotected void fireChoosingCanceled()
protected void fireInputInvalid()
public boolean isSelectAllOnFocusGained()
public void setSelectAllOnFocusGained(boolean selectAllOnFocusGained)
selectAllOnFocusGained
- The selectAllOnFocusGained to set.public IFieldIdentifier getFieldIdentifier()
public void setFieldIdentifier(IFieldIdentifier fieldIdentifier)
fieldIdentifier
- The fieldIdentifier to set.public boolean isTextfieldMouseWheelEnable()
public void setTextfieldMouseWheelEnable(boolean mouseWheelEnable)
mouseWheelEnable
- true for enablepublic TimeChooser getTimeChooser()
null
public void setTimeChooser(TimeChooser timeChooser)
timeChooser
- time chooser
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |