bibliothek.gui.dock.common.mode
Class CStationContainerHistoryRewriter

java.lang.Object
  extended by bibliothek.gui.dock.common.mode.CStationContainerHistoryRewriter
All Implemented Interfaces:
HistoryRewriter<Location,CLocationMode>

public class CStationContainerHistoryRewriter
extends Object
implements HistoryRewriter<Location,CLocationMode>

The CStationContainerHistoryRewriter tries to ensure that a CDockable stays on the same CStationContainer when changing the ExtendedMode.

Author:
Benjamin Sigg

Constructor Summary
CStationContainerHistoryRewriter(CControl control)
          Creates a new rewriter
 
Method Summary
protected  CStationContainer getContainer(CStation<?> child)
          Searches the CStationContainer which is the parent of child.
 CControl getControl()
          Gets the CControl that is using this rewriter.
protected  CStation<?> getMatchingStation(Dockable dockable, ExtendedMode mode)
          Searches a CStation which could be the new parent of dockable if it should be in mode mode.
protected  CStation<?> getMatchingStation(Dockable dockable, String root)
          Given the current location of dockable and the root station it is going to use, this method decides which CStation is actually going to be the new parent root station.
protected  CStation<?> getParent(Dockable dockable)
          Gets the first parent CStation of dockable.
 Location rewrite(Dockable dockable, CLocationMode mode, Location history)
          Checks whether the history object history is still valid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CStationContainerHistoryRewriter

public CStationContainerHistoryRewriter(CControl control)
Creates a new rewriter

Parameters:
control - provides the list of CStationContainers to check
Method Detail

getControl

public CControl getControl()
Gets the CControl that is using this rewriter.

Returns:
the control

getMatchingStation

protected CStation<?> getMatchingStation(Dockable dockable,
                                         String root)
Given the current location of dockable and the root station it is going to use, this method decides which CStation is actually going to be the new parent root station.

Parameters:
dockable - the element that is going to be moved around
root - the new root station
Returns:
a replacement for root, a value of null means that root should be used.

getMatchingStation

protected CStation<?> getMatchingStation(Dockable dockable,
                                         ExtendedMode mode)
Searches a CStation which could be the new parent of dockable if it should be in mode mode.

Parameters:
dockable - the element for which a new parent is searched
mode - the mode element should be in
Returns:
the new parent or null

getParent

protected CStation<?> getParent(Dockable dockable)
Gets the first parent CStation of dockable.

Parameters:
dockable - some dockable whose parent station is searched
Returns:
the parent station or null if not found

getContainer

protected CStationContainer getContainer(CStation<?> child)
Searches the CStationContainer which is the parent of child.

Parameters:
child - some CStation whose parent is searched
Returns:
the parent of child or null

rewrite

public Location rewrite(Dockable dockable,
                        CLocationMode mode,
                        Location history)
Description copied from interface: HistoryRewriter
Checks whether the history object history is still valid.

Specified by:
rewrite in interface HistoryRewriter<Location,CLocationMode>
Parameters:
dockable - the element which is about to change its mode
mode - the mode that is going to be applied
history - the history object that will be forwarded to mode, may be null
Returns:
the history object to use, may be null