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.state.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.state.StateManager
StateManager.Location, StateManager.LocationConverter, StateManager.StateManagerSetting<B>
 
Field Summary
 
Fields inherited from class bibliothek.gui.dock.facile.state.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.
protected  CDockable.ExtendedMode convertMode(String mode)
          Converts mode into one of the CDockable.ExtendedModes.
protected  boolean createEntryDuringRead(String key)
          Tells whether an entry for a missing Dockable should be created.
 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.
 CLocation getLocation(Dockable dockable, CDockable.ExtendedMode mode)
          Assuming that dockable is currently not in mode mode, then this method searches for the previously stored location of dockable.
 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.
protected  void modeChanged(Dockable dockable, String oldMode, String newMode)
          Called when the mode of a known dockable has been changed.
 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.
protected  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 setLocation(Dockable dockable, CDockable.ExtendedMode mode, CLocation location)
          Sets the default location of dockable when going into mode.
 void setMaximizeBehavior(CMaximizeBehavior maximizeBehavior)
          Sets a new CMaximizeBehavior.
 void setMode(Dockable dockable, CDockable.ExtendedMode mode)
          Changes the mode of dockable.
 
Methods inherited from class bibliothek.gui.dock.facile.state.StateManager
add, add, add, addMaximizingArea, childsMode, createSetting, currentLocation, currentMode, currentModeSharp, ensureNotHidden, ensureNothingMaximized, getDefaultMode, getMaximizeArea, getMaximizeArea, getMaximized, getMaximizingArea, getMaximizingAreas, getRootName, getSetting, getStation, init, isOnTransition, putMode, remove, removeMaximizingArea, setMaximizingArea, setMaximizingStation, setSetting, store, store, transition, 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

protected 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

createEntryDuringRead

protected boolean createEntryDuringRead(String key)
Description copied from class: ModeTransitionManager
Tells whether an entry for a missing Dockable should be created. This will result in a call to ModeTransitionManager.addEmpty(String) during ModeTransitionManager.setSetting(ModeTransitionSetting). The default implementation returns always false.

Overrides:
createEntryDuringRead in class ModeTransitionManager<StateManager.Location>
Parameters:
key - the key for which to create a new entry
Returns:
true if an entry should be created

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)

setLocation

public void setLocation(Dockable dockable,
                        CDockable.ExtendedMode mode,
                        CLocation location)
Sets the default location of dockable when going into mode. The properties set here will be overridden as soon as the user drags dockable to another location (within the same mode) or dockable is removed permanently.
This method has no effect if dockable is already in mode. There is also no effect if dockable has not been registered at the CStateManager.
Note: it is the clients responsibility to ensure that location and mode belong to each other.

Parameters:
dockable - the element whose location will be set
mode - the mode for which the location is to be set
location - the new location
Throws:
IllegalArgumentException - if either argument is null or if CLocation.findRoot() or CLocation.findProperty() returns null

getLocation

public CLocation getLocation(Dockable dockable,
                             CDockable.ExtendedMode mode)
Assuming that dockable is currently not in mode mode, then this method searches for the previously stored location of dockable. Note that this method can't tell where dockable would be shown if it never was in that mode and the client never specified the location.

Parameters:
dockable - the dockable whose location is searched
mode - the mode which might be taken by dockable
Returns:
the location or null
Throws:
IllegalArgumentException - if any argument is null

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

convertMode

protected CDockable.ExtendedMode convertMode(String mode)
Converts mode into one of the CDockable.ExtendedModes.

Parameters:
mode - StateManager.EXTERNALIZED, StateManager.MAXIMIZED, StateManager.MINIMIZED or StateManager.NORMALIZED.
Returns:
the mode represented as CDockable.ExtendedMode

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.


modeChanged

protected void modeChanged(Dockable dockable,
                           String oldMode,
                           String newMode)
Description copied from class: ModeTransitionManager
Called when the mode of a known dockable has been changed. This method is intended to be overriden and does not do anything in its basic version.

Overrides:
modeChanged in class ModeTransitionManager<StateManager.Location>
Parameters:
dockable - the element whose mode changed
oldMode - the mode before the change
newMode - the mode after the change

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.