com.sdm.quasar.client.core.dialog
Interface FeatureManager

All Known Subinterfaces:
DialogControl
All Known Implementing Classes:
DefaultDialogControl, DefaultFeatureManager

public interface FeatureManager

A FeatureManager manages a set of Features for a single DialogControl instance.

The functionality of FeatureManager is an integral part of DialogControl. Every DialogControl is (per inheritence) a FeatureManager!

When using Features, it is important, that the feature instances are registered within the FeatureManager to work properly; otherwise they cannot take part on the dialog lifecycle installed to.

A FeatureManager does support accessing installed Features via key classes. Such a key class must be a superclass or interface of the concrete Feature implementation and must implement Feature. This key class must be provided on feature-registration (see installFeature(Class, Feature) or installFeature(Class, Class)). If a feature is installed without a key class, it cannot be retreived from the FeatureManager. To remove a Feature instance from the FeatureManager eighter dispose them (see Feature.dispose()) or uninstall them (see uninstallFeature(Feature).

There are two ways of installing and accessing Features within an application:

  1. Install a feature (instance) and get it where needed:
     // Setup-code:
     getDialogControl().installFeature(VisualRepresentationFeature.class,new VisualRepresentationFeature());
     // Access code (usually wrapped within a getter method)
     (VisualRepresentationFeature)getDialogControl().getFeature(VisualRepresentationFeature.class);
     
  2. Always require the feature (in this case the key class must be the same than the/a implementation class; no abstract class or interface allowed here):
     // Access code (usually wrapped within a getter method)
     (VisualRepresentationFeature)getDialogControl().requireFeature(VisualRepresentationFeature.class);
     

    Version:
    1.$Revision$
    Author:
    Thomas Wolf

    Method Summary
     Feature getFeature(java.lang.Class keyClass)
              Returns the Feature associated with the given key class.
     boolean hasFeature(java.lang.Class keyClass)
              Returns true, if a Feature is registered under the given key class.
     Feature installFeature(java.lang.Class featureClass)
              Installs an instance of the specified feature class.
     Feature installFeature(java.lang.Class keyClass, java.lang.Class featureClass)
              Installs an instance of the specified feature class under the given key class.
     Feature installFeature(java.lang.Class keyClass, Feature feature)
              Installs the specified feature under the given key class.
     Feature installFeature(Feature feature)
              Installs the specified feature.
     Feature requireFeature(java.lang.Class featureClass)
              Returns the feature associated with the given key class; if no such feature was registered before, a new instance of the given class will created and installed as Feature for it's concrete class as feature key class.
     Feature uninstallFeature(Feature feature)
              Uninstalls the specified feature instance.
     

    Method Detail

    installFeature

    public Feature installFeature(Feature feature)
    Installs the specified feature. The Feature cannote be accessed by a key class, so therefore installFeature(Class, Feature) should be called.

    Parameters:
    feature - the feature instance to be installed
    Returns:
    the installed Feature instance (the same than the parameter)

    installFeature

    public Feature installFeature(java.lang.Class keyClass,
                                  Feature feature)
    Installs the specified feature under the given key class. The given feature must be of the same class or a subclass or subinterface of the key class.

    Note: There must no feature installed with the given key class before, otherwise an assertion will be thrown.

    Parameters:
    keyClass - the key class to refer to the feature
    feature - the feature instance to be installed
    Returns:
    the installed Feature instance (the same than the parameter)

    uninstallFeature

    public Feature uninstallFeature(Feature feature)
    Uninstalls the specified feature instance. Only the exact feature instance will be uninstalled.

    Parameters:
    feature - the feature instance to be uninstalled
    Returns:
    the uninstalled Feature instance

    installFeature

    public Feature installFeature(java.lang.Class keyClass,
                                  java.lang.Class featureClass)
    Installs an instance of the specified feature class under the given key class. The FeatureManager tries to create the feature instance using the registered FeatureCreator's. It is assumed, that the most specific FeatureCreator is added last. The given feature class must be a subclass of the key class given.

    Note: There must no feature installed with the given key class before, otherwise an assertion will be thrown.

    Parameters:
    keyClass - the key class to refer to the feature (if null, the feature instance will be installed, but no mapping will be made)
    featureClass - the feature class to install an instance of
    Returns:
    the installed Feature instance

    installFeature

    public Feature installFeature(java.lang.Class featureClass)
    Installs an instance of the specified feature class. This feature instance if mapped to no key class. To install a feature under a key class use installFeature(Class, Class). The FeatureManager tries to create the feature instance using the registered FeatureCreator's. It is assumed, that the most specific FeatureCreator is added last.

    Parameters:
    featureClass - the feature class to install an instance of
    Returns:
    the installed Feature instance
    See Also:
    installFeature(Class, Class)

    hasFeature

    public boolean hasFeature(java.lang.Class keyClass)
    Returns true, if a Feature is registered under the given key class.

    Parameters:
    keyClass - the key class to check containment for

    getFeature

    public Feature getFeature(java.lang.Class keyClass)
    Returns the Feature associated with the given key class.

    Parameters:
    keyClass - the key class to get a Feature for
    Returns:
    the Feature instance
    Throws:
    java.lang.IllegalArgumentException - if no feature was installed for the given key Class

    requireFeature

    public Feature requireFeature(java.lang.Class featureClass)
    Returns the feature associated with the given key class; if no such feature was registered before, a new instance of the given class will created and installed as Feature for it's concrete class as feature key class.

    Parameters:
    featureClass - the key and concrete feature class
    Returns:
    the Feature associated with the given key class.
    See Also:
    installFeature(Class)