bibliothek.gui.dock.layout
Class PredefinedDockSituation

java.lang.Object
  extended by bibliothek.gui.dock.layout.DockSituation
      extended by bibliothek.gui.dock.layout.PredefinedDockSituation

public class PredefinedDockSituation
extends DockSituation

A DockSituation that does not load or store all DockElements. All elements which are registered by put(DockElement) are stored in an internal list. On writing, just a unique id is written to the stream. A DockFactory is still necessary for these elements, but the factory may just do nothing.

Author:
Benjamin Sigg

Constructor Summary
PredefinedDockSituation()
           
 
Method Summary
 void addBackup(DockFactory<? extends DockElement,BackupFactoryData<?>> factory)
          Adds a backup factory to this situation.
protected  DockFactory<? extends DockElement,BackupFactoryData<?>> getBackup(String id)
          Searches a backup factory with the name id.
protected  DockFactory<? extends DockElement,?> getFactory(String id)
          Gets the factory which has the given id.
protected  String getFactoryID(String id)
          Transforms an id read from a stream to the id of the factory which would be used.
protected  String getID(DockElement dockable)
          Gets the id of the factory which is needed to write (and later read) the element dockable.
protected  String getID(DockFactory<?,?> factory)
          Gets the id of factory.
 void put(DockElement element)
          Registers an element at this situation.
 void put(String key, DockElement element)
          Registers an element at this situation.
 void removeBackup(String id)
          Removes the backup factory with the name id.
 
Methods inherited from class bibliothek.gui.dock.layout.DockSituation
add, addAdjacent, convert, convert, getAdjacentFactory, getAdjacentFactoryID, getAdjacentID, getIgnore, getMissingAdjacentFactory, getMissingFactory, ignoreChildren, ignoreElement, read, read, readComposition, readCompositionXML, readXML, setIgnore, setMissingAdjacentFactory, setMissingFactory, write, write, writeComposition, writeCompositionXML, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PredefinedDockSituation

public PredefinedDockSituation()
Method Detail

addBackup

public void addBackup(DockFactory<? extends DockElement,BackupFactoryData<?>> factory)
Adds a backup factory to this situation. A backup factory is used when a element should be in the cache, but is missing. The backup factory receives a BackupFactoryData object, the identifier of that object does not have to be stored by factory. The factory has only to look at the data-property. This PredefinedDockSituation will set the identifier whenever a method of factory is called, that has a BackupFactoryData as parameter.

Parameters:
factory - a backup factory

removeBackup

public void removeBackup(String id)
Removes the backup factory with the name id.

Parameters:
id - the id of the factory which should be removed

put

public void put(DockElement element)
Registers an element at this situation. When a stream is read, this element will be returned instead a newly created element (assuming that the element was written into the stream). The key for the element is generated automatically

Parameters:
element - the element

put

public void put(String key,
                DockElement element)
Registers an element at this situation. When a stream is read, this element will be returned instead a newly created element (assuming that the element was written into the stream).

Parameters:
key - the key of the element
element - the element
Throws:
IllegalArgumentException - if the key is already used

getID

protected String getID(DockElement dockable)
Description copied from class: DockSituation
Gets the id of the factory which is needed to write (and later read) the element dockable.

Overrides:
getID in class DockSituation
Parameters:
dockable - the dockable to write
Returns:
the id of the factory
See Also:
DockSituation.getID(DockFactory), DockSituation.getFactory(String)

getID

protected String getID(DockFactory<?,?> factory)
Description copied from class: DockSituation
Gets the id of factory. The default behavior is just to return DockConverter.getID(). Note that this method should be a bijection to DockSituation.getFactory(String).

Overrides:
getID in class DockSituation
Parameters:
factory - the factory whose id is needed
Returns:
the id of the factory

getFactoryID

protected String getFactoryID(String id)
Description copied from class: DockSituation
Transforms an id read from a stream to the id of the factory which would be used. This method must fulfill one contract: DockFactory factory = ... factory.getID().equals( getFactoryID( getID( factory )));

Overrides:
getFactoryID in class DockSituation
Parameters:
id - the id read from a stream
Returns:
the id of the original factory

getFactory

protected DockFactory<? extends DockElement,?> getFactory(String id)
Description copied from class: DockSituation
Gets the factory which has the given id. Note that this method should be a bijection to DockSituation.getID(DockFactory). The default behavior compares id with the DockSituation.getID(DockFactory).

Overrides:
getFactory in class DockSituation
Parameters:
id - the name of the factory
Returns:
the factory or null if no factory has this id

getBackup

protected DockFactory<? extends DockElement,BackupFactoryData<?>> getBackup(String id)
Searches a backup factory with the name id.

Parameters:
id - the name of the factory
Returns:
the factory or null