de.jaret.util.ui.datechooser
Class DateChooserPanel

java.lang.Object
  extended by org.eclipse.swt.widgets.Widget
      extended by org.eclipse.swt.widgets.Control
          extended by org.eclipse.swt.widgets.Scrollable
              extended by org.eclipse.swt.widgets.Composite
                  extended by de.jaret.util.ui.datechooser.DateChooserPanel
All Implemented Interfaces:
java.util.EventListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.graphics.Drawable, org.eclipse.swt.internal.SWTEventListener

public class DateChooserPanel
extends org.eclipse.swt.widgets.Composite
implements org.eclipse.swt.events.MouseListener

The DateChooserPanel is intended to be used as a dropdown for the DateFieldCombo (@see de.jaret.swt.util.datechooser.DateFieldCombo). However if it seems useful it is possible to be used as a standalone control for selecting a date. It features

TODO selectable font

Field Summary
protected static java.util.Calendar _calendar
          calendar instance.
protected  java.util.Date _date
          currently selected date.
protected static java.text.DateFormatSymbols _dateFormatSymbols
          date format symbols instance.
protected  de.jaret.util.ui.datechooser.DateChooserPanel.DayGrid _dayGrid
          the daygrid canvas.
protected  IAdditionalDayInformationProvider _dayInformationProvider
          provider for additional day information.
protected  org.eclipse.swt.widgets.Button _decMonthButton
          decrement month button.
protected  boolean _displayWeeks
          true: a columnn showing the number of the week in the year should be displayed.
protected  org.eclipse.swt.graphics.Color _holidayColor
          actual color for the foreground of holidays.
protected  de.jaret.util.date.holidayenumerator.HolidayEnumerator _holidayEnumerator
          holiday enumerator.
protected  org.eclipse.swt.widgets.Button _incMonthButton
          increment month button.
protected  java.util.List<IDateChooserListener> _listenerList
          listener list.
protected  java.util.Locale _locale
          locale for the panel.
protected  org.eclipse.swt.graphics.Color _markerColor
          actual color for the background marking.
protected  org.eclipse.swt.widgets.Label _monthLabel
          label displaying the month.
protected  boolean _oneClickSelection
          true: a single click will select.
protected  org.eclipse.swt.graphics.Color _specialDayColor
          actual color for the foreground of special days.
protected  org.eclipse.swt.widgets.Label _todayLabel
          label displaying teh current date.
protected static org.eclipse.swt.graphics.Color DEFAULTHOLIDAYCOLOR
          default color for drawing holidays.
protected static org.eclipse.swt.graphics.Color DEFAULTMARKERCOLOR
          default color for marking selected date in the panel.
protected static org.eclipse.swt.graphics.Color DEFAULTSPECIALDAYCOLOR
          default color for drawing special days.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
DateChooserPanel(org.eclipse.swt.widgets.Composite parent, int style)
          Constructor for the DateChooserPanel.
DateChooserPanel(org.eclipse.swt.widgets.Composite parent, int style, boolean oneClickSelection, boolean displayWeeks, java.util.Locale locale)
          Constructor for the DateChooserPanel.
 
Method Summary
 void addDateChooserListener(IDateChooserListener listener)
          Add a DateChooserListener to be informed about changes.
 void dispose()
          
protected  void fireChoosingCanceled()
          Inform listeners about cancellation f the choosing.
protected  void fireDateChosen(java.util.Date date)
          Inform listeners about a chosing action.
protected  void fireIntermediateChange(java.util.Date date)
          Inform listeners about an intermediate date change.
 IAdditionalDayInformationProvider getAdditionalDayInformationProvider()
          Retrieve the additional information provider.
 java.util.Date getDate()
          Get the selected Date.
 org.eclipse.swt.graphics.Color getHolidayColor()
          Retrieve the color used for painting the foreground of a holiday.
 de.jaret.util.date.holidayenumerator.HolidayEnumerator getHolidayEnumerator()
          Retrieve the HolidayEnumerator.
 org.eclipse.swt.graphics.Color getMarkerColor()
          Retrieve the color used for painting the background of the marked day.
 org.eclipse.swt.graphics.Color getSpecialDayColor()
          Retrieve the color used for painting the foreground of a special day.
 boolean isDisplayWeeks()
           
 boolean isOneClickSelection()
           
 void mouseDoubleClick(org.eclipse.swt.events.MouseEvent event)
          
 void mouseDown(org.eclipse.swt.events.MouseEvent event)
          
 void mouseUp(org.eclipse.swt.events.MouseEvent event)
          
 void redraw()
           Also redraws the grid.
 void remDateChooserListener(IDateChooserListener listener)
          Remove a DateChooserListener.
 void setAdditionalDayInformationProvider(IAdditionalDayInformationProvider informationProvider)
          Set an additional provider for day information.
 void setBackground(org.eclipse.swt.graphics.Color color)
           Propagate the change to the elements.
 void setDate(java.util.Date date)
          Set the currently selected date.
protected  boolean setDateByLocation(int x, int y)
          Sets the calendar day for a given location.
 void setDisplayWeeks(boolean displayWeeks)
          Set whether a column showing the week of the year should be displayed.
 void setHolidayColor(org.eclipse.swt.graphics.Color holidayColor)
          Set the color to paint the foreground of holidays.
 void setHolidayEnumerator(de.jaret.util.date.holidayenumerator.HolidayEnumerator holidayEnumerator)
          Set the HolidayEnumerator.
 void setMarkerColor(org.eclipse.swt.graphics.Color markerColor)
          Set the color to paint the background of the marked day.
 void setOneClickSelection(boolean oneClickSelection)
          Set whether a single or a double click will select the date.
 void setSpecialDayColor(org.eclipse.swt.graphics.Color specialDayColor)
          Set the color to paint the foreground of special days.
 
Methods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, computeSize, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, setBackgroundMode, setFocus, 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, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setEnabled, 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, 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

_date

protected java.util.Date _date
currently selected date.


_dateFormatSymbols

protected static java.text.DateFormatSymbols _dateFormatSymbols
date format symbols instance.


_calendar

protected static java.util.Calendar _calendar
calendar instance.


DEFAULTMARKERCOLOR

protected static final org.eclipse.swt.graphics.Color DEFAULTMARKERCOLOR
default color for marking selected date in the panel.


DEFAULTHOLIDAYCOLOR

protected static final org.eclipse.swt.graphics.Color DEFAULTHOLIDAYCOLOR
default color for drawing holidays.


DEFAULTSPECIALDAYCOLOR

protected static final org.eclipse.swt.graphics.Color DEFAULTSPECIALDAYCOLOR
default color for drawing special days.


_markerColor

protected org.eclipse.swt.graphics.Color _markerColor
actual color for the background marking.


_holidayColor

protected org.eclipse.swt.graphics.Color _holidayColor
actual color for the foreground of holidays.


_specialDayColor

protected org.eclipse.swt.graphics.Color _specialDayColor
actual color for the foreground of special days.


_displayWeeks

protected boolean _displayWeeks
true: a columnn showing the number of the week in the year should be displayed.


_oneClickSelection

protected boolean _oneClickSelection
true: a single click will select.


_holidayEnumerator

protected de.jaret.util.date.holidayenumerator.HolidayEnumerator _holidayEnumerator
holiday enumerator.


_dayInformationProvider

protected IAdditionalDayInformationProvider _dayInformationProvider
provider for additional day information.


_monthLabel

protected org.eclipse.swt.widgets.Label _monthLabel
label displaying the month.


_todayLabel

protected org.eclipse.swt.widgets.Label _todayLabel
label displaying teh current date.


_incMonthButton

protected org.eclipse.swt.widgets.Button _incMonthButton
increment month button.


_decMonthButton

protected org.eclipse.swt.widgets.Button _decMonthButton
decrement month button.


_dayGrid

protected de.jaret.util.ui.datechooser.DateChooserPanel.DayGrid _dayGrid
the daygrid canvas.


_listenerList

protected java.util.List<IDateChooserListener> _listenerList
listener list.


_locale

protected java.util.Locale _locale
locale for the panel.

Constructor Detail

DateChooserPanel

public DateChooserPanel(org.eclipse.swt.widgets.Composite parent,
                        int style,
                        boolean oneClickSelection,
                        boolean displayWeeks,
                        java.util.Locale locale)
Constructor for the DateChooserPanel.

Parameters:
parent - Composite parent
style - style bits
oneClickSelection - if true, a single mouse click will be considered a valid selection. Otherwise a selection will need a double click.
displayWeeks - if true the panel will display a week of the year column
locale - Locale to be used

DateChooserPanel

public DateChooserPanel(org.eclipse.swt.widgets.Composite parent,
                        int style)
Constructor for the DateChooserPanel. OneClickselection defaults to false, displayWeeks defaults to true. The Locale used is the default locale.

Parameters:
parent - Composite parent
style - style bits
Method Detail

dispose

public void dispose()

Overrides:
dispose in class org.eclipse.swt.widgets.Widget

setBackground

public void setBackground(org.eclipse.swt.graphics.Color color)
Propagate the change to the elements.

Overrides:
setBackground in class org.eclipse.swt.widgets.Control

setDate

public void setDate(java.util.Date date)
Set the currently selected date. A value of null will be transformed to the current date.

Parameters:
date - Date to be displayed

getDate

public java.util.Date getDate()
Get the selected Date.

Returns:
the currently selected date.

redraw

public void redraw()
Also redraws the grid.

Overrides:
redraw in class org.eclipse.swt.widgets.Control

mouseDoubleClick

public void mouseDoubleClick(org.eclipse.swt.events.MouseEvent event)

Specified by:
mouseDoubleClick in interface org.eclipse.swt.events.MouseListener

mouseDown

public void mouseDown(org.eclipse.swt.events.MouseEvent event)

Specified by:
mouseDown in interface org.eclipse.swt.events.MouseListener

mouseUp

public void mouseUp(org.eclipse.swt.events.MouseEvent event)

Specified by:
mouseUp in interface org.eclipse.swt.events.MouseListener

setDateByLocation

protected boolean setDateByLocation(int x,
                                    int y)
Sets the calendar day for a given location. This will succeed if a valid day (i.e. a day in the current month is selected).

Parameters:
x - x coordinate
y - y coordinate
Returns:
true if a valid day could be selected

addDateChooserListener

public void addDateChooserListener(IDateChooserListener listener)
Add a DateChooserListener to be informed about changes.

Parameters:
listener - the DateChooserListener to be added

remDateChooserListener

public void remDateChooserListener(IDateChooserListener listener)
Remove a DateChooserListener.

Parameters:
listener - the DateChooserListener to be removed

fireDateChosen

protected void fireDateChosen(java.util.Date date)
Inform listeners about a chosing action.

Parameters:
date - date chosen

fireIntermediateChange

protected void fireIntermediateChange(java.util.Date date)
Inform listeners about an intermediate date change.

Parameters:
date - date currently selected

fireChoosingCanceled

protected void fireChoosingCanceled()
Inform listeners about cancellation f the choosing.


getHolidayEnumerator

public de.jaret.util.date.holidayenumerator.HolidayEnumerator getHolidayEnumerator()
Retrieve the HolidayEnumerator.

Returns:
Returns the HolidayEnumerator.

setHolidayEnumerator

public void setHolidayEnumerator(de.jaret.util.date.holidayenumerator.HolidayEnumerator holidayEnumerator)
Set the HolidayEnumerator. A value of null is valid meaning no HolidayEnumerator should be used.

Parameters:
holidayEnumerator - The HolidayEnumerator to set.

getAdditionalDayInformationProvider

public IAdditionalDayInformationProvider getAdditionalDayInformationProvider()
Retrieve the additional information provider.

Returns:
the information provider

setAdditionalDayInformationProvider

public void setAdditionalDayInformationProvider(IAdditionalDayInformationProvider informationProvider)
Set an additional provider for day information.

Parameters:
informationProvider - the information provider

isDisplayWeeks

public boolean isDisplayWeeks()
Returns:
true if weeks should be displayed

setDisplayWeeks

public void setDisplayWeeks(boolean displayWeeks)
Set whether a column showing the week of the year should be displayed.

Parameters:
displayWeeks - if set to true a column with the number of the week in the year is displayed.

isOneClickSelection

public boolean isOneClickSelection()
Returns:
true if a single click will select the date

setOneClickSelection

public void setOneClickSelection(boolean oneClickSelection)
Set whether a single or a double click will select the date.

Parameters:
oneClickSelection - if set to true one click will select the date. If set to false the date selection requires a double click.

getMarkerColor

public org.eclipse.swt.graphics.Color getMarkerColor()
Retrieve the color used for painting the background of the marked day.

Returns:
the marker color

setMarkerColor

public void setMarkerColor(org.eclipse.swt.graphics.Color markerColor)
Set the color to paint the background of the marked day.

Parameters:
markerColor - color for the marker

getHolidayColor

public org.eclipse.swt.graphics.Color getHolidayColor()
Retrieve the color used for painting the foreground of a holiday.

Returns:
the holiday color

setHolidayColor

public void setHolidayColor(org.eclipse.swt.graphics.Color holidayColor)
Set the color to paint the foreground of holidays.

Parameters:
holidayColor - holiday color

getSpecialDayColor

public org.eclipse.swt.graphics.Color getSpecialDayColor()
Retrieve the color used for painting the foreground of a special day.

Returns:
the special day color

setSpecialDayColor

public void setSpecialDayColor(org.eclipse.swt.graphics.Color specialDayColor)
Set the color to paint the foreground of special days.

Parameters:
specialDayColor - color for special days


Copyright © 2012. All Rights Reserved.