bibliothek.gui.dock.common.intern
Class CStateManager

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

public class CStateManager
extends StateManager

A manager that can change the extended-state of CDockables

Author:
Benjamin Sigg

Nested Class Summary
 
Nested classes/interfaces inherited from class bibliothek.gui.dock.facile.action.StateManager
StateManager.Location, StateManager.LocationConverter, StateManager.StateManagerSetting<B>
 
Field Summary
 
Fields inherited from class bibliothek.gui.dock.facile.action.StateManager
EXTERNALIZED, ICON_MANAGER_KEY_EXTERNALIZE, ICON_MANAGER_KEY_MAXIMIZE, ICON_MANAGER_KEY_MINIMIZE, ICON_MANAGER_KEY_NORMALIZE, MAXIMIZED, MINIMIZED, NORMALIZED
 
Constructor Summary
CStateManager(CControlAccess control)
          Creates a new manager
 
Method Summary
protected  void added(Dockable dockable)
          Called when a Dockable has been added to this manager.
protected  String[] availableModes(String current, Dockable dockable)
          Makes a list of all modes dockable can be going into.
 CDockable.ExtendedMode childsExtendedMode(DockStation station)
          Finds out which mode a child of station would have.
protected  String convertMode(CDockable.ExtendedMode mode)
          Converts mode into one of the strings StateManager.EXTERNALIZED, StateManager.MAXIMIZED, StateManager.MINIMIZED or StateManager.NORMALIZED.
 void ensureValidLocation(CDockable dockable)
          Ensures that dockable is in a valid location (a mode that is enabled by dockable and in the correct working area, perhaps changes the current location to ensure that.
protected  CStation getAreaOf(Dockable dockable)
          Searches dockable and its parent for the first CStation that is a working area.
protected  CContentArea getCenterOf(Dockable dockable)
          Searches the CContentArea on which dockable is shown.
protected  DockStation getDefaultNormal(Dockable dockable)
          Gets the DockStation which should be used as default normal parent for dockable.
 DockAction getIngoingAction(String mode, Dockable dockable)
          Gets the action that is used to go into mode mode and that is shown on dockable.
 CLocation getLocation(Dockable dockable)
          Gets an element describing the location of dockable as good as possible.
 CMaximizeBehavior getMaximizeBehavior()
          Gets the currently used maximize-behavior.
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.
 CDockable.ExtendedMode getMode(Dockable dockable)
          Gets the mode dockable is currently into.
protected  boolean isValidNormalized(Dockable dockable)
          Tells whether the element dockable is on a valid normalized area or not.
 void normalizeAllWorkingAreaChildren()
          Ensures that all CDockables which have a working area as parent, are in their preferred mode.
protected  boolean process(Dockable dockable, KeyEvent event)
          Invoked whenever a key is pressed, released or typed.
 void rebuild(Dockable dockable)
          Called when the list of actions for dockable has to be rebuild.
 void removed(Dockable dockable)
          Called after a Dockable was removed from this managar.
 void setLocation(CommonDockable dockable, CLocation location)
          Tries to set the location of dockable.
 void setMaximizeBehavior(CMaximizeBehavior maximizeBehavior)
          Sets a new CMaximizeBehavior.
 void setMode(Dockable dockable, CDockable.ExtendedMode mode)
          Changes the mode of dockable.
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.
 
Methods inherited from class bibliothek.gui.dock.facile.action.StateManager
add, add, add, childsMode, createSetting, currentLocation, currentMode, currentModeSharp, getDefaultMode, getRootName, getSetting, getStation, init, isOnTransition, putMode, remove, setMaximizingStation, setSetting, store, store, transitionDuringRead
 
Methods inherited from class bibliothek.gui.dock.support.action.ModeTransitionManager
add, addEmpty, getDockables, getIngoingAction, getName, getOutgoingAction, getOutgoingAction, getProperties, getSource, goIn, goOut, history, previousMode, put, putIngoingAction, putMode, putOutgoingAction, react, read, rebuildAll, reduceToEmpty, remove, removeEmpty, setMode, setProperties, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CStateManager

public CStateManager(CControlAccess control)
Creates a new manager

Parameters:
control - internal access to the CControl that uses this manager
Method Detail

getMaximizingElement

protected Dockable getMaximizingElement(Dockable dockable)
Description copied from class: StateManager
Gets the element which must be maximized when the user requests that dockable is maximized.

Overrides:
getMaximizingElement in class StateManager
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)
Description copied from class: StateManager
Gets the element which would be maximized if old is currently maximized, and dockable is or will not be maximized.

Overrides:
getMaximizingElement in class StateManager
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

added

protected void added(Dockable dockable)
Description copied from class: ModeTransitionManager
Called when a Dockable has been added to this manager.

Overrides:
added in class ModeTransitionManager<StateManager.Location>
Parameters:
dockable - the new dockable

removed

public void removed(Dockable dockable)
Description copied from class: ModeTransitionManager
Called after a Dockable was removed from this managar.

Overrides:
removed in class ModeTransitionManager<StateManager.Location>
Parameters:
dockable - the element that was removed

setMaximizeBehavior

public void setMaximizeBehavior(CMaximizeBehavior maximizeBehavior)
Sets a new CMaximizeBehavior. The behavior decides what happens when the user maximizes or un-maximizes a CDockable.

Parameters:
maximizeBehavior - the new behavior
Throws:
NullPointerException - if maximizeBehavior is null

getMaximizeBehavior

public CMaximizeBehavior getMaximizeBehavior()
Gets the currently used maximize-behavior.

Returns:
the behavior
See Also:
setMaximizeBehavior(CMaximizeBehavior)

setMode

public void setMode(Dockable dockable,
                    CDockable.ExtendedMode mode)
Changes the mode of dockable.

Parameters:
dockable - an element whose mode will be changed
mode - the new mode

getMode

public CDockable.ExtendedMode getMode(Dockable dockable)
Gets the mode dockable is currently into.

Parameters:
dockable - the questioned element
Returns:
the mode of dockable

childsExtendedMode

public CDockable.ExtendedMode childsExtendedMode(DockStation station)
Finds out which mode a child of station would have.

Parameters:
station - the station
Returns:
the mode or null if the station is unknown

setLocation

public void setLocation(CommonDockable dockable,
                        CLocation location)
Tries to set the location of dockable.

Parameters:
dockable - the element to move
location - the new location of dockable

convertMode

protected String convertMode(CDockable.ExtendedMode mode)
Converts mode into one of the strings StateManager.EXTERNALIZED, StateManager.MAXIMIZED, StateManager.MINIMIZED or StateManager.NORMALIZED.

Parameters:
mode - the mode, not null
Returns:
the mode represented as string

getLocation

public CLocation getLocation(Dockable dockable)
Gets an element describing the location of dockable as good as possible.

Parameters:
dockable - the element whose location should be searched
Returns:
the location or null if no location was found

getAreaOf

protected CStation getAreaOf(Dockable dockable)
Searches dockable and its parent for the first CStation that is a working area.

Parameters:
dockable - the element whose working area is searched
Returns:
the first working area or null

isValidNormalized

protected boolean isValidNormalized(Dockable dockable)
Description copied from class: StateManager
Tells whether the element dockable is on a valid normalized area or not.

Overrides:
isValidNormalized in class StateManager
Parameters:
dockable - the element to check
Returns:
true if dockable can remain at the location that it currently has

getCenterOf

protected CContentArea getCenterOf(Dockable dockable)
Searches the CContentArea on which dockable is shown.

Parameters:
dockable - the element whose center is searched
Returns:
the center or null

availableModes

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

Overrides:
availableModes in class StateManager
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

ensureValidLocation

public void ensureValidLocation(CDockable dockable)
Ensures that dockable is in a valid location (a mode that is enabled by dockable and in the correct working area, perhaps changes the current location to ensure that.

Parameters:
dockable - the element which might not be in a valid location

normalizeAllWorkingAreaChildren

public void normalizeAllWorkingAreaChildren()
Ensures that all CDockables which have a working area as parent, are in their preferred mode.


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.

Overrides:
transition in class StateManager
Parameters:
oldMode - the mode dockable is currently in
newMode - the mode dockable is going to be
dockable - the element that changes its mode

getDefaultNormal

protected DockStation getDefaultNormal(Dockable dockable)
Description copied from class: StateManager
Gets the DockStation which should be used as default normal parent for dockable.

Overrides:
getDefaultNormal in class StateManager
Parameters:
dockable - some Dockable
Returns:
the preferred normal parent for dockable or null

getIngoingAction

public DockAction getIngoingAction(String mode,
                                   Dockable dockable)
Description copied from class: ModeTransitionManager
Gets the action that is used to go into mode mode and that is shown on dockable.

Overrides:
getIngoingAction in class ModeTransitionManager<StateManager.Location>
Parameters:
mode - the mode whose ingoing action is searched
dockable - the element for which the action will be used
Returns:
the action or null

rebuild

public void rebuild(Dockable dockable)
Description copied from class: ModeTransitionManager
Called when the list of actions for dockable has to be rebuild.

Overrides:
rebuild in class ModeTransitionManager<StateManager.Location>
Parameters:
dockable - the element whose actions are searched

process

protected boolean process(Dockable dockable,
                          KeyEvent event)
Invoked whenever a key is pressed, released or typed.

Parameters:
dockable - the element to which the event belongs
event - the event
Returns:
true if the event has been processed, false if the event was not used up.