edu.washington.cs.supple.wlib.awt
Class ListWidget

java.lang.Object
  extended byedu.washington.cs.supple.render.AbstractWidget
      extended byedu.washington.cs.supple.render.SimpleWidget
          extended byedu.washington.cs.supple.wlib.awt.ListWidget
All Implemented Interfaces:
AwtWidget, java.lang.Cloneable, java.util.EventListener, java.beans.PropertyChangeListener, UnwrappedWidget, Widget

public class ListWidget
extends SimpleWidget
implements AwtWidget

Author:
Jing Jing Long TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
protected  java.util.Hashtable cells
           
protected  java.awt.Button dataEdit
           
protected  SuppleType elementType
           
protected  boolean exactLength
           
protected  java.awt.event.ItemListener itemListener
           
protected  java.awt.List list
           
protected  java.awt.ScrollPane listPane
           
protected  int listSize
           
protected  boolean multipleMode
           
protected  java.awt.Panel panel
           
protected  boolean updatingWidget
           
protected  VectorType vtype
           
 
Fields inherited from class edu.washington.cs.supple.render.AbstractWidget
bag, cost, engaged, object, parent, stateVar, textLabel, type, widgetDescriptor, wrapper
 
Fields inherited from interface edu.washington.cs.supple.render.Widget
MAX_HINT, NO_BORDER, NO_NAME, TOP_LEVEL_WIDGET
 
Constructor Summary
ListWidget(UiObject object, int listSize)
           
 
Method Summary
protected  java.awt.Component buildList()
           
 void disengage()
          Used to break the connection between the widget and the underlying ui object
protected  void displayDetails()
          Used when the underlying object is of UiObjectType or UiObjectValueVectorType it renders the detailed information about the selected values
 void engage()
          Used to tie the widgets with the underlying ui objects
protected  WidgetDescriptor generateWidgetDescriptor()
          Subclasses can override this method if their widget descriptor include extra information
protected  java.util.Vector getAddDiffs(java.util.Collection oldStuff, java.util.Collection newStuff)
          Creates a list of elements that are present in newStuff but not in oldStuff
 java.awt.Component getAwtComponent(int hints)
           
protected  java.util.Vector getDeleteDiffs(java.util.Collection oldStuff, java.util.Collection newStuff)
          Creates a list of elements that are present in oldStuff but not in newStuff
 float getEffortEstimate(ActionDescription a)
          This method is hear temporarily until we implement it for all simple widgets
protected  java.awt.event.ItemListener getItemListener()
           
 int getListSize()
          Returns the lenght of the list widget rendered; 0 means that the list will be as long as the number of elements in the domain of the object displayed
protected  java.awt.Dimension getPreferredSize()
          Calculates the preferred size for this widget.
 WidgetProperties getWidgetProperties()
          Returns the corresponding WidgetProperties
 boolean isExactLength()
          Returns true if the list widget is precisely the same length as the domain of the underlying object
protected  boolean isUpdating()
          This method lets you find out if the widget is in the process of updating itself (useful for breaking the cycle of change propagation between the widget and the underlying UiObject)
protected  void legalValuesChanged(java.beans.PropertyChangeEvent evt)
          reacts to the change in the list of legal values in the underlying object
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
 void setEnabled(boolean enabled)
          This method is exposed only so that wrappers can access it; others should stay away
protected  void setUpdating(boolean b)
           
 java.lang.String toString()
           
protected  void updateSelection()
           
protected  void updateSelection(int startIndex, int endIndex)
          Updates the selection based on the current value of the underlying object; uses the limiting indices to do the work only within small bounds if they are known; bounds are inclusive
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 edu.washington.cs.supple.render.SimpleWidget
childIterator, hasChildren
 
Methods inherited from class edu.washington.cs.supple.render.AbstractWidget
anotherPropertyChanged, clone, clone, dismissCurrentView, displayDynamic, equals, executeAction, getBag, getConcreteWidget, getConcreteWidget, getCost, getParent, getPath, getSize, getSizeCache, getTextLabel, getType, getUiObject, getWidgetDescriptor, indexChanged, isEngaged, isEquivalent, likelyValuesChanged, propertyChange, reportActionExecutionEvent, reportValueChangedEvent, setBag, setCost, setParent, setSizeCache, setValue, setWrapper, unwrapWidget
 
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, clone, clone, getBag, getConcreteWidget, getConcreteWidget, getCost, getPath, getSize, getSizeCache, getTextLabel, getType, getUiObject, getWidgetDescriptor, hasChildren, isEngaged, isEquivalent, setBag, setCost, setParent, setSizeCache, setWrapper, unwrapWidget
 

Field Detail

listSize

protected int listSize

exactLength

protected boolean exactLength

vtype

protected VectorType vtype

elementType

protected SuppleType elementType

list

protected java.awt.List list

panel

protected java.awt.Panel panel

listPane

protected java.awt.ScrollPane listPane

dataEdit

protected java.awt.Button dataEdit

itemListener

protected java.awt.event.ItemListener itemListener

multipleMode

protected boolean multipleMode

updatingWidget

protected boolean updatingWidget

cells

protected java.util.Hashtable cells
Constructor Detail

ListWidget

public ListWidget(UiObject object,
                  int listSize)
Parameters:
object -
Method Detail

getListSize

public int getListSize()
Returns the lenght of the list widget rendered; 0 means that the list will be as long as the number of elements in the domain of the object displayed

Returns:
the lenght of the list widget

isExactLength

public boolean isExactLength()
Returns true if the list widget is precisely the same length as the domain of the underlying object


getWidgetProperties

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

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

generateWidgetDescriptor

protected WidgetDescriptor generateWidgetDescriptor()
Description copied from class: AbstractWidget
Subclasses can override this method if their widget descriptor include extra information

Overrides:
generateWidgetDescriptor in class AbstractWidget
Returns:
a new widget descriptor for this widge

getEffortEstimate

public float getEffortEstimate(ActionDescription a)
Description copied from class: SimpleWidget
This method is hear temporarily until we implement it for all simple widgets

Specified by:
getEffortEstimate in interface Widget
Overrides:
getEffortEstimate in class SimpleWidget

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 for instances of enumerable vector types

getAwtComponent

public java.awt.Component getAwtComponent(int hints)
Specified by:
getAwtComponent in interface AwtWidget
Parameters:
hints - specifies the variant of the widget to be rendered
Returns:
a renderable component

buildList

protected java.awt.Component buildList()

displayDetails

protected void displayDetails()
Used when the underlying object is of UiObjectType or UiObjectValueVectorType it renders the detailed information about the selected values


getPreferredSize

protected java.awt.Dimension getPreferredSize()
Calculates the preferred size for this widget. If listSize is set to 0, then it will use the current size of the domain of the corresponding UI object to detrmine the height.

Returns:
the preferred size for this widget

getItemListener

protected java.awt.event.ItemListener getItemListener()

isUpdating

protected boolean isUpdating()
This method lets you find out if the widget is in the process of updating itself (useful for breaking the cycle of change propagation between the widget and the underlying UiObject)

Returns:
true if the widget is updating itself, false otherwise

setUpdating

protected void setUpdating(boolean b)

updateSelection

protected void updateSelection()

updateSelection

protected void updateSelection(int startIndex,
                               int endIndex)
Updates the selection based on the current value of the underlying object; uses the limiting indices to do the work only within small bounds if they are known; bounds are inclusive

Parameters:
startIndex -
endIndex -

getAddDiffs

protected java.util.Vector getAddDiffs(java.util.Collection oldStuff,
                                       java.util.Collection newStuff)
Creates a list of elements that are present in newStuff but not in oldStuff

Parameters:
oldStuff - old list
newStuff - new list
Returns:
a list of things to add to oldStuff so that its membership would be the same as that of newStuff

getDeleteDiffs

protected java.util.Vector getDeleteDiffs(java.util.Collection oldStuff,
                                          java.util.Collection newStuff)
Creates a list of elements that are present in oldStuff but not in newStuff

Parameters:
oldStuff - old list
newStuff - new list
Returns:
a list of things to delete from oldStuff so that its membership would be the same as that of newStuff

legalValuesChanged

protected void legalValuesChanged(java.beans.PropertyChangeEvent evt)
reacts to the change in the list of legal values in the underlying object

Overrides:
legalValuesChanged in class AbstractWidget
Parameters:
evt - property change event with details

valueChanged

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

Overrides:
valueChanged in class AbstractWidget
Parameters:
evt - property change event with details

toString

public java.lang.String toString()
Overrides:
toString in class AbstractWidget

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
Overrides:
disengage in class AbstractWidget

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
Overrides:
engage in class AbstractWidget

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: Widget
This method is exposed only so that wrappers can access it; others should stay away

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