bibliothek.gui.dock.util
Class DockProperties

java.lang.Object
  extended by bibliothek.gui.dock.util.DockProperties

public class DockProperties
extends Object

A set of properties that are used at different places all over the framework. The map uses a Priority based system, allowing clients to override behavior of themes or set default values in case a theme does not set one.

Author:
Benjamin Sigg

Constructor Summary
DockProperties(DockController controller)
          Creates a new map.
 
Method Summary
<A> void
addListener(PropertyKey<A> key, DockPropertyListener<A> listener)
          Adds a listener that will be informed whenever the value accessed through key changes.
<A> void
finalize(PropertyKey<A> key)
          Ensures that the value behind key will never be changed.
<A> A
get(PropertyKey<A> key)
          Gets the value accessed by key.
<A> A
get(PropertyKey<A> key, Priority priority)
          Gets the value of key for the given priority.
 DockController getController()
          Gets the owner of this DockProperties.
<A> boolean
isSet(PropertyKey<A> key)
          Tells whether there is value set for key.
<A> boolean
isSet(PropertyKey<A> key, Priority priority)
          Tells whether there is value set for key with priority.
<A> void
removeListener(PropertyKey<A> key, DockPropertyListener<A> listener)
          Removes an earlier added listener.
<A> void
set(PropertyKey<A> key, A value)
          Sets a value.
<A> void
set(PropertyKey<A> key, A value, Priority priority)
          Sets a value.
<A> void
setOrRemove(PropertyKey<A> key, A value, Priority priority)
          Either sets the property key to value or set the default value for key.
 void unset(PropertyKey<?> key)
          Tells the entry key that the user has never set its value.
 void unset(PropertyKey<?> key, Priority priority)
          Tells the entry key that the user has never set its value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockProperties

public DockProperties(DockController controller)
Creates a new map.

Parameters:
controller - the owner of this map
Method Detail

getController

public DockController getController()
Gets the owner of this DockProperties.

Returns:
the owner, not null

set

public <A> void set(PropertyKey<A> key,
                    A value)
Sets a value. This is equivalent to calling set( key, value, Priority.CLIENT ).

Type Parameters:
A - the type of the value
Parameters:
key - the key to access the value
value - the value, can be null

set

public <A> void set(PropertyKey<A> key,
                    A value,
                    Priority priority)
Sets a value.

Type Parameters:
A - the type of the value
Parameters:
key - the key to access the value
value - the value, can be null
priority - the priority of the new value

finalize

public <A> void finalize(PropertyKey<A> key)
Ensures that the value behind key will never be changed. Should be used with care: any attempt to set the value afterwards will be responded with an IllegalStateException. Most times it is much better to just use Priority.CLIENT to mark some setting as important.

Type Parameters:
A - the type of the value
Parameters:
key - the key to protect

setOrRemove

public <A> void setOrRemove(PropertyKey<A> key,
                            A value,
                            Priority priority)
Either sets the property key to value or set the default value for key.

Type Parameters:
A - the type of the value
Parameters:
key - the key to access the value
value - the new value, if null then the default value will be set
priority - the priority of the value to remove

unset

public void unset(PropertyKey<?> key)
Tells the entry key that the user has never set its value. This is equivalent to calling unset( key, Priority.CLIENT ).

Parameters:
key - the key to access the entry

unset

public void unset(PropertyKey<?> key,
                  Priority priority)
Tells the entry key that the user has never set its value. Also removes the old value of the entry.

Parameters:
key - the key to access the entry
priority - the priority for which to remove the value

get

public <A> A get(PropertyKey<A> key)
Gets the value accessed by key. If the value in the properties is not set, then the default value is returned.

Type Parameters:
A - the type of the value
Parameters:
key - the key to search
Returns:
the value or null

get

public <A> A get(PropertyKey<A> key,
                 Priority priority)
Gets the value of key for the given priority.

Type Parameters:
A - the kind of value
Parameters:
key - some key, not null
priority - the priority, not null
Returns:
the value, might be null even if get(PropertyKey) returns a non-null value

isSet

public <A> boolean isSet(PropertyKey<A> key,
                         Priority priority)
Tells whether there is value set for key with priority.

Type Parameters:
A - the kind of value
Parameters:
key - the key to check
priority - the priority for which something might be set
Returns:
true if there is a value set

isSet

public <A> boolean isSet(PropertyKey<A> key)
Tells whether there is value set for key.

Type Parameters:
A - the kind of value
Parameters:
key - the key to check
Returns:
true if there is a value set

addListener

public <A> void addListener(PropertyKey<A> key,
                            DockPropertyListener<A> listener)
Adds a listener that will be informed whenever the value accessed through key changes.

Type Parameters:
A - the type of the value
Parameters:
key - the key that accesses the value
listener - the new listener

removeListener

public <A> void removeListener(PropertyKey<A> key,
                               DockPropertyListener<A> listener)
Removes an earlier added listener.

Type Parameters:
A - the type of value observed by the listener
Parameters:
key - the key to access the observed entry
listener - the listener to remove