bibliothek.gui.dock.control
Class DockRegister

java.lang.Object
  extended by bibliothek.gui.dock.control.DockRegister

public class DockRegister
extends java.lang.Object

A set of all Dockables and DockStations currently used in the system.

Author:
Benjamin Sigg

Nested Class Summary
private  class DockRegister.StationListener
          A listener to the controller of the enclosing register.
 
Field Summary
private  DockController controller
          The controller for which the dockables and stations are stored
private  java.util.List<Dockable> dockables
          the known dockables
private  java.util.List<DockRegisterListener> listeners
          a list of listeners which are informed whenever the registered dockables and stations change
private  boolean stalled
          tells whether register and unregister-events should be stalled or not
private  DockRegister.StationListener stationListener
          an observer of the stations
private  java.util.List<DockStation> stations
          the known stations
 
Constructor Summary
DockRegister(DockController controller)
          Creates a new register.
 
Method Summary
 void add(DockStation station)
          Adds a station to this register.
 void addDockRegisterListener(DockRegisterListener listener)
          Registers a listener which will receive notifications when a Dockable or a DockStation is added or removed from this register.
protected  void fireDockableRegistered(Dockable dockable)
          Informs all listeners that a Dockable has been registered.
protected  void fireDockableRegistering(Dockable dockable)
          Informs all listeners that a Dockable will be registered.
protected  void fireDockableUnregistered(Dockable dockable)
          Informs all listeners that a Dockable has been unregistered.
protected  void fireDockStationRegistered(DockStation station)
          Informs all listeners that station has been registered.
protected  void fireDockStationRegistering(DockStation station)
          Informs all listeners that station will be registered.
protected  void fireDockStationUnregistered(DockStation station)
          Informs all listeners that station has been unregistered.
 DockController getController()
          Gets the controller for which this register stores Dockables and DockStations.
 DockStation getStation(int index)
          Gets the station at the specified position.
 int getStationCount()
          Gest the number of stations that are registered.
 void kill()
          Removes all listeners and connections to the stations and dockables known to this register.
protected  DockRegisterListener[] listDockRegisterListeners()
          Gets a list of all listeners which are registered.
 DockStation[] listDockStations()
          Gets an array containing all known DockStations.
 DockStation[] listRoots()
          Gets a list of stations which have no parent and are therefore the roots of the dock-trees.
protected  void register(Dockable dockable)
          Registers dockable, the associated controller will know the titles of dockable to allow drag and drop operations.
Clients and subclasses should not call this method.
protected  void register(DockStation station)
          Registers station, the associated controller will support drag and drop for station.
Clients and subclasses should not call this method.
 void remove(DockStation station)
          Removes a station which was managed by this register.
 void removeDockRegisterListener(DockRegisterListener listener)
          Removes a listener from this register.
 void setStalled(boolean stalled)
          Sets whether the listener to all DockStation should forward changes of the tree to the un-/register-methods or not.
protected  void unregister(Dockable dockable)
          Unregisters dockable, the associated controller will no longer support drag and drop for dockable.
Clients and subclasses should not call this method.
protected  void unregister(DockStation station)
          Unregisters station, the associated controller will no longer support drag and drop operations for station.
Clients and subclasses should not call this method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stations

private java.util.List<DockStation> stations
the known stations


dockables

private java.util.List<Dockable> dockables
the known dockables


controller

private DockController controller
The controller for which the dockables and stations are stored


listeners

private java.util.List<DockRegisterListener> listeners
a list of listeners which are informed whenever the registered dockables and stations change


stationListener

private DockRegister.StationListener stationListener
an observer of the stations


stalled

private boolean stalled
tells whether register and unregister-events should be stalled or not

Constructor Detail

DockRegister

public DockRegister(DockController controller)
Creates a new register.

Parameters:
controller - the controller for which the dockables and stations are stored.
Method Detail

getController

public DockController getController()
Gets the controller for which this register stores Dockables and DockStations.

Returns:
the controller

addDockRegisterListener

public void addDockRegisterListener(DockRegisterListener listener)
Registers a listener which will receive notifications when a Dockable or a DockStation is added or removed from this register.

Parameters:
listener - the new listener

removeDockRegisterListener

public void removeDockRegisterListener(DockRegisterListener listener)
Removes a listener from this register.

Parameters:
listener - the listener to remove
See Also:
addDockRegisterListener(DockRegisterListener)

kill

public void kill()
Removes all listeners and connections to the stations and dockables known to this register.


add

public void add(DockStation station)
Adds a station to this register. The associated controller allows the user to drag and drop children from and to station. If the children of station are stations itself, then they will be added automatically

Parameters:
station - the new station

remove

public void remove(DockStation station)
Removes a station which was managed by this register.

Parameters:
station - the station to remove

getStationCount

public int getStationCount()
Gest the number of stations that are registered.

Returns:
the number of stations
See Also:
add(DockStation)

getStation

public DockStation getStation(int index)
Gets the station at the specified position.

Parameters:
index - the location
Returns:
the station

listDockStations

public DockStation[] listDockStations()
Gets an array containing all known DockStations.

Returns:
the modifiable array of stations

listRoots

public DockStation[] listRoots()
Gets a list of stations which have no parent and are therefore the roots of the dock-trees.

Returns:
the roots

register

protected void register(Dockable dockable)
Registers dockable, the associated controller will know the titles of dockable to allow drag and drop operations.
Clients and subclasses should not call this method.

Parameters:
dockable - a new Dockable

unregister

protected void unregister(Dockable dockable)
Unregisters dockable, the associated controller will no longer support drag and drop for dockable.
Clients and subclasses should not call this method.

Parameters:
dockable - the element to remove

register

protected void register(DockStation station)
Registers station, the associated controller will support drag and drop for station.
Clients and subclasses should not call this method.

Parameters:
station - the station to add

unregister

protected void unregister(DockStation station)
Unregisters station, the associated controller will no longer support drag and drop operations for station.
Clients and subclasses should not call this method.

Parameters:
station - the station to remove

listDockRegisterListeners

protected DockRegisterListener[] listDockRegisterListeners()
Gets a list of all listeners which are registered.

Returns:
the list of listeners

fireDockableRegistering

protected void fireDockableRegistering(Dockable dockable)
Informs all listeners that a Dockable will be registered.

Parameters:
dockable - the Dockable which will be registered

fireDockableRegistered

protected void fireDockableRegistered(Dockable dockable)
Informs all listeners that a Dockable has been registered.

Parameters:
dockable - the registered Dockable

fireDockableUnregistered

protected void fireDockableUnregistered(Dockable dockable)
Informs all listeners that a Dockable has been unregistered.

Parameters:
dockable - the unregistered Dockable

fireDockStationRegistering

protected void fireDockStationRegistering(DockStation station)
Informs all listeners that station will be registered.

Parameters:
station - the new station

fireDockStationRegistered

protected void fireDockStationRegistered(DockStation station)
Informs all listeners that station has been registered.

Parameters:
station - the new station

fireDockStationUnregistered

protected void fireDockStationUnregistered(DockStation station)
Informs all listeners that station has been unregistered.

Parameters:
station - the unregistered station

setStalled

public void setStalled(boolean stalled)
Sets whether the listener to all DockStation should forward changes of the tree to the un-/register-methods or not. If the register was stalled and now the argument is false, then all pending events will be handled immediately.

Parameters:
stalled - true if events should be stalled, false if all pending events should be handled and new events should be handled immediately