bibliothek.gui.dock.facile.mode.status
Class AbstractExtendedModeEnablement

java.lang.Object
  extended by bibliothek.gui.dock.facile.mode.status.AbstractExtendedModeEnablement
All Implemented Interfaces:
ExtendedModeEnablement
Direct Known Subclasses:
DefaultExtendedModeEnablement

public abstract class AbstractExtendedModeEnablement
extends java.lang.Object
implements ExtendedModeEnablement

Abstract implementation of an ExtendedModeEnablement. This implementation handles ExtendedModeEnablementListeners and tells subclasses when to add or remove listeners to or from Dockables.
Note: Subclasses must call init().

Author:
Benjamin Sigg

Constructor Summary
AbstractExtendedModeEnablement(LocationModeManager<?> manager)
          Creates a new enablement.
 
Method Summary
 void addListener(ExtendedModeEnablementListener listener)
          Adds a listener to this enablement, the listener has be informed if the availability state of a mode in respect to a dockable has changed.
protected abstract  void connect(Dockable dockable)
          Adds listeners to dockable in order to call fire(Dockable, ExtendedMode, boolean) once the availability of some mode changed.
 void destroy()
          Informs this enablement that it is no longer of any use.
protected abstract  void disconnect(Dockable dockable)
          Removes listeners from dockable that were added earlier.
protected  void fire(Dockable dockable, ExtendedMode mode, boolean available)
          Calls ExtendedModeEnablementListener.availabilityChanged(Dockable, ExtendedMode, boolean) for all listeners that are registered.
 LocationModeManager<?> getManager()
          Gets the manager in whose realm this enablement is used.
protected  void init()
          Initializes this enablement: adds a listener to the manager and calls connect(Dockable) for all known Dockables.
 void removeListener(ExtendedModeEnablementListener listener)
          Removes a listener from this enablement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.facile.mode.status.ExtendedModeEnablement
isAvailable
 

Constructor Detail

AbstractExtendedModeEnablement

public AbstractExtendedModeEnablement(LocationModeManager<?> manager)
Creates a new enablement. Subclasses should call init() afterwards.

Parameters:
manager - the manager in whose realm this enablement is used, not null
Method Detail

getManager

public LocationModeManager<?> getManager()
Gets the manager in whose realm this enablement is used.

Returns:
the manager, null if destroy() has been called.

init

protected void init()
Initializes this enablement: adds a listener to the manager and calls connect(Dockable) for all known Dockables.


addListener

public void addListener(ExtendedModeEnablementListener listener)
Description copied from interface: ExtendedModeEnablement
Adds a listener to this enablement, the listener has be informed if the availability state of a mode in respect to a dockable has changed. Only Dockables that are registered at the LocationModeManager have to be observed.

Specified by:
addListener in interface ExtendedModeEnablement
Parameters:
listener - the new listener

removeListener

public void removeListener(ExtendedModeEnablementListener listener)
Description copied from interface: ExtendedModeEnablement
Removes a listener from this enablement.

Specified by:
removeListener in interface ExtendedModeEnablement
Parameters:
listener - the listener to remove

fire

protected void fire(Dockable dockable,
                    ExtendedMode mode,
                    boolean available)
Calls ExtendedModeEnablementListener.availabilityChanged(Dockable, ExtendedMode, boolean) for all listeners that are registered.

Parameters:
dockable - the element which is affected
mode - the mode which is affected
available - the new availability state

destroy

public void destroy()
Description copied from interface: ExtendedModeEnablement
Informs this enablement that it is no longer of any use. The enablement should remove any listeners it added to any other object.

Specified by:
destroy in interface ExtendedModeEnablement

connect

protected abstract void connect(Dockable dockable)
Adds listeners to dockable in order to call fire(Dockable, ExtendedMode, boolean) once the availability of some mode changed.

Parameters:
dockable - the element which needs new listeners

disconnect

protected abstract void disconnect(Dockable dockable)
Removes listeners from dockable that were added earlier.

Parameters:
dockable - the element which is no longer to be connected