at.spardat.xma.mdl.simple
Class SimpleUIDelegateClient

java.lang.Object
  extended byat.spardat.xma.mdl.UIDelegateClient
      extended byat.spardat.xma.mdl.simple.SimpleUIDelegateClient

public class SimpleUIDelegateClient
extends UIDelegateClient

The UIDelegateClient for a SimpleWM. Responsible for handling all UI-related stuff of a SimpleWidgetModel.

The following attachements are eligible:

 SimpleWM                   SWT-Control
 -----------------------------------------------------
 T_BOOLEAN                      Button of types CHECK, RADIO, TOGGLE
 T_*                            every model may be attached to Text and Label controls.
 


Constructor Summary
SimpleUIDelegateClient(SimpleWMClient model)
          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 SWT widgets: Widget EVENT -------------------------------------------------------------------- Button (RADIO, CHECK, TOGGLE) SelectionEvent Text VerifyEvent, ModifyEvent, FocusEvent from FocusListener.focusLost (important: do not call with FocusEvents from focusGained method).
 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.
 boolean isValidateIfUneditable()
           
 void resetWidgetFromModel()
          Sets the widget to the current value of the model.
 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.
 void setValidateIfUneditable(boolean what)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleUIDelegateClient

public SimpleUIDelegateClient(SimpleWMClient model)
Constructor

Method Detail

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)

detachUI

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

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

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()

handleUIEvent

public void handleUIEvent(java.lang.Object event,
                          int type)
The following events must be notified from SWT widgets:
 Widget                             EVENT
 --------------------------------------------------------------------
 Button (RADIO, CHECK, TOGGLE)      SelectionEvent
 Text                               VerifyEvent, ModifyEvent, FocusEvent from FocusListener.focusLost
                                    (important: do not call with FocusEvents from focusGained method).
 

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(Object,int type)

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(ModelChangeEvent)

resetWidgetFromModel

public void resetWidgetFromModel()
Sets the widget to the current value of the model. The only situation where widget and model may differ, is if the widget contains a value not accepted by the validiator. In this case the model contains the last known valid value.


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()

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()

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)

isValidateIfUneditable

public boolean isValidateIfUneditable()
Returns:
the validateUneditable property
Since:
version_number
See Also:
at.spardat.xma.mdl.IWModelClient#isValidateIfUneditable()

setValidateIfUneditable

public void setValidateIfUneditable(boolean what)
Parameters:
what -
Since:
version_number
See Also:
at.spardat.xma.mdl.IWModelClient#setValidateIfUneditable()