Class CLocationModeManager


public class CLocationModeManager extends LocationModeManager<CLocationMode>
LocationModeManager providing additional methods for working with CLocations, CommonDockables and other items specific to the common project.
Author:
Benjamin Sigg
  • Field Details

  • Constructor Details

    • CLocationModeManager

      public CLocationModeManager(CControlAccess control)
      Creates a new manager.
      Parameters:
      control - the control in whose realm this manager works
  • Method Details

    • getNormalMode

      public CNormalMode getNormalMode()
      Direct access to the mode handling "normal" Dockables.
      Returns:
      the mode
    • getMaximizedMode

      public CMaximizedMode getMaximizedMode()
      Direct access to the mode handling "maximized" Dockables.
      Returns:
      the mode
    • getMinimizedMode

      public CMinimizedMode getMinimizedMode()
      Direct access to the mode handling "minimized" Dockables.
      Returns:
      the mode
    • getExternalizedMode

      public CExternalizedMode getExternalizedMode()
      Direct access to the mode handling "externalized" Dockables.
      Returns:
      the mode
    • createEntryDuringRead

      protected boolean createEntryDuringRead(String key)
      Description copied from class: ModeManager
      Tells whether an entry for a missing Dockable should be created. This will result in a call to ModeManager.addEmpty(String) during ModeManager.readSettings(ModeSettings). The default implementation returns always false.
      Overrides:
      createEntryDuringRead in class ModeManager<Location,CLocationMode>
      Parameters:
      key - the key for which to create a new entry
      Returns:
      true if an entry should be created
    • remove

      public void remove(Dockable dockable)
      Description copied from class: ModeManager
      Removes the properties that belong to dockable.
      Overrides:
      remove in class ModeManager<Location,CLocationMode>
      Parameters:
      dockable - the element to remove
    • createModeSettings

      public <B> ModeSettings<Location,B> createModeSettings(ModeSettingsConverter<Location,B> converter)
      Description copied from class: ModeManager
      Creates the empty set of settings for this ModeManager. Subclasses may override this method to use another set of settings. This method does not need to call ModeSettings.addFactory(ModeSettingFactory).
      Overrides:
      createModeSettings in class ModeManager<Location,CLocationMode>
      Type Parameters:
      B - the intermediate format
      Parameters:
      converter - conversion tool from this manager's meta-data format to the intermediate format.
      Returns:
      the new empty settings
    • readSettings

      public void readSettings(ModeSettings<Location,?> settings)
      Description copied from class: ModeManager
      Reads the contents of settings and stores it.
      Overrides:
      readSettings in class ModeManager<Location,CLocationMode>
      Parameters:
      settings - the settings to read
    • readSettings

      public Runnable readSettings(ModeSettings<Location,?> settings, UndoableModeSettings pending)
      Description copied from class: ModeManager
      Reads the contents of settings, creates new entries if either ModeManager.createEntryDuringRead(String) or if pending allows the setting to be undone if not needed.
      Overrides:
      readSettings in class ModeManager<Location,CLocationMode>
      Parameters:
      settings - the settings to read
      pending - undoable settings, can be null
      Returns:
      an algorithm that will remove any entry that was created because pending did advise so, null if pending was null
    • setLocation

      public void setLocation(Dockable dockable, CLocation location)
      Tries to set the location of dockable. Does nothing if location is invalid or requires information that is not available. If dockable is a CommonDockable and the mode respects working-areas, then the working-area is set or removed depending on the value of CStation.isWorkingArea().
      Parameters:
      dockable - the element to move
      location - the new location of dockable
    • setLocation

      public void setLocation(Dockable dockable, ExtendedMode mode, CLocation location)
      Sets the default location of dockable when going into mode. The properties set here will be overridden as soon as the user drags dockable to another location (within the same mode) or dockable is removed permanently.
      This method has no effect if dockable is already in mode. There is also no effect if dockable has not been registered at the CLocationModeManager.
      Note: it is the clients responsibility to ensure that location and mode belong to each other.
      Parameters:
      dockable - the element whose location will be set
      mode - the mode for which the location is to be set or null
      location - the new location
      Throws:
      IllegalArgumentException - if either argument is null or if CLocation.findRoot() or CLocation.findProperty() returns null
    • getLocation

      public CLocation getLocation(Dockable dockable)
      Gets an element describing the location of dockable as good as possible.
      Parameters:
      dockable - the element whose location should be searched
      Returns:
      the location or null if no location was found
    • getLocation

      public CLocation getLocation(Dockable dockable, ExtendedMode mode)
      Assuming that dockable is currently not in mode mode, then this method searches for the previously stored location of dockable. Note that this method can't tell where dockable would be shown if it never was in that mode and the client never specified the location.
      Parameters:
      dockable - the dockable whose location is searched
      mode - the mode which might be taken by dockable
      Returns:
      the location or null
      Throws:
      IllegalArgumentException - if any argument is null
    • getDropLocation

      public CLocation getDropLocation(CStation<?> station)
      Tries to find the "optimal spot" where to put a new child onto station. In this case the optimal spot is CLocation.aside() the latest focused child of station.
      Parameters:
      station - the station where a CDockable is about to be dropped onto
      Returns:
      the preferred location of the new child
    • ensureValidLocation

      public void ensureValidLocation(Dockable dockable)
      Description copied from class: LocationModeManager
      Empty method evaluating the correct location of a Dockable. To be overridden by subclasses to handle elements which have additional restrictions.
      Overrides:
      ensureValidLocation in class LocationModeManager<CLocationMode>
      Parameters:
      dockable - the element to check
    • ensureValidLocation

      public void ensureValidLocation(CDockable dockable)
      This method compares the current mode of dockable with its availability set. If the current mode is not available, then dockable is put into another mode (usually the normal mode).
      This method also checks the working area, provided that the current mode respects the working-area settings.
      This method returns immediately if in layouting mode
      Parameters:
      dockable - the element whose mode is to be checked
    • ensureBasicModes

      public boolean ensureBasicModes()
      Ensures that all dockables are in a basic mode.
      This method returns immediately if in layouting mode
      Returns:
      true if at least one element was affected by changes, false if nothing happened.
    • resetWorkingAreaChildren

      public void resetWorkingAreaChildren()
      Updates the location of all dockables that should be on a working-area and that are currently in a mode that does not support working-areas. The history of the elements is searched for the first mode which supports working-areas. If no such mode is found, then the normal-mode is applied.
    • childsExtendedMode

      public ExtendedMode childsExtendedMode(DockStation parent)
      Guesses the result of LocationModeManager.getCurrentMode(Dockable) once a Dockable is dropped onto DockStation. If more than one mode is using parent, then the guess might not always be correct.
      Parameters:
      parent - some station
      Returns:
      the mode its children are in, or null if no guess can be made
    • getAreaOf

      protected CStation<?> getAreaOf(Dockable dockable)
      Searches dockable and its parent for the first CStation that is a working area.
      Parameters:
      dockable - the element whose working area is searched
      Returns:
      the first working area or null