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

public class LocationModeManager<M extends LocationMode> extends ModeManager<Location,M>
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 Details

  • Constructor Details

    • LocationModeManager

      public LocationModeManager(DockController controller)
      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: ModeManager
      Unregisters listeners which this manager added to the DockController and other components.
      Overrides:
      destroy in class ModeManager<Location,M extends LocationMode>
    • updateEnablement

      protected void updateEnablement()
      Updates the current ExtendedModeEnablement using the factory provided by MODE_ENABLEMENT.
    • setGroupBehavior

      public void setGroupBehavior(CGroupBehavior behavior)
      Sets the group behavior. The group behavior is applied if setMode(Dockable, ExtendedMode) is called and modifies the call such that another Dockable receives the event. Any call directly to any of the apply methods will not be modified by the group behavior.
      Parameters:
      behavior - the new behavior, not null
    • getGroupBehavior

      public CGroupBehavior getGroupBehavior()
      Gets the current group behavior.
      Returns:
      the current behavior, not null
      See Also:
    • setMode

      public void setMode(Dockable dockable, ExtendedMode extendedMode)
      Sets the current mode of dockable.
      Parameters:
      dockable - the dockable whose mode is to be set
      extendedMode - the mode
      Throws:
      IllegalArgumentException - if extendedMode is unknown
    • getCurrentAction

      public CGroupMovement getCurrentAction()
      Gets the action that is currently carried out.
      Returns:
      the current action, can be null
    • apply

      public void apply(Dockable dockable, ExtendedMode extendedMode, CGroupMovement action)
      Executes action in a transaction assuming that the result of this action will lead to dockable having the new mode extendedMode.
      Parameters:
      dockable - the primary Dockable, this item may very well be the new focus owner
      extendedMode - the expected mode dockable will have after action completed
      action - the action to execute
    • getMode

      public ExtendedMode getMode(Dockable dockable)
      Gets the current mode of dockable.
      Parameters:
      dockable - the element whose mode is searched
      Returns:
      the mode or null if not found
    • getRepresentations

      public Map<ExtendedMode,DockStation> getRepresentations(String id)
      Checks all LocationModes of this manager and returns all DockStations 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

      protected void applyDuringRead(String key, Path old, Path current, Dockable dockable)
      Ignores the call, the position of Dockables is set elsewhere.
      Specified by:
      applyDuringRead in class ModeManager<Location,M extends LocationMode>
      Parameters:
      key - the identifier of dockable
      old - the mode dockable is currently in
      current - the mode dockable is going to be
      dockable - the element that changes its mode, might be null
    • apply

      public void apply(Dockable dockable, M mode, Location history, AffectedSet set)
      Description copied from class: ModeManager
      Alters the mode of dockable to be mode. This method does not alter the modes of other dockables, notice however that the methods Mode.apply(Dockable, Object, AffectedSet) may trigger additional mode-changes.
      Overrides:
      apply in class ModeManager<Location,M extends LocationMode>
      Parameters:
      dockable - the element whose mode is changed
      mode - the new mode of dockable
      history - history information for Mode.apply(Dockable, Object, AffectedSet), can be null
      set - to store elements that have changed
    • isModeAvailable

      public boolean isModeAvailable(Dockable dockable, ExtendedMode mode)
      Using the current ExtendedModeEnablement this method tells whether mode mode can be applied to dockable.
      Parameters:
      dockable - some element, not null
      mode - some mode, not null
      Returns:
      the result of ExtendedModeEnablement.isAvailable(Dockable, ExtendedMode)
    • isModeHidden

      public boolean isModeHidden(Dockable dockable, ExtendedMode mode)
      Using the current ExtendedModeEnablement this method tells whether mode mode is hidden from the user when looking at dockable. A hidden mode
      Parameters:
      dockable - some element, not null
      mode - some mode, not null
      Returns:
      the result of ExtendedModeEnablement.isAvailable(Dockable, ExtendedMode)
    • addListener

      public void addListener(Path identifier, LocationModeListener listener)
      Adds a listener to the mode with unique identifier identifier. 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, not null
    • removeListener

      public void removeListener(Path identifier, LocationModeListener listener)
      Removes a listener from the mode identifier.
      Parameters:
      identifier - the name of a mode
      listener - the listener to remove
    • getCurrentMode

      public M getCurrentMode(Dockable dockable)
      Description copied from class: ModeManager
      Tries to find the mode dockable is currently in. This method calls Mode.isCurrentMode(Dockable) and returns the first Mode where the answer was true.
      Overrides:
      getCurrentMode in class ModeManager<Location,M extends LocationMode>
      Parameters:
      dockable - some dockable, not null
      Returns:
      the current mode or null if not found
    • getDoubleClickStrategy

      public DoubleClickLocationStrategy getDoubleClickStrategy()
      Gets the current strategy for handing double-clicks.
      Returns:
      the strategy, never null
      See Also:
    • setDoubleClickStrategy

      public void setDoubleClickStrategy(DoubleClickLocationStrategy strategy)
      Sets the current strategy for handling double-clicks on Dockables. This strategy will be asked what mode to assign to an element that has been double-clicked. Results that are not allowed by the current ExtendedModeEnablement are ignored.
      Parameters:
      strategy - the new strategy, can be null to 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:
      true if layouting mode is active
    • runLayoutTransaction

      public void runLayoutTransaction(Runnable run)
      Activates the layout mode while run is running.
      Parameters:
      run - some code to execute
    • ensureNotHidden

      public void ensureNotHidden(Dockable dockable)
      Ensures that dockable is not hidden behind another Dockable. That does not mean that dockable becomes visible, just that it is easier reachable without the need to change modes of any Dockables.
      This method returns immediately if in layouting mode
      Parameters:
      dockable - the element which should not be hidden
    • ensureValidLocation

      public void ensureValidLocation(Dockable dockable)
      Empty method evaluating the correct location of a Dockable. To be overridden by subclasses to handle elements which have additional restrictions.
      Parameters:
      dockable - the element to check
    • setLocationAside

      public void setLocationAside(Dockable dockable, Dockable aside)
      Iterates through all the LocationModes for which aside has stored locations, and sets dockable as neighbor. This method does not change the actual location of dockable, rather a call to apply would be necessary to update the location.
      It is the responsibility of the caller to ensure that dockable can actually be placed at any location where aside ever was.
      Parameters:
      dockable - the item whose location should change
      aside - the item whose neighbor is set
    • getSharedActions

      public DockActionSource getSharedActions(DockStation station)
      Description copied from class: ModeManager
      Gets a list of actions that should be shown on station depending on the current children of station. This method is called every time when either a child is added, removed or selected on station.
      Specified by:
      getSharedActions in class ModeManager<Location,M extends LocationMode>
      Parameters:
      station - the station whose actions are asked
      Returns:
      the actions, can be null
    • delayedRefresh

      public void delayedRefresh(Dockable dockable)
      If the DockRegister is currently stalled, then a call to ModeManager.refresh(Dockable, boolean) is scheduled, otherwise the call is performed directly.
      Parameters:
      dockable - the dockable which should be forwarded to ModeManager.refresh(Dockable, boolean)