bibliothek.gui.dock.common.intern
Class DefaultCControlRegister

java.lang.Object
  extended by bibliothek.gui.dock.common.intern.DefaultCControlRegister
All Implemented Interfaces:
CControlRegister, MutableCControlRegister

public class DefaultCControlRegister
extends java.lang.Object
implements MutableCControlRegister

Standard implementation of CControlRegister.

Author:
Benjamin Sigg

Constructor Summary
DefaultCControlRegister(CControl control)
          Creates a new register
 
Method Summary
 void addContentArea(CContentArea area)
          Adds a new content area to this register.
 void addMultipleDockable(MultipleCDockable dockable)
          Adds dockable to this register.
 void addSingleDockable(SingleCDockable dockable)
          Adds dockable to this register.
 void addStation(CStation<?> station)
          Adds station to this register.
 CommonSingleDockableFactory getBackupFactory()
          Gets the backup factory for missing SingleCDockables.
 CommonMultipleDockableFactory getCommonMultipleDockableFactory(java.lang.String id)
          Gets the factory with identifier id.
 java.util.List<CContentArea> getContentAreas()
          Gets an unmodifiable list of all CContentAreas known to this register.
 CControl getControl()
          Gets the control for which this register is used.
 CContentArea getDefaultContentArea()
          Gets the default content area.
 CDockable getDockable(int index)
          Gets the index'th dockable that is registered
 int getDockableCount()
          Gets the number of CDockables that are registered.
 java.util.List<CDockable> getDockables()
          Gets an unmodifiable list of all CDockables which are known to this register.
 java.util.Map<java.lang.String,MultipleCDockableFactory<?,?>> getFactories()
          Gets an unmodifiable map of all MultipleCDockableFactorys that are known to this register.
 MultipleCDockableFactory<?,?> getFactory(java.lang.String id)
          Searches the factory with identifier id.
 java.util.List<MultipleCDockable> getMultipleDockables()
          Gets an unmodifiable list of all MultipleCDockables which are known to this register.
 SingleCDockable getSingleDockable(java.lang.String id)
          Searches the one SingleCDockable whose unique id equals id.
 java.util.List<SingleCDockable> getSingleDockables()
          Gets an unmodifiable list of all SingleCDockables which are known to this register.
 java.util.List<CStation<?>> getStations()
          Gets an unmodifiable list of all CStations which are known to this register.
 boolean isMultiId(java.lang.String id)
          Checks whether id could be created by CControlRegister.toMultiId(String).
 boolean isSingleId(java.lang.String id)
          Checks whether id could be created by CControlRegister.toSingleId(String).
 java.util.List<CDockable> listDockablesInMode(ExtendedMode mode)
          Gets a list of all visible CDockables in the given mode.
 java.util.Set<java.lang.String> listMultipleDockableFactories()
          Gets a list of identifiers of all MultipleCDockableFactorys which are currently registered at this control.
 java.util.List<MultipleCDockable> listMultipleDockables(MultipleCDockableFactory<?,?> factory)
          Gets a list of all MultipleCDockables that are registered at this control and whose MultipleCDockable.getFactory() method returns factory.
 java.util.Set<java.lang.String> listSingleBackupFactories()
          Gets a list of keys for all SingleCDockableFactorys which are currently registered at this control.
 java.util.Set<java.lang.String> listSingleDockables()
          Gets a list of all identifiers of SingleCDockable for which this control has location information within the current setting.
 java.lang.String multiToNormalId(java.lang.String id)
          Undoes the changes of CControlRegister.toMultiId(String).
 void putCommonMultipleDockableFactory(java.lang.String id, CommonMultipleDockableFactory factory)
          Adds factory to this register.
 CommonMultipleDockableFactory removeCommonMultipleDockableFactory(java.lang.String id)
          Removes the CommonMultipleDockableFactory with identifier id rom this register.
 boolean removeContentArea(CContentArea area)
          Removes area from this register
 boolean removeMultipleDockable(MultipleCDockable dockable)
          Removes dockable from this register.
 boolean removeSingleDockable(SingleCDockable dockable)
          Removes dockable from this register.
 boolean removeStation(CStation<?> station)
          Removes station from this register.
 void setDefaultContentArea(CContentArea area)
          Sets the default content area.
 java.lang.String singleToNormalId(java.lang.String id)
          Undoes the changes of CControlRegister.toSingleId(String).
 java.lang.String toMultiId(java.lang.String id)
          Transforms an identifier to an identifier for a MultipleCDockable.
 java.lang.String toSingleId(java.lang.String id)
          Transforms an identifier to an identifier for a SingleCDockable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultCControlRegister

public DefaultCControlRegister(CControl control)
Creates a new register

Parameters:
control - the owner of this register
Method Detail

getControl

public CControl getControl()
Description copied from interface: CControlRegister
Gets the control for which this register is used.

Specified by:
getControl in interface CControlRegister
Returns:
the control

getDockables

public java.util.List<CDockable> getDockables()
Description copied from interface: CControlRegister
Gets an unmodifiable list of all CDockables which are known to this register. The list might or might not be updated when the contents of this register changes.

Specified by:
getDockables in interface CControlRegister
Returns:
an unmodifiable list of elements

getMultipleDockables

public java.util.List<MultipleCDockable> getMultipleDockables()
Description copied from interface: CControlRegister
Gets an unmodifiable list of all MultipleCDockables which are known to this register. The list might or might not be updated when the contents of this register change.

Specified by:
getMultipleDockables in interface CControlRegister
Returns:
an unmodifiable list of elements

getSingleDockables

public java.util.List<SingleCDockable> getSingleDockables()
Description copied from interface: CControlRegister
Gets an unmodifiable list of all SingleCDockables which are known to this register. The list might or might not be updated when the contents of this register changes.

Specified by:
getSingleDockables in interface CControlRegister
Returns:
an unmodifiable list of elements

getStations

public java.util.List<CStation<?>> getStations()
Description copied from interface: CControlRegister
Gets an unmodifiable list of all CStations which are known to this register. The list might or might not be updated when the content of this register changes.

Specified by:
getStations in interface CControlRegister
Returns:
an unmodifiable list of elements

getContentAreas

public java.util.List<CContentArea> getContentAreas()
Description copied from interface: MutableCControlRegister
Gets an unmodifiable list of all CContentAreas known to this register. The list might or might not be updated when the contents of this register change.

Specified by:
getContentAreas in interface MutableCControlRegister
Returns:
the unmodifiable list

addContentArea

public void addContentArea(CContentArea area)
Description copied from interface: MutableCControlRegister
Adds a new content area to this register.

Specified by:
addContentArea in interface MutableCControlRegister
Parameters:
area - the new area

listSingleBackupFactories

public java.util.Set<java.lang.String> listSingleBackupFactories()
Gets a list of keys for all SingleCDockableFactorys which are currently registered at this control.

Specified by:
listSingleBackupFactories in interface CControlRegister
Returns:
the list of keys

listMultipleDockableFactories

public java.util.Set<java.lang.String> listMultipleDockableFactories()
Gets a list of identifiers of all MultipleCDockableFactorys which are currently registered at this control.

Specified by:
listMultipleDockableFactories in interface CControlRegister
Returns:
the list of factories

listMultipleDockables

public java.util.List<MultipleCDockable> listMultipleDockables(MultipleCDockableFactory<?,?> factory)
Gets a list of all MultipleCDockables that are registered at this control and whose MultipleCDockable.getFactory() method returns factory.

Specified by:
listMultipleDockables in interface CControlRegister
Parameters:
factory - the factory to look out for
Returns:
the list of dockables, never null but might be empty

listDockablesInMode

public java.util.List<CDockable> listDockablesInMode(ExtendedMode mode)
Gets a list of all visible CDockables in the given mode.

Specified by:
listDockablesInMode in interface CControlRegister
Parameters:
mode - the mode which each CDockable must have
Returns:
the list of CDockables

listSingleDockables

public java.util.Set<java.lang.String> listSingleDockables()
Gets a list of all identifiers of SingleCDockable for which this control has location information within the current setting.

Specified by:
listSingleDockables in interface CControlRegister
Returns:
the list of ids, never null

toSingleId

public java.lang.String toSingleId(java.lang.String id)
Description copied from interface: CControlRegister
Transforms an identifier to an identifier for a SingleCDockable.
Note that this method must never create an identifier that passes CControlRegister.isMultiId(String).

Specified by:
toSingleId in interface CControlRegister
Parameters:
id - some identifier
Returns:
an identifier marked as being for a SingleCDockable

isSingleId

public boolean isSingleId(java.lang.String id)
Description copied from interface: CControlRegister
Checks whether id could be created by CControlRegister.toSingleId(String).

Specified by:
isSingleId in interface CControlRegister
Parameters:
id - the id to check
Returns:
true if there is an input for CControlRegister.toSingleId(String) that would result in id

singleToNormalId

public java.lang.String singleToNormalId(java.lang.String id)
Description copied from interface: CControlRegister
Undoes the changes of CControlRegister.toSingleId(String). It must be true that singleToNormalId( toSingleId( id )) = id. The behavior of this method is unspecified if CControlRegister.isSingleId(String) returns false for id.

Specified by:
singleToNormalId in interface CControlRegister
Parameters:
id - some id create by CControlRegister.toSingleId(String).
Returns:
the original id

toMultiId

public java.lang.String toMultiId(java.lang.String id)
Description copied from interface: CControlRegister
Transforms an identifier to an identifier for a MultipleCDockable.
Note that this method must never create an identifier that passes CControlRegister.isSingleId(String).

Specified by:
toMultiId in interface CControlRegister
Parameters:
id - some identifier
Returns:
an identifier marked as being for a MultipleCDockable

isMultiId

public boolean isMultiId(java.lang.String id)
Description copied from interface: CControlRegister
Checks whether id could be created by CControlRegister.toMultiId(String).

Specified by:
isMultiId in interface CControlRegister
Parameters:
id - the id to check
Returns:
true if there is an input for CControlRegister.toMultiId(String) that would result in id

multiToNormalId

public java.lang.String multiToNormalId(java.lang.String id)
Description copied from interface: CControlRegister
Undoes the changes of CControlRegister.toMultiId(String). It must be true that multiToNormalId( toMultiId( id )) = id. The behavior of this method is unspecified if CControlRegister.isMultiId(String) returns false for id.

Specified by:
multiToNormalId in interface CControlRegister
Parameters:
id - some id create by CControlRegister.toMultiId(String).
Returns:
the original id

addMultipleDockable

public void addMultipleDockable(MultipleCDockable dockable)
Description copied from interface: MutableCControlRegister
Adds dockable to this register.

Specified by:
addMultipleDockable in interface MutableCControlRegister
Parameters:
dockable - the new element

addSingleDockable

public void addSingleDockable(SingleCDockable dockable)
Description copied from interface: MutableCControlRegister
Adds dockable to this register.

Specified by:
addSingleDockable in interface MutableCControlRegister
Parameters:
dockable - the new element

getSingleDockable

public SingleCDockable getSingleDockable(java.lang.String id)
Description copied from interface: MutableCControlRegister
Searches the one SingleCDockable whose unique id equals id.

Specified by:
getSingleDockable in interface MutableCControlRegister
Parameters:
id - some id to search
Returns:
a dockable with the same id

addStation

public void addStation(CStation<?> station)
Description copied from interface: MutableCControlRegister
Adds station to this register.

Specified by:
addStation in interface MutableCControlRegister
Parameters:
station - the new station

getBackupFactory

public CommonSingleDockableFactory getBackupFactory()
Description copied from interface: MutableCControlRegister
Gets the backup factory for missing SingleCDockables.

Specified by:
getBackupFactory in interface MutableCControlRegister
Returns:
the factory, never null

getCommonMultipleDockableFactory

public CommonMultipleDockableFactory getCommonMultipleDockableFactory(java.lang.String id)
Description copied from interface: MutableCControlRegister
Gets the factory with identifier id.

Specified by:
getCommonMultipleDockableFactory in interface MutableCControlRegister
Parameters:
id - the id of the factory
Returns:
the factory or null

getDefaultContentArea

public CContentArea getDefaultContentArea()
Description copied from interface: MutableCControlRegister
Gets the default content area.

Specified by:
getDefaultContentArea in interface MutableCControlRegister
Returns:
the area, can be null

putCommonMultipleDockableFactory

public void putCommonMultipleDockableFactory(java.lang.String id,
                                             CommonMultipleDockableFactory factory)
Description copied from interface: MutableCControlRegister
Adds factory to this register.

Specified by:
putCommonMultipleDockableFactory in interface MutableCControlRegister
Parameters:
id - the id for the factory
factory - the new factory

removeCommonMultipleDockableFactory

public CommonMultipleDockableFactory removeCommonMultipleDockableFactory(java.lang.String id)
Description copied from interface: MutableCControlRegister
Removes the CommonMultipleDockableFactory with identifier id rom this register.

Specified by:
removeCommonMultipleDockableFactory in interface MutableCControlRegister
Parameters:
id - the identifier of the factory
Returns:
the factory that was removed or null

removeContentArea

public boolean removeContentArea(CContentArea area)
Description copied from interface: MutableCControlRegister
Removes area from this register

Specified by:
removeContentArea in interface MutableCControlRegister
Parameters:
area - the area to remove
Returns:
true if area was known to this register before, false if area could not be removed because it was not in the list

removeMultipleDockable

public boolean removeMultipleDockable(MultipleCDockable dockable)
Description copied from interface: MutableCControlRegister
Removes dockable from this register.

Specified by:
removeMultipleDockable in interface MutableCControlRegister
Parameters:
dockable - the element to remove
Returns:
true if dockable was removed, false if not

removeSingleDockable

public boolean removeSingleDockable(SingleCDockable dockable)
Description copied from interface: MutableCControlRegister
Removes dockable from this register.

Specified by:
removeSingleDockable in interface MutableCControlRegister
Parameters:
dockable - the element to remove
Returns:
true if dockable was removed, false if not

removeStation

public boolean removeStation(CStation<?> station)
Description copied from interface: MutableCControlRegister
Removes station from this register.

Specified by:
removeStation in interface MutableCControlRegister
Parameters:
station - the station to remove
Returns:
true if station was removed, false otherwise

setDefaultContentArea

public void setDefaultContentArea(CContentArea area)
Description copied from interface: MutableCControlRegister
Sets the default content area.

Specified by:
setDefaultContentArea in interface MutableCControlRegister
Parameters:
area - the new area

getDockable

public CDockable getDockable(int index)
Description copied from interface: CControlRegister
Gets the index'th dockable that is registered

Specified by:
getDockable in interface CControlRegister
Parameters:
index - the index of the element
Returns:
the selected dockable

getDockableCount

public int getDockableCount()
Description copied from interface: CControlRegister
Gets the number of CDockables that are registered.

Specified by:
getDockableCount in interface CControlRegister
Returns:
the number of dockables

getFactories

public java.util.Map<java.lang.String,MultipleCDockableFactory<?,?>> getFactories()
Description copied from interface: CControlRegister
Gets an unmodifiable map of all MultipleCDockableFactorys that are known to this register. The map may or may not be updated when the content of this register changes.

Specified by:
getFactories in interface CControlRegister
Returns:
the unmodifiable map of factories

getFactory

public MultipleCDockableFactory<?,?> getFactory(java.lang.String id)
Description copied from interface: CControlRegister
Searches the factory with identifier id.

Specified by:
getFactory in interface CControlRegister
Parameters:
id - the id of the factory
Returns:
the factory or null