public class CalendarCombo
extends org.eclipse.swt.widgets.Composite
Website
If you want more info or more documentation, please visit: http://www.hexapixel.com
Description
CalendarCombo is a widget that opens a calendar when dropped down. The calendar is modelled after Microsoft Outlook's
calendar widget and acts and behaves exactly the same (and it is also theme based). The combo is not based on CCombo
(as many other custom implementations), but is instead attached to the native Combo box.
Example Creation Code
CalendarCombo cCombo = new CalendarCombo(parentControl, SWT.READ_ONLY);
...
Another example using depending combos and date range selection on the first combo
CalendarCombo cComboStart = new CalendarCombo(parentControl, SWT.READ_ONLY, true);
CalendarCombo cComboEnd = new CalendarCombo(parentControl, SWT.READ_ONLY);
cComboStart.setDependingCombo(cComboEnd);
This will cause the end date for the date range selection to be populated in the cComboEnd combo.
Customizing
There are two interfaces that are of importance for customizing, one is IColorManager and the other is ISettings.
Let's start with the IColorManager.
IColorManager
If you don't specify a color manager, the DefaultColorManager will be used. The color manager's job is to return
colors to the method that is painting all the actual days and months etc. The colors that are returned from the
ColorManager will determine everything as far as looks go.
ISettings
To control the spacing between dates, various formats and text values, you will want to implement the ISettings
interface. If you don't specify one, DefaultSettings will be used.
Modifier and Type | Field and Description |
---|---|
protected static boolean |
OS_CARBON |
protected static boolean |
OS_GTK |
protected static boolean |
OS_WINDOWS |
Constructor and Description |
---|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style)
Creates a new calendar combo box with the given style.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
boolean allowDateRange)
Creates a new calendar combo box with the given style.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
CalendarCombo dependingCombo)
Lets you create a depending CalendarCombo box, which, when no dates are set on the current one will set the
starting date when popped up to be the date of the pullDateFrom CalendarCombo, should that box have a date set in
it.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
CalendarCombo dependingCombo,
boolean allowDateRange)
Lets you create a depending CalendarCombo box, which, when no dates are set on the current one will set the
starting date when popped up to be the date of the pullDateFrom CalendarCombo, should that box have a date set in
it.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
CalendarCombo dependingCombo,
ISettings settings,
IColorManager colorManager)
Lets you create a depending CalendarCombo box, which, when no dates are set on the current one will set the
starting date when popped up to be the date of the pullDateFrom CalendarCombo, should that box have a date set in
it.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
CalendarCombo dependingCombo,
ISettings settings,
IColorManager colorManager,
boolean allowDateRange)
Lets you create a depending CalendarCombo box, which, when no dates are set on the current one will set the
starting date when popped up to be the date of the pullDateFrom CalendarCombo, should that box have a date set in
it.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
ISettings settings,
IColorManager colorManager)
Creates a new calendar mCombo box with the given style, ISettings and IColorManager implementations.
|
CalendarCombo(org.eclipse.swt.widgets.Composite parent,
int style,
ISettings settings,
IColorManager colorManager,
boolean allowDateRange)
Creates a new calendar mCombo box with the given style, ISettings and IColorManager implementations.
|
Modifier and Type | Method and Description |
---|---|
void |
addCalendarListener(ICalendarListener listener)
Adds a calendar listener.
|
void |
addControlListener(org.eclipse.swt.events.ControlListener listener) |
void |
addDateParseExceptionListener(IDateParseExceptionListener listener)
Adds a
IDateParseExceptionListener that listens to date parse exceptions |
void |
addDisposeListener(org.eclipse.swt.events.DisposeListener listener) |
void |
addDragDetectListener(org.eclipse.swt.events.DragDetectListener listener) |
void |
addFocusListener(org.eclipse.swt.events.FocusListener listener) |
void |
addHelpListener(org.eclipse.swt.events.HelpListener listener) |
void |
addKeyListener(org.eclipse.swt.events.KeyListener listener) |
void |
addListener(int eventType,
org.eclipse.swt.widgets.Listener listener) |
void |
addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener) |
void |
addModifyListener(org.eclipse.swt.events.ModifyListener ml)
Adds a modification listener to the combo box.
|
void |
addMouseListener(org.eclipse.swt.events.MouseListener listener) |
void |
addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener) |
void |
addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener) |
void |
addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener) |
void |
addPaintListener(org.eclipse.swt.events.PaintListener listener) |
void |
addTraverseListener(org.eclipse.swt.events.TraverseListener listener) |
void |
clear()
Removes date and clears combo, same as setDate(null).
|
void |
closeCalendar()
Closes the calendar popup.
|
boolean |
forceFocus() |
org.eclipse.swt.widgets.Composite |
getActiveComboControl() |
FlatCalendarCombo |
getCCombo() |
org.eclipse.swt.widgets.Combo |
getCombo()
Returns the combo box widget.
|
java.util.Calendar |
getDate()
Returns the currently set date.
|
java.lang.String |
getDateAsString()
Returns the set date as the raw String representation that is currently displayed in the combo.
|
CalendarCombo |
getDependingCombo()
Returns the CalendarCombo that is the recipient of (end date) date range changes as well as date start date that
will be used.
|
java.util.Calendar |
getDisallowAfterDate()
The date after which selection is not allowed.
|
java.util.Calendar |
getDisallowBeforeDate()
The date prior to which selection is not allowed.
|
void |
grabFocus()
Deprecated.
please use
setFocus() |
boolean |
isEnabled() |
void |
notifyListeners(int eventType,
org.eclipse.swt.widgets.Event event) |
void |
openCalendar()
Pops open the calendar popup.
|
void |
removeCalendarListener(ICalendarListener listener)
Removes a calendar listener.
|
void |
removeControlListener(org.eclipse.swt.events.ControlListener listener) |
void |
removeDateParseExceptionListener(IDateParseExceptionListener listener)
Removes a
IDateParseExceptionListener listener. |
void |
removeDisposeListener(org.eclipse.swt.events.DisposeListener listener) |
void |
removeDragDetectListener(org.eclipse.swt.events.DragDetectListener listener) |
void |
removeFocusListener(org.eclipse.swt.events.FocusListener listener) |
void |
removeHelpListener(org.eclipse.swt.events.HelpListener listener) |
void |
removeKeyListener(org.eclipse.swt.events.KeyListener listener) |
void |
removeListener(int eventType,
org.eclipse.swt.widgets.Listener listener) |
void |
removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener) |
void |
removeModifyListener(org.eclipse.swt.events.ModifyListener ml)
Removes a modification listener from the combo box.
|
void |
removeMouseListener(org.eclipse.swt.events.MouseListener listener) |
void |
removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener) |
void |
removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener) |
void |
removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener) |
void |
removePaintListener(org.eclipse.swt.events.PaintListener listener) |
void |
removeTraverseListener(org.eclipse.swt.events.TraverseListener listener) |
void |
setDate(java.util.Calendar cal)
Sets the current date.
|
void |
setDate(java.util.Date date)
Sets the current date.
|
void |
setDependingCombo(CalendarCombo combo)
Sets the CalendarCombo that will be the recipient of (end date) date range changes as well as date start date
that will be used.
|
void |
setDisallowAfterDate(java.util.Calendar disallowAfterDate)
Sets the date after which selection is not allowed.
|
void |
setDisallowAfterDate(java.util.Date disallowAfterDate)
Sets the date after which selection is not allowed.
|
void |
setDisallowBeforeDate(java.util.Calendar disallowBeforeDate)
Sets the date prior to which selection is not allowed.
|
void |
setDisallowBeforeDate(java.util.Date disallowBeforeDate)
Sets the date prior to which selection is not allowed.
|
void |
setEnabled(boolean enabled) |
boolean |
setFocus() |
void |
setText(java.lang.String text)
Sets the text in the combo area to the given value.
|
void |
showCalendar() |
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
addGestureListener, addTouchListener, computeSize, computeSize, dragDetect, dragDetect, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeGestureListener, removeTouchListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setFont, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, removeListener, reskin, setData, setData, toString
protected static final boolean OS_CARBON
protected static final boolean OS_GTK
protected static final boolean OS_WINDOWS
public CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style)
parent
- Parent controlstyle
- Combo stylepublic CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, boolean allowDateRange)
parent
- Parent controlstyle
- Combo styleallowDateRange
- Whether to allow date range selection (note that if there is no depending CalendarCombo set
you will have to deal with the date range event yourself).public CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager)
parent
- Parent controlstyle
- Combo stylesettings
- ISettings implementationcolorManager
- IColorManager implementationpublic CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, ISettings settings, IColorManager colorManager, boolean allowDateRange)
parent
- Parent controlstyle
- Combo stylesettings
- ISettings implementationcolorManager
- IColorManager implementationallowDateRange
- Whether to allow date range selection (note that if there is no depending CalendarCombo set
you will have to deal with the date range event yourself).public CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, CalendarCombo dependingCombo)
parent
- style
- dependingCombo
- CalendarCombo from where start date is pulled when no date has been set locally.public CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, CalendarCombo dependingCombo, boolean allowDateRange)
parent
- style
- dependingCombo
- CalendarCombo from where start date is pulled when no date has been set locally.allowDateRange
- Whether to allow date range selectionpublic CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, CalendarCombo dependingCombo, ISettings settings, IColorManager colorManager)
parent
- style
- dependingCombo
- CalendarCombo from where start date is pulled when no date has been set locally.settings
- ISettings implementationcolorManager
- IColorManager implementationpublic CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, CalendarCombo dependingCombo, ISettings settings, IColorManager colorManager, boolean allowDateRange)
parent
- style
- dependingCombo
- CalendarCombo from where start date is pulled when no date has been set locally.settings
- ISettings implementationcolorManager
- IColorManager implementationallowDateRange
- Whether to allow date range selectionpublic void setDate(java.util.Date date)
date
- Date to setpublic void setDate(java.util.Calendar cal)
cal
- Calendar to setpublic void setText(java.lang.String text)
text
- Text to displaypublic void openCalendar()
public void closeCalendar()
public java.lang.String getDateAsString()
public java.util.Calendar getDate()
public void showCalendar()
public void addDateParseExceptionListener(IDateParseExceptionListener listener)
IDateParseExceptionListener
that listens to date parse exceptionslistener
- to addpublic void removeDateParseExceptionListener(IDateParseExceptionListener listener)
IDateParseExceptionListener
listener.listener
- to removepublic void addCalendarListener(ICalendarListener listener)
listener
- Listenerpublic void removeCalendarListener(ICalendarListener listener)
listener
- Listenerpublic org.eclipse.swt.widgets.Combo getCombo()
NOTE: The Combo box has a lot of listeners on it, please be "careful" when using it as you may cause unplanned-for things to happen.
public FlatCalendarCombo getCCombo()
public void clear()
public void grabFocus()
setFocus()
public boolean setFocus()
setFocus
in class org.eclipse.swt.widgets.Composite
public boolean forceFocus()
forceFocus
in class org.eclipse.swt.widgets.Control
public void setEnabled(boolean enabled)
setEnabled
in class org.eclipse.swt.widgets.Control
public boolean isEnabled()
isEnabled
in class org.eclipse.swt.widgets.Control
public void addModifyListener(org.eclipse.swt.events.ModifyListener ml)
ml
- ModifyListenerpublic void removeModifyListener(org.eclipse.swt.events.ModifyListener ml)
ml
- ModifyListenerpublic java.util.Calendar getDisallowBeforeDate()
public void setDisallowBeforeDate(java.util.Calendar disallowBeforeDate)
disallowBeforeDate
- Datepublic void setDisallowBeforeDate(java.util.Date disallowBeforeDate)
disallowBeforeDate
- Datepublic java.util.Calendar getDisallowAfterDate()
public void setDisallowAfterDate(java.util.Calendar disallowAfterDate)
disallowAfterDate
- Datepublic void setDisallowAfterDate(java.util.Date disallowAfterDate)
disallowAfterDate
- public void setDependingCombo(CalendarCombo combo)
combo
- CalendarCombopublic CalendarCombo getDependingCombo()
public void addControlListener(org.eclipse.swt.events.ControlListener listener)
addControlListener
in class org.eclipse.swt.widgets.Control
public void addDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)
addDragDetectListener
in class org.eclipse.swt.widgets.Control
public void addFocusListener(org.eclipse.swt.events.FocusListener listener)
addFocusListener
in class org.eclipse.swt.widgets.Control
public void addHelpListener(org.eclipse.swt.events.HelpListener listener)
addHelpListener
in class org.eclipse.swt.widgets.Control
public void addKeyListener(org.eclipse.swt.events.KeyListener listener)
addKeyListener
in class org.eclipse.swt.widgets.Control
public void addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)
addMenuDetectListener
in class org.eclipse.swt.widgets.Control
public void addMouseListener(org.eclipse.swt.events.MouseListener listener)
addMouseListener
in class org.eclipse.swt.widgets.Control
public void addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)
addMouseMoveListener
in class org.eclipse.swt.widgets.Control
public void addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)
addMouseTrackListener
in class org.eclipse.swt.widgets.Control
public void addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
addMouseWheelListener
in class org.eclipse.swt.widgets.Control
public void addPaintListener(org.eclipse.swt.events.PaintListener listener)
addPaintListener
in class org.eclipse.swt.widgets.Control
public void addTraverseListener(org.eclipse.swt.events.TraverseListener listener)
addTraverseListener
in class org.eclipse.swt.widgets.Control
public void addDisposeListener(org.eclipse.swt.events.DisposeListener listener)
addDisposeListener
in class org.eclipse.swt.widgets.Widget
public void addListener(int eventType, org.eclipse.swt.widgets.Listener listener)
addListener
in class org.eclipse.swt.widgets.Widget
public void removeControlListener(org.eclipse.swt.events.ControlListener listener)
removeControlListener
in class org.eclipse.swt.widgets.Control
public void removeDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)
removeDragDetectListener
in class org.eclipse.swt.widgets.Control
public void removeFocusListener(org.eclipse.swt.events.FocusListener listener)
removeFocusListener
in class org.eclipse.swt.widgets.Control
public void removeHelpListener(org.eclipse.swt.events.HelpListener listener)
removeHelpListener
in class org.eclipse.swt.widgets.Control
public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
removeKeyListener
in class org.eclipse.swt.widgets.Control
public void removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)
removeMenuDetectListener
in class org.eclipse.swt.widgets.Control
public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)
removeMouseListener
in class org.eclipse.swt.widgets.Control
public void removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)
removeMouseMoveListener
in class org.eclipse.swt.widgets.Control
public void removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)
removeMouseTrackListener
in class org.eclipse.swt.widgets.Control
public void removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)
removeMouseWheelListener
in class org.eclipse.swt.widgets.Control
public void removePaintListener(org.eclipse.swt.events.PaintListener listener)
removePaintListener
in class org.eclipse.swt.widgets.Control
public void removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)
removeTraverseListener
in class org.eclipse.swt.widgets.Control
public void notifyListeners(int eventType, org.eclipse.swt.widgets.Event event)
notifyListeners
in class org.eclipse.swt.widgets.Widget
public void removeDisposeListener(org.eclipse.swt.events.DisposeListener listener)
removeDisposeListener
in class org.eclipse.swt.widgets.Widget
public void removeListener(int eventType, org.eclipse.swt.widgets.Listener listener)
removeListener
in class org.eclipse.swt.widgets.Widget
public org.eclipse.swt.widgets.Composite getActiveComboControl()