at.spardat.xma.mdl.list
Class ListDomUIDelegateClient

java.lang.Object
  extended byat.spardat.xma.mdl.UIDelegateClient
      extended byat.spardat.xma.mdl.list.ListDomUIDelegateClient

public class ListDomUIDelegateClient
extends UIDelegateClient

This class is the UIDelegate for a ListDomWMClient widget model. It manages the interaction between a SWT-DROP_DOWN-combo and the widget model. The attached Combo must be created with the style SWT.DROP_DOWN. The style SWT.READ_ONLY must not be set.

Technical footnote#1: A Combo that is not read-only has two states: its text (in the text field) and the selectionIndex of the drop-down-list. If the selectionIndex is set (differs from -1), the text-field is displayed with selected contents if the shell is resized in the current version of SWT. Therefore, this class never sets the selectionIndex, but just the text. On loose-focus, a selection index, if any, is cleared and the text is set.


Constructor Summary
ListDomUIDelegateClient(ListDomWMClient wModel)
          Constructor
 
Method Summary
 void attachUI(java.lang.Object control, java.lang.Object label)
          Attaches a UI library control.
 void detachUI()
          Detaches the UI-control.
 java.lang.Object getUIControl()
          This method returns the attached UI-control.
 java.lang.Object getUILabel()
          Returns the label that has been provided via attachUI.
 WModel getWModel()
          Returns the WidgetModel this UIDelegateClient is attached to.
 void handleModelChangeEvent(ModelChangeEvent event)
          The widget model has been changed.
 void handleUIEvent(java.lang.Object event, int type)
          The following events must be notified from the SWT combo box: SelectionEvent ModifyEvent FocusEvent for lost focus
 boolean isEditable()
          Returns true if this model's widget may be modified by the end-user.
 boolean isEnabled()
          Returns true, if this model's widget is enabled.
 boolean isUIAttached()
          Yields true, if this UIDelegateClient is attached, i.e., has a Control of the UI-library associated.
 void setEditable(boolean what)
          Sets the editable-state of this models's widget.
 void setEnabled(boolean what)
          Sets the enabled-state of this model's widget.
 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

ListDomUIDelegateClient

public ListDomUIDelegateClient(ListDomWMClient wModel)
Constructor

Method Detail

handleUIEvent

public void handleUIEvent(java.lang.Object event,
                          int type)
The following events must be notified from the SWT combo box:
  1. SelectionEvent
  2. ModifyEvent
  3. FocusEvent for lost focus

Specified by:
handleUIEvent in class UIDelegateClient
Parameters:
event - the Event-object from a particular UI libraray, e.g., SWT.
type - TODO
See Also:
UIDelegateClient.handleUIEvent(java.lang.Object, int)

handleModelChangeEvent

public void handleModelChangeEvent(ModelChangeEvent event)
Description copied from class: UIDelegateClient
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.

Specified by:
handleModelChangeEvent in class UIDelegateClient
See Also:
UIDelegateClient.handleModelChangeEvent(at.spardat.xma.mdl.ModelChangeEvent)

getWModel

public WModel getWModel()
Description copied from class: UIDelegateClient
Returns the WidgetModel this UIDelegateClient is attached to.

Specified by:
getWModel in class UIDelegateClient
Returns:
the WidgetModel, never null.
See Also:
UIDelegateClient.getWModel()

isUIAttached

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

Specified by:
isUIAttached in class UIDelegateClient
Returns:
true if attached.
See Also:
UIDelegateClient.isUIAttached()

attachUI

public void attachUI(java.lang.Object control,
                     java.lang.Object label)
              throws AttachmentExceptionClient
Description copied from class: UIDelegateClient
Attaches a UI library control. Upon successful attachement, isUIAttached() holds true.

Specified by:
attachUI in class UIDelegateClient
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.
See Also:
UIDelegateClient.attachUI(java.lang.Object, java.lang.Object)

getUIControl

public java.lang.Object getUIControl()
Description copied from class: UIDelegateClient
This method returns the attached UI-control.

Specified by:
getUIControl in class UIDelegateClient
Returns:
The attached UI-control.
See Also:
UIDelegateClient.getUIControl()

getUILabel

public java.lang.Object getUILabel()
Description copied from class: UIDelegateClient
Returns the label that has been provided via attachUI. Returns null if the label provided in attachUI was null.

Specified by:
getUILabel in class UIDelegateClient
See Also:
UIDelegateClient.getUILabel()

detachUI

public void detachUI()
Description copied from class: UIDelegateClient
Detaches the UI-control.

Specified by:
detachUI in class UIDelegateClient
See Also:
UIDelegateClient.detachUI()

setErrorColor

public 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.

Specified by:
setErrorColor in class UIDelegateClient

isEnabled

public boolean isEnabled()
Description copied from class: UIDelegateClient
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.

Specified by:
isEnabled in class UIDelegateClient
See Also:
UIDelegateClient.isEnabled()

setEnabled

public void setEnabled(boolean what)
Description copied from class: UIDelegateClient
Sets the enabled-state of this model's widget.

Specified by:
setEnabled in class UIDelegateClient
Parameters:
what - the state to set.
See Also:
UIDelegateClient.setEnabled(boolean)

isEditable

public boolean isEditable()
Description copied from class: UIDelegateClient
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.

Specified by:
isEditable in class UIDelegateClient
See Also:
UIDelegateClient.isEditable()

setEditable

public void setEditable(boolean what)
Description copied from class: UIDelegateClient
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.

Specified by:
setEditable in class UIDelegateClient
Parameters:
what - true if the model's widget should be editable, false otherwise.
See Also:
UIDelegateClient.setEditable(boolean)