bibliothek.gui.dock.util
Class TypedUIProperties

java.lang.Object
  extended by bibliothek.gui.dock.util.TypedUIProperties
Direct Known Subclasses:
ThemeManager

public class TypedUIProperties
extends Object

A wrapper around an UIProperties enhancing the properties with type safety.

Author:
Benjamin Sigg

Nested Class Summary
static class TypedUIProperties.Type<T>
          A class describing a type, different TypedUIProperties.Type objects may share the same Class object but with different or even equal generic parameters.
 
Constructor Summary
TypedUIProperties(DockController controller)
          Creates a new map.
 
Method Summary
<V> void
add(String id, Path kind, TypedUIProperties.Type<V> type, UIValue<V> value)
          Adds the listener value to this manager.
 void clear(Priority priority)
          Removes all resources that were stored on the level priority.
<V> V
get(String id, TypedUIProperties.Type<V> type)
          Gets the current value of the resource id with type type.
 UIScheme<Object,UIValue<Object>,UIBridge<Object,UIValue<Object>>> getScheme(Priority priority)
          Gets the scheme which fills missing entries on the level priority
<V> void
publish(Priority priority, Path kind, TypedUIProperties.Type<V> type, UIBridge<V,UIValue<V>> bridge)
          Adds an UIBridge to this manager, the bridge will be responsible for UIValues of kind kind.
<V> void
put(Priority priority, String id, TypedUIProperties.Type<V> type, V value)
          Sets a value of this manager.
<T> void
registerType(TypedUIProperties.Type<T> type)
          Registers type at this properties.
 void remove(UIValue<?> value)
          Removes the observer value from this manager.
 void setScheme(Priority priority, UIScheme<Object,UIValue<Object>,UIBridge<Object,UIValue<Object>>> scheme)
          Sets a scheme that is used to fill missing entries.
<V> void
unpublish(Priority priority, Path kind, TypedUIProperties.Type<V> type)
          Removes the UIBridge that was responsible for handling UIValues of kind kind and wrapping type type
<V> void
unpublish(Priority priority, UIBridge<V,UIValue<V>> bridge)
          Removes any occurrence of bridge from this manager.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedUIProperties

public TypedUIProperties(DockController controller)
Creates a new map.

Parameters:
controller - the controller that uses this map
Method Detail

registerType

public <T> void registerType(TypedUIProperties.Type<T> type)
Registers type at this properties. Only after type has been registered it can be used to call the methods of this object. Note that type cannot be removed nor can it be altered. An attempt to use another TypedUIProperties.Type with the same key will always result in an exception.

Type Parameters:
T - the type
Parameters:
type - the new type, not null

setScheme

public void setScheme(Priority priority,
                      UIScheme<Object,UIValue<Object>,UIBridge<Object,UIValue<Object>>> scheme)
Sets a scheme that is used to fill missing entries.

Parameters:
priority - the level on which the scheme will operate
scheme - the new scheme or null

getScheme

public UIScheme<Object,UIValue<Object>,UIBridge<Object,UIValue<Object>>> getScheme(Priority priority)
Gets the scheme which fills missing entries on the level priority

Parameters:
priority - the level to question
Returns:
the scheme or null

add

public <V> void add(String id,
                    Path kind,
                    TypedUIProperties.Type<V> type,
                    UIValue<V> value)
Adds the listener value to this manager.

Type Parameters:
V - the type of object value supports.
Parameters:
id - the unique identifier of the property to observe
kind - what kind of object value actually is
type - V in a form that can be tested by this manager
value - the new observer
Throws:
IllegalArgumentException - if type is not known to this manager or if either of the arguments is null

remove

public void remove(UIValue<?> value)
Removes the observer value from this manager.

Parameters:
value - the observer to remove

publish

public <V> void publish(Priority priority,
                        Path kind,
                        TypedUIProperties.Type<V> type,
                        UIBridge<V,UIValue<V>> bridge)
Adds an UIBridge to this manager, the bridge will be responsible for UIValues of kind kind. Please note that UIValues of a sub-kind of kind might be handled by bridge as well, unless a bridge was installed for that sub-kind.

Type Parameters:
V - the type
Parameters:
priority - the importance of bridge
kind - the kind of UIValues bridge has to handle
type - The type of objects hanlded by bridge
bridge - the new bridge

unpublish

public <V> void unpublish(Priority priority,
                          Path kind,
                          TypedUIProperties.Type<V> type)
Removes the UIBridge that was responsible for handling UIValues of kind kind and wrapping type type

Type Parameters:
V - the type
Parameters:
priority - the level on which the bridge worked
kind - the kind of UIValue the bridge handled
type - the type of value the UIValues handle

unpublish

public <V> void unpublish(Priority priority,
                          UIBridge<V,UIValue<V>> bridge)
Removes any occurrence of bridge from this manager.

Type Parameters:
V - the type handled by the UIValues
Parameters:
priority - the level on which to search the bridge
bridge - the bridge to remove everywhere

put

public <V> void put(Priority priority,
                    String id,
                    TypedUIProperties.Type<V> type,
                    V value)
Sets a value of this manager.

Type Parameters:
V - the type
Parameters:
priority - the level on which to store value
id - the unique identifier of value
type - the type of value
value - the resources itself, can be null

get

public <V> V get(String id,
                 TypedUIProperties.Type<V> type)
Gets the current value of the resource id with type type.

Type Parameters:
V - the type
Parameters:
id - the identifier of some resource
type - the type of the resource
Returns:
the resource or null

clear

public void clear(Priority priority)
Removes all resources that were stored on the level priority.

Parameters:
priority - the priority of the level to remove