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

@Todo(compatibility=BREAK_MINOR,
      priority=MAJOR,
      target=VERSION_1_1_0,
      description="Use typesafe keys instead of Path")
public class UIProperties<V,U extends UIValue<V>,B extends UIBridge<V,U>>
extends 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(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(String id)
          Gets a resource.
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.
 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, 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 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.


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.

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. All UIValues that used bridge are redistributed.

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

add

public void add(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 value

remove

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

Parameters:
value - the observer to remove

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,
                String id,
                V resource)
Sets a new resource and informs all UIValue that are observing id about the change.

Parameters:
priority - the importance of this value
id - the id of the color
resource - the new resource

get

public V get(String id)
Gets a resource.

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

clear

public void clear(Priority priority)
Removes all values that stored under the given priority.

Parameters:
priority - the priority whose elements should be removed