bibliothek.gui.dock.support.mode
Interface Mode<H>

Type Parameters:
H - class storing history information
All Known Subinterfaces:
CLocationMode, LocationMode
All Known Implementing Classes:
AbstractLocationMode, CExternalizedMode, CMaximizedMode, CMinimizedMode, CNormalMode, DefaultLocationMode, ExternalizedMode, MaximizedMode, MinimizedMode, NormalMode

public interface Mode<H>

A mode describes a state in which a Dockable can be. A Dockable can be in exactly one Mode at a time. Notice that the mode may change through events that are not registered or influenced by this mode.

Author:
Benjamin Sigg

Method Summary
 boolean apply(Dockable dockable, H history, AffectedSet set)
          Applies this mode to dockable.
 H current(Dockable dockable)
          Provides history information about the current state of dockable in respect to this mode.
 DockActionSource getActionsFor(Dockable dockable, Mode<H> mode)
          Gets a DockActionSource which should be shown on dockable which is currently in mode.
 ModeSettingFactory<H> getSettingFactory()
          Gets a factory for creating new ModeSettings.
 Path getUniqueIdentifier()
          Gets a unique identifier, only this Mode must have this identifier.
 boolean isCurrentMode(Dockable dockable)
          Tells whether dockable fulfills the requirements of this mode, meaning whether dockable has this mode.
 boolean isDefaultMode(Dockable dockable)
          Checks whether this mode is a default mode of dockable.
 void readSetting(ModeSetting<H> setting)
          Sets the properties of this mode.
 void writeSetting(ModeSetting<H> setting)
          Gets the current properties of this mode in an independent way.
 

Method Detail

getActionsFor

DockActionSource getActionsFor(Dockable dockable,
                               Mode<H> mode)
Gets a DockActionSource which should be shown on dockable which is currently in mode. This method will be called every time when dockable changes its mode.

Parameters:
dockable - some element, not null
mode - the mode of dockable, not null
Returns:
the actions for dockable, can be null

getUniqueIdentifier

Path getUniqueIdentifier()
Gets a unique identifier, only this Mode must have this identifier. Identifiers with the first segment being "dock" are reserved for this framework, clients may choose any other identifiers.

Returns:
the identifier, not null, should contain at least one segment.

apply

boolean apply(Dockable dockable,
              H history,
              AffectedSet set)
Applies this mode to dockable. This method may fail for example because a DockAcceptance does prevent dockable from being moved.

Parameters:
dockable - the element whose mode becomes this
history - history information that was returned by this mode on its last call to current(Dockable). May be null if this mode was never applied or returns null on current(Dockable).
set - this method has to store all Dockables which might have changed their mode in the set.
Returns:
true if dockable was succesfully moved on its parent or to a new parent, or false if dockable did not change its location

current

H current(Dockable dockable)
Provides history information about the current state of dockable in respect to this mode.

Parameters:
dockable - the element
Returns:
history information that is needed when calling apply(Dockable, Object, AffectedSet)

isDefaultMode

boolean isDefaultMode(Dockable dockable)
Checks whether this mode is a default mode of dockable. A default mode is a mode that is choosen per default, if no other mode is selected. There should be only one default-mode per Dockable.

Parameters:
dockable - some dockable, not null
Returns:
whether this is a default mode

isCurrentMode

boolean isCurrentMode(Dockable dockable)
Tells whether dockable fulfills the requirements of this mode, meaning whether dockable has this mode. There should be only at most one mode which returns true for this question. Please note, the mode selected in the ModeManager may be out of date, and should not be considered when checking the current mode.

Parameters:
dockable - some dockable, not null
Returns:
whether dockable is in this mode

writeSetting

void writeSetting(ModeSetting<H> setting)
Gets the current properties of this mode in an independent way.

Parameters:
setting - a ModeSetting with the same id as this Mode. This setting was created by a ModeSettingFactory with the same id as this Mode.

readSetting

void readSetting(ModeSetting<H> setting)
Sets the properties of this mode. This method will only be called with a ModeSetting that has been created by the current ModeSettingFactory

Parameters:
setting - the new set of properties, not null

getSettingFactory

ModeSettingFactory<H> getSettingFactory()
Gets a factory for creating new ModeSettings.

Returns:
the factory, can be null