bibliothek.gui.dock.common.intern.layout
Class CLayoutChangeStrategy

java.lang.Object
  extended by bibliothek.gui.dock.frontend.DefaultLayoutChangeStrategy
      extended by bibliothek.gui.dock.common.intern.layout.CLayoutChangeStrategy
All Implemented Interfaces:
LayoutChangeStrategy

@FrameworkOnly
public class CLayoutChangeStrategy
extends DefaultLayoutChangeStrategy

Strategy that pays attention to MultipleCDockableFactory.match(bibliothek.gui.dock.common.MultipleCDockable, bibliothek.gui.dock.common.MultipleCDockableLayout) and that fires CVetoClosingEvents for MultipleCDockables as well.

Author:
Benjamin Sigg

Nested Class Summary
protected  class CLayoutChangeStrategy.CSettingAccess
          A DefaultLayoutChangeStrategy.SettingAccess that modifies the roots by calling replaceMultipleDockables(DockFrontendInternals, CSettingAccess, DockLayoutComposition).
 
Nested classes/interfaces inherited from class bibliothek.gui.dock.frontend.DefaultLayoutChangeStrategy
DefaultLayoutChangeStrategy.SettingAccess
 
Constructor Summary
CLayoutChangeStrategy(CControl control)
          Creates a new strategy.
 
Method Summary
protected  DefaultLayoutChangeStrategy.SettingAccess createAccess(DockFrontendInternals frontend, Setting setting)
          Creates a wrapper around setting that allows the algorithm of this LayoutChangeStrategy to access the setting.
protected  PredefinedDockSituation createSituation(DockFrontendInternals frontend, boolean entry, boolean onSetLayout)
          Creates a DockSituation which represents all the knowledge frontend currently has.
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.
protected  DockLayoutComposition replaceMultipleDockables(DockFrontendInternals frontend, CLayoutChangeStrategy.CSettingAccess setting, DockLayoutComposition composition)
          Checks the DockLayout that is associated with composition and may replace the layout by another layout if a MultipleCDockableFactory finds a match between an existing item and meta-data about an item.
protected  boolean shouldPredefine(Dockable dockable)
          Tells whether the element dockable should be added as predefined element to the PredefinedDockSituation that is created by DefaultLayoutChangeStrategy.createSituation(DockFrontendInternals, boolean, boolean).
 
Methods inherited from class bibliothek.gui.dock.frontend.DefaultLayoutChangeStrategy
applyInvisibleLayout, applyLayout, approveClosing, createPerspective, createSituation, createTransformer, estimateLocations, getPlaceholderStrategy, listEstimateLocations, listLayouts, setLayout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CLayoutChangeStrategy

public CLayoutChangeStrategy(CControl control)
Creates a new strategy.

Parameters:
control - the control in whose realm this strategy will be used
Method Detail

createSituation

protected PredefinedDockSituation createSituation(DockFrontendInternals frontend,
                                                  boolean entry,
                                                  boolean onSetLayout)
Description copied from class: DefaultLayoutChangeStrategy
Creates a DockSituation which represents all the knowledge frontend currently has.

Overrides:
createSituation in class DefaultLayoutChangeStrategy
Parameters:
frontend - the frontend for which the situation is required
entry - 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 DefaultLayoutChangeStrategy.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 layout
Returns:
the situation, the default implementation always returns a PredefinedDockSituation, subclasses may override and return other situations.

shouldPredefine

protected boolean shouldPredefine(Dockable dockable)
Description copied from class: DefaultLayoutChangeStrategy
Tells whether the element dockable should be added as predefined element to the PredefinedDockSituation that is created by DefaultLayoutChangeStrategy.createSituation(DockFrontendInternals, boolean, boolean).

Overrides:
shouldPredefine in class DefaultLayoutChangeStrategy
Parameters:
dockable - the element which may need to be predefined
Returns:
true if dockable is to be predefined

estimateVisible

protected Set<Dockable> estimateVisible(DockFrontendInternals frontend,
                                        DockSituation situation,
                                        DockLayoutComposition layout)
Description copied from class: DefaultLayoutChangeStrategy
Tries to estimate which of the currently visible Dockables will still be visible if layout is applied to frontend. The default implementation assumes that situation is a PredefinedDockSituation.
Subclasses may override this method and modify the result in any way they like

Overrides:
estimateVisible in class DefaultLayoutChangeStrategy
Parameters:
frontend - the caller of this method
situation - algorithm used to convert layout
layout - the layout that will be applied
Returns:
an estimation of the elements that will be made invisible or null

getClosingDockables

protected Collection<Dockable> getClosingDockables(DockFrontendInternals frontend,
                                                   Set<Dockable> visible)
Description copied from class: DefaultLayoutChangeStrategy
Creates a collection of all the 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.

Overrides:
getClosingDockables in class DefaultLayoutChangeStrategy
Parameters:
frontend - the caller of this method
visible - the elements that remain visible as told by DefaultLayoutChangeStrategy.estimateVisible(DockFrontendInternals, DockSituation, DockLayoutComposition).
Returns:
the set of dockables that is about to be closed, not null, may be empty

replaceMultipleDockables

protected DockLayoutComposition replaceMultipleDockables(DockFrontendInternals frontend,
                                                         CLayoutChangeStrategy.CSettingAccess setting,
                                                         DockLayoutComposition composition)
Checks the DockLayout that is associated with composition and may replace the layout by another layout if a MultipleCDockableFactory finds a match between an existing item and meta-data about an item.

Parameters:
frontend - the caller of this method
setting - the layout that is about to be applied
composition - the composition to modify, may be null
Returns:
the replacement composition or null

createAccess

protected DefaultLayoutChangeStrategy.SettingAccess createAccess(DockFrontendInternals frontend,
                                                                 Setting setting)
Description copied from class: DefaultLayoutChangeStrategy
Creates a wrapper around setting that allows the algorithm of this LayoutChangeStrategy to access the setting.

Overrides:
createAccess in class DefaultLayoutChangeStrategy
Parameters:
frontend - the caller of this method
setting - the setting to hide
Returns:
the wrapper