All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sgi.sysadm.ui.EditableList

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----javax.swing.JComponent
                           |
                           +----javax.swing.JPanel
                                   |
                                   +----com.sgi.sysadm.ui.EditableList

public class EditableList
extends JPanel
implements SwingConstants
EditableList provides a user interface for editing and displaying a list of information. The list itself is a scrollable table, and the caller supplies a user interface for adding and modifying entries in the list. EditableList provides buttons for adding, deleting, and modifying entries in the list.

The editor within an EditableList can be any AWT Component. Typically, an editor provides one input field for each column of the EditableList, and each input field has a label above it describing what it is for. The method getEditorLayout can be used to obtain a LayoutManager to be passed to the setLayout method of a Container to facilitate development of an editor that integrates smoothly with its EditableList.

An EditableList can optionally be reorderable, in which case each entry in the list is numbered and buttons are provided for changing the order of the entries.

EditableList uses TaskData both for its internal representation of the list and to give access to the data in the list to clients. TaskData is also used for communicating between EditableList and the editor supplied by the caller.

The caller specifies the name of a Long Attribute to be used to keep track of the number of rows in the list, and an array of names, one for each column in the table. When the "Add" button is pressed, the value for each column of the row that is added is obtained by getting the Attribute from TaskData, using the array of names. For each row in the table, the TaskData is populated by setting string Attributes based on the array of names with the row-number appended.

For example, suppose the table contains the following data:

    rogerc     Roger Chickering
    kirthiga   Kirthiga Reddy
    wessmith   Wesley Smith
    ctb        Chris Beekhuis
 
and the number of rows is stored in the Long Attribute named by numUsers. Suppose also that the names of the columns are loginName and fullName. The following code gets the data out of the EditableList:
    int numUsers = (int)taskData.getLong("numUsers");
    for (int row = 0; row < numUsers; row++) {
        String loginName = taskData.getString("loginName" + row);
        String fullName = taskData.getString("fullName" + row);
    }
 
The editor sets the data to be added to the table when the "Add" button is pressed with this code:
    taskData.setString("loginName", "orosz");
    taskData.setString("fullName", "Jim Orosz");
 
TaskDataListeners such as JStringTextComponentListener can be used to synchronize editor components with the TaskData.

Attribute names for columns and the number of rows can be specified either programmatically or via a ResourceStack.

An EditableList can also have invisible columns. When the "Add" button is pressed, the editor Attributes for invisible columns are copied to the next row along with the visible Attributes. When the "Modify" button is pressed, the Attributes for the invisible columns in the row being modified are copied back into the editor TaskData. The difference between visible and invisible columns is that invisible columns have no presentation in the list's table.

Invisible columns are typically used to store information for each row that is different from but related to the visible columns.


Variable Index

 o ADD_BUTTON_LABEL
The resource EditableList.addButtonLabel or <componentName>.addButtonLabel is the String displayed on the Add button.
 o CHANGED_SINCE_LAST_ADD_ATTR_NAME
The resource EditableList.changedSinceLastAddAttrName or <componentName>.changedSinceLastAddAttrName specifies the name of a Boolean Attribute in TaskData that gets bound to the state of the editor: the Attribute will be true if the user has made changes and false otherwise.
 o COLUMN_ATTR_NAME
The resource set EditableList.columnAttrName<n> or <componentName>.columnAttrName<n> specifies the Attribute name for each column in the list.
 o COLUMN_WIDTH
The resource set EditableList.columnWidth<n> or <componentName>.columnWidth<n> specifies the widths in points of the columns in the list.
 o DELETE_BUTTON_LABEL
The resource EditableList.deleteButtonLabel or <componentName>.deleteButtonLabel is the String displayed on the Delete button.
 o EDITOR_VGAP
The resource EditableList.editorVGap or <componentName>.editorVGap is an Integer specifying the spacing in points between the bottom of the editor and the top of the list.
 o HEADING
The resource set EditableList.heading<n> or <componentName>.heading<n> specifies the headings that appear in the table of entries.
 o HGAP
The resource EditableList.hGap or <componentName>.hGap is an Integer specifying the horizontal gaps in points between the various Components (buttons, labels, JTable).
 o HMARGIN
The resource EditableList.hMargin or <componentName>.hMargin is an Integer specifying the horizontal margin in points.
 o HORIZONTAL_ALIGNMENT
The resource EditableList.horizontalAlignment.<row>,<column> or <componentName>.horizontalAlignment.<row>,<column> specifies the horizontal alignment of the editor component in the cell specified by row and column.
 o INVISIBLE_COLUMN_ATTR_NAME
The resource set EditableList.invisibleColumnAttrName<n> or <componentName>.invisibleColumnAttrName<n> specifies the Attribute name for invisible columns.
 o LIST_HEIGHT
The resource EditableList.listHeight or <componentName>.listHeight is an Integer specifying the height in points of the JTable Component used to display the entries in the list.
 o LIST_WIDTH
The resource EditableList.listWidth or <componentName>.listWidth is an Integer specifying the width in points of the JTable Component used to display the entries in the list.
 o MODIFY_BUTTON_LABEL
The resource EditableList.modifyButtonLabel or <componentName>.modifyButtonLabel is the String displayed on the Modify button.
 o NUM_ROWS_ATTR_NAME
The resource EditableList.numRowsAttrName or <componentName>.numRowsAttrName is a String specifying the name of the Long Attribute in TaskData that keeps track of the number of rows in the entry table.
 o NUMBER_COLUMN_WIDTH
The resource EditableList.numberColumnWidth or <componentName>.numberColumnWidth is an Integer specifying the width in points of the table column used for numbering the rows of a reorderable list.
 o NUMBER_FORMAT_STRING
The resource EditableList.numberFormatString or <componentName>.numberFormatString is a String specifying the format of the strings used to number the rows in a reorderable list.
 o ORDER_HEADING
The resource EditableList.orderHeading or <componentName>.orderHeading is the String displayed above the column of numbers on reorderable lists.
 o REORDERABLE
The resource EditableList.reorderable or <componentName>.reorderable is a Boolean that controls whether or not the list is reorderable.
 o RESET_BUTTON_LABEL
The resource EditableList.resetButtonLabel or <componentName>.resetButtonLabel is the String displayed on the Reset button.
 o SHOW_MODIFY_BUTTON
The resource EditableList.showModifyButton or <componentName>.showModifyButton is a Boolean that controls whether the Modify button is visible.
 o SHOW_RESET_BUTTON
The resource EditableList.showResetButton or <componentName>.showResetButton is a Boolean that controls whether the Reset button is visible.
 o VERTICAL_ALIGNMENT
The resource EditableList.verticalAlignment.<row>,<column> or <componentName>.verticalAlignment.<row>,<column> specifies the vertical alignment of the editor component in the cell specified by row and column.
 o VGAP
The resource EditableList.vGap or <componentName>.vGap is an Integer specifying the vertical gaps in points between the various Components (buttons, labels, JTable).
 o VMARGIN
The resource EditableList.vMargin or <componentName>.vMargin is an Integer specifying the vertical margin in points.

Constructor Index

 o EditableList(String, ResourceStack, TaskData)
Construct an EditableList.

Method Index

 o addNotify()
Called when we're added to a Container.
 o changedSinceLastAdd()
Determine whether the user has changed anything in the editor since the last time the "Add" button was pressed.
 o clearList()
Removes all the row data from the list.
 o getEditorLayout()
Get a LayoutManager that can be used with the editor of this EditableList.
 o setColumns(String, String[], String[])
Set up the columns of this EditableList.
 o setColumns(String, String[], String[], String[])
Set up the columns of this EditableList, including invisible columns.
 o setEditor(Component)
Called to set the Component to be used to edit a row in this EditableTable.
 o setEditor(Component, EditableList. EditVerifier)
Called to set the Component to be used to edit a row in this EditableTable.
 o setEnabled(boolean)
enable this EditableList (and all its components).
 o setReorderable(boolean)
Set whether the list should be reorderable.
 o updateList()
Update the information displayed in the list.

Variables

 o HGAP
 public static final String HGAP
The resource EditableList.hGap or <componentName>.hGap is an Integer specifying the horizontal gaps in points between the various Components (buttons, labels, JTable).

 o VGAP
 public static final String VGAP
The resource EditableList.vGap or <componentName>.vGap is an Integer specifying the vertical gaps in points between the various Components (buttons, labels, JTable).

 o HMARGIN
 public static final String HMARGIN
The resource EditableList.hMargin or <componentName>.hMargin is an Integer specifying the horizontal margin in points. The horizontal margin is the gap between the table and the editor and the left and right edges of the containing Panel.

 o VMARGIN
 public static final String VMARGIN
The resource EditableList.vMargin or <componentName>.vMargin is an Integer specifying the vertical margin in points. The vertical margin is the gap between the table and the editor and the top and bottom edges of the containing Panel.

 o EDITOR_VGAP
 public static final String EDITOR_VGAP
The resource EditableList.editorVGap or <componentName>.editorVGap is an Integer specifying the spacing in points between the bottom of the editor and the top of the list.

 o NUM_ROWS_ATTR_NAME
 public static final String NUM_ROWS_ATTR_NAME
The resource EditableList.numRowsAttrName or <componentName>.numRowsAttrName is a String specifying the name of the Long Attribute in TaskData that keeps track of the number of rows in the entry table. This Attribute is used to initialize the list at startup, to keep track of the number of rows as the user edits the list, and to programmatically get values out of the list.

 o HEADING
 public static final String HEADING
The resource set EditableList.heading<n> or <componentName>.heading<n> specifies the headings that appear in the table of entries.

 o COLUMN_ATTR_NAME
 public static final String COLUMN_ATTR_NAME
The resource set EditableList.columnAttrName<n> or <componentName>.columnAttrName<n> specifies the Attribute name for each column in the list. A call to setColumns overrides this resource.

See Also:
setColumns
 o INVISIBLE_COLUMN_ATTR_NAME
 public static final String INVISIBLE_COLUMN_ATTR_NAME
The resource set EditableList.invisibleColumnAttrName<n> or <componentName>.invisibleColumnAttrName<n> specifies the Attribute name for invisible columns. Each row in the list can have invisible columns, whose corresponding TaskData Attributes may be of any type. A call to setColumns overrides this resource.

Invisible columns are added, moved, and deleted along with the visible columns, but are not displayed to the user. They can be used to store auxiliary information in the TaskData for each row.

See Also:
setColumns
 o CHANGED_SINCE_LAST_ADD_ATTR_NAME
 public static final String CHANGED_SINCE_LAST_ADD_ATTR_NAME
The resource EditableList.changedSinceLastAddAttrName or <componentName>.changedSinceLastAddAttrName specifies the name of a Boolean Attribute in TaskData that gets bound to the state of the editor: the Attribute will be true if the user has made changes and false otherwise.

EditableList keeps the CHANGED_SINCE_LAST_ADD_ATTR_NAME Attribute up to date by calling its EditVerifier's changedSinceLastAdd method whenever any of the Attributes for the editor change.

See Also:
changedSinceLastAdd, changedSinceLastAdd
 o COLUMN_WIDTH
 public static final String COLUMN_WIDTH
The resource set EditableList.columnWidth<n> or <componentName>.columnWidth<n> specifies the widths in points of the columns in the list. Any columns with missing columnWidth resources are sized dynamically based on the size of the table.

 o NUMBER_COLUMN_WIDTH
 public static final String NUMBER_COLUMN_WIDTH
The resource EditableList.numberColumnWidth or <componentName>.numberColumnWidth is an Integer specifying the width in points of the table column used for numbering the rows of a reorderable list.

 o NUMBER_FORMAT_STRING
 public static final String NUMBER_FORMAT_STRING
The resource EditableList.numberFormatString or <componentName>.numberFormatString is a String specifying the format of the strings used to number the rows in a reorderable list. The string is formatted using MessageFormat.format(), passing one Integer argument.

 o REORDERABLE
 public static final String REORDERABLE
The resource EditableList.reorderable or <componentName>.reorderable is a Boolean that controls whether or not the list is reorderable. The resource setting can be overridden by the caller by using the setReorderable() method.

 o LIST_WIDTH
 public static final String LIST_WIDTH
The resource EditableList.listWidth or <componentName>.listWidth is an Integer specifying the width in points of the JTable Component used to display the entries in the list. If all of the columns in the table have widths specified (via the COLUMN_WIDTH resource), LIST_WIDTH will be ignored and the width of the list will be set to the sum of the column widths and the column margins.

 o LIST_HEIGHT
 public static final String LIST_HEIGHT
The resource EditableList.listHeight or <componentName>.listHeight is an Integer specifying the height in points of the JTable Component used to display the entries in the list.

 o ADD_BUTTON_LABEL
 public static final String ADD_BUTTON_LABEL
The resource EditableList.addButtonLabel or <componentName>.addButtonLabel is the String displayed on the Add button.

 o MODIFY_BUTTON_LABEL
 public static final String MODIFY_BUTTON_LABEL
The resource EditableList.modifyButtonLabel or <componentName>.modifyButtonLabel is the String displayed on the Modify button.

 o RESET_BUTTON_LABEL
 public static final String RESET_BUTTON_LABEL
The resource EditableList.resetButtonLabel or <componentName>.resetButtonLabel is the String displayed on the Reset button.

 o SHOW_MODIFY_BUTTON
 public static final String SHOW_MODIFY_BUTTON
The resource EditableList.showModifyButton or <componentName>.showModifyButton is a Boolean that controls whether the Modify button is visible.

 o SHOW_RESET_BUTTON
 public static final String SHOW_RESET_BUTTON
The resource EditableList.showResetButton or <componentName>.showResetButton is a Boolean that controls whether the Reset button is visible.

 o DELETE_BUTTON_LABEL
 public static final String DELETE_BUTTON_LABEL
The resource EditableList.deleteButtonLabel or <componentName>.deleteButtonLabel is the String displayed on the Delete button.

 o ORDER_HEADING
 public static final String ORDER_HEADING
The resource EditableList.orderHeading or <componentName>.orderHeading is the String displayed above the column of numbers on reorderable lists.

 o HORIZONTAL_ALIGNMENT
 public static final String HORIZONTAL_ALIGNMENT
The resource EditableList.horizontalAlignment.<row>,<column> or <componentName>.horizontalAlignment.<row>,<column> specifies the horizontal alignment of the editor component in the cell specified by row and column. Specify "CENTER", "LEFT", or "RIGHT".

 o VERTICAL_ALIGNMENT
 public static final String VERTICAL_ALIGNMENT
The resource EditableList.verticalAlignment.<row>,<column> or <componentName>.verticalAlignment.<row>,<column> specifies the vertical alignment of the editor component in the cell specified by row and column. Specify "CENTER", "TOP", or "BOTTOM".

Constructors

 o EditableList
 public EditableList(String componentName,
                     ResourceStack rs,
                     TaskData taskData)
Construct an EditableList.

Parameters:
componentName - Name of this component for resource purposes.
rs - Used to get resource settings that control the appearance and behavior of this EditableList.
taskData - TaskData to be used for storing the information in the table.

Methods

 o setEditor
 public void setEditor(Component editorComponent)
Called to set the Component to be used to edit a row in this EditableTable.

Parameters:
editorComponent - Component to be used to edit a row.
 o setEditor
 public void setEditor(Component editorComponent,
                       EditableList. EditVerifier verifier)
Called to set the Component to be used to edit a row in this EditableTable. Also specifies an EditVerifier.

Parameters:
editorComponent - The editor component.
verifier - Verifies edits.
 o changedSinceLastAdd
 public boolean changedSinceLastAdd()
Determine whether the user has changed anything in the editor since the last time the "Add" button was pressed. The CHANGED_SINCE_LAST_ADD_ATTR_NAME property can also be used to determine whether the editor has changed.

Returns:
true if changes have been made, false otherwise.
See Also:
CHANGED_SINCE_LAST_ADD_ATTR_NAME
 o setColumns
 public void setColumns(String numRowsAttr,
                        String columnAttrs[],
                        String headings[])
Set up the columns of this EditableList. Calling this method overrides settings of the COLUMN_ATTR_NAME and INVISIBLE_COLUMN_ATTR_NAME resources.

Parameters:
numRowsAttr - name of long Attribute to be used to keep track of the number of columns.
columnAttrs - array of Attribute names, one for each column.
headings - array of Strings to be displayed as headings in the table. These strings should be localized by the caller.
See Also:
COLUMN_ATTR_NAME, INVISIBLE_COLUMN_ATTR_NAME
 o setColumns
 public void setColumns(String numRowsAttr,
                        String columnAttrs[],
                        String headings[],
                        String invisibleColumnAttrs[])
Set up the columns of this EditableList, including invisible columns.

Parameters:
numRowsAttr - name of long Attribute to be used to keep track of the number of columns.
columnAttrs - array of Attribute names, one for each column.
headings - array of Strings to be displayed as headings in the table. These strings should be localized by the caller.
invisibleColumnAttrs - array of Attribute names, one for each invisible column.
 o setReorderable
 public void setReorderable(boolean reorderable)
Set whether the list should be reorderable. If the list is reorderable, the rows will be numbered and buttons will be provided for moving entries up and down.

Parameters:
reorderable - true if the list should be reorderable.
 o getEditorLayout
 public LayoutManager getEditorLayout()
Get a LayoutManager that can be used with the editor of this EditableList. getEditorLayout returns a LayoutManager that keeps columns of Components lined up with the columns in this list.

By default, components are laid out from left to right in the order in which they are added. When the number of Components exceeds the number of columns, a new row is started.

More fine-grained control over the placement of components can be achieved by specifying constraints of type Cell when adding Components to a Container that uses the LayoutManager returned by getEditorLayout.

Returns:
LayoutManager associated with this EditableList
See Also:
EditableList. Cell
 o clearList
 public void clearList()
Removes all the row data from the list. Clears the strings in the editor task data. Does not do anything to the invisible editor task data.

 o updateList
 public void updateList()
Update the information displayed in the list. This should be called after the task data is changed.

 o addNotify
 public void addNotify()
Called when we're added to a Container. Build our UI.

Overrides:
addNotify in class JComponent
 o setEnabled
 public void setEnabled(boolean enable)
enable this EditableList (and all its components).

Parameters:
enable - enable if true, disable if false.
Overrides:
setEnabled in class JComponent

All Packages  Class Hierarchy  This Package  Previous  Next  Index