speedscheduler
Class DayOfWeekComposite

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 speedscheduler.DayOfWeekComposite
All Implemented Interfaces:
org.eclipse.swt.graphics.Drawable

 class DayOfWeekComposite
extends org.eclipse.swt.widgets.Composite

A widget that draws checkboxes for each day of the week and provides accessor methods for fetching user input.


Field Summary
private  boolean[] selectedDays
          Stores which days have been selected with the widget.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
DayOfWeekComposite(org.eclipse.swt.widgets.Composite parent)
          Creates a new DayOfWeekChooser using the style of the specified parent.
DayOfWeekComposite(org.eclipse.swt.widgets.Composite parent, boolean[] defaultSelectedDays)
          Creates a new DayOfWeekChooser given the specified parent Composite and style.
 
Method Summary
private  org.eclipse.swt.widgets.Button createDayOfWeekCheckbox(int dayOfWeek)
          Factory to crank out a checkbox for a day of the week, complete with text and a listener that calls handleDayOfWeekClick() on clicks.
private  void dumpSelectedDays()
          Prints to stderr the status for each day (whether selected or not)
protected  boolean[] getSelectedDays()
          Get the selected days array.
private  void handleDayOfWeekClick(org.eclipse.swt.widgets.Button buttonClicked, int dayOfWeek)
          When a day-of-week checkbox is clicked.
private  void initializeSelectedDays(boolean[] defaultSelectedDays)
          Initializes all days to false or to the specified defaults.
protected  boolean isDaySelected(int dayOfWeek)
          Gets whether a day is selected by day index.
private  void setDaySelected(int dayOfWeek, boolean selected)
          Wrapper access to selectedDays array.
 
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, getCursor, 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, 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, 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

selectedDays

private boolean[] selectedDays
Stores which days have been selected with the widget. Index 0 is Sunday, 1 is Monday, ..., and 6 is Saturday.

Constructor Detail

DayOfWeekComposite

public DayOfWeekComposite(org.eclipse.swt.widgets.Composite parent)
Creates a new DayOfWeekChooser using the style of the specified parent.


DayOfWeekComposite

public DayOfWeekComposite(org.eclipse.swt.widgets.Composite parent,
                          boolean[] defaultSelectedDays)
Creates a new DayOfWeekChooser given the specified parent Composite and style.

Method Detail

createDayOfWeekCheckbox

private org.eclipse.swt.widgets.Button createDayOfWeekCheckbox(int dayOfWeek)
Factory to crank out a checkbox for a day of the week, complete with text and a listener that calls handleDayOfWeekClick() on clicks.

Parameters:
dayOfWeek - The day of the week index from 0 to TimeUtils.WEEK_LEN-1.
Returns:
A Button ready for action.

handleDayOfWeekClick

private void handleDayOfWeekClick(org.eclipse.swt.widgets.Button buttonClicked,
                                  int dayOfWeek)
When a day-of-week checkbox is clicked.


setDaySelected

private void setDaySelected(int dayOfWeek,
                            boolean selected)
Wrapper access to selectedDays array.


initializeSelectedDays

private void initializeSelectedDays(boolean[] defaultSelectedDays)
Initializes all days to false or to the specified defaults.


isDaySelected

protected boolean isDaySelected(int dayOfWeek)
Gets whether a day is selected by day index.

Parameters:
dayOfWeek - Valid range is from 0 to TimeUtils.WEEK_LEN-1, where 0 represents the first day of the week (typically Sunday) and TimeUtils.WEEK_LEN-1 (typically 6, ie Saturday) represents the last day of the week.
Returns:
True if the specified dayOfWeek is selected, or false if not.

getSelectedDays

protected boolean[] getSelectedDays()
Get the selected days array. This returns an array of booleans of length TimeUtils.WEEK_LEN (typically 7) where each entry in the array indicates whether the day is selected (true) or not (false).

Returns:
The array of boolean selected days.

dumpSelectedDays

private void dumpSelectedDays()
Prints to stderr the status for each day (whether selected or not)