bibliothek.gui.dock.util
Class UIProperties<V,U extends UIValue<V>,B extends UIBridge<V,U>>

java.lang.Object
  extended by bibliothek.gui.dock.util.UIProperties<V,U,B>
Type Parameters:
V - The kind of values this map contains
U - The kind of observers used to read values from this map
B - The kind of bridges used to transfer values V to observers U
Direct Known Subclasses:
ColorManager, FontManager, IconManager, TextManager

public class UIProperties<V,U extends UIValue<V>,B extends UIBridge<V,U>>
extends java.lang.Object

A map containing which contains some string-values pairs and so called bridges to modify these values when reading them out.

Author:
Benjamin Sigg

Constructor Summary
UIProperties(DockController controller)
          Creates a new map.
 
Method Summary
 void add(java.lang.String id, Path path, U value)
          Installs a new UIValue.
 void clear(Priority priority)
          Removes all values that stored under the given priority.
 V get(java.lang.String id)
          Gets a resource.
 void get(java.lang.String id, Path kind, U key)
          Call UIValue.set(Object) with the matching value that is stored in this map for id.
 B getBridge(Priority priority, Path path)
          Gets the bridge which is stored on level priority for UIValues of kind path.
protected  B getBridgeFor(Path path)
          Searches a bridge that can be used for path.
 DockController getController()
          Gets the controller in whose realm this map is used.
 UIScheme<V,U,B> getScheme(Priority priority)
          Gets the UIScheme that is used to fill up missing values in the level priority.
 boolean isObserved(Path path)
          Tells whether the bridge with id path is observed by at least one UIValue.
 boolean isObserved(java.lang.String id)
          Tells whether the value with id id is observed by at least one UIValue.
 boolean isStored(B bridge)
          Tells whether bridge is stored in this map.
 void lockUpdate()
          Tells this manager to stall all updates.
 void publish(Priority priority, Path path, B bridge)
          Adds a new bridge between this UIProperties and a set of UIValues that have a certain type.
 void put(Priority priority, java.lang.String id, V resource)
          Sets a new resource and informs all UIValue that are observing id about the change.
 void remove(U value)
          Uninstalls an observer of a resource
 void setScheme(Priority priority, UIScheme<V,U,B> scheme)
          Sets or removes an UIScheme for the level priority of this UIProperties.
 void unlockUpdate()
          Tells this manager no longer to stall updates.
 void unpublish(Priority priority, B bridge)
          Searches for all occurrences of bridge and removes them.
 void unpublish(Priority priority, Path path)
          Removes the bridge that handles the UIValues of kind path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIProperties

public UIProperties(DockController controller)
Creates a new map.

Parameters:
controller - the owner of this map
Method Detail

getController

public DockController getController()
Gets the controller in whose realm this map is used.

Returns:
the controller, not null

lockUpdate

public void lockUpdate()
Tells this manager to stall all updates. No UIValue will be informed when a color or provider changes.


unlockUpdate

public void unlockUpdate()
Tells this manager no longer to stall updates. This triggers a full update on all UIValues.


getScheme

public UIScheme<V,U,B> getScheme(Priority priority)
Gets the UIScheme that is used to fill up missing values in the level priority.

Parameters:
priority - some priority
Returns:
the scheme of that level or null
See Also:
setScheme(Priority, UIScheme)

setScheme

public void setScheme(Priority priority,
                      UIScheme<V,U,B> scheme)
Sets or removes an UIScheme for the level priority of this UIProperties. The scheme will be used to fill missing values of this properties. Since a "missing resource" cannot be removed, any attempt to delete a resource created by a scheme must fail.

Parameters:
priority - the level which will be provided with new values from scheme.
scheme - the new scheme or null

publish

public void publish(Priority priority,
                    Path path,
                    B bridge)
Adds a new bridge between this UIProperties and a set of UIValues that have a certain type.

Parameters:
priority - the importance of the new provider
path - the path for which this bridge should be used.
bridge - the new bridge

unpublish

public void unpublish(Priority priority,
                      Path path)
Removes the bridge that handles the UIValues of kind path. Please note that bridges created by the current UIScheme cannot be removed. Also note that the removed bridge may be replaced by a bridge created by the current UIScheme.

Parameters:
priority - the importance of the bridge
path - the path of the bridge

unpublish

public void unpublish(Priority priority,
                      B bridge)
Searches for all occurrences of bridge and removes them. Please note that bridges created by the current UIScheme cannot be removed. Also note that the removed bridge may be replaced by a bridge created by the current UIScheme. All UIValues that used bridge are redistributed.

Parameters:
priority - the importance of the bridge
bridge - the bridge to remove

getBridge

public B getBridge(Priority priority,
                   Path path)
Gets the bridge which is stored on level priority for UIValues of kind path.

Parameters:
priority - the level in which to search
path - the kind of the UIValues
Returns:
either null, a bridge that has been published or a bridge that was created by an UIScheme

isStored

public boolean isStored(B bridge)
Tells whether bridge is stored in this map.

Parameters:
bridge - some object to search
Returns:
true if bridge was found anywhere

isObserved

public boolean isObserved(Path path)
Tells whether the bridge with id path is observed by at least one UIValue.

Parameters:
path - the name of some UIBridge
Returns:
if path is observed

add

public void add(java.lang.String id,
                Path path,
                U value)
Installs a new UIValue. The value will be informed about any change in the resource id.

Parameters:
id - the id of the resource that value will monitor
path - the kind of the value
value - the new observer

remove

public void remove(U value)
Uninstalls an observer of a resource

Parameters:
value - the observer to remove

isObserved

public boolean isObserved(java.lang.String id)
Tells whether the value with id id is observed by at least one UIValue.

Parameters:
id - the name of some value
Returns:
if id is observed

getBridgeFor

protected B getBridgeFor(Path path)
Searches a bridge that can be used for path.

Parameters:
path - the kind of bridge that is searched. First a bridge for path will be searched, then for the parent of path, and so on...
Returns:
the bridge or null

put

public void put(Priority priority,
                java.lang.String id,
                V resource)
Sets a new resource and informs all UIValue that are observing id about the change. Please note that values created by an UIScheme cannot be removed, and that a removed value may be replaced by a value of an UIScheme.

Parameters:
priority - the importance of this value
id - the name of the value
resource - the new resource, can be null

get

public V get(java.lang.String id)
Gets a resource.

Parameters:
id - the id of the resource
Returns:
the resource or null
See Also:
put(Priority, String, Object)

get

public void get(java.lang.String id,
                Path kind,
                U key)
Call UIValue.set(Object) with the matching value that is stored in this map for id.

Parameters:
id - the unique identifier of the value to read
kind - the kind of value key is
key - the destination of the value

clear

public void clear(Priority priority)
Removes all values that stored under the given priority. Values created by an UIScheme are not affected by this call.

Parameters:
priority - the priority whose elements should be removed