bibliothek.gui.dock.control
Class DockRegister

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

@LayoutLocked(locked=false)
public class DockRegister
extends Object

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

Author:
Benjamin Sigg

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 registerListeners that a Dockable has been registered.
protected  void fireDockableRegistering(Dockable dockable)
          Informs all registerListeners that a Dockable will be registered.
protected  void fireDockableUnregistered(Dockable dockable)
          Informs all registerListeners that a Dockable has been unregistered.
protected  void fireDockStationRegistered(DockStation station)
          Informs all registerListeners that station has been registered.
protected  void fireDockStationRegistering(DockStation station)
          Informs all registerListeners that station will be registered.
protected  void fireDockStationUnregistered(DockStation station)
          Informs all registerListeners that station has been unregistered.
protected  void fireStalled()
          Informs all DockRegisterListener that this DockRegister is stalled.
protected  void fireStalledChange(Dockable dockable)
          Informs all RegisterListeners that dockable cycled the register.
protected  void fireUnstalled()
          Informs all DockRegisterListeners that this DockRegister is no longer stalled.
 DockController getController()
          Gets the controller for which this register stores Dockables and DockStations.
 Dockable getDockable(int index)
          Gets the index'th Dockable that is registered at this DockRegister.
 int getDockableCount()
          Gets the number of dockables registered at this DockRegister.
 DockStation getStation(int index)
          Gets the station at the specified position.
 int getStationCount()
          Gest the number of stations that are registered.
 boolean isProtected(DockStation station)
          Tells whether station is protected.
 boolean isRegistered(Dockable dockable)
          Tells whether dockable is known to this register.
 boolean isStalled()
          Whether the register is currently stalled and does not forward changes to the tree.
 void kill()
          Removes all registerListeners and connections to the stations and dockables known to this register.
 Dockable[] listDockables()
          Gets a list of all Dockables.
protected  DockRegisterListener[] listDockRegisterListeners()
          Gets a list of all registerListeners 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, boolean requiresListener)
          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 setProtected(DockStation station, boolean protect)
          Marks station as protected.
 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.
 boolean willBeRegistered(Dockable dockable)
          Tells whether dockable will be registered after the currently stalled events have been fired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 registerListeners and connections to the stations and dockables known to this register.


setProtected

public void setProtected(DockStation station,
                         boolean protect)
Marks station as protected. Any DockStation can be protected, a protected DockStation will never be automatically unregistered due to loosing its parent. Instead of unregistering, a protected station is promoted to root-station. This property is only stored for DockStations which are already registered, it will be deleted if station is removed.

Parameters:
station - the station to protect
protect - the new protection state

isProtected

public boolean isProtected(DockStation station)
Tells whether station is protected.

Parameters:
station - the station to search
Returns:
the protected state
See Also:
setProtected(DockStation, boolean)

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

getDockableCount

public int getDockableCount()
Gets the number of dockables registered at this DockRegister.

Returns:
the number of dockables

getDockable

public Dockable getDockable(int index)
Gets the index'th Dockable that is registered at this DockRegister.

Parameters:
index - the location of the Dockable
Returns:
the element

isRegistered

public boolean isRegistered(Dockable dockable)
Tells whether dockable is known to this register.

Parameters:
dockable - the dockable to search
Returns:
true if dockable was found

willBeRegistered

public boolean willBeRegistered(Dockable dockable)
Tells whether dockable will be registered after the currently stalled events have been fired. The result of this method may change with any new stalled event. Returns the same result as isRegistered(Dockable) if there are no stalled events waiting.

Parameters:
dockable - the element to search
Returns:
whether dockable will be known to this register

listDockables

public Dockable[] listDockables()
Gets a list of all Dockables.

Returns:
the list of Dockables

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,
                        boolean requiresListener)
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
requiresListener - if true, then the DockStationListener of this DockRegister will be added to station, if false the listener will not be added

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 registerListeners which are registered.

Returns:
the list of registerListeners

fireDockableRegistering

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

Parameters:
dockable - the Dockable which will be registered

fireDockableRegistered

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

Parameters:
dockable - the registered Dockable

fireDockableUnregistered

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

Parameters:
dockable - the unregistered Dockable

fireDockStationRegistering

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

Parameters:
station - the new station

fireDockStationRegistered

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

Parameters:
station - the new station

fireDockStationUnregistered

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

Parameters:
station - the unregistered station

fireStalledChange

protected void fireStalledChange(Dockable dockable)
Informs all RegisterListeners that dockable cycled the register.

Parameters:
dockable - the cycling element

fireStalled

protected void fireStalled()
Informs all DockRegisterListener that this DockRegister is stalled.


fireUnstalled

protected void fireUnstalled()
Informs all DockRegisterListeners that this DockRegister is no longer stalled.


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.
Nested calls to this method are possible, if setStalled was called two times with true, then the events will be fired only after setStalled was called twice with false.

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

isStalled

public boolean isStalled()
Whether the register is currently stalled and does not forward changes to the tree.

Returns:
true if stalled