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 boolean
OS_CARBON
protected static boolean
OS_GTK
protected static boolean
OS_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 void
addCalendarListener(ICalendarListener listener)
Adds a calendar listener.void
addControlListener(org.eclipse.swt.events.ControlListener listener)
void
addDateParseExceptionListener(IDateParseExceptionListener listener)
Adds aIDateParseExceptionListener
that listens to date parse exceptionsvoid
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 usesetFocus()
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 aIDateParseExceptionListener
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()
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, toString
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
Methods 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, update
Methods 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 aIDateParseExceptionListener
that listens to date parse exceptions- Parameters:
listener
- to add
-
removeDateParseExceptionListener
Removes aIDateParseExceptionListener
listener.- 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:
setFocus
in classorg.eclipse.swt.widgets.Composite
-
forceFocus
public boolean forceFocus()- Overrides:
forceFocus
in classorg.eclipse.swt.widgets.Control
-
setEnabled
public void setEnabled(boolean enabled)- Overrides:
setEnabled
in classorg.eclipse.swt.widgets.Control
-
isEnabled
public boolean isEnabled()- Overrides:
isEnabled
in 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:
addControlListener
in classorg.eclipse.swt.widgets.Control
-
addDragDetectListener
public void addDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)- Overrides:
addDragDetectListener
in classorg.eclipse.swt.widgets.Control
-
addFocusListener
public void addFocusListener(org.eclipse.swt.events.FocusListener listener)- Overrides:
addFocusListener
in classorg.eclipse.swt.widgets.Control
-
addHelpListener
public void addHelpListener(org.eclipse.swt.events.HelpListener listener)- Overrides:
addHelpListener
in classorg.eclipse.swt.widgets.Control
-
addKeyListener
public void addKeyListener(org.eclipse.swt.events.KeyListener listener)- Overrides:
addKeyListener
in classorg.eclipse.swt.widgets.Control
-
addMenuDetectListener
public void addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)- Overrides:
addMenuDetectListener
in classorg.eclipse.swt.widgets.Control
-
addMouseListener
public void addMouseListener(org.eclipse.swt.events.MouseListener listener)- Overrides:
addMouseListener
in classorg.eclipse.swt.widgets.Control
-
addMouseMoveListener
public void addMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)- Overrides:
addMouseMoveListener
in classorg.eclipse.swt.widgets.Control
-
addMouseTrackListener
public void addMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)- Overrides:
addMouseTrackListener
in classorg.eclipse.swt.widgets.Control
-
addMouseWheelListener
public void addMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)- Overrides:
addMouseWheelListener
in classorg.eclipse.swt.widgets.Control
-
addPaintListener
public void addPaintListener(org.eclipse.swt.events.PaintListener listener)- Overrides:
addPaintListener
in classorg.eclipse.swt.widgets.Control
-
addTraverseListener
public void addTraverseListener(org.eclipse.swt.events.TraverseListener listener)- Overrides:
addTraverseListener
in classorg.eclipse.swt.widgets.Control
-
addDisposeListener
public void addDisposeListener(org.eclipse.swt.events.DisposeListener listener)- Overrides:
addDisposeListener
in classorg.eclipse.swt.widgets.Widget
-
addListener
public void addListener(int eventType, org.eclipse.swt.widgets.Listener listener)- Overrides:
addListener
in classorg.eclipse.swt.widgets.Widget
-
removeControlListener
public void removeControlListener(org.eclipse.swt.events.ControlListener listener)- Overrides:
removeControlListener
in classorg.eclipse.swt.widgets.Control
-
removeDragDetectListener
public void removeDragDetectListener(org.eclipse.swt.events.DragDetectListener listener)- Overrides:
removeDragDetectListener
in classorg.eclipse.swt.widgets.Control
-
removeFocusListener
public void removeFocusListener(org.eclipse.swt.events.FocusListener listener)- Overrides:
removeFocusListener
in classorg.eclipse.swt.widgets.Control
-
removeHelpListener
public void removeHelpListener(org.eclipse.swt.events.HelpListener listener)- Overrides:
removeHelpListener
in classorg.eclipse.swt.widgets.Control
-
removeKeyListener
public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)- Overrides:
removeKeyListener
in classorg.eclipse.swt.widgets.Control
-
removeMenuDetectListener
public void removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener listener)- Overrides:
removeMenuDetectListener
in classorg.eclipse.swt.widgets.Control
-
removeMouseListener
public void removeMouseListener(org.eclipse.swt.events.MouseListener listener)- Overrides:
removeMouseListener
in classorg.eclipse.swt.widgets.Control
-
removeMouseMoveListener
public void removeMouseMoveListener(org.eclipse.swt.events.MouseMoveListener listener)- Overrides:
removeMouseMoveListener
in classorg.eclipse.swt.widgets.Control
-
removeMouseTrackListener
public void removeMouseTrackListener(org.eclipse.swt.events.MouseTrackListener listener)- Overrides:
removeMouseTrackListener
in classorg.eclipse.swt.widgets.Control
-
removeMouseWheelListener
public void removeMouseWheelListener(org.eclipse.swt.events.MouseWheelListener listener)- Overrides:
removeMouseWheelListener
in classorg.eclipse.swt.widgets.Control
-
removePaintListener
public void removePaintListener(org.eclipse.swt.events.PaintListener listener)- Overrides:
removePaintListener
in classorg.eclipse.swt.widgets.Control
-
removeTraverseListener
public void removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)- Overrides:
removeTraverseListener
in classorg.eclipse.swt.widgets.Control
-
notifyListeners
public void notifyListeners(int eventType, org.eclipse.swt.widgets.Event event)- Overrides:
notifyListeners
in classorg.eclipse.swt.widgets.Widget
-
removeDisposeListener
public void removeDisposeListener(org.eclipse.swt.events.DisposeListener listener)- Overrides:
removeDisposeListener
in classorg.eclipse.swt.widgets.Widget
-
removeListener
public void removeListener(int eventType, org.eclipse.swt.widgets.Listener listener)- Overrides:
removeListener
in classorg.eclipse.swt.widgets.Widget
-
getActiveComboControl
public org.eclipse.swt.widgets.Composite getActiveComboControl()
-