Package bibliothek.gui.dock.facile.mode
Class LocationModeManager<M extends LocationMode>
java.lang.Object
bibliothek.gui.dock.support.mode.ModeManager<Location,M>
bibliothek.gui.dock.facile.mode.LocationModeManager<M>
- Type Parameters:
M- the kind of mode this manager handles
- Direct Known Subclasses:
CLocationModeManager
ModeManager for the location of a Dockable. This manager is able to
work together with CControl or together with DockController. Clients
using it together with a DockController need to set icons for the
modes manually, they can use the IconManager and the keys provided in
each mode (e.g. NormalMode.ICON_IDENTIFIER).- Author:
- Benjamin Sigg
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyKey<DoubleClickLocationStrategy>PropertyKeyfor theDoubleClickLocationStrategythat should be used to change theExtendedModeof an element which has been double-clicked.static final PropertyKey<ExtendedModeEnablementFactory>PropertyKeyfor theExtendedModeEnablementthat should be used by aLocationModeManagerto activate and deactivate the modes. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(Path identifier, LocationModeListener listener) Adds a listener to the mode with unique identifieridentifier.voidapply(Dockable dockable, ExtendedMode extendedMode, CGroupMovement action) Executesactionin a transaction assuming that the result of this action will lead todockablehaving the new modeextendedMode.voidapply(Dockable dockable, M mode, Location history, AffectedSet set) Alters the mode ofdockableto bemode.protected voidapplyDuringRead(String key, Path old, Path current, Dockable dockable) Ignores the call, the position ofDockables is set elsewhere.voiddelayedRefresh(Dockable dockable) If theDockRegisteris currently stalled, then a call toModeManager.refresh(Dockable, boolean)is scheduled, otherwise the call is performed directly.voiddestroy()Unregisters listeners which this manager added to theDockControllerand other components.voidensureNotHidden(Dockable dockable) Ensures thatdockableis not hidden behind anotherDockable.voidensureValidLocation(Dockable dockable) Empty method evaluating the correct location of aDockable.Gets the action that is currently carried out.getCurrentMode(Dockable dockable) Tries to find the modedockableis currently in.Gets the current strategy for handing double-clicks.Gets the current group behavior.Gets the current mode ofdockable.Checks allLocationModes of this manager and returns allDockStations that were registered with the given id.getSharedActions(DockStation station) Gets a list of actions that should be shown onstationdepending on the current children ofstation.booleanTells whether this mode is currently in layouting mode.booleanisModeAvailable(Dockable dockable, ExtendedMode mode) Using the currentExtendedModeEnablementthis method tells whether modemodecan be applied todockable.booleanisModeHidden(Dockable dockable, ExtendedMode mode) Using the currentExtendedModeEnablementthis method tells whether modemodeis hidden from the user when looking atdockable.voidremoveListener(Path identifier, LocationModeListener listener) Removes a listener from the modeidentifier.voidActivates thelayout modewhilerunis running.voidSets the current strategy for handling double-clicks onDockables.voidsetGroupBehavior(CGroupBehavior behavior) Sets the group behavior.voidsetLocationAside(Dockable dockable, Dockable aside) Iterates through all theLocationModes for whichasidehas stored locations, and setsdockableas neighbor.voidsetMode(Dockable dockable, ExtendedMode extendedMode) Sets the current mode ofdockable.protected voidUpdates the currentExtendedModeEnablementusing the factory provided byMODE_ENABLEMENT.Methods inherited from class bibliothek.gui.dock.support.mode.ModeManager
add, addAffected, addEmpty, addModeManagerListener, addToModeHistory, apply, apply, apply, apply, apply, createEntryDuringRead, createModeSettings, createSettings, fireAdded, fireAdded, fireModeChanged, fireRemoved, fireRemoved, getController, getDefaultMode, getDoubleClickTarget, getFactories, getHistory, getHistoryRewriter, getKey, getMode, getModeHistory, getPreviousMode, getProperties, getPropertyHistory, isEmpty, isOnContinuous, isOnTransaction, isRegistered, listDockables, listeners, modes, put, putFactory, putMode, readSettings, readSettings, rebuild, rebuildAll, reduceToEmpty, refresh, refresh, remove, removeEmpty, removeMode, removeModeManagerListener, runTransaction, runTransaction, runTransaction, runTransaction, setHistoryRewriter, setProperties, store, store, toString, writeSettings
-
Field Details
-
MODE_ENABLEMENT
PropertyKeyfor theExtendedModeEnablementthat should be used by aLocationModeManagerto activate and deactivate the modes. -
DOUBLE_CLICK_STRATEGY
PropertyKeyfor theDoubleClickLocationStrategythat should be used to change theExtendedModeof an element which has been double-clicked.
-
-
Constructor Details
-
LocationModeManager
Creates a new manager.- Parameters:
controller- the controller in whose realm this manager will work
-
-
Method Details
-
destroy
public void destroy()Description copied from class:ModeManagerUnregisters listeners which this manager added to theDockControllerand other components.- Overrides:
destroyin classModeManager<Location,M extends LocationMode>
-
updateEnablement
protected void updateEnablement()Updates the currentExtendedModeEnablementusing the factory provided byMODE_ENABLEMENT. -
setGroupBehavior
Sets the group behavior. The group behavior is applied ifsetMode(Dockable, ExtendedMode)is called and modifies the call such that anotherDockablereceives the event. Any call directly to any of theapplymethods will not be modified by the group behavior.- Parameters:
behavior- the new behavior, notnull
-
getGroupBehavior
Gets the current group behavior.- Returns:
- the current behavior, not
null - See Also:
-
setMode
Sets the current mode ofdockable.- Parameters:
dockable- the dockable whose mode is to be setextendedMode- the mode- Throws:
IllegalArgumentException- ifextendedModeis unknown
-
getCurrentAction
Gets the action that is currently carried out.- Returns:
- the current action, can be
null
-
apply
Executesactionin a transaction assuming that the result of this action will lead todockablehaving the new modeextendedMode.- Parameters:
dockable- the primaryDockable, this item may very well be the new focus ownerextendedMode- the expected modedockablewill have afteractioncompletedaction- the action to execute
-
getMode
Gets the current mode ofdockable.- Parameters:
dockable- the element whose mode is searched- Returns:
- the mode or
nullif not found
-
getRepresentations
Checks allLocationModes of this manager and returns allDockStations that were registered with the given id. The same station or the same id might be used for different modes.- Parameters:
id- the id of some station- Returns:
- each mode-area pair where the area is not
null, can be empty
-
applyDuringRead
Ignores the call, the position ofDockables is set elsewhere.- Specified by:
applyDuringReadin classModeManager<Location,M extends LocationMode> - Parameters:
key- the identifier ofdockableold- the modedockableis currently incurrent- the modedockableis going to bedockable- the element that changes its mode, might benull
-
apply
Description copied from class:ModeManagerAlters the mode ofdockableto bemode. This method does not alter the modes of other dockables, notice however that the methodsMode.apply(Dockable, Object, AffectedSet)may trigger additional mode-changes.- Overrides:
applyin classModeManager<Location,M extends LocationMode> - Parameters:
dockable- the element whose mode is changedmode- the new mode ofdockablehistory- history information forMode.apply(Dockable, Object, AffectedSet), can benullset- to store elements that have changed
-
isModeAvailable
Using the currentExtendedModeEnablementthis method tells whether modemodecan be applied todockable.- Parameters:
dockable- some element, notnullmode- some mode, notnull- Returns:
- the result of
ExtendedModeEnablement.isAvailable(Dockable, ExtendedMode)
-
isModeHidden
Using the currentExtendedModeEnablementthis method tells whether modemodeis hidden from the user when looking atdockable. A hidden mode- Parameters:
dockable- some element, notnullmode- some mode, notnull- Returns:
- the result of
ExtendedModeEnablement.isAvailable(Dockable, ExtendedMode)
-
addListener
Adds a listener to the mode with unique identifieridentifier. If the mode is exchanged then this listener is automatically removed and may be re-added to the new mode.- Parameters:
identifier- the identifier of some mode (not necessarily registered yet).listener- the new listener, notnull
-
removeListener
Removes a listener from the modeidentifier.- Parameters:
identifier- the name of a modelistener- the listener to remove
-
getCurrentMode
Description copied from class:ModeManagerTries to find the modedockableis currently in. This method callsMode.isCurrentMode(Dockable)and returns the firstModewhere the answer wastrue.- Overrides:
getCurrentModein classModeManager<Location,M extends LocationMode> - Parameters:
dockable- some dockable, notnull- Returns:
- the current mode or
nullif not found
-
getDoubleClickStrategy
Gets the current strategy for handing double-clicks.- Returns:
- the strategy, never
null - See Also:
-
setDoubleClickStrategy
Sets the current strategy for handling double-clicks onDockables. This strategy will be asked what mode to assign to an element that has been double-clicked. Results that are not allowed by the currentExtendedModeEnablementare ignored.- Parameters:
strategy- the new strategy, can benullto set the default strategy
-
isLayouting
public boolean isLayouting()Tells whether this mode is currently in layouting mode. Some methods of this manager do not react while in layouting mode.- Returns:
trueif layouting mode is active
-
runLayoutTransaction
Activates thelayout modewhilerunis running.- Parameters:
run- some code to execute
-
ensureNotHidden
Ensures thatdockableis not hidden behind anotherDockable. That does not mean thatdockablebecomes visible, just that it is easier reachable without the need to change modes of anyDockables.
This method returns immediately if inlayouting mode- Parameters:
dockable- the element which should not be hidden
-
ensureValidLocation
Empty method evaluating the correct location of aDockable. To be overridden by subclasses to handle elements which have additional restrictions.- Parameters:
dockable- the element to check
-
setLocationAside
Iterates through all theLocationModes for whichasidehas stored locations, and setsdockableas neighbor. This method does not change the actual location ofdockable, rather a call toapplywould be necessary to update the location.
It is the responsibility of the caller to ensure thatdockablecan actually be placed at any location whereasideever was.- Parameters:
dockable- the item whose location should changeaside- the item whose neighbor is set
-
delayedRefresh
If theDockRegisteris currently stalled, then a call toModeManager.refresh(Dockable, boolean)is scheduled, otherwise the call is performed directly.- Parameters:
dockable- the dockable which should be forwarded toModeManager.refresh(Dockable, boolean)
-