org.zaval.lw
Class LwSwitchManager

java.lang.Object
  |
  +--org.zaval.lw.LwSwitchManager
Direct Known Subclasses:
LwGroup, LwSwitchManImpl

public abstract class LwSwitchManager
extends java.lang.Object

This abstract class can be used to control state of switching components. The switching component is a component that can have one of the following two states: "off" or "on". The class provides ability to control state of the component by getState setState methods. The abstract methods have to be implemented.

It is possible to organize combined action for a set of switching components. For example, if we have group of switching components where only one component can be "on" at the given moment than we can use the class to implement appropriate switch manager. First of all we should have ability to register and unregister the components as a members of the set. For the purpose the class provides install and uninstall methods. Than we should implement getState and setState abstract methods. The input argument for install, uninstall and setState methods is Switchable interface. The interface has to be used as a callback interface to notify a switching component by calling switchedOff and switchedOn methods about changing state of the switching component.

The switch manager has to perform action events when a state has been changed. Use addActionListener and removeActionListener to register and unregister listeners of the events.


Constructor Summary
LwSwitchManager()
           
 
Method Summary
 void addActionListener(LwActionListener a)
          Adds the specified action listener to receive action events from this manager.
abstract  boolean getState(Switchable o)
          Gets state for the specified switching component.
 void install(Switchable o)
          Registers the specified switching component that wants to use the manager.
protected  void perform(Switchable s)
          Fires the action event for the list of LwActionListener with the specified switching component as the event source.
 void removeActionListener(LwActionListener a)
          Removes the specified action listener so it no longer receives action events from this manager.
abstract  void setState(Switchable o, boolean b)
          Sets the specified state for the switching component.
 void uninstall(Switchable o)
          Unregisters the specified switching component that doesn't want to use the manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LwSwitchManager

public LwSwitchManager()
Method Detail

install

public void install(Switchable o)
Registers the specified switching component that wants to use the manager.
Parameters:
o - the specified switching component.

uninstall

public void uninstall(Switchable o)
Unregisters the specified switching component that doesn't want to use the manager.
Parameters:
o - the specified switching component.

addActionListener

public void addActionListener(LwActionListener a)
Adds the specified action listener to receive action events from this manager.
Parameters:
a - the specified action listener.

removeActionListener

public void removeActionListener(LwActionListener a)
Removes the specified action listener so it no longer receives action events from this manager.
Parameters:
a - the specified action listener.

perform

protected void perform(Switchable s)
Fires the action event for the list of LwActionListener with the specified switching component as the event source.
Parameters:
s - the specified switching component.

getState

public abstract boolean getState(Switchable o)
Gets state for the specified switching component.
Parameters:
o - the specified switching component.
Returns:
true if the switching component has "on" state, false if it has "off" state.

setState

public abstract void setState(Switchable o,
                              boolean b)
Sets the specified state for the switching component.
Parameters:
o - the specified switching component.
b - the specified state. The true value corresponds to "on" state and false value corresponds to "off" state.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org