at.spardat.xma.mdl
Class UIDelegateClient

java.lang.Object
  extended byat.spardat.xma.mdl.UIDelegateClient
Direct Known Subclasses:
ListDomUIDelegateClient, ListUIDelegateClient, SimpleUIDelegateClient, TableUIDelegateClient, TreeUIDelegateClient

public abstract class UIDelegateClient
extends java.lang.Object

A UIDelegateClient is an aspect of a WidgetModel which is responsible for handling all UI related tasks. All client side widget models have a UIDelegateClient attached at construction time.

A UIDelegateClient is in one of two states: isUIAttached() or not. This specifies, whether a widget is attachet or not. A note about the WModel enable/disable behauvior as implemented by the UIDelegateClients: 1. A call to WModel.setEnabled() is stored at the attribute enabled_ and set at the underlying widget. 2. If WModel.isEnabled() is called the value is always taken from the underlying widget. Then this actual value is also stored at the attribute enabled_. So if the widget was manipulated directly this is reflected at the model. Also this is the behauvior as implemented so far. 3. Normally at attachUI() the enabled_ value is set at the widget. 4. attachUI(): If the widget is disabled then this overrides the model's enabled_ state. Then the attribute enabled_ is set to false, too. It is assumed that disabling a widget is done deliberately (as it is not the default), so the value is taken from there (instead from the model). Also this is the behauvior as implemented so far (e.g. in the *Gen classes disabling is set on widgets). 5.Resume: The widget model now stores the enabled state. But this is always overritten by a widget's negative enabled state, or in other words: Only a negative enable state of a WModel is rembered, a positive is always overwritten.


Constructor Summary
protected UIDelegateClient()
          Constructs a UIDelegateClient.
 
Method Summary
abstract  void attachUI(java.lang.Object control, java.lang.Object label)
          Attaches a UI library control.
abstract  void detachUI()
          Detaches the UI-control.
abstract  java.lang.Object getUIControl()
          This method returns the attached UI-control.
abstract  java.lang.Object getUILabel()
          Returns the label that has been provided via attachUI.
abstract  WModel getWModel()
          Returns the WidgetModel this UIDelegateClient is attached to.
abstract  void handleModelChangeEvent(ModelChangeEvent event)
          The widget model has been changed.
abstract  void handleUIEvent(java.lang.Object event, int type)
          This method is responsible for accepting events originating from the UI library, creating corresponding ModelChangeEvents and updating the WidgetModels.
abstract  boolean isEditable()
          Returns true if this model's widget may be modified by the end-user.
abstract  boolean isEnabled()
          Returns true, if this model's widget is enabled.
abstract  boolean isUIAttached()
          Yields true, if this UIDelegateClient is attached, i.e., has a Control of the UI-library associated.
abstract  void setEditable(boolean what)
          Sets the editable-state of this models's widget.
abstract  void setEnabled(boolean what)
          Sets the enabled-state of this model's widget.
abstract  void setErrorColor(boolean inError)
          If inError, this method sets the background of the corresponding Control c to the error color defined in ComponentClient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UIDelegateClient

protected UIDelegateClient()
Constructs a UIDelegateClient. Used by the UIDelegateFactoryClient. After this method returns, isUIAttached() is false.

Method Detail

handleUIEvent

public abstract void handleUIEvent(java.lang.Object event,
                                   int type)
This method is responsible for accepting events originating from the UI library, creating corresponding ModelChangeEvents and updating the WidgetModels.

This method does nothing if isUIAttached() is false.

Parameters:
event - the Event-object from a particular UI libraray, e.g., SWT.
type - TODO

handleModelChangeEvent

public abstract void handleModelChangeEvent(ModelChangeEvent event)
The widget model has been changed. The change is described by the provided event object. If this UIDelegateClient is UI-attached, this method must synchronize the change with the UI. Note that the change has already been applied to the model, i.e., the model already reflects the new (changed) state.


getWModel

public abstract WModel getWModel()
Returns the WidgetModel this UIDelegateClient is attached to.

Returns:
the WidgetModel, never null.

isUIAttached

public abstract boolean isUIAttached()
Yields true, if this UIDelegateClient is attached, i.e., has a Control of the UI-library associated.

Returns:
true if attached.

attachUI

public abstract void attachUI(java.lang.Object control,
                              java.lang.Object label)
                       throws AttachmentExceptionClient
Attaches a UI library control. Upon successful attachement, isUIAttached() holds true.

Parameters:
control - an object of the UI class library. For example, in the case of SWT it is a SWT Widget like a Text, Label or Check Box.
label - a widget of the UI class library which is the label for control. With SWT, typically it the control is a Text field, the label is a Label widget which usually is the widget holding the describing text in front of the Text field. The label is used in error messages. It may be null.
Throws:
AttachmentExceptionClient - if the control cannot be attached.

getUIControl

public abstract java.lang.Object getUIControl()
This method returns the attached UI-control.

Returns:
The attached UI-control.
Throws:
java.lang.IllegalStateException - if !isUIAttached().

getUILabel

public abstract java.lang.Object getUILabel()
Returns the label that has been provided via attachUI. Returns null if the label provided in attachUI was null.

Throws:
java.lang.IllegalStateException - if !isUIAttached().

detachUI

public abstract void detachUI()
Detaches the UI-control.


isEditable

public abstract boolean isEditable()
Returns true if this model's widget may be modified by the end-user. Returns false, if the widget may not be edited, but the content of the widget should be readable and receive focus.


setEditable

public abstract void setEditable(boolean what)
Sets the editable-state of this models's widget. A widget which is not editable can not be modified by the end user. Unlike the disabled-state, its contents remains readable and still receives focus.

Usually, this method is called on all widget-models of a page to set the whole page to a read-only mode.

If this method is not called, the default is true.

Parameters:
what - true if the model's widget should be editable, false otherwise.

isEnabled

public abstract boolean isEnabled()
Returns true, if this model's widget is enabled. Returns false, if it is disabled. A disabled control is displayed in a grayed look and does not receive focus.


setEnabled

public abstract void setEnabled(boolean what)
Sets the enabled-state of this model's widget.

Parameters:
what - the state to set.

setErrorColor

public abstract void setErrorColor(boolean inError)
If inError, this method sets the background of the corresponding Control c to the error color defined in ComponentClient. If inError is false, the background is reset to the default color.