com.sdm.quasar.client.core.dialog.impl
Class DefaultDialogControl

java.lang.Object
  extended bycom.sdm.quasar.client.core.dialog.impl.DefaultDialogControl
All Implemented Interfaces:
DialogControl, DialogServiceAccess, FeatureManager, LifeCycleControl, LifeCycleStateProvider

public class DefaultDialogControl
extends java.lang.Object
implements DialogControl

Default implementation of DialogControl.

Version:
1.0
Author:
Thomas Wolf, sd&m AG

Method Summary
 void attachToLifeCycle(LifeCycle lifeCycle)
          Attaches a component that is interested in the life cycle of this dialog to the notification chain.
 boolean canCreateSubDialog(java.lang.String dialogId)
          Tests, whether the dialog with the given id can be created as subdialog.
 SubDialogControl createSubDialog(java.lang.String dialogId, java.lang.Object context)
          Creates a new dialog that is dependent on this dialog.
 void detachFromLifeCycle(LifeCycle lifeCycle)
          Detaches a component from the life cycle notification.
 Service findServiceInHierarchy(java.lang.Class service)
          Returns the first implementation of a desired service in the hierarchy of the node.
 Service findServiceInParentHierarchy(java.lang.Class service)
          Returns the first implementation of a desired service in the hierarchy of the parent node.
 java.lang.Object getCreationContext()
          Returns the creation context passed by the dialog instance creation of this dialog instance.
 DialogInstanceId getDialogInstanceId()
           
 Feature getFeature(java.lang.Class keyClass)
          Returns the Feature associated with the given key class.
 LifeCycleState getLifeCycleState()
           
 Service getServiceDirect(ID id, java.lang.Class service)
          Returns the implementation of a desired service registered at the node with the given id.
 boolean hasFeature(java.lang.Class keyClass)
          Returns true, if a Feature is registered under the given key class.
 boolean hasServiceDirect(ID id, java.lang.Class service)
          Tests whether a specific node offers a service.
 boolean hasServiceInHierarchy(java.lang.Class service)
          Tests if a service exists in the hierarchy of the node.
 boolean hasServiceInParentHierarchy(java.lang.Class service)
          Tests if a service exists in the hierarchy of the parent node.
 boolean hasSubDialog(SubDialogControl subDialogControl)
          Returns true, if the SubDialogControl given is a valid sub dialog of this DialogControl (created via createSubDialog(String, Object)), that is currently not disposed.
 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.
 void registerService(java.lang.Class service, Service implementation)
          Registers a service for this node.
 void registerServiceForHierarchy(java.lang.Class service, Service implementation)
          Registers a service for this node for hierarchical use only.
 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.
 void unregisterService(java.lang.Class service, Service implementation)
          Unregisters a service for this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createSubDialog

public SubDialogControl createSubDialog(java.lang.String dialogId,
                                        java.lang.Object context)
Description copied from interface: DialogControl
Creates a new dialog that is dependent on this dialog.

Specified by:
createSubDialog in interface DialogControl
Parameters:
dialogId - the dialog id of the new dialog
context - the initialization context of the new dialog
Returns:
the interface to control the lifecycle of a sub dialog
See Also:
com.sdm.quasar.client.comp.dlgdef.lifecyclectrl.DialogControl#createSubDialog(java.lang.String, java.lang.Object)

hasSubDialog

public boolean hasSubDialog(SubDialogControl subDialogControl)
Description copied from interface: DialogControl
Returns true, if the SubDialogControl given is a valid sub dialog of this DialogControl (created via DialogControl.createSubDialog(String, Object)), that is currently not disposed.

Specified by:
hasSubDialog in interface DialogControl
Parameters:
subDialogControl - the SubDialogControl to check
Returns:
true, if the SubDialogControl is created by this DialogControl and
See Also:
DialogControl.hasSubDialog(com.sdm.quasar.client.core.dialog.SubDialogControl)

canCreateSubDialog

public boolean canCreateSubDialog(java.lang.String dialogId)
Description copied from interface: DialogControl
Tests, whether the dialog with the given id can be created as subdialog.

Specified by:
canCreateSubDialog in interface DialogControl
Parameters:
dialogId - Id of the dialog to be created
Returns:
true, iff the dialog can be created
See Also:
com.sdm.quasar.client.comp.dlgdef.lifecyclectrl.DialogControl#canCreateSubDialog(java.lang.String, java.lang.Object)

getDialogInstanceId

public DialogInstanceId getDialogInstanceId()
Specified by:
getDialogInstanceId in interface DialogControl
Returns:
the instance id of the dialog that this control is assigned to
See Also:
DialogControl.getDialogInstanceId()

getCreationContext

public java.lang.Object getCreationContext()
Description copied from interface: DialogControl
Returns the creation context passed by the dialog instance creation of this dialog instance.

Specified by:
getCreationContext in interface DialogControl
See Also:
DialogControl.getCreationContext()

attachToLifeCycle

public void attachToLifeCycle(LifeCycle lifeCycle)
Description copied from interface: LifeCycleControl
Attaches a component that is interested in the life cycle of this dialog to the notification chain. All registered LifeCycle implementations will be notified of lifecycle changes in the order they have been registered for calls to LifeCycle.prepare() and LifeCycle.activate() and in reverse order for LifeCycle.deactivate() and LifeCycle.release().

Specified by:
attachToLifeCycle in interface LifeCycleControl
Parameters:
lifeCycle - the life cycle to be notified
See Also:
LifeCycleControl.attachToLifeCycle(LifeCycle)

detachFromLifeCycle

public void detachFromLifeCycle(LifeCycle lifeCycle)
Description copied from interface: LifeCycleControl
Detaches a component from the life cycle notification.

Specified by:
detachFromLifeCycle in interface LifeCycleControl
Parameters:
lifeCycle - the life cycle that should not be notified any more
See Also:
LifeCycleControl.detachFromLifeCycle(LifeCycle)

getLifeCycleState

public LifeCycleState getLifeCycleState()
Specified by:
getLifeCycleState in interface LifeCycleStateProvider
Returns:
the life cycle state of this dialog
See Also:
LifeCycleStateProvider.getLifeCycleState()

findServiceInHierarchy

public Service findServiceInHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Returns the first implementation of a desired service in the hierarchy of the node.

Specified by:
findServiceInHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
the object implementing the service that is registered closest to the node
See Also:
com.sdm.quasar.client.comp.dlgdef.DialogServiceAccess#findServiceInHierarchy(java.lang.Class)

findServiceInParentHierarchy

public Service findServiceInParentHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Returns the first implementation of a desired service in the hierarchy of the parent node.

Specified by:
findServiceInParentHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
the object implementing the service that is registered closest to the node
See Also:
DialogServiceAccess.findServiceInParentHierarchy(java.lang.Class)

hasServiceInHierarchy

public boolean hasServiceInHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Tests if a service exists in the hierarchy of the node.

Specified by:
hasServiceInHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
true, iff the service is available.
See Also:
com.sdm.quasar.client.comp.dlgdef.DialogServiceAccess#hasServiceInHierarchy(java.lang.Class)

hasServiceInParentHierarchy

public boolean hasServiceInParentHierarchy(java.lang.Class service)
Description copied from interface: DialogServiceAccess
Tests if a service exists in the hierarchy of the parent node.

Specified by:
hasServiceInParentHierarchy in interface DialogServiceAccess
Parameters:
service - the class of the service interface that is searched for
Returns:
true, iff the service is available.
See Also:
DialogServiceAccess.hasServiceInParentHierarchy(java.lang.Class)

registerService

public void registerService(java.lang.Class service,
                            Service implementation)
Description copied from interface: DialogServiceAccess
Registers a service for this node. The service class must be an interface that extend Service, and the implementation implement that interface.

If there is already an implementation registered for that service, that implementation is replaced by the passed as a parameter.

Please note that a a registered service should be unregistered when the life cycle of the provider ends.

Specified by:
registerService in interface DialogServiceAccess
Parameters:
service - the interface that defines the service
implementation - the implementation of the service
See Also:
com.sdm.quasar.client.comp.dlgdef.DialogServiceAccess#registerService(java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

registerServiceForHierarchy

public void registerServiceForHierarchy(java.lang.Class service,
                                        Service implementation)
Description copied from interface: DialogServiceAccess
Registers a service for this node for hierarchical use only. The service implementation will not be found by accessing it via DialogServiceAccess.getServiceDirect(ID, Class); it will be found only via DialogServiceAccess.findServiceInHierarchy(Class). Please note, that a service interface can eighter be registered for hierarchical use (this method) or for direct and hierarchical use (see #registerService(ID, Class, Service)). The last registration overwrites the previous; it is not possible to register two different implementations: one for hierarchical and one for direct use!

The service class must be an interface that extend Service, and the implementation implement that interface.

If there is already an implementation registered for that service, that implementation is replaced by the passed as a parameter.

Please note that a a registered service should be unregistered when the life cycle of the provider ends.

Specified by:
registerServiceForHierarchy in interface DialogServiceAccess
Parameters:
service - the interface that defines the service
implementation - the implementation of the service
See Also:
DialogServiceAccess.registerServiceForHierarchy(java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

unregisterService

public void unregisterService(java.lang.Class service,
                              Service implementation)
Description copied from interface: DialogServiceAccess
Unregisters a service for this node.

If the service is not registered for this node or the given implementation is not the one that is registered, nothing happens.

Therefore, if a service implementation is replaced by another implementation, the unregistering of the first implementation is harmless since the second implementation will stay registered. However, if the second implementation is unregistered first, then no service will be available, even though the first service implementation hasn't been unregistered yet.

Specified by:
unregisterService in interface DialogServiceAccess
Parameters:
service - the interface that defines the service
implementation - the registered implementation of the service
See Also:
com.sdm.quasar.client.comp.dlgdef.DialogServiceAccess#unregisterService(java.lang.Class, com.sdm.quasar.client.core.common.services.Service)

getServiceDirect

public Service getServiceDirect(ID id,
                                java.lang.Class service)
Description copied from interface: DialogServiceAccess
Returns the implementation of a desired service registered at the node with the given id. The returned Object will implement the service interface.

Specified by:
getServiceDirect in interface DialogServiceAccess
Parameters:
id - the id of the node
service - the class of the service interface that is requested
Returns:
the object implementing the service that is registered at the specified node
See Also:
DialogServiceAccess.getServiceDirect(com.sdm.quasar.client.core.common.ID, java.lang.Class)

hasServiceDirect

public boolean hasServiceDirect(ID id,
                                java.lang.Class service)
Description copied from interface: DialogServiceAccess
Tests whether a specific node offers a service. In this case, the hierarchical dependency is ignored.

Specified by:
hasServiceDirect in interface DialogServiceAccess
Parameters:
id - the id of the node
service - the class of the service interface that is searched for
Returns:
true iff the service is available.
See Also:
DialogServiceAccess.hasServiceDirect(com.sdm.quasar.client.core.common.ID, java.lang.Class)

hasFeature

public boolean hasFeature(java.lang.Class keyClass)
Description copied from interface: FeatureManager
Returns true, if a Feature is registered under the given key class.

Specified by:
hasFeature in interface FeatureManager
Parameters:
keyClass - the key class to check containment for
See Also:
FeatureManager.hasFeature(java.lang.Class)

getFeature

public Feature getFeature(java.lang.Class keyClass)
Description copied from interface: FeatureManager
Returns the Feature associated with the given key class.

Specified by:
getFeature in interface FeatureManager
Parameters:
keyClass - the key class to get a Feature for
Returns:
the Feature instance
See Also:
FeatureManager.getFeature(java.lang.Class)

requireFeature

public Feature requireFeature(java.lang.Class featureClass)
Description copied from interface: FeatureManager
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.

Specified by:
requireFeature in interface FeatureManager
Parameters:
featureClass - the key and concrete feature class
Returns:
the Feature associated with the given key class.
See Also:
FeatureManager.requireFeature(java.lang.Class)

installFeature

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

Specified by:
installFeature in interface FeatureManager
Parameters:
feature - the feature instance to be installed
Returns:
the installed Feature instance (the same than the parameter)
See Also:
FeatureManager.installFeature(Feature)

installFeature

public Feature installFeature(java.lang.Class keyClass,
                              Feature feature)
Description copied from interface: FeatureManager
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.

Specified by:
installFeature in interface FeatureManager
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)
See Also:
FeatureManager.installFeature(Class, Feature)

installFeature

public Feature installFeature(java.lang.Class featureClass)
Description copied from interface: FeatureManager
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 FeatureManager.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.

Specified by:
installFeature in interface FeatureManager
Parameters:
featureClass - the feature class to install an instance of
Returns:
the installed Feature instance
See Also:
FeatureManager.installFeature(java.lang.Class)

installFeature

public Feature installFeature(java.lang.Class keyClass,
                              java.lang.Class featureClass)
Description copied from interface: FeatureManager
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.

Specified by:
installFeature in interface FeatureManager
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
See Also:
FeatureManager.installFeature(java.lang.Class, java.lang.Class)

uninstallFeature

public Feature uninstallFeature(Feature feature)
Description copied from interface: FeatureManager
Uninstalls the specified feature instance. Only the exact feature instance will be uninstalled.

Specified by:
uninstallFeature in interface FeatureManager
Parameters:
feature - the feature instance to be uninstalled
Returns:
the uninstalled Feature instance
See Also:
FeatureManager.uninstallFeature(Feature)