bibliothek.gui.dock
Class SingleParentRemover

java.lang.Object
  extended by bibliothek.gui.dock.SingleParentRemover

public class SingleParentRemover
extends java.lang.Object

An observer of a DockController. The remover ensures that there is no dockable DockStation with only one or none child.

Author:
Benjamin Sigg

Nested Class Summary
private  class SingleParentRemover.Listener
          Listens to a DockController and call testAll(DockController) if the structure of the dock-tree changes.
 
Field Summary
private  SingleParentRemover.Listener listener
          A listener added to a controller
private  boolean onTest
          state, ensures that no station is tested more than once in a run
 
Constructor Summary
SingleParentRemover()
           
 
Method Summary
 void install(DockController controller)
          Commands this remover to observe controller.
protected  boolean shouldTest(DockStation station)
          Tells whether station should be automatically removed or just be ignored.
private  boolean test(DockStation station)
          Tries to replace station with its only child or remove station if it has no children at all.
 void testAll(DockController controller)
          Tests all stations of controller and removes as many of them as possible
 void uninstall(DockController controller)
          Commands this remover that it should no longer observe controller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listener

private SingleParentRemover.Listener listener
A listener added to a controller


onTest

private boolean onTest
state, ensures that no station is tested more than once in a run

Constructor Detail

SingleParentRemover

public SingleParentRemover()
Method Detail

install

public void install(DockController controller)
Commands this remover to observe controller.

Parameters:
controller - a controller to observe

uninstall

public void uninstall(DockController controller)
Commands this remover that it should no longer observe controller.

Parameters:
controller - a controller

testAll

public void testAll(DockController controller)
Tests all stations of controller and removes as many of them as possible

Parameters:
controller - the controller to test

shouldTest

protected boolean shouldTest(DockStation station)
Tells whether station should be automatically removed or just be ignored.

Parameters:
station - a station to test
Returns:
true if the station may be removed by this remover, false otherwise.

test

private boolean test(DockStation station)
Tries to replace station with its only child or remove station if it has no children at all. If the parent of station refuses to accept the replacement or station refuses to let its child go, nothing will happen.

Parameters:
station - the station to test
Returns:
whether the station was replaced or removed