bibliothek.gui.dock.facile.mode
Class MaximizedMode<M extends MaximizedModeArea>

java.lang.Object
  extended by bibliothek.gui.dock.facile.mode.AbstractLocationMode<M>
      extended by bibliothek.gui.dock.facile.mode.MaximizedMode<M>
Type Parameters:
M - the kind of areas this mode handles
All Implemented Interfaces:
LocationMode, Mode<Location>, java.lang.Iterable<M>
Direct Known Subclasses:
CMaximizedMode

public class MaximizedMode<M extends MaximizedModeArea>
extends AbstractLocationMode<M>

Dockables are maximized if they take up the whole space a frame or a screen offers.

Author:
Benjamin Sigg

Nested Class Summary
 
Nested classes/interfaces inherited from class bibliothek.gui.dock.facile.mode.AbstractLocationMode
AbstractLocationMode.DockableHandle
 
Field Summary
static java.lang.String ICON_IDENTIFIER
          the key used for the IconManager to read the Icon for the "maximize"-action
static Path IDENTIFIER
          unique identifier for this mode
 
Constructor Summary
protected MaximizedMode()
          Empty default constructor.
  MaximizedMode(CControl control)
          Creates a new mode
  MaximizedMode(DockController controller)
          Creates a new mode.
 
Method Summary
protected  void applyDone(LocationModeEvent event)
           
protected  void applyStarting(LocationModeEvent event)
           
 Location current(Dockable dockable)
          Provides history information about the current state of dockable in respect to this mode.
 void ensureNotHidden(Dockable dockable)
          Ensures that no Dockable that has this mode hides dockable.
 ExtendedMode getExtendedMode()
          Gets the unique identifier of this mode.
 MaximizedModeArea getMaximizeArea(Dockable dockable)
          Searches the first MaximizedModeArea which is a parent of dockable.
 MaximizedModeArea getMaximizeArea(DockStation station)
          Searches the one MaximizedModeArea whose station is station.
 Dockable getMaximizingElement(Dockable dockable)
          Gets the element which must be maximized when the user requests that dockable is maximized.
 Dockable getMaximizingElement(Dockable old, Dockable dockable)
          Gets the element which would be maximized if old is currently maximized, and dockable is or will not be maximized.
 MaximizedModeArea getNextMaximizeArea(DockStation station)
          Searches the MaximizedModeArea which either represents station or its nearest parent.
 ModeSettingFactory<Location> getSettingFactory()
          Gets a factory for creating new ModeSettings.
 Path getUniqueIdentifier()
          Gets a unique identifier, only this Mode must have this identifier.
 LocationMode getUnmaximizedMode(Dockable dockable)
          Assuming dockable is a maximized element, tells which mode would be the preferred mode for unmaximization.
 boolean isCurrentMode(Dockable dockable)
          If this method is not able to clearly find out whether dockable has this mode, it returns false.
 boolean isDefaultMode(Dockable dockable)
          Checks whether this mode is a default mode of dockable.
 void maximize(MaximizedModeArea area, Dockable dockable, AffectedSet set)
          Ensures that dockable is maximized.
 void maximize(MaximizedModeArea area, Dockable dockable, Location history, AffectedSet set)
          Ensures that dockable is maximized.
protected  boolean process(Dockable dockable, java.awt.event.KeyEvent event)
          Invoked whenever a key is pressed, released or typed.
 void readSetting(ModeSetting<Location> setting)
          Sets the properties of this mode.
 void runApply(Dockable dockable, Location history, AffectedSet set)
          Called by AbstractLocationMode.apply(Dockable, Location, AffectedSet) after the LocationModeListeners are informed.
 void setManager(LocationModeManager<?> manager)
          Sets the manager which is using this mode.
 boolean switchMode(Dockable dockable)
          Tries to switch the current mode of dockable to or from the maximized mode.
 void unmaximize(Dockable dockable, AffectedSet set)
          Ensures that dockable is not maximized.
 void unmaximize(DockStation station, AffectedSet affected)
          Ensures that either the MaximizedModeArea station or its nearest parent does not show a maximized element.
 void unmaximize(MaximizedModeArea area, AffectedSet affected)
          Ensures that area has no maximized child.
 void writeSetting(ModeSetting<Location> setting)
          Gets the current properties of this mode in an independent way.
 
Methods inherited from class bibliothek.gui.dock.facile.mode.AbstractLocationMode
add, addLocationModeListener, apply, createHandle, get, get, get, getActionsFor, getController, getDefaultArea, getManager, getRepresentation, isModeAvailable, isRepresenting, iterator, listeners, remove, removeLocationModeListener, setActionProvider, setController, setDefaultArea, setShouldAutoFocus, shouldAutoFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IDENTIFIER

public static final Path IDENTIFIER
unique identifier for this mode


ICON_IDENTIFIER

public static final java.lang.String ICON_IDENTIFIER
the key used for the IconManager to read the Icon for the "maximize"-action

See Also:
Constant Field Values
Constructor Detail

MaximizedMode

protected MaximizedMode()
Empty default constructor. Subclasses should call AbstractLocationMode.setActionProvider(LocationModeActionProvider) to complete initialization of this mode.


MaximizedMode

public MaximizedMode(CControl control)
Creates a new mode

Parameters:
control - the control in whose realm this mode will work

MaximizedMode

public MaximizedMode(DockController controller)
Creates a new mode.

Parameters:
controller - the owner of this mode
Method Detail

setManager

public void setManager(LocationModeManager<?> manager)
Description copied from interface: LocationMode
Sets the manager which is using this mode.

Specified by:
setManager in interface LocationMode
Overrides:
setManager in class AbstractLocationMode<M extends MaximizedModeArea>
Parameters:
manager - the manager or null

getUniqueIdentifier

public Path getUniqueIdentifier()
Description copied from interface: Mode
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.

getExtendedMode

public ExtendedMode getExtendedMode()
Description copied from interface: LocationMode
Gets the unique identifier of this mode.

Returns:
the unique identifier

runApply

public void runApply(Dockable dockable,
                     Location history,
                     AffectedSet set)
Description copied from class: AbstractLocationMode
Called by AbstractLocationMode.apply(Dockable, Location, AffectedSet) after the LocationModeListeners are informed. Applies this mode to dockable.

Specified by:
runApply in class AbstractLocationMode<M extends MaximizedModeArea>
Parameters:
dockable - the element whose mode becomes this
history - history information that was returned by this mode when calling Mode.current(Dockable) the last time.
set - this method has to store all Dockables which might have changed their mode in the set.

current

public Location current(Dockable dockable)
Description copied from interface: Mode
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 Mode.apply(Dockable, Object, AffectedSet)

isCurrentMode

public boolean isCurrentMode(Dockable dockable)
Description copied from interface: LocationMode
If this method is not able to clearly find out whether dockable has this mode, it returns false. The LocationModeManager will ask again with the parent station of dockable.

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

isDefaultMode

public boolean isDefaultMode(Dockable dockable)
Description copied from interface: Mode
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

getUnmaximizedMode

public LocationMode getUnmaximizedMode(Dockable dockable)
Assuming dockable is a maximized element, tells which mode would be the preferred mode for unmaximization.

Parameters:
dockable - some child
Returns:
the preferred unmaximized mode, can be null

maximize

public void maximize(MaximizedModeArea area,
                     Dockable dockable,
                     AffectedSet set)
Ensures that dockable is maximized.

Parameters:
area - the future parent of dockable, can be null
dockable - the element that should be made maximized
set - a set of Dockables which will be filled by the elements that change their mode because of this method

maximize

public void maximize(MaximizedModeArea area,
                     Dockable dockable,
                     Location history,
                     AffectedSet set)
Ensures that dockable is maximized.

Parameters:
area - the future parent of dockable, can be null
dockable - the element that should be made maximized
history - the expected location of dockable after this method has finished, can be null. No guarantees are given that the final location matches history.
set - a set of Dockables which will be filled by the elements that change their mode because of this method

unmaximize

public void unmaximize(Dockable dockable,
                       AffectedSet set)
Ensures that dockable is not maximized. Does nothing if the parent MaximizedModeArea of dockable has not maximized dockable or if the LocationModeManager does not know dockable.

Parameters:
dockable - the element that might be maximized currently
set - a set of Dockables which will be filled by the elements that change their mode because of this method

getNextMaximizeArea

public MaximizedModeArea getNextMaximizeArea(DockStation station)
Searches the MaximizedModeArea which either represents station or its nearest parent.

Parameters:
station - some station
Returns:
the nearest area or null

unmaximize

public void unmaximize(DockStation station,
                       AffectedSet affected)
Ensures that either the MaximizedModeArea station or its nearest parent does not show a maximized element.

Parameters:
station - an area or a child of an area
affected - elements whose mode changes will be added to this set

unmaximize

public void unmaximize(MaximizedModeArea area,
                       AffectedSet affected)
Ensures that area has no maximized child.

Parameters:
area - some area
affected - the element whose mode might change

ensureNotHidden

public void ensureNotHidden(Dockable dockable)
Description copied from interface: LocationMode
Ensures that no Dockable that has this mode hides dockable. Note that dockable may or may not be in this mode.

Parameters:
dockable - the element which must not be hidden

getMaximizeArea

public MaximizedModeArea getMaximizeArea(Dockable dockable)
Searches the first MaximizedModeArea which is a parent of dockable. This method will never return dockable itself.

Parameters:
dockable - the element whose maximize area is searched
Returns:
the area or null

getMaximizeArea

public MaximizedModeArea getMaximizeArea(DockStation station)
Searches the one MaximizedModeArea whose station is station.

Parameters:
station - the station whose area is searched
Returns:
the area or null if not found

getMaximizingElement

public Dockable getMaximizingElement(Dockable dockable)
Gets the element which must be maximized when the user requests that dockable is maximized.

Parameters:
dockable - some element, not null
Returns:
the element that must be maximized, might be dockable itself, not null

getMaximizingElement

public Dockable getMaximizingElement(Dockable old,
                                     Dockable dockable)
Gets the element which would be maximized if old is currently maximized, and dockable is or will not be maximized.

Parameters:
old - some element
dockable - some element, might be old
Returns:
the element which would be maximized if dockable is no longer maximized, can be null

applyStarting

protected void applyStarting(LocationModeEvent event)

applyDone

protected void applyDone(LocationModeEvent event)

getSettingFactory

public ModeSettingFactory<Location> getSettingFactory()
Description copied from interface: Mode
Gets a factory for creating new ModeSettings.

Returns:
the factory, can be null

writeSetting

public void writeSetting(ModeSetting<Location> setting)
Description copied from interface: Mode
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

public void readSetting(ModeSetting<Location> setting)
Description copied from interface: Mode
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

process

protected boolean process(Dockable dockable,
                          java.awt.event.KeyEvent event)
Invoked whenever a key is pressed, released or typed.

Parameters:
dockable - the element to which the event belongs
event - the event
Returns:
true if the event has been processed, false if the event was not used up.

switchMode

public boolean switchMode(Dockable dockable)
Tries to switch the current mode of dockable to or from the maximized mode.

Parameters:
dockable - the element whose mode is to be changed
Returns:
whether the operation was successful