edu.washington.cs.supple.wlib.java2
Class ContainerSwingWidget

java.lang.Object
  extended byedu.washington.cs.supple.render.AbstractWidget
      extended byedu.washington.cs.supple.render.AbstractContainerWidget
          extended byedu.washington.cs.supple.wlib.java2.ContainerSwingWidget
All Implemented Interfaces:
java.lang.Cloneable, ContainerWidget, java.util.EventListener, java.beans.PropertyChangeListener, SwingWidget, UnwrappedWidget, Widget
Direct Known Subclasses:
AbstractDynamicPopupWidget, GridBagContainerWidget, HorizontalContainerWidget, SingleParamActionWidget, TabContainerWidget, VerticalContainerWidget

public abstract class ContainerSwingWidget
extends AbstractContainerWidget
implements SwingWidget

Author:
kgajos

Field Summary
protected  javax.swing.JButton actionButton
           
static int LEFT
           
static java.lang.String LIST_PLACEMENT_PROPERTY
           
static java.lang.String LISTING_WIDGET_PROPERTY
           
protected  SwingWidget listingWidget
           
protected  int listPlacement
           
static int TOP
           
 
Fields inherited from class edu.washington.cs.supple.render.AbstractContainerWidget
children, containerType
 
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
ContainerSwingWidget(UiObject object)
           
ContainerSwingWidget(UiObject object, SwingWidget lWidget, int placement)
           
ContainerSwingWidget(UiObject object, WidgetDescriptor wd, WidgetFactory f)
           
 
Method Summary
protected  java.awt.Dimension addActionButtonSize(java.awt.Dimension cdim)
          Given the size for the container object, it adds the size for the action button; this method should be overriden by children that change the implementation of makeActionButton
protected  boolean addChildren(javax.swing.JComponent container, int hints)
          A convenience method that will add all the children widgets to the specified container.
 void disengage()
          Used to break the connection between the widget and the underlying ui object
 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  javax.swing.JComponent getComponentForChild(UiObject object, int hints)
          Returns the Swing component of a child corresponding to object description and rendered according to the hings
 ConcreteWidget getConcreteWidget(java.io.Serializable renderingContext, int hints)
          Returns the concrete component (specific to a particular platform)
protected  java.awt.Dimension getContainerSize(int hints)
          Unless a child overrides getSize, it should override this method
 SwingWidget getListingWidget()
           
 java.awt.Dimension getSize(int hints)
           
 javax.swing.JComponent getSwingComponent(int hints)
          For regular container types, it returns the result of calling makeSwingContainer.
 WidgetProperties getWidgetProperties()
          Returns the corresponding WidgetProperties
 boolean hasListingWidget()
          Lets you easily check if this container widget has a listing built in
protected  javax.swing.JButton makeActionButton(java.lang.String label, java.awt.event.ActionListener listener)
          A convenience method for creating buttons
protected  javax.swing.JComponent makeActionButtons(int hints)
          Creates a panel with appropriate action buttons
protected  javax.swing.JComponent makeSwingContainer(int hints)
          To be overriden by children (unless they override getSwingComponent)
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
 void setListingWidget(SwingWidget listingWidget, int placement)
           
 java.lang.String toString()
           
 
Methods inherited from class edu.washington.cs.supple.render.AbstractContainerWidget
childIterator, getChild, getChildFor, getMaxChildSize, getMaxChildSize, getMinChildSize, getSumChildSize, getSumChildSize, hasChildren, makeVisible, setChildren
 
Methods inherited from class edu.washington.cs.supple.render.AbstractWidget
anotherPropertyChanged, clone, clone, dismissCurrentView, displayDynamic, equals, executeAction, getBag, getConcreteWidget, getCost, getParent, getPath, getSizeCache, getTextLabel, getType, getUiObject, getWidgetDescriptor, indexChanged, isEngaged, isEquivalent, legalValuesChanged, likelyValuesChanged, propertyChange, reportActionExecutionEvent, reportValueChangedEvent, setBag, setCost, setParent, setSizeCache, setValue, setWrapper, unwrapWidget, valueChanged
 
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, getCost, getEffortEstimate, getPath, getSizeCache, getTextLabel, getType, getUiObject, getWidgetDescriptor, hasChildren, isEngaged, isEquivalent, setBag, setCost, setParent, setSizeCache, setWrapper, unwrapWidget
 

Field Detail

listingWidget

protected SwingWidget listingWidget

actionButton

protected javax.swing.JButton actionButton

listPlacement

protected int listPlacement

LEFT

public static final int LEFT
See Also:
Constant Field Values

TOP

public static final int TOP
See Also:
Constant Field Values

LISTING_WIDGET_PROPERTY

public static final java.lang.String LISTING_WIDGET_PROPERTY
See Also:
Constant Field Values

LIST_PLACEMENT_PROPERTY

public static final java.lang.String LIST_PLACEMENT_PROPERTY
See Also:
Constant Field Values
Constructor Detail

ContainerSwingWidget

public ContainerSwingWidget(UiObject object)
Parameters:
object -

ContainerSwingWidget

public ContainerSwingWidget(UiObject object,
                            SwingWidget lWidget,
                            int placement)

ContainerSwingWidget

public ContainerSwingWidget(UiObject object,
                            WidgetDescriptor wd,
                            WidgetFactory f)
                     throws java.lang.Exception
Method Detail

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

getWidgetProperties

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

Specified by:
getWidgetProperties in interface Widget
Overrides:
getWidgetProperties in class AbstractContainerWidget
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

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 all coumpound objects (including actions provided they have at least two arguments); false otherwise

getSize

public java.awt.Dimension getSize(int hints)
Specified by:
getSize in interface Widget
Overrides:
getSize in class AbstractWidget

getContainerSize

protected java.awt.Dimension getContainerSize(int hints)
Unless a child overrides getSize, it should override this method

Parameters:
hints - rendering hints
Returns:
the size of the container object

addActionButtonSize

protected java.awt.Dimension addActionButtonSize(java.awt.Dimension cdim)
Given the size for the container object, it adds the size for the action button; this method should be overriden by children that change the implementation of makeActionButton

Parameters:
cdim - the dimensions of the container
Returns:
the dimension of the container and the action button

getSwingComponent

public javax.swing.JComponent getSwingComponent(int hints)
For regular container types, it returns the result of calling makeSwingContainer. for action parameters type, it creates a larger panel with an action button

Specified by:
getSwingComponent in interface SwingWidget
Parameters:
hints - specifies the variant of the widget to be rendered
Returns:
a renderable component

makeSwingContainer

protected javax.swing.JComponent makeSwingContainer(int hints)
To be overriden by children (unless they override getSwingComponent)

Parameters:
hints - rendering hints
Returns:
the container with all elements listed in the type

makeActionButtons

protected javax.swing.JComponent makeActionButtons(int hints)
Creates a panel with appropriate action buttons

Parameters:
hints - TODO
Returns:
the panel with action buttons

makeActionButton

protected javax.swing.JButton makeActionButton(java.lang.String label,
                                               java.awt.event.ActionListener listener)
A convenience method for creating buttons

Parameters:
label - text label to be put on the button
listener - action listener to be added to the button
Returns:
A rendering for an action button

getComponentForChild

protected javax.swing.JComponent getComponentForChild(UiObject object,
                                                      int hints)
Returns the Swing component of a child corresponding to object description and rendered according to the hings

Parameters:
object - description
hints - rendering hints
Returns:
Swing component of the maching child if set; null otherwise

addChildren

protected boolean addChildren(javax.swing.JComponent container,
                              int hints)
A convenience method that will add all the children widgets to the specified container.

Parameters:
container - The container to hold the children
hints - rendering hints
Returns:
true if all children were added, false if there were problems

hasListingWidget

public boolean hasListingWidget()
Lets you easily check if this container widget has a listing built in

Returns:

getListingWidget

public SwingWidget getListingWidget()
Returns:
Returns the listingWidget.

setListingWidget

public void setListingWidget(SwingWidget listingWidget,
                             int placement)
Parameters:
listingWidget - The listingWidget to set.

toString

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

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 AbstractContainerWidget

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 AbstractContainerWidget

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