semorg.gui.util
Class TimeControl

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

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

The Class TimeControl provides widgets to enter times.


Nested Class Summary
static interface TimeControl.TimeChangeListener
          The listener interface for receiving timeChange events.
 
Field Summary
private  boolean activated
          Indicates if the composite is activated or not.
private  org.eclipse.swt.widgets.Text backgroundHack
          The background text field.
private  org.eclipse.swt.widgets.Button checker
          The button to enable the control.
private  org.eclipse.swt.graphics.Font defaultFont
          The default font.
private  boolean enabled
          If true the control is enabled, false otherwise.
private  org.eclipse.swt.widgets.Label floatingPoint
          The colon between the hours and minutes.
private  org.eclipse.swt.widgets.Spinner hours
          The hours spinner.
private  Set<TimeControl.TimeChangeListener> listeners
          The listeners which react on changes of the time.
private  org.eclipse.swt.widgets.Spinner minutes
          The minutes spinner.
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Constructor Summary
TimeControl(org.eclipse.swt.widgets.Composite par)
          Instantiates a new time control.
 
Method Summary
 void addTimeChangeListener(TimeControl.TimeChangeListener listener)
          Adds the time change listener.
private  void fireInputChanged()
          Fires all TimeControl.TimeChangeListener listener in the vector listeners.
 int getHours()
          Returns the hours of the hours control.
 int getMinutes()
          Returns the minutes of the minutes control.
 Time getTime()
          If acivated is true this method returns the time entered in the hours and minutes controls.
 void removeTimeChangeListener(TimeControl.TimeChangeListener listener)
          Removes the time change listener.
protected  void setActivated(boolean activ)
          Activates / deactivates the controls of this composite depending on the given parameter.
 void setData(String key, String value)
          Sets a pair of key and value to this control needed for testing with ATOSj.
 void setEnabled(boolean enabled)
          Enables the receiver if the argument is true, and disables it otherwise.
 void setTime(Time time)
          Sets time the given time to hours and minutes controls.
 void setToolTipText(String toolTipText)
          Sets the tooltip text of the composite to the tooltips of the checker, the floatingPoint, the hours and the minutes components, such that it appears if the user moves the mouse pointer of one of the visible components of the control.
 
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, setFont, 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

hours

private final org.eclipse.swt.widgets.Spinner hours
The hours spinner.


minutes

private final org.eclipse.swt.widgets.Spinner minutes
The minutes spinner.


checker

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


floatingPoint

private final org.eclipse.swt.widgets.Label floatingPoint
The colon between the hours and minutes.


backgroundHack

private org.eclipse.swt.widgets.Text backgroundHack
The background text field.


defaultFont

private final org.eclipse.swt.graphics.Font defaultFont
The default font.


activated

private boolean activated
Indicates if the composite is activated or not. This Composite delivers only time values if it is activated.


enabled

private boolean enabled
If true the control is enabled, false otherwise.


listeners

private Set<TimeControl.TimeChangeListener> listeners
The listeners which react on changes of the time.

Constructor Detail

TimeControl

public TimeControl(org.eclipse.swt.widgets.Composite par)
Instantiates a new time control.

Parameters:
par - the parent composite
Method Detail

getHours

public int getHours()
Returns the hours of the hours control.

Returns:
the hours as int or -1 if activated is null.

getMinutes

public int getMinutes()
Returns the minutes of the minutes control.

Returns:
the minutes as int or -1 if activated is null.

getTime

public Time getTime()
If acivated is true this method returns the time entered in the hours and minutes controls.

Returns:
the time from the controls.

fireInputChanged

private void fireInputChanged()
Fires all TimeControl.TimeChangeListener listener in the vector listeners.


addTimeChangeListener

public void addTimeChangeListener(TimeControl.TimeChangeListener listener)
Adds the time change listener.

Parameters:
listener - the listener to add

removeTimeChangeListener

public void removeTimeChangeListener(TimeControl.TimeChangeListener listener)
Removes the time change listener.

Parameters:
listener - the listener to remove

setTime

public void setTime(Time time)
Sets time the given time to hours and minutes controls. If the given time is null the controls get deactivated.

Parameters:
time - the new time

setActivated

protected void setActivated(boolean activ)
Activates / deactivates the controls of this composite depending on the given parameter.

Parameters:
activ - the new activated state

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
Parameters:
enabled - the new enabled state.

setData

public void setData(String key,
                    String value)
Sets a pair of key and value to this control needed for testing with ATOSj.

Parameters:
key - the key (type) of the value set
value - the value set to the control

setToolTipText

public void setToolTipText(String toolTipText)
Sets the tooltip text of the composite to the tooltips of the checker, the floatingPoint, the hours and the minutes components, such that it appears if the user moves the mouse pointer of one of the visible components of the control.

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