com.sage.swt.client.widget
Class SwtWidgetHelper

java.lang.Object
  extended by com.sage.swt.client.widget.SwtWidgetHelper
All Implemented Interfaces:
com.google.gwt.event.shared.HasHandlers, HasPropertyChangeHandlers, PropertyBag, HasSwtChangeHandlers

public class SwtWidgetHelper
extends java.lang.Object
implements PropertyBag, HasSwtChangeHandlers

Class that implements some common functionality (such as storing properties) for a SWT widget.


Constructor Summary
SwtWidgetHelper(WidgetKey widgetKey, SwtErrorStack errorStack)
          Constructor.
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addChangeHandler(SwtChangeHandler handler)
          Adds a change handler to the widget.
 com.google.gwt.event.shared.HandlerRegistration addPropertyChangeHandler(PropertyChangeHandler handler)
          Adds a PropertyChangeEvent handler.
 void fireChange(SwtChangeEvent evt)
          Notifies SwtChangeHandlers that a change event as occurred.
 void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
           
 void firePropertyChangeEvent(PropertyBag propertyBag, Property property, java.lang.Object newValue)
          Fires the property change event on behalf of the specified property bag to this default property bag's property change handlers.
 java.lang.String getElementID()
          Gets an id that uniquely identifies this widget in the application - that will be used as the Element ID for the widget in the DOM.
 SwtErrorStack getErrorStack()
          Gets the error stack.
 InstanceContext getInstanceContext()
          Returns the instance context where this widget resides.
 java.util.Collection<Property> getProperties()
          Gets the collection of properties contained in this bag.
 java.lang.Object getPropertyDefaultValue(Property property)
          Gets the default value of a property.
 java.lang.Object getPropertyValue(Property property)
          Gets the value of a property.
 WidgetKey getWidgetKey()
          Gets the widget's key.
 void setInstanceContext(InstanceContext context)
          Sets the instance context where this widget resides.
 void setPropertyDefaultValue(Property property, java.lang.Object defaultValue)
          Sets the default value of a property.
 void setPropertyValue(Property property, java.lang.Object newValue)
          Sets the value of a property.
 void setWidgetKey(WidgetKey widgetKey)
          Sets the widget's key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwtWidgetHelper

public SwtWidgetHelper(WidgetKey widgetKey,
                       SwtErrorStack errorStack)
Constructor.

Parameters:
widgetKey - The WidgetKey for the widget.
errorStack - The SwtErrorStack that stores the list of UI errors.
Method Detail

addChangeHandler

public com.google.gwt.event.shared.HandlerRegistration addChangeHandler(SwtChangeHandler handler)
Adds a change handler to the widget.

Specified by:
addChangeHandler in interface HasSwtChangeHandlers
Parameters:
handler - The SwtChangeHandler for the widget.
Returns:
The HandlerRegistration for this handler.

fireChange

public void fireChange(SwtChangeEvent evt)
Notifies SwtChangeHandlers that a change event as occurred.

Parameters:
evt - The SwtChangeEvent that will be fired.

getWidgetKey

public WidgetKey getWidgetKey()
Gets the widget's key. Implementations must return non-null keys (even if they are empty keys).

Returns:
the widget key.

setWidgetKey

public void setWidgetKey(WidgetKey widgetKey)
Sets the widget's key. A null keys will be stored as an empty key.

Parameters:
widgetKey - The widget key.

getInstanceContext

public InstanceContext getInstanceContext()
Returns the instance context where this widget resides.

Returns:
InstanceContext The instance context where this widget resides.

setInstanceContext

public void setInstanceContext(InstanceContext context)
Sets the instance context where this widget resides.

Parameters:
context - The InstanceContext for this UI instance.

getElementID

public java.lang.String getElementID()
Gets an id that uniquely identifies this widget in the application - that will be used as the Element ID for the widget in the DOM. This is used by automated testing tools (like Selenium).

Returns:
An id that uniquely identifies this widget.

getErrorStack

public SwtErrorStack getErrorStack()
Gets the error stack.

Returns:
the error stack.

addPropertyChangeHandler

public com.google.gwt.event.shared.HandlerRegistration addPropertyChangeHandler(PropertyChangeHandler handler)
Adds a PropertyChangeEvent handler.

Specified by:
addPropertyChangeHandler in interface HasPropertyChangeHandlers
Parameters:
handler - the handler
Returns:
the handler registration

firePropertyChangeEvent

public void firePropertyChangeEvent(PropertyBag propertyBag,
                                    Property property,
                                    java.lang.Object newValue)
Fires the property change event on behalf of the specified property bag to this default property bag's property change handlers.

Parameters:
propertyBag - The property bag whose property change event we want to fire.
property - The property whose value has changed.
newValue - The new value of the property.

getProperties

public java.util.Collection<Property> getProperties()
Gets the collection of properties contained in this bag.

Specified by:
getProperties in interface PropertyBag
Returns:
The collection of properties contained in this bag. Implementors should make sure that this collection is unmodifiable.

getPropertyValue

public java.lang.Object getPropertyValue(Property property)
Gets the value of a property.

Specified by:
getPropertyValue in interface PropertyBag
Parameters:
property - The property in question.
Returns:
The value of the property.

setPropertyValue

public void setPropertyValue(Property property,
                             java.lang.Object newValue)
Sets the value of a property.

Specified by:
setPropertyValue in interface PropertyBag
Parameters:
property - The property in question.
newValue - The new value of the property.

getPropertyDefaultValue

public java.lang.Object getPropertyDefaultValue(Property property)
Gets the default value of a property.

Specified by:
getPropertyDefaultValue in interface PropertyBag
Parameters:
property - The property in question.
Returns:
The default value of the property.

setPropertyDefaultValue

public void setPropertyDefaultValue(Property property,
                                    java.lang.Object defaultValue)
Sets the default value of a property.

Specified by:
setPropertyDefaultValue in interface PropertyBag
Parameters:
property - The property in question.
defaultValue - The default value of the property.

fireEvent

public void fireEvent(com.google.gwt.event.shared.GwtEvent<?> event)
Specified by:
fireEvent in interface com.google.gwt.event.shared.HasHandlers


Copyright © 2011 Sage Software, Inc. All rights reserved.