semorg.gui.util
Class CalendarControl

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 semorg.gui.util.CalendarControl
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

public class CalendarControl
extends org.eclipse.swt.widgets.Composite

This class provides a CalendarControl which enables the user to select a date in very comfortable manner.


Nested Class Summary
private  class CalendarControl.SWTCalendar
          This class provides the calendar of the control.
 class CalendarControl.SWTCalendarEvent
          The Class SWTCalendarEvent.
static interface CalendarControl.SWTCalendarListener
          The listener interface for receiving SWTCalendar events.
private  class CalendarControl.SWTCalendarPopup
          The Class SWTCalendarPopup.
static interface CalendarControl.SWTCalendarPopupListener
          The listener interface for receiving SWTCalendarPopup events.
 class CalendarControl.SWTDayChooser
          The Class SWTDayChooser.
private  class CalendarControl.SWTMonthChooser
          The Class SWTMonthChooser.
 
Field Summary
private  boolean activated
          true if the popup window is open, false otherwise.
private  org.eclipse.swt.widgets.Text backgroundHack
          The background hack.
private  org.eclipse.swt.widgets.Button checker
          The button to activate the control.
private  Date date
          The date displayed in the control.
private  List<CalendarControl.SWTCalendarListener> dateChangeListeners
          The date change listeners.
private  org.eclipse.swt.widgets.Button openPopupButton
          The button to open th popup.
private  org.eclipse.swt.widgets.Composite parent
          The parent composite.
private  CalendarControl.SWTCalendarPopup popup
          The popup.
private  List<CalendarControl.SWTCalendarPopupListener> popupListeners
          The popup listeners.
private  org.eclipse.swt.widgets.Text t
          The text field to display the date.
private  int titleBarHeight
          The title bar height.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
CalendarControl(org.eclipse.swt.widgets.Composite par, int tbh)
          Instantiates a new calendar control.
 
Method Summary
 void addSWTCalendarlistener(CalendarControl.SWTCalendarListener listener)
          Adds the given SWT calendar listener from the dateChangeListeners vector.
 void addSWTCalendarPopuplistener(CalendarControl.SWTCalendarPopupListener listener)
          Adds the given SWT calendar popup listener to popupListeners.
 void closePopup()
          Closes popup window.
private  void fireSWTCalendarDateChanged()
          Fires all CalendarControl.SWTCalendarListener instances in the dateChangeListeners Vector.
private  void fireSWTCalendarPopupClosed()
          Fires all CalendarControl.SWTCalendarListener in the vector popupListeners.
private  void fireSWTCalendarPopupOpened()
          Fires all CalendarControl.SWTCalendarListener instances in the vector popupListeners.
 Date getDate()
          Returns the date.
 org.eclipse.swt.widgets.Button getOpenPopupButton()
          Return button to open the popup.
 boolean isPopupOpen()
          Checks if the popup window is open.
private  void onOpen()
          This method is invoked on clicking the openPopupButton.
 void removeSWTCalendarlistener(CalendarControl.SWTCalendarListener listener)
          Removes the given SWT calendar listener from the dateChangeListeners vector.
 void removeSWTCalendarPopuplistener(CalendarControl.SWTCalendarPopupListener listener)
          Removes the given SWT calendar popup listener from popupListeners.
 void setActivated(boolean activ)
          Sets activated to the give value, i.e. activates / deactivates the calendar control.
 void setDate(Date d)
          Sets the date displayed in the text field to the given value..
 void setEnabled(boolean enabled)
          Enables the receiver if the argument is true, and disables it otherwise.
 void setFont(org.eclipse.swt.graphics.Font font)
          Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.
 void setToolTipText(String toolTipText)
          Sets the tooltip the CalendarControl to the given string.
 
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, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setForeground, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, 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

parent

private final org.eclipse.swt.widgets.Composite parent
The parent composite.


t

private final org.eclipse.swt.widgets.Text t
The text field to display the date.


openPopupButton

private final org.eclipse.swt.widgets.Button openPopupButton
The button to open th popup.


checker

private final org.eclipse.swt.widgets.Button checker
The button to activate the control.


date

private Date date
The date displayed in the control.


titleBarHeight

private int titleBarHeight
The title bar height.


backgroundHack

private org.eclipse.swt.widgets.Text backgroundHack
The background hack.


activated

private boolean activated
true if the popup window is open, false otherwise.


dateChangeListeners

private List<CalendarControl.SWTCalendarListener> dateChangeListeners
The date change listeners.


popupListeners

private List<CalendarControl.SWTCalendarPopupListener> popupListeners
The popup listeners.


popup

private CalendarControl.SWTCalendarPopup popup
The popup.

Constructor Detail

CalendarControl

public CalendarControl(org.eclipse.swt.widgets.Composite par,
                       int tbh)
Instantiates a new calendar control.

Parameters:
par - the parent composite
tbh - the tbh
Method Detail

onOpen

private void onOpen()
This method is invoked on clicking the openPopupButton. It activates the calendar control, i.e. it opens the popup.


fireSWTCalendarPopupClosed

private void fireSWTCalendarPopupClosed()
Fires all CalendarControl.SWTCalendarListener in the vector popupListeners.


fireSWTCalendarPopupOpened

private void fireSWTCalendarPopupOpened()
Fires all CalendarControl.SWTCalendarListener instances in the vector popupListeners.


setActivated

public void setActivated(boolean activ)
Sets activated to the give value, i.e. activates / deactivates the calendar control. If deactivated the controls appears "grayed".

Parameters:
activ - the new activated state.

getDate

public Date getDate()
Returns the date.

Returns:
the date if activated is true, null otherwise.

setFont

public void setFont(org.eclipse.swt.graphics.Font font)
Sets the font that the receiver will use to paint textual information to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Overrides:
setFont in class org.eclipse.swt.widgets.Control
Parameters:
font - the new font (or null)
See Also:
Control.setFont(org.eclipse.swt.graphics.Font)

setDate

public void setDate(Date d)
Sets the date displayed in the text field to the given value..

Parameters:
d - the new date to display.

addSWTCalendarPopuplistener

public void addSWTCalendarPopuplistener(CalendarControl.SWTCalendarPopupListener listener)
Adds the given SWT calendar popup listener to popupListeners.

Parameters:
listener - the listener to add.

removeSWTCalendarPopuplistener

public void removeSWTCalendarPopuplistener(CalendarControl.SWTCalendarPopupListener listener)
Removes the given SWT calendar popup listener from popupListeners.

Parameters:
listener - the listener to remove.

addSWTCalendarlistener

public void addSWTCalendarlistener(CalendarControl.SWTCalendarListener listener)
Adds the given SWT calendar listener from the dateChangeListeners vector.

Parameters:
listener - the listener

removeSWTCalendarlistener

public void removeSWTCalendarlistener(CalendarControl.SWTCalendarListener listener)
Removes the given SWT calendar listener from the dateChangeListeners vector.

Parameters:
listener - the listener to remove.

fireSWTCalendarDateChanged

private void fireSWTCalendarDateChanged()
Fires all CalendarControl.SWTCalendarListener instances in the dateChangeListeners Vector.


setEnabled

public void setEnabled(boolean enabled)
Enables the receiver if the argument is true, and disables it otherwise.

A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

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

getOpenPopupButton

public org.eclipse.swt.widgets.Button getOpenPopupButton()
Return button to open the popup.

Returns:
Button instance to open the popup.

isPopupOpen

public boolean isPopupOpen()
Checks if the popup window is open.

Returns:
true, if the popup is open, otherwise false.

closePopup

public void closePopup()
Closes popup window.


setToolTipText

public void setToolTipText(String toolTipText)
Sets the tooltip the CalendarControl to the given string.

Overrides:
setToolTipText in class org.eclipse.swt.widgets.Control
Parameters:
toolTipText - the new tooltip text.