edu.washington.cs.supple.render
Class AbstractWidget

java.lang.Object
  extended byedu.washington.cs.supple.render.AbstractWidget
All Implemented Interfaces:
java.lang.Cloneable, java.util.EventListener, java.beans.PropertyChangeListener, UnwrappedWidget, Widget
Direct Known Subclasses:
AbstractContainerWidget, SimpleWidget

public abstract class AbstractWidget
extends java.lang.Object
implements UnwrappedWidget, java.beans.PropertyChangeListener

Author:
kgajos An abstraction for all widgets

Field Summary
protected  WidgetBag bag
           
protected  float cost
           
protected  boolean engaged
           
protected  UiObject object
           
protected  Widget parent
           
protected  StateVar stateVar
           
protected  java.lang.String textLabel
           
protected  SuppleType type
           
protected  WidgetDescriptor widgetDescriptor
           
protected  WidgetWrapper wrapper
           
 
Fields inherited from interface edu.washington.cs.supple.render.Widget
MAX_HINT, NO_BORDER, NO_NAME, TOP_LEVEL_WIDGET
 
Constructor Summary
AbstractWidget(UiObject object)
           
 
Method Summary
protected  void anotherPropertyChanged(java.beans.PropertyChangeEvent evt)
          If some widgets are looking for other properties, I would prefer them to override this method rather than overriding propertyChange(); this method gets called when the property change event cannot be assigned to any of the known classes
 java.lang.Object clone()
           
 Widget clone(WidgetBag bag)
          A convenience method -- clones the widget and sets the value of the owner widget bag (used when cloning widget bags)
 void disengage()
          Used to break the connection between the widget and the underlying ui object
protected  boolean dismissCurrentView()
          Allows widgets to dismiss/close the current view
protected  RenderedView displayDynamic(UiObject dynObject)
           
 void engage()
          Used to tie the widgets with the underlying ui objects
 boolean equals(java.lang.Object o)
           
 RenderedView executeAction()
          A method for executing the corresponding action (if this widget is rendering an action object);
protected  WidgetDescriptor generateWidgetDescriptor()
          Subclasses can override this method if their widget descriptor include extra information
 WidgetBag getBag()
          Returns the widget bag containing this widget; widget bags are used in the search process as holders of the possible renderings for each UI element;
 ConcreteWidget getConcreteWidget(int hints)
          Returns the concrete component (specific to a particular platform)
 ConcreteWidget getConcreteWidget(java.io.Serializable renderingContext, int hints)
          Returns the concrete component (specific to a particular platform)
 float getCost()
          Returns the cost assigned to this widget instance
protected  Widget getParent()
           
 java.util.Vector getPath()
          Returns path (from the root) to this widget in the interface (ignoring shortcuts)
 java.awt.Dimension getSize(int hints)
           
 java.awt.Dimension getSizeCache(int hints)
           
 java.lang.String getTextLabel()
          Returns the text label assigned to this widget
 SuppleType getType()
          Returns the type of the corresponding UI object
 UiObject getUiObject()
          Returns the corresponding UI object
 WidgetDescriptor getWidgetDescriptor()
          Returns a descriptor for this widget
 WidgetProperties getWidgetProperties()
          Returns the corresponding WidgetProperties
protected  void indexChanged(java.beans.PropertyChangeEvent evt)
          Subclasses should override this method if they want to update display the index of the underlying type changes
 boolean isEngaged()
           
 boolean isEquivalent(Widget w)
          Checks if two widgets are equivalent to each other; they are equivalent if they have identical widget descriptors
protected  void legalValuesChanged(java.beans.PropertyChangeEvent evt)
          Subclasses should override this method if they want to update display in response to the change in the legal values
protected  void likelyValuesChanged(java.beans.PropertyChangeEvent evt)
          Subclasses should override this method if they want to update display in response to the change in the likely values
 void propertyChange(java.beans.PropertyChangeEvent evt)
          This method gets called by the type this widget represents whenever changes occur that need to be reflected in the display
static boolean rendersObject(UiObject object)
          A static method for testing the applicability of the widget given a type of the UI component to be rendered
protected  void reportActionExecutionEvent()
          A convenient method for reporting that an action has been executed
protected  void reportValueChangedEvent(java.lang.Object newValue)
          A convenient method for reporting value change events
 void setBag(WidgetBag bag)
          Sets the enclosing widget bag for this widget
 void setCost(float f)
          This method is used by the cost function
 void setEnabled(boolean enabled)
          Subclasses should override this method if they want to respond to the underlying ui objects being active or inactive
 void setParent(Widget parent)
          Sets the parent widget
 void setSizeCache(int hints, java.awt.Dimension dim)
           
protected  void setValue(java.lang.Object value)
          A method for setting the value for the underlying variable; Only works if the underlying type is a ValueType.
 void setWrapper(WidgetWrapper wrapper)
           
 java.lang.String toString()
           
 UnwrappedWidget unwrapWidget()
          Returns the enclosed widget for wrappers or self for actual widgets
protected  void valueChanged(java.beans.PropertyChangeEvent evt)
          Subclasses should override this method if they want to update display the value of the underlying type changes
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.washington.cs.supple.render.Widget
childIterator, getEffortEstimate, hasChildren
 

Field Detail

textLabel

protected java.lang.String textLabel

type

protected SuppleType type

object

protected UiObject object

stateVar

protected StateVar stateVar

parent

protected Widget parent

widgetDescriptor

protected WidgetDescriptor widgetDescriptor

cost

protected float cost

engaged

protected boolean engaged

bag

protected transient WidgetBag bag

wrapper

protected WidgetWrapper wrapper
Constructor Detail

AbstractWidget

public AbstractWidget(UiObject object)
Method Detail

getConcreteWidget

public ConcreteWidget getConcreteWidget(int hints)
Description copied from interface: Widget
Returns the concrete component (specific to a particular platform)

Specified by:
getConcreteWidget in interface Widget
Parameters:
hints - rendering hints
Returns:

getTextLabel

public java.lang.String getTextLabel()
Description copied from interface: Widget
Returns the text label assigned to this widget

Specified by:
getTextLabel in interface Widget
Returns:
label associated with this widget

getType

public SuppleType getType()
Description copied from interface: Widget
Returns the type of the corresponding UI object

Specified by:
getType in interface Widget
Returns:
the type corresponding to this widget

getWidgetProperties

public WidgetProperties getWidgetProperties()
Description copied from interface: Widget
Returns the corresponding WidgetProperties

Specified by:
getWidgetProperties in interface Widget
Returns:
properties associated with this widget

getWidgetDescriptor

public WidgetDescriptor getWidgetDescriptor()
Description copied from interface: Widget
Returns a descriptor for this widget

Specified by:
getWidgetDescriptor in interface Widget

generateWidgetDescriptor

protected WidgetDescriptor generateWidgetDescriptor()
Subclasses can override this method if their widget descriptor include extra information

Returns:
a new widget descriptor for this widge

setValue

protected void setValue(java.lang.Object value)
A method for setting the value for the underlying variable; Only works if the underlying type is a ValueType. Otherwise the method throws UnsupportedOperationException

Parameters:
value - the new value

executeAction

public RenderedView executeAction()
A method for executing the corresponding action (if this widget is rendering an action object);


reportValueChangedEvent

protected void reportValueChangedEvent(java.lang.Object newValue)
A convenient method for reporting value change events

Parameters:
newValue - the new value for the corresponding object

reportActionExecutionEvent

protected void reportActionExecutionEvent()
A convenient method for reporting that an action has been executed


dismissCurrentView

protected boolean dismissCurrentView()
Allows widgets to dismiss/close the current view

Returns:
true if the view was dismissed, false otherwise

getUiObject

public UiObject getUiObject()
Description copied from interface: Widget
Returns the corresponding UI object

Specified by:
getUiObject in interface Widget
Returns:
the corresponding ui object

rendersObject

public static boolean rendersObject(UiObject object)
A static method for testing the applicability of the widget given a type of the UI component to be rendered

Returns:
true if the widget can be used to render a UI element of a certain type; false otherwise

getCost

public float getCost()
Description copied from interface: Widget
Returns the cost assigned to this widget instance

Specified by:
getCost in interface Widget
Returns:
the cost of assigning this widget to its corresponding ui object

setCost

public void setCost(float f)
This method is used by the cost function

Specified by:
setCost in interface Widget
Parameters:
f - the cost of assigning this widget to its corresponding ui object

getBag

public WidgetBag getBag()
Description copied from interface: Widget
Returns the widget bag containing this widget; widget bags are used in the search process as holders of the possible renderings for each UI element;

Specified by:
getBag in interface Widget
Returns:
the enclosing widget bag

setBag

public void setBag(WidgetBag bag)
Sets the enclosing widget bag for this widget

Specified by:
setBag in interface Widget
Parameters:
bag - the enclosing widget bag

setParent

public void setParent(Widget parent)
Description copied from interface: Widget
Sets the parent widget

Specified by:
setParent in interface Widget
Parameters:
parent - the parent widget

getParent

protected Widget getParent()

toString

public java.lang.String toString()

clone

public java.lang.Object clone()
Specified by:
clone in interface Widget

clone

public Widget clone(WidgetBag bag)
A convenience method -- clones the widget and sets the value of the owner widget bag (used when cloning widget bags)

Specified by:
clone in interface Widget
Parameters:
bag - the new owning widget bag
Returns:
a clone of the widget

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent evt)
This method gets called by the type this widget represents whenever changes occur that need to be reflected in the display

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

setEnabled

public void setEnabled(boolean enabled)
Subclasses should override this method if they want to respond to the underlying ui objects being active or inactive

Specified by:
setEnabled in interface Widget
Parameters:
enabled - indicates if the underlying object is active

valueChanged

protected void valueChanged(java.beans.PropertyChangeEvent evt)
Subclasses should override this method if they want to update display the value of the underlying type changes

Parameters:
evt - property change event with details

indexChanged

protected void indexChanged(java.beans.PropertyChangeEvent evt)
Subclasses should override this method if they want to update display the index of the underlying type changes

Parameters:
evt - property change event with details

legalValuesChanged

protected void legalValuesChanged(java.beans.PropertyChangeEvent evt)
Subclasses should override this method if they want to update display in response to the change in the legal values

Parameters:
evt - property change event with details

likelyValuesChanged

protected void likelyValuesChanged(java.beans.PropertyChangeEvent evt)
Subclasses should override this method if they want to update display in response to the change in the likely values

Parameters:
evt - property change event with details

anotherPropertyChanged

protected void anotherPropertyChanged(java.beans.PropertyChangeEvent evt)
If some widgets are looking for other properties, I would prefer them to override this method rather than overriding propertyChange(); this method gets called when the property change event cannot be assigned to any of the known classes

Parameters:
evt -

disengage

public void disengage()
Description copied from interface: Widget
Used to break the connection between the widget and the underlying ui object

Specified by:
disengage in interface Widget

engage

public void engage()
Description copied from interface: Widget
Used to tie the widgets with the underlying ui objects

Specified by:
engage in interface Widget

isEngaged

public boolean isEngaged()
Specified by:
isEngaged in interface Widget

getPath

public java.util.Vector getPath()
Description copied from interface: Widget
Returns path (from the root) to this widget in the interface (ignoring shortcuts)

Specified by:
getPath in interface Widget
Returns:
the path from the root to this widget, includes the widget itself

displayDynamic

protected RenderedView displayDynamic(UiObject dynObject)

unwrapWidget

public UnwrappedWidget unwrapWidget()
Description copied from interface: Widget
Returns the enclosed widget for wrappers or self for actual widgets

Specified by:
unwrapWidget in interface Widget
Returns:
the enclosed widget

setWrapper

public void setWrapper(WidgetWrapper wrapper)
Specified by:
setWrapper in interface Widget

getConcreteWidget

public ConcreteWidget getConcreteWidget(java.io.Serializable renderingContext,
                                        int hints)
Description copied from interface: Widget
Returns the concrete component (specific to a particular platform)

Specified by:
getConcreteWidget in interface Widget
Parameters:
renderingContext - extra context information requried by some platforms
hints - rendering hints
Returns:

getSize

public java.awt.Dimension getSize(int hints)
Specified by:
getSize in interface Widget
Parameters:
hints - extra information concerning the variant of the widget that the size is needed for; at the moment I envision that some times we will want border-less and nameless versions of the widget
Returns:
the dimensions of the rendered widget

getSizeCache

public java.awt.Dimension getSizeCache(int hints)
Specified by:
getSizeCache in interface Widget

setSizeCache

public void setSizeCache(int hints,
                         java.awt.Dimension dim)
Specified by:
setSizeCache in interface Widget

equals

public boolean equals(java.lang.Object o)

isEquivalent

public boolean isEquivalent(Widget w)
Description copied from interface: Widget
Checks if two widgets are equivalent to each other; they are equivalent if they have identical widget descriptors

Specified by:
isEquivalent in interface Widget
Parameters:
w -
Returns: