Package bibliothek.gui.dock.facile.mode
Class AbstractLocationMode<A extends ModeArea>
java.lang.Object
bibliothek.gui.dock.facile.mode.AbstractLocationMode<A>
- Type Parameters:
A- the values managed by this mode
- All Implemented Interfaces:
LocationMode,Mode<Location>,Iterable<A>
- Direct Known Subclasses:
DefaultLocationMode,MaximizedMode
public abstract class AbstractLocationMode<A extends ModeArea>
extends Object
implements Iterable<A>, LocationMode
This abstract class offers various properties that may be useful for any implementation
of
LocationMode. It also allows to store a set of ModeAreas. Basic methods
to verify and change the Mode of a Dockable are implemented too.- Author:
- Benjamin Sigg
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classMeta information about a currently registered Dockable. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds an area to this mode.voidaddLocationModeListener(LocationModeListener listener) Adds a listener to this mode.booleanapply(Dockable dockable, Location history, AffectedSet set) Applies this mode todockable.aside(AsideRequest request, Location location) CallsDockStation.aside(AsideRequest)on a station that matcheslocation.protected AbstractLocationMode<A>.DockableHandlecreateHandle(Dockable dockable) Creates a new handle fordockable.Recursively searches through all stations ofdockableuntil a station is found that is registered at this mode.Recursively searches through all stations ofdockableuntil a station is found that is registered at this mode.get(DockStation station) Recursively searches through all areas known to this mode until the mode is found that representsstation.Gets the area with the specified id.getActionsFor(Dockable dockable, Mode<Location> mode) Gets the controller in whose realm this mode works.Gets the default area of this mode, can benull.Gets the owner of this mode.getRepresentation(String uniqueId) Gets the oneDockStationthat is known with the root-iduniqueId.Gets all the unique identifiers that will yield a non-nullresult when callingLocationMode.getRepresentation(String).protected booleanisModeAvailable(Dockable dockable) Tells whether this mode is available fordockable.protected booleanisModeHidden(Dockable dockable) Tells whether this mode is hidden fordockable.booleanisRepresenting(DockStation station) Tells whether this mode knowsstationand represents the mode children ofstationare in.iterator()protected LocationModeListener[]Gets all the listeners that are currently registered at this mode.Removes the area with identifierkeyfrom this mode.voidRemoveslistenerfrom this mode.protected abstract booleanrunApply(Dockable dockable, Location history, AffectedSet set) Called byapply(Dockable, Location, AffectedSet)after theLocationModeListeners are informed.voidsetActionProvider(LocationModeActionProvider actionProvider) Sets theLocationModeActionProviderfor this mode.voidsetController(DockController controller) Connects this mode with a controller.voidsetDefaultArea(A defaultArea) Sets the default area of this mode.voidsetManager(LocationModeManager<?> manager) Sets the manager which is using this mode.voidsetShouldAutoFocus(boolean autoFocus) Sets the result ofshouldAutoFocus().booleanTells theLocationModeManagerwhether the focus should be transferred to aDockablethat has this mode.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface bibliothek.gui.dock.facile.mode.LocationMode
ensureNotHidden, getExtendedMode, isCurrentModeMethods inherited from interface bibliothek.gui.dock.support.mode.Mode
current, getSettingFactory, getUniqueIdentifier, isDefaultMode, readSetting, writeSetting
-
Constructor Details
-
AbstractLocationMode
public AbstractLocationMode()
-
-
Method Details
-
setActionProvider
Sets theLocationModeActionProviderfor this mode.- Parameters:
actionProvider- the provider, notnull- Throws:
IllegalArgumentException- ifactionProviderisnullIllegalStateException- if there are alreadyDockables which show actions that are provided by the currentLocationModeActionProvider
-
setManager
Description copied from interface:LocationModeSets the manager which is using this mode.- Specified by:
setManagerin interfaceLocationMode- Parameters:
manager- the manager ornull
-
getManager
Gets the owner of this mode.- Specified by:
getManagerin interfaceLocationMode- Returns:
- the owner, not
null
-
setController
Description copied from interface:LocationModeConnects this mode with a controller. It is up to the mode to add or remove listeners if necessary. This mode should also forward the controller to itsModeAreas.- Specified by:
setControllerin interfaceLocationMode- Parameters:
controller- the new controller ornull
-
getController
Gets the controller in whose realm this mode works.- Returns:
- the controller or
null
-
addLocationModeListener
Description copied from interface:LocationModeAdds a listener to this mode. The listener is to be called ifapplystarts or finishes.- Specified by:
addLocationModeListenerin interfaceLocationMode- Parameters:
listener- the new listener
-
removeLocationModeListener
Description copied from interface:LocationModeRemoveslistenerfrom this mode.- Specified by:
removeLocationModeListenerin interfaceLocationMode- Parameters:
listener- the listener to remove
-
listeners
Gets all the listeners that are currently registered at this mode.- Returns:
- all the listeners
-
shouldAutoFocus
public boolean shouldAutoFocus()Description copied from interface:LocationModeTells theLocationModeManagerwhether the focus should be transferred to aDockablethat has this mode.- Specified by:
shouldAutoFocusin interfaceLocationMode- Returns:
- whether auto-focus should be enabled or not
-
setShouldAutoFocus
public void setShouldAutoFocus(boolean autoFocus) Sets the result ofshouldAutoFocus().- Parameters:
autoFocus- whether automatic focus transfer toDockablein this mode should be allowed
-
add
Adds an area to this mode.- Parameters:
area- the new area, notnull
-
remove
Removes the area with identifierkeyfrom this mode.- Parameters:
key- the identifier of the area- Returns:
- the removed area or
null
-
iterator
-
setDefaultArea
Sets the default area of this mode. The default area is used whenget(Dockable)returnsnullfor some key.- Parameters:
defaultArea- the default area, can benull. Must be registered usingadd(ModeArea)first.
-
getDefaultArea
Gets the default area of this mode, can benull. The default area is the oldest area that was added to this mode and whose propertyModeArea.autoDefaultArea()istrue, or the one area set throughsetDefaultArea(ModeArea).- Returns:
- the default area
-
get
Gets the area with the specified id.- Parameters:
key- the name of the area- Returns:
- the area or
null
-
getRepresentation
Description copied from interface:LocationModeGets the oneDockStationthat is known with the root-iduniqueId. TheuniqueIdis the same id as used returned byLocation.getRoot()ofLocations issued by this mode.- Specified by:
getRepresentationin interfaceLocationMode- Parameters:
uniqueId- the id of some station- Returns:
- the station or
null
-
getRepresentationIds
Description copied from interface:LocationModeGets all the unique identifiers that will yield a non-nullresult when callingLocationMode.getRepresentation(String).- Specified by:
getRepresentationIdsin interfaceLocationMode- Returns:
- the ids of all the available
DockStations, the result may not be modifiable
-
get
Recursively searches through all stations ofdockableuntil a station is found that is registered at this mode.- Parameters:
dockable- the element whose root is searched- Returns:
- the root or
null, neverdockableitself
-
get
Recursively searches through all stations ofdockableuntil a station is found that is registered at this mode.- Parameters:
dockable- the element whose root is searchedlocationRoot- iftrue, then only thoseModeAreas are returned which areModeArea.isLocationRoot()- Returns:
- the root or
null, neverdockableitself
-
get
Recursively searches through all areas known to this mode until the mode is found that representsstation. Ifstationis aDockablethat its parent station is searched too.- Parameters:
station- the station whose area is to be found- Returns:
- an area for which
ModeArea.getStation()equalsstation, may benull
-
aside
Description copied from interface:LocationModeCallsDockStation.aside(AsideRequest)on a station that matcheslocation.- Specified by:
asidein interfaceLocationMode- Parameters:
request- the request to forward to aDockStationor to processlocation- the source of the location whose neighbor is searched- Returns:
- the neighbor or a value of
nullif the request could not be processed
-
getActionsFor
Description copied from interface:ModeGets aDockActionSourcewhich should be shown ondockablewhich is currently inmode. This method will be called every time whendockablechanges its mode.- Specified by:
getActionsForin interfaceMode<A extends ModeArea>- Parameters:
dockable- some element, notnullmode- the mode ofdockable, notnull- Returns:
- the actions for
dockable, can benull
-
isModeAvailable
Tells whether this mode is available fordockable.- Parameters:
dockable- some element to check- Returns:
trueif this mode is available
-
isModeHidden
Tells whether this mode is hidden fordockable. If the mode is hidden then the actions of theaction providerdo not show up.- Parameters:
dockable- some element to check- Returns:
trueif this mode is available
-
isRepresenting
Description copied from interface:LocationModeTells whether this mode knowsstationand represents the mode children ofstationare in.- Specified by:
isRepresentingin interfaceLocationMode- Parameters:
station- the station which is to be tested- Returns:
- whether this mode is represented by
station
-
apply
Description copied from interface:ModeApplies this mode todockable. This method may fail for example because aDockAcceptancedoes preventdockablefrom being moved.- Specified by:
applyin interfaceMode<A extends ModeArea>- Parameters:
dockable- the element whose mode becomesthishistory- history information that was returned by this mode on its last call toMode.current(Dockable). May benullif this mode was never applied or returnsnullonMode.current(Dockable).set- this method has to store allDockables which might have changed their mode in the set.- Returns:
trueifdockablewas successfully moved on its parent or to a new parent, orfalseifdockabledid not change its location
-
runApply
Called byapply(Dockable, Location, AffectedSet)after theLocationModeListeners are informed. Applies this mode todockable.- Parameters:
dockable- the element whose mode becomesthishistory- history information that was returned by this mode when callingMode.current(Dockable)the last time.set- this method has to store allDockables which might have changed their mode in the set.- Returns:
trueifdockablewas moved,falseif the method failed to set the location ofdockablefor any reason
-
createHandle
Creates a new handle fordockable.- Parameters:
dockable- the newly registered element- Returns:
- the new handle
-