public class DefaultLayoutChangeStrategy extends Object implements LayoutChangeStrategy
LayoutChangeStrategy heavily depends on the methods of PredefinedDockSituation. It
also offers a set of methods that may be interesting for subclasses which do not use a PredefinedDockSituation.| Modifier and Type | Class and Description |
|---|---|
protected class |
DefaultLayoutChangeStrategy.SettingAccess
A wrapper around a
Setting, allows algorithms access to the settings
but also allows to modify the data without changing the setting. |
| Constructor and Description |
|---|
DefaultLayoutChangeStrategy() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyInvisibleLayout(DockFrontendInternals frontend,
DockSituation situation,
DefaultLayoutChangeStrategy.SettingAccess setting)
Applies
setting to the invisible elements. |
protected void |
applyLayout(DockFrontendInternals frontend,
DockSituation situation,
DefaultLayoutChangeStrategy.SettingAccess setting,
boolean entry)
Applies the layout described in
setting to the visible elements. |
protected Collection<Dockable> |
approveClosing(DockFrontendInternals frontend,
DockSituation situation,
DefaultLayoutChangeStrategy.SettingAccess setting)
Asks the
VetoManager whether some Dockables can be hidden. |
protected DefaultLayoutChangeStrategy.SettingAccess |
createAccess(DockFrontendInternals frontend,
Setting setting)
Creates a wrapper around
setting that allows the algorithm of this
LayoutChangeStrategy to access the setting. |
DockFrontendPerspective |
createPerspective(DockFrontendInternals frontend,
boolean entry,
FrontendPerspectiveCache cache)
Creates a
Perspective that is used to read and write perspectives related to frontend. |
PredefinedDockSituation |
createSituation(DockFrontendInternals frontend,
boolean entry)
Forwards to
createSituation(DockFrontendInternals, boolean, boolean) with the
last argument set to false. |
protected PredefinedDockSituation |
createSituation(DockFrontendInternals frontend,
boolean entry,
boolean onSetLayout)
Creates a
DockSituation which represents all the knowledge
frontend currently has. |
PropertyTransformer |
createTransformer(DockFrontendInternals frontend)
Creates a converter for reading and writing
DockablePropertys. |
void |
estimateLocations(DockFrontendInternals frontend,
DockSituation situation,
DockLayoutComposition layout)
Tries to fill the property
location
for each element in layout. |
protected Set<Dockable> |
estimateVisible(DockFrontendInternals frontend,
DockSituation situation,
DockLayoutComposition layout)
Tries to estimate which of the currently visible
Dockables will
still be visible if layout is applied to frontend. |
protected Collection<Dockable> |
getClosingDockables(DockFrontendInternals frontend,
Set<Dockable> visible)
Creates a collection of all the
Dockables that are about to be closed. |
PlaceholderStrategy |
getPlaceholderStrategy(DockFrontendInternals frontend)
Gets the default
PlaceholderStrategy which should be used to filter placeholders by frontend. |
protected Map<String,DockableProperty> |
listEstimateLocations(DockSituation situation,
DockLayoutComposition layout)
Tries to estimate the location of missing
Dockables. |
protected Map<String,DockLayoutComposition> |
listLayouts(DockSituation situation,
DockLayoutComposition layout)
Tries to estimate the layouts of missing
Dockables. |
boolean |
setLayout(DockFrontendInternals frontend,
Setting setting,
boolean entry)
Changes the layout of
frontend by reading and applying setting. |
protected boolean |
shouldPredefine(Dockable dockable)
Tells whether the element
dockable should be added as predefined element to the PredefinedDockSituation
that is created by createSituation(DockFrontendInternals, boolean, boolean). |
boolean |
shouldUpdateLayoutOnAdd(Dockable dockable)
Called when
dockable is added to a DockFrontend, and the frontend already knows the layout which should be used
for dockable. |
public boolean setLayout(DockFrontendInternals frontend, Setting setting, boolean entry) throws IOException, XException
LayoutChangeStrategyfrontend by reading and applying setting.
The DockRegister is stalled while this method runs.VetoManager provided by frontend to ensure
that all operations are legal.setLayout in interface LayoutChangeStrategyfrontend - internal information about a DockFrontendsetting - the layout to read and applyentry - true if setting contains only little information about
the layout, false if there is much information abut the layout.true if the layout has been applied, false if
the operation was canceled due of any reasonIOException - in case of some stream that cannot be readXException - in case of some XElement that cannot be readLayoutChangeStrategy.shouldUpdateLayoutOnAdd(Dockable)public boolean shouldUpdateLayoutOnAdd(Dockable dockable)
LayoutChangeStrategydockable is added to a DockFrontend, and the frontend already knows the layout which should be used
for dockable. If the result is true, then all children of dockable are removed, and reloaded to apply the layout
that is stored in the frontend.false if LayoutChangeStrategy.setLayout(DockFrontendInternals, Setting, boolean) is currently executed, preventing concurrent
modifications of the dock-tree.shouldUpdateLayoutOnAdd in interface LayoutChangeStrategydockable - the dockable that is added to a DockFrontendtrue if the layout of dockable should be updated.protected DefaultLayoutChangeStrategy.SettingAccess createAccess(DockFrontendInternals frontend, Setting setting)
setting that allows the algorithm of this
LayoutChangeStrategy to access the setting.frontend - the caller of this methodsetting - the setting to hidepublic PredefinedDockSituation createSituation(DockFrontendInternals frontend, boolean entry)
createSituation(DockFrontendInternals, boolean, boolean) with the
last argument set to false.createSituation in interface LayoutChangeStrategyfrontend - the frontend for which the situation is requiredentry - true if the situation is used for a regular setting,
false if the situation is used as the final setting which will
be loaded the next time the application starts.protected PredefinedDockSituation createSituation(DockFrontendInternals frontend, boolean entry, boolean onSetLayout)
DockSituation which represents all the knowledge
frontend currently has.frontend - the frontend for which the situation is requiredentry - true if the situation is used for a regular setting,
false if the situation is used as the final setting which will
be loaded the next time the application starts.onSetLayout - whether this method is called by setLayout(DockFrontendInternals, Setting, boolean) or not. If
true then the situation is used to apply some layout, otherwise it is used to store or read a layoutPredefinedDockSituation, subclasses
may override and return other situations.protected boolean shouldPredefine(Dockable dockable)
dockable should be added as predefined element to the PredefinedDockSituation
that is created by createSituation(DockFrontendInternals, boolean, boolean).dockable - the element which may need to be predefinedtrue if dockable is to be predefinedpublic DockFrontendPerspective createPerspective(DockFrontendInternals frontend, boolean entry, FrontendPerspectiveCache cache)
LayoutChangeStrategyPerspective that is used to read and write perspectives related to frontend.createPerspective in interface LayoutChangeStrategyfrontend - the frontend for which the situation is requiredentry - true if the situation is used for a regular setting,
false if the situation is used as the final setting which will
be loaded the next time the application starts.cache - a cache that takes DockElements and returns the matching PerspectiveElement. The cache
also offers methods to convert ids and PerspectiveElements directlypublic PropertyTransformer createTransformer(DockFrontendInternals frontend)
LayoutChangeStrategyDockablePropertys.createTransformer in interface LayoutChangeStrategyfrontend - the frontend for which the converter is requiredprotected void applyLayout(DockFrontendInternals frontend, DockSituation situation, DefaultLayoutChangeStrategy.SettingAccess setting, boolean entry) throws IOException, XException
setting to the visible elements.
This implementation tries to estimate the location of missing dockables using
listEstimateLocations(DockSituation, DockLayoutComposition).frontend - the caller of this methodsituation - used to convert the layoutsetting - the new layoutentry - whether the layout is a full or regular layoutIOException - if the layout cannot be convertedXException - if the layout cannot be convertedprotected void applyInvisibleLayout(DockFrontendInternals frontend, DockSituation situation, DefaultLayoutChangeStrategy.SettingAccess setting) throws IOException, XException
setting to the invisible elements.frontend - the caller of this methodsituation - to convert the layoutsetting - the new layoutIOException - if the layout cannot be convertedXException - if the layout cannot be convertedprotected Map<String,DockLayoutComposition> listLayouts(DockSituation situation, DockLayoutComposition layout)
Dockables. The
default implementation works with any PredefinedDockSituation.situation - the situation to use for transforming informationlayout - the layout to analyzeDockable-names as key or nullprotected Map<String,DockableProperty> listEstimateLocations(DockSituation situation, DockLayoutComposition layout)
Dockables. The
default implementation works with any PredefinedDockSituation.situation - the situation to use for transforming informationlayout - the layout to analyzeDockable-names as key or nullpublic void estimateLocations(DockFrontendInternals frontend, DockSituation situation, DockLayoutComposition layout)
LayoutChangeStrategylocation
for each element in layout.estimateLocations in interface LayoutChangeStrategyfrontend - the frontend which calls this methodsituation - the situation to use for transforming informationlayout - the layout to estimateprotected Collection<Dockable> approveClosing(DockFrontendInternals frontend, DockSituation situation, DefaultLayoutChangeStrategy.SettingAccess setting)
VetoManager whether some Dockables can be hidden. Only Dockables that
are returned by DockFrontendInternals.getDockables() are checked by this method.frontend - the caller of this methodsituation - the situation that will convert the layoutsetting - the new layoutnull if the operation should be canceledprotected Collection<Dockable> getClosingDockables(DockFrontendInternals frontend, Set<Dockable> visible)
Dockables that are about to be closed. Subclasses
may override this method, they should at least check all the Dockables that are
registered at frontend. Subclasses may need to override
estimateVisible as
well to get the correct set of visible elements.frontend - the caller of this methodvisible - the elements that remain visible as told by estimateVisible(DockFrontendInternals, DockSituation, DockLayoutComposition).null, may be emptyprotected Set<Dockable> estimateVisible(DockFrontendInternals frontend, DockSituation situation, DockLayoutComposition layout)
Dockables will
still be visible if layout is applied to frontend. The
default implementation assumes that situation is a PredefinedDockSituation.frontend - the caller of this methodsituation - algorithm used to convert layoutlayout - the layout that will be appliednullpublic PlaceholderStrategy getPlaceholderStrategy(DockFrontendInternals frontend)
LayoutChangeStrategyPlaceholderStrategy which should be used to filter placeholders by frontend.getPlaceholderStrategy in interface LayoutChangeStrategyfrontend - information about the DockFrontend that needs the strategynullCopyright © 2017 Docking Frames. All rights reserved.