bibliothek.gui.dock.common.intern.ui
Class UITransmitter<V,U extends UIValue<V>>

java.lang.Object
  extended by bibliothek.gui.dock.common.intern.ui.UITransmitter<V,U>
Type Parameters:
V - the kind of value that is described by the UIValue
U - the kind of UIValue used in this transmitter
All Implemented Interfaces:
UIBridge<V,U>
Direct Known Subclasses:
ColorTransmitter, FontTransmitter

public abstract class UITransmitter<V,U extends UIValue<V>>
extends Object
implements UIBridge<V,U>

An UITransmitter listens to some kind of map and updates some UIValues when the contents of that map change.

Author:
Benjamin Sigg

Constructor Summary
UITransmitter(String... keys)
          Creates a new ColorTransmitter.
 
Method Summary
 void add(String id, U value)
          Adds a new UIValue that gets its resource from this bridge.
protected abstract  void connect(CDockable dockable)
          Adds a listener to dockable and calls update(CDockable, String, Object) whenever some value needs an update.
protected abstract  void disconnect(CDockable dockable)
          Removes a listener from dockable.
protected abstract  V get(V value, String id, U observer)
          Called when a value needs to be set whose key has been registered at this UITransmitter.
protected abstract  CDockable getDockable(U observer)
          Gets the CDockable which is associated with observer.
 void remove(String id, U value)
          Removes a value from this bridge.
protected  void set(String id, V value, CDockable dockable)
          Transmits value to all UIValues which listen to the given id and which are associated with dockable.
 void set(String id, V value, U observer)
          Called by the UIProperties when one resource or UIValue has been exchanged.
 void setControl(CControl control)
          Sets the CControl which should be observed for new CDockables by this transmitter.
protected abstract  void update(CDockable dockable, String key, V value)
          Called when a value in an observed map has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UITransmitter

public UITransmitter(String... keys)
Creates a new ColorTransmitter.

Parameters:
keys - the keys which should be monitored by this transmitter
Method Detail

add

public void add(String id,
                U value)
Description copied from interface: UIBridge
Adds a new UIValue that gets its resource from this bridge.

Specified by:
add in interface UIBridge<V,U extends UIValue<V>>
Parameters:
id - the id of the resource the new value needs
value - a value that can be modified by this bride

remove

public void remove(String id,
                   U value)
Description copied from interface: UIBridge
Removes a value from this bridge.

Specified by:
remove in interface UIBridge<V,U extends UIValue<V>>
Parameters:
id - the id of the resource the value needed
value - the value that is no longer in use

setControl

public void setControl(CControl control)
Sets the CControl which should be observed for new CDockables by this transmitter.

Parameters:
control - the observed control, can be null

set

public void set(String id,
                V value,
                U observer)
Description copied from interface: UIBridge
Called by the UIProperties when one resource or UIValue has been exchanged. Normally an UIBridge can just call UIValue.set(Object) with the argument value.

Specified by:
set in interface UIBridge<V,U extends UIValue<V>>
Parameters:
id - the identifier of the resource
value - the new resource, can be null
observer - the value that is affected by the change

get

protected abstract V get(V value,
                         String id,
                         U observer)
Called when a value needs to be set whose key has been registered at this UITransmitter.

Parameters:
value - the original value
id - the key of the value
observer - the destination for the value
Returns:
the value that should be set to observer

update

protected abstract void update(CDockable dockable,
                               String key,
                               V value)
Called when a value in an observed map has changed.

Parameters:
dockable - the owner of the map
key - the name of the changed value
value - the new value in the map, can be null

getDockable

protected abstract CDockable getDockable(U observer)
Gets the CDockable which is associated with observer.

Parameters:
observer - some observer
Returns:
the associated dockable or null

set

protected void set(String id,
                   V value,
                   CDockable dockable)
Transmits value to all UIValues which listen to the given id and which are associated with dockable.

Parameters:
id - the id of the changed value
value - the new value, might be null
dockable - the associated dockable, might be null

connect

protected abstract void connect(CDockable dockable)
Adds a listener to dockable and calls update(CDockable, String, Object) whenever some value needs an update.

Parameters:
dockable - the element to observe

disconnect

protected abstract void disconnect(CDockable dockable)
Removes a listener from dockable.

Parameters:
dockable - the element from which a listener should be removed