Class CalendarCombo
- All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable
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.
- Version:
- 1.1.2008.11.25
-
Field Summary
Fields Modifier and Type Field Description protected static booleanOS_CARBONprotected static booleanOS_GTKprotected static booleanOS_WINDOWS -
Constructor Summary
Constructors Constructor 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. -
Method Summary
Modifier and Type Method Description voidaddCalendarListener(ICalendarListener listener)Adds a calendar listener.voidaddControlListener(org.eclipse.swt.events.ControlListener listener)voidaddDateParseExceptionListener(IDateParseExceptionListener listener)Adds aIDateParseExceptionListenerthat listens to date parse exceptionsvoidaddDisposeListener(org.eclipse.swt.events.DisposeListener listener)voidaddDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)voidaddFocusListener(org.eclipse.swt.events.FocusListener listener)voidaddHelpListener(org.eclipse.swt.events.HelpListener listener)voidaddKeyListener(org.eclipse.swt.events.KeyListener listener)voidaddListener(int eventType, org.eclipse.swt.widgets.Listener listener)voidaddMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)voidaddModifyListener(org.eclipse.swt.events.ModifyListener ml)Adds a modification listener to the combo box.voidaddMouseListener(org.eclipse.swt.events.MouseListener listener)voidaddMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)voidaddMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)voidaddMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)voidaddPaintListener(org.eclipse.swt.events.PaintListener listener)voidaddTraverseListener(org.eclipse.swt.events.TraverseListener listener)voidclear()Removes date and clears combo, same as setDate(null).voidcloseCalendar()Closes the calendar popup.booleanforceFocus()org.eclipse.swt.widgets.CompositegetActiveComboControl()FlatCalendarCombogetCCombo()org.eclipse.swt.widgets.CombogetCombo()Returns the combo box widget.java.util.CalendargetDate()Returns the currently set date.java.lang.StringgetDateAsString()Returns the set date as the raw String representation that is currently displayed in the combo.CalendarCombogetDependingCombo()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.CalendargetDisallowAfterDate()The date after which selection is not allowed.java.util.CalendargetDisallowBeforeDate()The date prior to which selection is not allowed.voidgrabFocus()Deprecated.please usesetFocus()booleanisEnabled()voidnotifyListeners(int eventType, org.eclipse.swt.widgets.Event event)voidopenCalendar()Pops open the calendar popup.voidremoveCalendarListener(ICalendarListener listener)Removes a calendar listener.voidremoveControlListener(org.eclipse.swt.events.ControlListener listener)voidremoveDateParseExceptionListener(IDateParseExceptionListener listener)Removes aIDateParseExceptionListenerlistener.voidremoveDisposeListener(org.eclipse.swt.events.DisposeListener listener)voidremoveDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)voidremoveFocusListener(org.eclipse.swt.events.FocusListener listener)voidremoveHelpListener(org.eclipse.swt.events.HelpListener listener)voidremoveKeyListener(org.eclipse.swt.events.KeyListener listener)voidremoveListener(int eventType, org.eclipse.swt.widgets.Listener listener)voidremoveMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)voidremoveModifyListener(org.eclipse.swt.events.ModifyListener ml)Removes a modification listener from the combo box.voidremoveMouseListener(org.eclipse.swt.events.MouseListener listener)voidremoveMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)voidremoveMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)voidremoveMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)voidremovePaintListener(org.eclipse.swt.events.PaintListener listener)voidremoveTraverseListener(org.eclipse.swt.events.TraverseListener listener)voidsetDate(java.util.Calendar cal)Sets the current date.voidsetDate(java.util.Date date)Sets the current date.voidsetDependingCombo(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.voidsetDisallowAfterDate(java.util.Calendar disallowAfterDate)Sets the date after which selection is not allowed.voidsetDisallowAfterDate(java.util.Date disallowAfterDate)Sets the date after which selection is not allowed.voidsetDisallowBeforeDate(java.util.Calendar disallowBeforeDate)Sets the date prior to which selection is not allowed.voidsetDisallowBeforeDate(java.util.Date disallowBeforeDate)Sets the date prior to which selection is not allowed.voidsetEnabled(boolean enabled)booleansetFocus()voidsetText(java.lang.String text)Sets the text in the combo area to the given value.voidshowCalendar()Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList, toStringMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods inherited from class org.eclipse.swt.widgets.Control
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, updateMethods inherited from class org.eclipse.swt.widgets.Widget
checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, removeListener, reskin, setData, setData
-
Field Details
-
OS_CARBON
protected static final boolean OS_CARBON -
OS_GTK
protected static final boolean OS_GTK -
OS_WINDOWS
protected static final boolean OS_WINDOWS
-
-
Constructor Details
-
CalendarCombo
public CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style)Creates a new calendar combo box with the given style.- Parameters:
parent- Parent controlstyle- Combo style
-
CalendarCombo
public CalendarCombo(org.eclipse.swt.widgets.Composite parent, int style, boolean allowDateRange)Creates a new calendar combo box with the given style.- Parameters:
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).
-
CalendarCombo
public 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.- Parameters:
parent- Parent controlstyle- Combo stylesettings- ISettings implementationcolorManager- IColorManager implementation
-
CalendarCombo
public 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.- Parameters:
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).
-
CalendarCombo
public 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.- Parameters:
parent-style-dependingCombo- CalendarCombo from where start date is pulled when no date has been set locally.
-
CalendarCombo
public 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. When the depending combo is set and the allowDateRange flag is true, the depending combo will be the recipient of the end date of any date range selection.- Parameters:
parent-style-dependingCombo- CalendarCombo from where start date is pulled when no date has been set locally.allowDateRange- Whether to allow date range selection
-
CalendarCombo
public 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.- Parameters:
parent-style-dependingCombo- CalendarCombo from where start date is pulled when no date has been set locally.settings- ISettings implementationcolorManager- IColorManager implementation
-
CalendarCombo
public 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. When the depending combo is set and the allowDateRange flag is true, the depending combo will be the recipient of the end date of any date range selection.- Parameters:
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 selection
-
-
Method Details
-
setDate
public void setDate(java.util.Date date)Sets the current date. Date will be automatically displayed in the text area of the combo according to the defined date format (in settings).- Parameters:
date- Date to set
-
setDate
public void setDate(java.util.Calendar cal)Sets the current date. Date will be automatically displayed in the text area of the combo according to the defined date format (in settings).- Parameters:
cal- Calendar to set
-
setText
public void setText(java.lang.String text)Sets the text in the combo area to the given value. Do note that if you set a text that is a non-pareseable date string according to the currently set date format, that string will be replaced or removed when the user opens the popup. This is mainly for disabled combos or combos where you need to add additional control to what's displayed in the text area.- Parameters:
text- Text to display
-
openCalendar
public void openCalendar()Pops open the calendar popup. -
closeCalendar
public void closeCalendar()Closes the calendar popup. -
getDateAsString
public java.lang.String getDateAsString()Returns the set date as the raw String representation that is currently displayed in the combo.- Returns:
- String date
-
getDate
public java.util.Calendar getDate()Returns the currently set date.- Returns:
- Calendar of date selection or null.
-
showCalendar
public void showCalendar() -
addDateParseExceptionListener
Adds aIDateParseExceptionListenerthat listens to date parse exceptions- Parameters:
listener- to add
-
removeDateParseExceptionListener
Removes aIDateParseExceptionListenerlistener.- Parameters:
listener- to remove
-
addCalendarListener
Adds a calendar listener.- Parameters:
listener- Listener
-
removeCalendarListener
Removes a calendar listener.- Parameters:
listener- Listener
-
getCombo
public org.eclipse.swt.widgets.Combo getCombo()Returns the combo box widget.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.
- Returns:
- Combo widget
-
getCCombo
-
clear
public void clear()Removes date and clears combo, same as setDate(null). -
grabFocus
public void grabFocus()Deprecated.please usesetFocus()Puts focus on the combo box. -
setFocus
public boolean setFocus()- Overrides:
setFocusin classorg.eclipse.swt.widgets.Composite
-
forceFocus
public boolean forceFocus()- Overrides:
forceFocusin classorg.eclipse.swt.widgets.Control
-
setEnabled
public void setEnabled(boolean enabled)- Overrides:
setEnabledin classorg.eclipse.swt.widgets.Control
-
isEnabled
public boolean isEnabled()- Overrides:
isEnabledin classorg.eclipse.swt.widgets.Control
-
addModifyListener
public void addModifyListener(org.eclipse.swt.events.ModifyListener ml)Adds a modification listener to the combo box.- Parameters:
ml- ModifyListener
-
removeModifyListener
public void removeModifyListener(org.eclipse.swt.events.ModifyListener ml)Removes a modification listener from the combo box.- Parameters:
ml- ModifyListener
-
getDisallowBeforeDate
public java.util.Calendar getDisallowBeforeDate()The date prior to which selection is not allowed.- Returns:
- Date
-
setDisallowBeforeDate
public void setDisallowBeforeDate(java.util.Calendar disallowBeforeDate)Sets the date prior to which selection is not allowed.- Parameters:
disallowBeforeDate- Date
-
setDisallowBeforeDate
public void setDisallowBeforeDate(java.util.Date disallowBeforeDate)Sets the date prior to which selection is not allowed.- Parameters:
disallowBeforeDate- Date
-
getDisallowAfterDate
public java.util.Calendar getDisallowAfterDate()The date after which selection is not allowed.- Returns:
- Date
-
setDisallowAfterDate
public void setDisallowAfterDate(java.util.Calendar disallowAfterDate)Sets the date after which selection is not allowed.- Parameters:
disallowAfterDate- Date
-
setDisallowAfterDate
public void setDisallowAfterDate(java.util.Date disallowAfterDate)Sets the date after which selection is not allowed.- Parameters:
disallowAfterDate-
-
setDependingCombo
Sets the CalendarCombo that will be the recipient of (end date) date range changes as well as date start date that will be used.- Parameters:
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.- Returns:
- CalendarCombo
-
addControlListener
public void addControlListener(org.eclipse.swt.events.ControlListener listener)- Overrides:
addControlListenerin classorg.eclipse.swt.widgets.Control
-
addDragDetectListener
public void addDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)- Overrides:
addDragDetectListenerin classorg.eclipse.swt.widgets.Control
-
addFocusListener
public void addFocusListener(org.eclipse.swt.events.FocusListener listener)- Overrides:
addFocusListenerin classorg.eclipse.swt.widgets.Control
-
addHelpListener
public void addHelpListener(org.eclipse.swt.events.HelpListener listener)- Overrides:
addHelpListenerin classorg.eclipse.swt.widgets.Control
-
addKeyListener
public void addKeyListener(org.eclipse.swt.events.KeyListener listener)- Overrides:
addKeyListenerin classorg.eclipse.swt.widgets.Control
-
addMenuDetectListener
public void addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)- Overrides:
addMenuDetectListenerin classorg.eclipse.swt.widgets.Control
-
addMouseListener
public void addMouseListener(org.eclipse.swt.events.MouseListener listener)- Overrides:
addMouseListenerin classorg.eclipse.swt.widgets.Control
-
addMouseMoveListener
public void addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)- Overrides:
addMouseMoveListenerin classorg.eclipse.swt.widgets.Control
-
addMouseTrackListener
public void addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)- Overrides:
addMouseTrackListenerin classorg.eclipse.swt.widgets.Control
-
addMouseWheelListener
public void addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)- Overrides:
addMouseWheelListenerin classorg.eclipse.swt.widgets.Control
-
addPaintListener
public void addPaintListener(org.eclipse.swt.events.PaintListener listener)- Overrides:
addPaintListenerin classorg.eclipse.swt.widgets.Control
-
addTraverseListener
public void addTraverseListener(org.eclipse.swt.events.TraverseListener listener)- Overrides:
addTraverseListenerin classorg.eclipse.swt.widgets.Control
-
addDisposeListener
public void addDisposeListener(org.eclipse.swt.events.DisposeListener listener)- Overrides:
addDisposeListenerin classorg.eclipse.swt.widgets.Widget
-
addListener
public void addListener(int eventType, org.eclipse.swt.widgets.Listener listener)- Overrides:
addListenerin classorg.eclipse.swt.widgets.Widget
-
removeControlListener
public void removeControlListener(org.eclipse.swt.events.ControlListener listener)- Overrides:
removeControlListenerin classorg.eclipse.swt.widgets.Control
-
removeDragDetectListener
public void removeDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)- Overrides:
removeDragDetectListenerin classorg.eclipse.swt.widgets.Control
-
removeFocusListener
public void removeFocusListener(org.eclipse.swt.events.FocusListener listener)- Overrides:
removeFocusListenerin classorg.eclipse.swt.widgets.Control
-
removeHelpListener
public void removeHelpListener(org.eclipse.swt.events.HelpListener listener)- Overrides:
removeHelpListenerin classorg.eclipse.swt.widgets.Control
-
removeKeyListener
public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)- Overrides:
removeKeyListenerin classorg.eclipse.swt.widgets.Control
-
removeMenuDetectListener
public void removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)- Overrides:
removeMenuDetectListenerin classorg.eclipse.swt.widgets.Control
-
removeMouseListener
public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)- Overrides:
removeMouseListenerin classorg.eclipse.swt.widgets.Control
-
removeMouseMoveListener
public void removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)- Overrides:
removeMouseMoveListenerin classorg.eclipse.swt.widgets.Control
-
removeMouseTrackListener
public void removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)- Overrides:
removeMouseTrackListenerin classorg.eclipse.swt.widgets.Control
-
removeMouseWheelListener
public void removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)- Overrides:
removeMouseWheelListenerin classorg.eclipse.swt.widgets.Control
-
removePaintListener
public void removePaintListener(org.eclipse.swt.events.PaintListener listener)- Overrides:
removePaintListenerin classorg.eclipse.swt.widgets.Control
-
removeTraverseListener
public void removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)- Overrides:
removeTraverseListenerin classorg.eclipse.swt.widgets.Control
-
notifyListeners
public void notifyListeners(int eventType, org.eclipse.swt.widgets.Event event)- Overrides:
notifyListenersin classorg.eclipse.swt.widgets.Widget
-
removeDisposeListener
public void removeDisposeListener(org.eclipse.swt.events.DisposeListener listener)- Overrides:
removeDisposeListenerin classorg.eclipse.swt.widgets.Widget
-
removeListener
public void removeListener(int eventType, org.eclipse.swt.widgets.Listener listener)- Overrides:
removeListenerin classorg.eclipse.swt.widgets.Widget
-
getActiveComboControl
public org.eclipse.swt.widgets.Composite getActiveComboControl()
-