All Packages Class Hierarchy This Package Previous Next Index
Class com.sgi.sysadm.ui.ItemTableController
java.lang.Object
|
+----com.sgi.sysadm.ui.ItemTableController
- public class ItemTableController
- extends Object
- implements ItemTableProperties
A class that controls an ItemTablePanel by looking up information
on how to display Items in a resource file.
The resources are described here, and defined in
ItemTableProperties.
ItemTableController has a default mode that it uses if it cannot
find any properties relating to the Category it is displaying. In
that case, there is a column in the table for each of the
Attributes in the Items of the Category.
To control how the ItemTable shows Items, you add resources to the
property file of the Category. The most important resource is the
COLUMNS resource, which names the columns that the ItemTable will
use.
For example, an ItemTable that is
displaying user accounts might have a properties file that
contains:
com.sgi.product.UserCategory.ItemTable.column0 = name
com.sgi.product.UserCategory.ItemTable.column1 = gecos
com.sgi.product.UserCategory.ItemTable.column2 = uid
com.sgi.product.UserCategory.ItemTable.column3 = shell
The names of the columns will frequently correspond to the names
of the Attributes of the Item that determine the value of that
column. All of the methods of rendering cells except for the "renderer"
methods assume that this is the case. If this is not the case,
then you must use the
BASED_ON attribute to specify which Attribute the column should be
based on. For example, to display
the "state" Attribute twice, once as an icon and once as a
string, the properties file should contain:
com.sgi.product.UserCategory.ItemTable.column0 = state_icon
com.sgi.product.UserCategory.ItemTable.column1 = state_string
com.sgi.product.UserCategory.ItemTable.basedOn.state_icon = state
com.sgi.product.UserCategory.ItemTable.basedOn.state_string = state
There are 7 different methods to choose from to display a column.
To set the method that a column uses, use the METHOD resource.
The methods are as follows:
- toString
- This is the most basic method of conversion. The value of
the attribute is turned into a String with the toString method
and displayed. No additional resources are needed for this
method.
- componentRenderer
- This specifies that the
getComponentForCellOfItemTable method will be called on the
ItemTableColumnRenderer object that was passed into the
constructor. The renderer can return any JComponent, and that
component will be displayed in the table. No additional
resources are needed for this method.
- stringRenderer
- This specifies that the
getStringForCellOfItemTable method will be called on the
ItemTableColumnRenderer object that was passed into the
constructor. The renderer can return any String, and that
String will be displayed in the table. No additional resources
are needed for this method.
- lookup
- This specifies that the Attribute's value should be turned
into a String with the toString method, and then used to create
the resource name LOOKUP which will be used as the string to
display. If that resource is not found, the toString method will
be used. This method is good for cases when the value of the
Attributes comes from a limited set of possible values, and you
wish to provide a mapping from the Attribute to some more
easily understandable String. For example, if the Attribute
was a boolean attribute, the following could be used in the
propery file:
com.sgi.product.UserCategory.ItemTable.lookup.turnedOn.true = True
com.sgi.product.UserCategory.ItemTable.lookup.turnedOn.false = False
The values displayed for true and false can now be localized
or modified easily.
- richText
- This is similar to the toString method, except that the
value of the Attribute will be turned into a link that can be
clicked to launch an ItemView. The Attribute's value will be
used as the displayed text of the link. The value of the
resource SELECTOR
will be interpreted as the key of an Attribute that contains
the selector of the Item to view. The value of the resource
CATEGORY will be used as the package-qualified name of the Category
to view.
- richTextRenderer
- Similar to the stringRenderer method, except that the
string returned by the getRichTextForCellOfItemTable
method of the ItemTableColumnRenderer is used to construct a RichText
component. The ItemTableController will handle catching user
clicks on the RichText and launching the appropriate ItemView.
- icon
- This specifies that the Attribute's value should be used to
determine an icon to display. The attribute's value is turned
into a string with the toString method, and then is used to
lookup the resource ICON. This resource should be the pathname of an icon
to show in the table. If the resource is not found, the
resource DEFAULT_ICON is used as a default.
For each column, you can provide a resource LABEL that defines
the label of the column.
For each column, you can provide a resource WIDTH that defines
the width (in points) of the column. If the WIDTH resource is not
found for a particular column, the DEFAULT_WIDTH resource is used.
For each column, you can provide a resource SORT that defines the
way that the Items will be sorted if the user requests that the
Table be sorted on a particular column. The choices are:
- lexical
- Specifies that a lexical sort should be used. Can be used
if the method for this column is toString, stringRenderer,
lookup, richText, or richTextRenderer
- numeric
- Specifies that a numeric sort should be used. Can be used
if the method for this column is toString, stringRenderer,
lookup, richText, or richTextRenderer
- none
- Specifies that there is no sort order for the column. Can
be used with any method.
- sorter
- Specifies that any two items can be sorted by passing the
two items and the attribute's name to sort on to the
compareItemsForItemTable method of the ItemTableAttributeRenderer
object passed to the constructor. Can be used with any method.
For each column, you can provide a resource ALIGNMENT that defines the
way that the Strings will be alligned in the column. The choices
are:
Alignment is only available on columns using the toString,
lookup, or stringRenderer methods.
For each column, you can provide a resource MISSING that defines a
string that will be displayed in the cell if the Attribute that the
column is based on is not present in the Item. The MISSING
resource works for columns using the toString,
lookup, or richText methods.
- See Also:
- COLUMNS, LABEL, METHOD, LOOKUP, BASED_ON, ICON, DEFAULT_ICON, WIDTH, DEFAULT_WIDTH, CATEGORY, SELECTOR, SORT, ALIGNMENT, MISSING
-
ItemTableController(ItemTablePanel, String, ItemTableContext, ItemTableColumnRenderer)
- Construct an ItemTableController
-
addItemViewLaunchRequestListener(ItemViewLaunchRequestListener)
-
Adds an ItemViewLaunchRequestListener.
-
destroy()
- Removes any CategoryListeners that have been installed so that
the object can be garbage collected.
-
getItemTablePanel()
-
Returns the ItemTablePanel that was passed to the constructor
-
getSelectedItems()
- Returns the Items that are selected.
-
removeItemViewLaunchRequestListener(ItemViewLaunchRequestListener)
- Removes an ItemViewLaunchRequestListener
-
setCategory(Category)
- Sets the Category that this ItemTableController is listening
to.
ItemTableController
public ItemTableController(ItemTablePanel itp,
String name,
ItemTableContext itc,
ItemTableColumnRenderer itcr)
- Construct an ItemTableController
- Parameters:
- itp - The ItemTablePanel to control
- name - The string to use to name this ItemTable
- rs - A ResourceStack to use to locate resources
- hostContext - The HostContext
- itcr - An ItemTableColumnRenderer to use for rendering
attributes. Can be null.
destroy
public void destroy()
- Removes any CategoryListeners that have been installed so that
the object can be garbage collected.
getItemTablePanel
public ItemTablePanel getItemTablePanel()
- Returns the ItemTablePanel that was passed to the constructor
- Returns:
- an ItemTablePanel
setCategory
public void setCategory(Category category)
- Sets the Category that this ItemTableController is listening
to. This category should be either the Category whose name was
passed to the constructor, or an Association with that Category
as the type of its members.
- Parameters:
- category - The category to use
addItemViewLaunchRequestListener
public void addItemViewLaunchRequestListener(ItemViewLaunchRequestListener listener)
- Adds an ItemViewLaunchRequestListener. The listener will be
called when a user clicks on a URL whose action is to launch an
ItemView. If no listeners are added, the default behavior is
to launch the ItemView in a new ItemViewFrame.
- Parameters:
- listener - the listener to add
removeItemViewLaunchRequestListener
public void removeItemViewLaunchRequestListener(ItemViewLaunchRequestListener listener)
- Removes an ItemViewLaunchRequestListener
- Parameters:
- listener - the listener to remove
getSelectedItems
public Item[] getSelectedItems()
- Returns the Items that are selected. There could be zero, one,
or multiple Items selected.
- Returns:
- An Item[] of the selected Items. If no Items are
selected, an empty Item[] will be returned.
All Packages Class Hierarchy This Package Previous Next Index