qflib 0.98.0

de.qfs.lib.config
Class ConfigWrapper

java.lang.Object
  |
  +--de.qfs.lib.config.ConfigWrapper
All Implemented Interfaces:
Configurable
Direct Known Subclasses:
DialogConfigWrapper, FrameConfigWrapper, JSplitPaneConfigWrapper, JTableConfigWrapper, JToolBarConfigWrapper

public class ConfigWrapper
extends java.lang.Object
implements Configurable

A ConfigWrapper implements the Configurable interface by wrapping itself around a client Object, getting and setting its state when needed.

Standard ConfigWrappers can be constructed dynamically by passing the object to wrap to the factory method makeWrapper. This will return a ConfigWrapper for the most derived class or baseclass of the object, for which a wrapper is available, e.g.:

 JFrame frame = new JFrame ();
 ConfigWrapper wrapper = ConfigWrapper.makeWrapper(frame, "name");
 
will create a JFrameConfigWrapper.

You can make ConfigWrappers available in a package different from de.qfs.lib.config by calling addPackage.

Version:
$Revision: 1.11 $
Author:
Gregor Schmid

Constructor Summary
protected ConfigWrapper()
          Create a new ConfigWrapper.
 
Method Summary
static void addPackage(java.lang.String packagename)
          Add a package to be searched for ConfigWrappers.
 java.lang.String getConfigurableName()
          Get the receiver's configuration name.
 java.util.Properties getConfigurableState()
          Get the Configurable's state.
static ConfigWrapper makeWrapper(java.lang.Object client)
          A factory method that dynamically creates a ConfigWrapper for the most derived class or baseclass of the client, for which a wrapper is available.
static ConfigWrapper makeWrapper(java.lang.Object client, java.lang.String name)
          A factory method that dynamically creates a ConfigWrapper for the most derived class or baseclass of the client, for which a wrapper is available.
 void registrationChanged(Configuration config, java.lang.String name, boolean registered, boolean valuesKept)
          This callback is used to notify the Configurable whenever it is registered with or unregistered from the Configuration, so it can decide whether to notify the Configuration when its state changes.
protected  void setClient(java.lang.Object client)
          Set the client object for the ConfigWrapper.
 void setConfigurableName(java.lang.String name)
          Set the receiver's configuration name.
 void setConfigurableState(java.util.Properties state)
          Set the Configurable's state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigWrapper

protected ConfigWrapper()
Create a new ConfigWrapper.
Method Detail

makeWrapper

public static ConfigWrapper makeWrapper(java.lang.Object client,
                                        java.lang.String name)
A factory method that dynamically creates a ConfigWrapper for the most derived class or baseclass of the client, for which a wrapper is available.
Parameters:
client - The object to wrap.
name - The name to give the new ConfigWrapper.
Returns:
The new ConfigWrapper.

makeWrapper

public static ConfigWrapper makeWrapper(java.lang.Object client)
A factory method that dynamically creates a ConfigWrapper for the most derived class or baseclass of the client, for which a wrapper is available.
Parameters:
client - The object to wrap.
Returns:
The new ConfigWrapper.

addPackage

public static void addPackage(java.lang.String packagename)
Add a package to be searched for ConfigWrappers. Packages added later are considered more specific and are searched first.
Parameters:
packagename - The name of the package to add.

setClient

protected void setClient(java.lang.Object client)
Set the client object for the ConfigWrapper.
Parameters:
client - The client object to set. Ignored.

setConfigurableName

public void setConfigurableName(java.lang.String name)
Set the receiver's configuration name.
Specified by:
setConfigurableName in interface Configurable
Parameters:
name - The name to set.

getConfigurableName

public java.lang.String getConfigurableName()
Get the receiver's configuration name.
Specified by:
getConfigurableName in interface Configurable
Returns:
The receiver's configuration name.

getConfigurableState

public java.util.Properties getConfigurableState()
Get the Configurable's state.
Specified by:
getConfigurableState in interface Configurable
Returns:
An empty Properties object.

setConfigurableState

public void setConfigurableState(java.util.Properties state)
Set the Configurable's state.
Specified by:
setConfigurableState in interface Configurable
Parameters:
state - The state to set. Ignored.

registrationChanged

public void registrationChanged(Configuration config,
                                java.lang.String name,
                                boolean registered,
                                boolean valuesKept)
This callback is used to notify the Configurable whenever it is registered with or unregistered from the Configuration, so it can decide whether to notify the Configuration when its state changes. This default implementation does nothing.
Specified by:
registrationChanged in interface Configurable
Parameters:
config - The affected Configuration.
name - The registration name of the Configurable which may be different from the Configurable's name.
registered - True if the Configurable was just registered, false if it was unregistered.
valuesKept - Whether the Configurable's values were kept, if it was just unregistered.

qflib 0.98.0