Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uchicago.src.reflector
Class ListPropertyDescriptor

    java.lang.Object
      uchicago.src.reflector.PropertyDescriptor
          uchicago.src.reflector.ListPropertyDescriptor

    public class ListPropertyDescriptor

extends PropertyDescriptor

Descriptor for model properties/parameters that can be represented as a closed list. A ListPropertyDescriptor can be used to present the user with a drop-down combo box containing a list parameter values of which he or she can choose one. It can also be used to represent a list of one type as a list of another type - a list of ints as a list of strings for example.

There are several ways to set up a list of parameter values to be displayed by the combo box. A vector of Objects, an array of Objects or a hashtable can be passed when the ListPropertyDescriptor when it is constructed. In the first two cases combo box displays the vector or the array, and passes the chosen object to the appropriate set method when combo-box item is selected. In the case of the hashtable, the values of the hashtable are displayed by the combox box and it is the key of the selected value that is passed to the appropriate set method. This allows for the display of natural language words representing numeric constants.

A ListPropertyDescriptor is typically setup in the constructor of your model. For example, ``

      Hashtable h1 = new Hashtable();
      h1.put(new Integer(0), "VON NEUMANN");
      h1.put(new Integer(1), "MOORE");
      ListPropertyDescriptor pd = new ListPropertyDescriptor("NType", h1);
      descriptors.put("NType", pd);

A ListPropertyDescriptor is created with the name of the property, and a hashtable as an argument. The property name must reflect the standard get/set accessor method coding style. In above case, the model has two methods getNType and setNType. Given the name of the property a ListPropertyDescriptor will call the appropriate set method when an item in the combo box is seleted. The second argument is a hashtable whose keys are the actual objects that can be selected and passed to the set method as well as a string representations of those objects. In the above case, the hashtable contains two keys: an Integer with a value of 0 and an Integer with a value of 1. The value of these to keys' are the Strings "VON NEUMANN" and "MOORE" respectively. What the user will see then is a combo box labeled as "NType" that contains two Strings "VON NEUMANN" and "MOORE". When the user selects one of these strings, the corresponding Integer is passed as an argument to the setNType method. Descriptors is an instance variable (a hashtable) of the SimModelImpl class and can be used by sub classes.

This class's widget is a PairComboBox or a PropertyComboBox.

Version:
  $Revision: 1.7 $ $Date: 2004/11/03 19:51:05 $
Author:
  Nick Collier

Field Summary

Fields inherited from class uchicago.src.reflector.PropertyDescriptor
`widget`

Constructor Summary
`ListPropertyDescriptor(java.lang.String name, java.util.Hashtable hash)` Creates a ListPropertyDescriptor for the specified property and the specified Hashtable where the objects to be sent to the set method are the keys, and their String representations are the values.
`ListPropertyDescriptor(java.lang.String name, java.lang.Object[] values)` Creates a ListPropertyDescriptor for the specified property and the specified array of values.
`ListPropertyDescriptor(java.lang.String name, java.util.Vector values)` Creates a ListPropertyDescriptor for the specified property and the specified Vector of values.

Method Summary
`java.util.Vector` | `getValues()` Gets the objects to be put in the combo box.

Methods inherited from class uchicago.src.reflector.PropertyDescriptor
`getName, getWidget`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ListPropertyDescriptor

    public ListPropertyDescriptor(java.lang.String name,
                                  java.util.Vector values)

  Creates a ListPropertyDescriptor for the specified property and the specified Vector of values.

  Parameters:
    `name` - the name of the property
    `values` - the objects to be displayed in the combo box and passed to the appropriate set method.

### ListPropertyDescriptor

    public ListPropertyDescriptor(java.lang.String name,
                                  java.lang.Object[] values)

  Creates a ListPropertyDescriptor for the specified property and the specified array of values.

  Parameters:
    `name` - the name of the property
    `values` - the objects to be displayed in the combo box and passed to the appropriate set method.

### ListPropertyDescriptor

    public ListPropertyDescriptor(java.lang.String name,
                                  java.util.Hashtable hash)

  Creates a ListPropertyDescriptor for the specified property and the specified Hashtable where the objects to be sent to the set method are the keys, and their String representations are the values.

  Parameters:
    `name` - the name of the property
    `hash` - the objects to be sent to the appropriate set method - the hashtable's keys, and their string representations - the hashtable's values.

Method Detail

### getValues

    public java.util.Vector getValues()

  Gets the objects to be put in the combo box.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD