wt.clients.util
Class WTMultiList

java.lang.Object
  extended by symantec.itools.awt.MultiList
      extended by wt.clients.util.WTMultiList
All Implemented Interfaces:
ItemListener, EventListener

public class WTMultiList
extends symantec.itools.awt.MultiList
implements ItemListener

WTMultiList is a multi column list which fixes bugs found in symantec.itools.awt.MultiList. Most of the fixes involve improving the display appearance on UNIX clients. It is possible to use this class in place of using the symantec.itools.awt.MultiList. WTMultiList can also be configured to display attributes of modeled Windchill business objects, such as Parts, Documents, etc in a multi column list. When taking advantage of this feature of WTMultiList, it is necessary to specify the class and attributes that will be used by the display methods. A wt.clients.beans.query.WTSchema object is used to specify the class and attributes used by WTMultiList for displaying Windchill business objects. The attributes defined by the WTSchema object are used to obtain the column headings and values for the cells within a column. Methods that allow adding/obtaining modeled Windchill business objects are included in this class. An icon representing the object associated with a particular row is always displayed in the first column. An example of using the WTMultiList to display modeled Windchill business objects is presenting the results of a database search to the user. After performing the database search, the objects obtained can be added to a WTMultiList object for later selection by the user. WTMultiList can be configured in single and multi-select mode. The user cannot type or edit a selection in a WTMultiList. The user can resize a column at run-time by dragging the column boundary to a new position. The following code demonstrates creating a WTMultiList in a Frame:


    Frame f = new Frame();
    f.setSize(400,200);
    WTMultiList multi_list = new WTMultiList();

    // Create a schema to display Name, Version and Description of
    // objects with class wt.doc.WTDocument
    WTSchema schema = new WTSchema("C:wt.doc.WTDocument; D:name; D:versionIdentifier; D:description;");
    multi_list.setSchema(schema);
    f.add(multi_list);
    f.show();

 

 

Supported API: true

Extendable: false

See Also:
MultiList, #wt.clients.beans.query.WTSchema

Constructor Summary
WTMultiList()
          Constructs a new WTMultiList.
WTMultiList(int cols)
          Constructs a new WTMultiList with the specified number of columns.
WTMultiList(int cols, boolean multi)
          Constructs a new WTMultiList with the spcified number of columns and whether multiple row selection allowed.
WTMultiList(int cols, boolean multi, Color bg)
          Constructs a new WTMultiList with the specified number of columns, whether multiple row selection is allowed, and given background color.
 
Method Summary
 void addItemListener(ItemListener l)
          Adds the specified item listener to receive item events from this list.
 WTObject addObject(WTObject an_object)
          Add a modeled Windchill business object to the WTMultiList.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a listener for all property change events.
 void addVetoableChangeListener(VetoableChangeListener listener)
          Adds a listener for all vetoable property change events.
static String escapeColumnSeparator(String item)
          Escape special characters within the column text of a WTMultiList row.
 String[] getListItems()
          Returns the text contents of all the cells as a string array.
 WTObject getObject(int a_row)
          Returns the object at a particular row.
 int getObjectRow(WTObject an_object)
          Returns the number of the row containing a particular object.
 String[] getRelativeColumnWidths()
          This is the public getter that will return an array of strings representing the relative widths of each column.
 WTObject getSelectedObject()
          Returns the currently selected object.
 Object[] getSelectedObjects()
          Returns the currently selected array of objects.
 void redrawColumns()
          This method should be called after the multilist is visible.
 void removeItemListener(ItemListener l)
          Removes the specified item listener from this list.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a listener for all property change events.
 void removeVetoableChangeListener(VetoableChangeListener listener)
          Removes a listener for all vetoable property change events.
 void setListItems(String[] items)
          Takes an array of Strings and puts them into a WTMultiList.
 void setRelativeColumnWidths(String[] widths)
          Sets the relativeColumnWidths property.
 void updateObject(WTObject an_object)
          Obtain new display values from the specified modeled Windchill business object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WTMultiList

public WTMultiList()
Constructs a new WTMultiList.

Supported API: true


WTMultiList

public WTMultiList(int cols)
Constructs a new WTMultiList with the specified number of columns.

Supported API: true

Parameters:
cols - the number of columns

WTMultiList

public WTMultiList(int cols,
                   boolean multi)
Constructs a new WTMultiList with the spcified number of columns and whether multiple row selection allowed.

Supported API: true

Parameters:
cols - the number of columns
multi - true for multiple row selection, false otherwise

WTMultiList

public WTMultiList(int cols,
                   boolean multi,
                   Color bg)
Constructs a new WTMultiList with the specified number of columns, whether multiple row selection is allowed, and given background color.

Supported API: true

Parameters:
cols - the number of columns
multi - true for multiple row selection, false otherwise
bg - the background color
Method Detail

setRelativeColumnWidths

public void setRelativeColumnWidths(String[] widths)
                             throws PropertyVetoException
Sets the relativeColumnWidths property. Pass an array of Strings that can be converted to ints. Use 1 to give that column a column width of 1 relative to the width of the whole table. Pass 0 for a hidden column. A value of 2 will create a column twice the width of the column with a value of 1.

Supported API: true

Parameters:
widths - the relative width for each column
Throws:
PropertyVetoException - if an error occurs setting the column sizes

getRelativeColumnWidths

public String[] getRelativeColumnWidths()
This is the public getter that will return an array of strings representing the relative widths of each column. A value of 0 represents a hidden column. A value of 2 represents a column twice the width of the column with a value of 1.

Supported API: true

Returns:
an array of relative column widths

redrawColumns

public void redrawColumns()
                   throws PropertyVetoException
This method should be called after the multilist is visible. It will calculate the new width of the WTMultiList and then distribute the widths to the columns based on that width. No column will be smaller than the minColumnWidth.

Supported API: true

Throws:
PropertyVetoException - if an error occurs setting the column sizes

addItemListener

public void addItemListener(ItemListener l)
Adds the specified item listener to receive item events from this list.

Supported API: true

Parameters:
l - the item listener.

removeItemListener

public void removeItemListener(ItemListener l)
Removes the specified item listener from this list.

Supported API: true

Parameters:
l - the item listener.

getObjectRow

public int getObjectRow(WTObject an_object)
Returns the number of the row containing a particular object.

Supported API: true

Parameters:
an_object - the object whose row number is to be found.
Returns:
the number of the row containing a particular object.

getObject

public WTObject getObject(int a_row)
Returns the object at a particular row.

Supported API: true

Parameters:
a_row - the row of the object.
Returns:
the object at the specified row.

getSelectedObject

public WTObject getSelectedObject()
Returns the currently selected object.

Supported API: true

Returns:
the currently selected object.

getSelectedObjects

public Object[] getSelectedObjects()
Returns the currently selected array of objects.

Supported API: true

Returns:
an array of currently selected objects.

addObject

public WTObject addObject(WTObject an_object)
Add a modeled Windchill business object to the WTMultiList. If the object is already in the list, the object will be updated to reflect the new values.

Supported API: true

Parameters:
an_object - the modeled Windchill business object to add.
Returns:
true if the object is already in the list, otherwise false.

updateObject

public void updateObject(WTObject an_object)
Obtain new display values from the specified modeled Windchill business object.

Supported API: true

Parameters:
an_object - the object to be refreshed.

escapeColumnSeparator

public static String escapeColumnSeparator(String item)
Escape special characters within the column text of a WTMultiList row. Each row of a list is represented by a string and colums within the row are separated by a semicolon, so if the column text contains a semicolon, it must be escaped. Also escape the escape character ("\").

Supported API: true

Parameters:
item - the column item to be escaped

setListItems

public void setListItems(String[] items)
                  throws PropertyVetoException
Takes an array of Strings and puts them into a WTMultiList. Each element of the array denotes a row in the WTMultiList. Semicolons";" denote new cells. Escaped semicolons "\;" are included in the cell text as semicolons ";".

Supported API: true

Parameters:
items - the text to be displayed in the WTMultiList
Throws:
PropertyVetoException

getListItems

public String[] getListItems()
Returns the text contents of all the cells as a string array. A new string is used for each row. The contents of each row's column are separated by ";". For example, the string "col0;;col2" would result from a "col0" in column 0, an empty column 1, and "col2" in column 2.

Returns:
the string array containing the text of all the cells
See Also:


Supported API: true

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener for all property change events.

Parameters:
listener - the listener to add
See Also:


Supported API: true

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener for all property change events.

Parameters:
listener - the listener to remove
See Also:


Supported API: true

addVetoableChangeListener

public void addVetoableChangeListener(VetoableChangeListener listener)
Adds a listener for all vetoable property change events.

Parameters:
listener - the listener to add
See Also:


Supported API: true

removeVetoableChangeListener

public void removeVetoableChangeListener(VetoableChangeListener listener)
Removes a listener for all vetoable property change events.

Parameters:
listener - the listener to remove
See Also:


Supported API: true