Class PlaceholderGrouping
java.lang.Object
bibliothek.gui.dock.common.grouping.PlaceholderGrouping
- All Implemented Interfaces:
DockableGrouping
When a
The
This object tries to ensure that for each
Clients may use the
Dockable is about to be moved to a new position, then this DockableGrouping searches for
a unique identifier, called a "placeholder", which indicates where the Dockable should be placed.The
placeholder is placed at the location of the Dockable, for which
hierarchyChanged(Dockable) was called last. Basically the placeholder always follows the last Dockable
that was moved around.This object tries to ensure that for each
ExtendedMode there is no more than one placeholder set. Meaning
there is only one location marked for each mode.Clients may use the
CControlPerspective, and methods like
CGridPerspective.gridPlaceholder,
to set the initial location of the placeholder.- Author:
- Benjamin Sigg
-
Constructor Summary
ConstructorsConstructorDescriptionPlaceholderGrouping(CControl control, Path placeholder) Creates a new grouping. -
Method Summary
Modifier and TypeMethodDescriptionprotected LocationfindLocationFor(Dockable dockable, CLocationMode mode) Searches a location fordockable.protected LocationfindLocationFor(Dockable dockable, CLocationMode mode, Location validatedHistory) Called bygetValidatedLocation(Dockable, CLocationMode, Location), this method tries to find a location on the root station designated byvalidatedHistory.voidfocusGained(Dockable dockable) Called afterdockablehas gained the focus.getInitialMode(Dockable dockable) Tries to find out how to displaydockableinitially.protected PathPlaceholder that marks the last position where thisPlaceholderGroupingdid store something.protected DockablePropertygetLocation(DockStation root) Searches the ideal location onrootthat matchesthe placeholder.Gets the placeholder that is searched by thisPlaceholderGrouping, and that is placed wherever aDockableis moved whenhierarchyChanged(Dockable)was called.getStoredLocation(Dockable dockable, CLocationMode mode, Location history) Called right after an old location ofdockableformodewas read.getValidatedLocation(Dockable dockable, CLocationMode mode, Location validatedHistory) Called right beforedockableis moved to a new location.voidhierarchyChanged(Dockable dockable) Always called afterdockablehas changed its location.protected voidmarkLocation(Dockable dockable) Makes sure that the placeholder marks the current location ofdockable.voidRemoves thelast placeholdereverywhere.
-
Constructor Details
-
PlaceholderGrouping
Creates a new grouping.- Parameters:
control- The realm in which this object acts, used to access things like the rootDockStationsplaceholder- a unique identifier with which the location of a group ofDockables is marked
-
-
Method Details
-
getPlaceholder
Gets the placeholder that is searched by thisPlaceholderGrouping, and that is placed wherever aDockableis moved whenhierarchyChanged(Dockable)was called.- Returns:
- the placeholder, not
null
-
getLastPlaceholder
Placeholder that marks the last position where thisPlaceholderGroupingdid store something. The default implementation always returnsplaceholder + "last", but subclasses may change the behavior.- Returns:
- the last location where something interesting happened
-
getStoredLocation
Description copied from interface:DockableGroupingCalled right after an old location ofdockableformodewas read. The method may change the location ofdockableby returning a newLocationobject.
If this method is called, thenDockableGrouping.getValidatedLocation(Dockable, CLocationMode, Location)will be called beforedockableactually is moved to a new location.- Specified by:
getStoredLocationin interfaceDockableGrouping- Parameters:
dockable- the dockable whose location is about to be changedmode- the target mode fordockablehistory- the old location ofdockable, may benull- Returns:
- either
history, or a newly created location. Alsonullis valid result. This method is allowed to return an invalid location, invalid locations however will be replaced with valid location.
-
getValidatedLocation
public Location getValidatedLocation(Dockable dockable, CLocationMode mode, Location validatedHistory) Description copied from interface:DockableGroupingCalled right beforedockableis moved to a new location.- Specified by:
getValidatedLocationin interfaceDockableGrouping- Parameters:
dockable- theDockablewhose location is about to be changedmode- the target mode fordockablevalidatedHistory- a validated location. This may be the result ofDockableGrouping.getStoredLocation(Dockable, CLocationMode, Location)if that result already was a valid location, or it may be a new location, may benull- Returns:
- either
validatedHistory, or a newly created location. Alsonullis a valid result. This method should return only valid locations, invalid locations will lead the framework to place the dockable at some default location
-
getInitialMode
Description copied from interface:DockableGroupingTries to find out how to displaydockableinitially.- Specified by:
getInitialModein interfaceDockableGrouping- Parameters:
dockable- an invisible dockable that is about to be made visible, and that does not have a location defined.- Returns:
- the initial mode of
dockable, ornull
-
findLocationFor
Searches a location fordockable.- Parameters:
dockable- the element whose new location is searchedmode- the target mode ofdockable- Returns:
- the new location, or
nullif no location can be calculated
-
findLocationFor
protected Location findLocationFor(Dockable dockable, CLocationMode mode, Location validatedHistory) Called bygetValidatedLocation(Dockable, CLocationMode, Location), this method tries to find a location on the root station designated byvalidatedHistory.- Parameters:
dockable- the element whose new location is searchedmode- the target mode ofdockablevalidatedHistory- the location where the unmodified algorithm would placedockable- Returns:
- either a replacement for
validatedHistory, orvalidatedHistory. Should not returnnull.
-
getLocation
Searches the ideal location onrootthat matchesthe placeholder.- Parameters:
root- the station on which to search the placeholder- Returns:
- the location of
the placeholder, ornullif the placeholder was not found
-
hierarchyChanged
Description copied from interface:DockableGroupingAlways called afterdockablehas changed its location. This method will be called for anyDockablethat changed its location, even ifDockableGrouping.getStoredLocation(Dockable, CLocationMode, Location)orDockableGrouping.getValidatedLocation(Dockable, CLocationMode, Location)was never called.
Note: this method acts as if aDockHierarchyListenerwould have been added todockable- Specified by:
hierarchyChangedin interfaceDockableGrouping- Parameters:
dockable- aDockablethat has a new place
-
focusGained
Description copied from interface:DockableGroupingCalled afterdockablehas gained the focus.- Specified by:
focusGainedin interfaceDockableGrouping- Parameters:
dockable- the element that just gained the focus
-
markLocation
Makes sure that the placeholder marks the current location ofdockable.- Parameters:
dockable- defines the location to mark
-
removePlaceholderEverywhere
public void removePlaceholderEverywhere()Removes thelast placeholdereverywhere.
-