bibliothek.gui.dock.frontend
Class DefaultFrontendPerspectiveCache

java.lang.Object
  extended by bibliothek.gui.dock.frontend.DefaultFrontendPerspectiveCache
All Implemented Interfaces:
FrontendPerspectiveCache

public class DefaultFrontendPerspectiveCache
extends Object
implements FrontendPerspectiveCache

This default implementation of a FrontendPerspectiveCache assumes that the information clients gave to a DockFrontend is enough and use only the default PerspectiveElements. This cache handles only the default implementation of the DockStations and of DefaultDockable. Using any other DockElement will result in exceptions.
DefaultDockables are represented by FrontendDockablePerspectives.
This implementation has several drawbacks:

Author:
Benjamin Sigg

Field Summary
static Path CACHE_EXTENSION
          Unique identifier to load extensions of type FrontendPerspectiveCacheExtension
 
Constructor Summary
DefaultFrontendPerspectiveCache(DockFrontend frontend)
          Creates a new cache
 
Method Summary
 String get(PerspectiveElement element)
          Gets the unique identifier of element.
 PerspectiveElement get(String id, boolean rootStation)
          Called to convert id to a PerspectiveElement.
 PerspectiveElement get(String id, DockElement element, boolean isRootStation)
          Given an element that was earlier created by the client and added to a DockFrontend, this method converts element to a PerspectiveElement.
When called multiple times with the same arguments, then this method is free to either return different objects or to always return the same object.
 boolean isRootStation(PerspectiveStation station)
          Tells whether station is supposed to be a root-station.
protected  void put(PerspectiveElement element, String id)
          Makes an association that the identifier id is used for element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CACHE_EXTENSION

public static final Path CACHE_EXTENSION
Unique identifier to load extensions of type FrontendPerspectiveCacheExtension

Constructor Detail

DefaultFrontendPerspectiveCache

public DefaultFrontendPerspectiveCache(DockFrontend frontend)
Creates a new cache

Parameters:
frontend - the frontend to query for information about DockElements.
Method Detail

get

public PerspectiveElement get(String id,
                              DockElement element,
                              boolean isRootStation)
Description copied from interface: FrontendPerspectiveCache
Given an element that was earlier created by the client and added to a DockFrontend, this method converts element to a PerspectiveElement.
When called multiple times with the same arguments, then this method is free to either return different objects or to always return the same object.

Specified by:
get in interface FrontendPerspectiveCache
Parameters:
id - the unique identifier under which element is known to the DockFrontend
element - the element whose perspective must be created
isRootStation - whether element is registered as root-station at the DockFrontend or as Dockable
Returns:
the perspective, must not be null

put

protected void put(PerspectiveElement element,
                   String id)
Makes an association that the identifier id is used for element.

Parameters:
element - the element whose identifier is stored, not null
id - the identifier to store, not null

get

public PerspectiveElement get(String id,
                              boolean rootStation)
Description copied from interface: FrontendPerspectiveCache
Called to convert id to a PerspectiveElement. This method will only be called with identifiers that were not used for FrontendPerspectiveCache.get(String, DockElement, boolean).

Specified by:
get in interface FrontendPerspectiveCache
Parameters:
id - the identifier of some element
rootStation - whether id represents a root-station or not
Returns:
the element, can be null

get

public String get(PerspectiveElement element)
Description copied from interface: FrontendPerspectiveCache
Gets the unique identifier of element.

Specified by:
get in interface FrontendPerspectiveCache
Parameters:
element - some element, can be either a dockable or a root-station
Returns:
the unique identifier or null if this cache is unable to associate element with an identifier. Should not be null for elements that were created by FrontendPerspectiveCache.get(String, boolean) or FrontendPerspectiveCache.get(String, DockElement, boolean).

isRootStation

public boolean isRootStation(PerspectiveStation station)
Description copied from interface: FrontendPerspectiveCache
Tells whether station is supposed to be a root-station.

Specified by:
isRootStation in interface FrontendPerspectiveCache
Parameters:
station - the element which may be a root-station
Returns:
true if station should be treated as root-station