bibliothek.gui.dock.facile.action
Class StateManager

java.lang.Object
  extended by bibliothek.gui.dock.support.action.ModeTransitionManager<StateManager.Location>
      extended by bibliothek.gui.dock.facile.action.StateManager
All Implemented Interfaces:
ActionGuard
Direct Known Subclasses:
CStateManager

public class StateManager
extends ModeTransitionManager<StateManager.Location>

A manager that can minimize/normalize/maximize and externalize a Dockable.

Author:
Benjamin Sigg

Nested Class Summary
static class StateManager.Location
          Describes the location of a Dockable.
static class StateManager.LocationConverter
          A transformer to read or write StateManager.Locations.
static class StateManager.StateManagerSetting<B>
          A set of properties used to store the contents of a StateManager
 
Field Summary
static String EXTERNALIZED
          key for the externalized mode
static String ICON_MANAGER_KEY_EXTERNALIZE
          the key used for the IconManager to read the Icon for the "externalize"-action
static String ICON_MANAGER_KEY_MAXIMIZE
          the key used for the IconManager to read the Icon for the "maximize"-action
static String ICON_MANAGER_KEY_MINIMIZE
          the key used for the IconManager to read the Icon for the "minimize"-action
static String ICON_MANAGER_KEY_NORMALIZE
          the key used for the IconManager to read the Icon for the "normalize"-action
static String MAXIMIZED
          key for the maximized mode
static String MINIMIZED
          key for the minimized mode
static String NORMALIZED
          key for the normalized mode
 
Constructor Summary
  StateManager(DockController controller)
          Creates a new manager.
protected StateManager(DockController controller, boolean init)
          Creates a new manager.
 
Method Summary
 void add(String name, FlapDockStation station)
          Adds a station to which a Dockable can be minimized.
 void add(String name, ScreenDockStation station)
          Adds a station to which a Dockable can be externalized.
 void add(String name, SplitDockStation station)
          Adds a station to which a Dockable can be normalized or maximized.
protected  String[] availableModes(String current, Dockable dockable)
          Makes a list of all modes dockable can be going into.
protected  String childsMode(DockStation station)
          Guesses the mode a child of station would have if it is dropped on station.
protected
<B> StateManager.StateManagerSetting<B>
createSetting(ModeTransitionConverter<StateManager.Location,B> converter)
          Creates a new, empty setting.
protected  StateManager.Location currentLocation(String mode, Dockable dockable)
          Creates the StateManager.Location describing the location of dockable.
protected  String currentMode(Dockable dockable)
          Gets the mode dockable is currently into.
protected  String currentModeSharp(Dockable dockable)
          Searches the current mode of dockable and returns the mode.
protected  String getDefaultMode(Dockable dockable)
          Gets the mode dockable should be go to if no other mode is preferred.
protected  DockStation getDefaultNormal(Dockable dockable)
          Gets the DockStation which should be used as default normal parent for dockable.
protected  Dockable getMaximizingElement(Dockable dockable)
          Gets the element which must be maximized when the user requests that dockable is maximized.
protected  Dockable getMaximizingElement(Dockable old, Dockable dockable)
          Gets the element which would be maximized if old is currently maximized, and dockable is or will not be maximized.
protected  String getRootName(Dockable dockable)
          Gets the name of the root of dockable.
<B> ModeTransitionSetting<StateManager.Location,B>
getSetting(ModeTransitionConverter<StateManager.Location,B> converter)
          Gets the current set or properties.
protected  DockStation getStation(String name)
          Gets the station that is registered under name.
protected  void init()
          Initializes all the elements of this manager.
 boolean isOnTransition()
          Tells whether this StateManager currently is executing a transition.
protected  boolean isValidNormalized(Dockable dockable)
          Tells whether the element dockable is on a valid normalized area or not.
protected  void putMode(Dockable dockable)
          Stores for each Dockable of the tree with the root dockable the current mode.
 void remove(String name)
          Removes the DockStation name from this manager.
 void setMaximizingStation(String name)
          Sets the station which should be used for maximized Dockables.
 void setSetting(ModeTransitionSetting<StateManager.Location,?> setting)
          Sets all properties of this manager.
protected  void store(Dockable dockable)
          Stores for each Dockable in the tree with the root dockable the location associated to their current mode.
protected  void store(String mode, Dockable dockable)
          Stores the location of dockable under the key mode.
protected  void transition(String oldMode, String newMode, Dockable dockable)
          Called when a Dockable has to change from one mode to another mode.
Subclasses might use ModeTransitionManager.getProperties(String, Dockable) and ModeTransitionManager.setProperties(String, Dockable, Object) to get or store properties associated with the mode.
protected  void transitionDuringRead(String oldMode, String newMode, Dockable dockable)
          Called while reading modes in ModeTransitionManager.setSetting(ModeTransitionSetting).
 
Methods inherited from class bibliothek.gui.dock.support.action.ModeTransitionManager
add, added, addEmpty, getDockables, getIngoingAction, getIngoingAction, getName, getOutgoingAction, getOutgoingAction, getProperties, getSource, goIn, goOut, history, previousMode, put, putIngoingAction, putMode, putOutgoingAction, react, read, rebuild, rebuildAll, reduceToEmpty, remove, removed, removeEmpty, setMode, setProperties, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ICON_MANAGER_KEY_MINIMIZE

public static final String ICON_MANAGER_KEY_MINIMIZE
the key used for the IconManager to read the Icon for the "minimize"-action

See Also:
Constant Field Values

ICON_MANAGER_KEY_MAXIMIZE

public static final String ICON_MANAGER_KEY_MAXIMIZE
the key used for the IconManager to read the Icon for the "maximize"-action

See Also:
Constant Field Values

ICON_MANAGER_KEY_NORMALIZE

public static final String ICON_MANAGER_KEY_NORMALIZE
the key used for the IconManager to read the Icon for the "normalize"-action

See Also:
Constant Field Values

ICON_MANAGER_KEY_EXTERNALIZE

public static final String ICON_MANAGER_KEY_EXTERNALIZE
the key used for the IconManager to read the Icon for the "externalize"-action

See Also:
Constant Field Values

MINIMIZED

public static final String MINIMIZED
key for the minimized mode

See Also:
Constant Field Values

MAXIMIZED

public static final String MAXIMIZED
key for the maximized mode

See Also:
Constant Field Values

NORMALIZED

public static final String NORMALIZED
key for the normalized mode

See Also:
Constant Field Values

EXTERNALIZED

public static final String EXTERNALIZED
key for the externalized mode

See Also:
Constant Field Values
Constructor Detail

StateManager

public StateManager(DockController controller)
Creates a new manager. Adds listeners to the controller and adds this as ActionGuard to the controller.

Parameters:
controller - the controller which is observed by this manager.

StateManager

protected StateManager(DockController controller,
                       boolean init)
Creates a new manager. Adds listeners to the controller and adds this as ActionGuard to the controller.

Parameters:
controller - the controller which is observed by this manager.
init - whether to initialize all the element of this manager or not. If false, then init() has to be called.
Method Detail

init

protected void init()
Initializes all the elements of this manager. That means adding listeners to the DockController, and setting text and icons of the DockActions used by this ModeTransitionManager.


getSetting

public <B> ModeTransitionSetting<StateManager.Location,B> getSetting(ModeTransitionConverter<StateManager.Location,B> converter)
Description copied from class: ModeTransitionManager
Gets the current set or properties.

Overrides:
getSetting in class ModeTransitionManager<StateManager.Location>
Type Parameters:
B - the type of the internal representation of the properties
Parameters:
converter - converts the properties into the internal representation
Returns:
the set of properties

setSetting

public void setSetting(ModeTransitionSetting<StateManager.Location,?> setting)
Description copied from class: ModeTransitionManager
Sets all properties of this manager. Registered elements which are not present in setting will not be affected by this method.

Overrides:
setSetting in class ModeTransitionManager<StateManager.Location>
Parameters:
setting - the set of properties

createSetting

protected <B> StateManager.StateManagerSetting<B> createSetting(ModeTransitionConverter<StateManager.Location,B> converter)
Description copied from class: ModeTransitionManager
Creates a new, empty setting.

Overrides:
createSetting in class ModeTransitionManager<StateManager.Location>
Type Parameters:
B - the type of properties stored in the setting
Parameters:
converter - used to convert properties of this manager to the properties of the setting
Returns:
the new setting

add

public void add(String name,
                SplitDockStation station)
Adds a station to which a Dockable can be normalized or maximized. If this is the first call to this method, then station becomes the default station for this kind or operation.

Parameters:
name - the name of the station
station - the new station.

setMaximizingStation

public void setMaximizingStation(String name)
Sets the station which should be used for maximized Dockables. Any currently maximized elements will be normalized.

Parameters:
name - the unique identifier of the station that should become the maximize area

add

public void add(String name,
                FlapDockStation station)
Adds a station to which a Dockable can be minimized. If this is the first call to this method, then station becomes the default station for this kind or operation.

Parameters:
name - the name of the station
station - the new station.

add

public void add(String name,
                ScreenDockStation station)
Adds a station to which a Dockable can be externalized. If this is the first call to this method, then station becomes the default station for this kind or operation.

Parameters:
name - the name of the station
station - the new station.

remove

public void remove(String name)
Removes the DockStation name from this manager. If the station is a default-station, then this property is set to null.

Parameters:
name - the name of the station to remove

availableModes

protected String[] availableModes(String current,
                                  Dockable dockable)
Description copied from class: ModeTransitionManager
Makes a list of all modes dockable can be going into.

Specified by:
availableModes in class ModeTransitionManager<StateManager.Location>
Parameters:
current - the mode dockable is currently in
dockable - the element whose available modes are searched
Returns:
an ordered list of available modes. If there is a logic for "going of of a mode", then the current mode should be included

currentMode

protected String currentMode(Dockable dockable)
Description copied from class: ModeTransitionManager
Gets the mode dockable is currently into. This method must also work if dockable is not registered at this ModeTransitionManager.

Specified by:
currentMode in class ModeTransitionManager<StateManager.Location>
Parameters:
dockable - the element whose mode is searched
Returns:
the current mode in dockable is, null is not valid.

currentModeSharp

protected String currentModeSharp(Dockable dockable)
Searches the current mode of dockable and returns the mode.

Parameters:
dockable - the element whose mode is searched
Returns:
the mode or null if the mode could not be found

childsMode

protected String childsMode(DockStation station)
Guesses the mode a child of station would have if it is dropped on station.

Parameters:
station - some station
Returns:
the mode or null. The mode is one of NORMALIZED, MINIMIZED or EXTERNALIZED. The mode MAXIMIZED will not be considered.

getDefaultMode

protected String getDefaultMode(Dockable dockable)
Description copied from class: ModeTransitionManager
Gets the mode dockable should be go to if no other mode is preferred.

Specified by:
getDefaultMode in class ModeTransitionManager<StateManager.Location>
Parameters:
dockable - the element whose default mode is asked
Returns:
the mode

isOnTransition

public boolean isOnTransition()
Tells whether this StateManager currently is executing a transition.

Returns:
true if currently in a transition.
See Also:
transition(String, String, Dockable)

transition

protected void transition(String oldMode,
                          String newMode,
                          Dockable dockable)
Description copied from class: ModeTransitionManager
Called when a Dockable has to change from one mode to another mode.
Subclasses might use ModeTransitionManager.getProperties(String, Dockable) and ModeTransitionManager.setProperties(String, Dockable, Object) to get or store properties associated with the mode.

Specified by:
transition in class ModeTransitionManager<StateManager.Location>
Parameters:
oldMode - the mode dockable is currently in
newMode - the mode dockable is going to be
dockable - the element that changes its mode

transitionDuringRead

protected void transitionDuringRead(String oldMode,
                                    String newMode,
                                    Dockable dockable)
Description copied from class: ModeTransitionManager
Called while reading modes in ModeTransitionManager.setSetting(ModeTransitionSetting). Subclasses might change the mode according to newMode.

Specified by:
transitionDuringRead in class ModeTransitionManager<StateManager.Location>
Parameters:
oldMode - the mode dockable is currently in
newMode - the mode dockable is going to be
dockable - the element that changes its mode

getMaximizingElement

protected Dockable getMaximizingElement(Dockable dockable)
Gets the element which must be maximized when the user requests that dockable is maximized.

Parameters:
dockable - some element, not null
Returns:
the element that must be maximized, might be dockable itself, not null

getMaximizingElement

protected Dockable getMaximizingElement(Dockable old,
                                        Dockable dockable)
Gets the element which would be maximized if old is currently maximized, and dockable is or will not be maximized.

Parameters:
old - some element
dockable - some element, might be old
Returns:
the element which would be maximized if dockable is no longer maximized, can be null

isValidNormalized

protected boolean isValidNormalized(Dockable dockable)
Tells whether the element dockable is on a valid normalized area or not.

Parameters:
dockable - the element to check
Returns:
true if dockable can remain at the location that it currently has

getDefaultNormal

protected DockStation getDefaultNormal(Dockable dockable)
Gets the DockStation which should be used as default normal parent for dockable.

Parameters:
dockable - some Dockable
Returns:
the preferred normal parent for dockable or null

store

protected void store(Dockable dockable)
Stores for each Dockable in the tree with the root dockable the location associated to their current mode.

Parameters:
dockable - a root of a tree

store

protected void store(String mode,
                     Dockable dockable)
Stores the location of dockable under the key mode.

Parameters:
mode - the mode dockable is currently in
dockable - the element whose location will be stored

putMode

protected void putMode(Dockable dockable)
Stores for each Dockable of the tree with the root dockable the current mode.

Parameters:
dockable - the element whose mode should be stored

currentLocation

protected StateManager.Location currentLocation(String mode,
                                                Dockable dockable)
Creates the StateManager.Location describing the location of dockable.

Parameters:
mode - the current mode
dockable - the element whose StateManager.Location is created
Returns:
the new StateManager.Location or null

getRootName

protected String getRootName(Dockable dockable)
Gets the name of the root of dockable.

Parameters:
dockable - the element whose station is searched
Returns:
the name of the root

getStation

protected DockStation getStation(String name)
Gets the station that is registered under name.

Parameters:
name - the name of the station
Returns:
the station or null