The first column of the ItemTable is reserved for the Icon that represents the Item. The Icon is not controlled by the ItemTable, but is generated by the ResourceBasedIconRenderer. See the tutorial on using ResourceBasedIconRenderer for details on how to control the Icon.
A: com.sgi.rhexamp.category.rhexampRhinoExampleCategory.ItemTable.column0=name B: com.sgi.rhexamp.category.rhexampRhinoExampleCategory.ItemTable.column1=type C: com.sgi.rhexamp.category.rhexampRhinoExampleCategory.ItemTable.column2=modeBecause the first part of each line is identical, it is common to use macros to shorten the lines of the resource file and to make the file easier to read. An example of the same resources using macros is shown below.
A: RHINO_EXAMPLE_CATEGORY=com.sgi.rhexamp.category.rhexampRhinoExampleCategory B: ITprefix=${RHINO_EXAMPLE_CATEGORY}.ItemTable C: D: ${ITprefix}.column0=name E: ${ITprefix}.column1=type F: ${ITprefix}.column2=mode
The three "column" lines (D - F) describe both the names of the columns and the order in which the columns will be displayed in the ItemTable. The names will be used later in the resource file to associate resources with particular columns. In this example, the names of the columns correspond exactly with the names of the Attributes in the Item that will be displayed in the column. By naming the columns in this manner, the ItemTable can use default behavior and automatically associate the correct Attribute with the column. It is also possible to give the columns names that are not the same as the names of Attributes. In that case, it may be necessary to use the "basedOn" property (defined below) to tell the ItemTable which Attribute is associated with a column.
Running an ItemTable with only the 5 lines described above in the
resource file will result in an ItemTable that is shown on the right.
Notice that the order of the columns (from left to right) is "name", "type", and then
"node", which was as specified in the resource file. ItemTable has used
the names of the columns as the labels for the columns. Information about how to
customize the labels is described below. The ItemTable is using the
default "toString" method (methods are described below). This is the
simplest method, and uses the results of calling Java's toString
method on the value of the Attribute.
If a column is given a name that does not correspond to the name of an Attribute, the "basedOn" property is used to tell the ItemTable which Attribute the column represents. The "basedOn" resources are defined as: <Category name>.ItemTable.basedOn.<column>, where <Category name> is the name of the Category, and <column> is the name of a column. (See the BASED_ON documentation for more details).
The stringRenderer, richTextRenderer, and componentRenderer methods (as described below) do not require that the column be associated with a particular Attribute. When using these methods, it is not necessary to specify the "basedOn" property even if the name of the column does not correspond to an Attribute. All the other methods, including the default "toString" method, require that the column be associated with a particular Attribute of the Item.
For example, suppose that for some reason we wish to display the name Attribute twice, once as the first column, and once as the last column. A resource file as follows would do just that:
A: RHINO_EXAMPLE_CATEGORY=com.sgi.rhexamp.category.rhexampRhinoExampleCategory B: ITprefix=${RHINO_EXAMPLE_CATEGORY}.ItemTable C: D: ${ITprefix}.column0=name1 E: ${ITprefix}.column1=type F: ${ITprefix}.column2=mode G: ${ITprefix}.column3=name2 H: I: ${ITprefix}.basedOn.name1=name J: ${ITprefix}.basedOn.name2=name
This would result is the name being shown twice, as is seen to the right:
The next step is to define the strings that will be used as the headers for the columns. The "label" resource controls this, and is defined as: <Category name>.ItemTable.label.<column>. (See the LABEL documentation for more details). For example, to add labels to the columns in the ItemTable, the resource file would get three new resources:
A: RHINO_EXAMPLE_CATEGORY=com.sgi.rhexamp.category.rhexampRhinoExampleCategory B: ITprefix=${RHINO_EXAMPLE_CATEGORY}.ItemTable C: D: ${ITprefix}.column0=name E: ${ITprefix}.column1=type F: ${ITprefix}.column2=mode G: H: ${ITprefix}.label.name=Name I: ${ITprefix}.label.type=Type J: ${ITprefix}.label.mode=Access
Displaying the ItemTable now shows that the correct labels are
displayed.
The next step is to choose what method the ItemTable should use to display the column. (In this usage, "method" does not refer to a Java method, but rather to the typical English definition of the word.) The "method" resource controls this, and is defined as: <Category name>.ItemTable.method.<column>. (See the METHOD documentation for more details) There are seven methods available:
For example, to specify that the "type" column should use the lookup method, and should display the type in Spanish instead of English, include the following in the resource file:
A: ${ITprefix}.method.type=lookup B: C: ${ITprefix}.lookup.type.Printer=Impresora D: ${ITprefix}.lookup.type.Clock=Reloj E: ${ITprefix}.lookup.type.NetscapeExecutable=Netscape
In this case, the type of the Item will be displayed in it's Spanish equivalent:
When using the richText method for a column, there must be two additional resources defined for each column. The first is the "category" resource, which is defined as <Category name>.ItemTable.category.<column> (See the CATEGORY documentation for more details). The second resource is the "selector" resource, which is defined as <Category name>.ItemTable.selector.<column> (See the SELECTOR documentation for more details). The "category" resource is a string that gives the package-qualifed name of the Category that the ItemView will use, and the "selector" resource names the Attribute whose value will be used as the selector of the Item the ItemView will show.
The example only has one Category, so to demonstrate the richText method, consider making the "name" column contain links to launch the appropriate ItemView. The following lines would be added the resource file:
A: ${ITprefix}.method.name=richText B: C: ${ITprefix}.category.name=${RHINO_EXAMPLE_CATEGORY} D: ${ITprefix}.selector.name=name
For example, to show an Icon that represents the "mode" Attribute, the following should be used as the resource file:
A: RHINO_EXAMPLE_CATEGORY=com.sgi.rhexamp.category.rhexampRhinoExampleCategory B: ITprefix=${RHINO_EXAMPLE_CATEGORY}.ItemTable C: D: ${ITprefix}.column0=name E: ${ITprefix}.column1=type F: ${ITprefix}.column2=mode-icon G: ${ITprefix}.column3=mode-text H: I: ${ITprefix}.basedOn.mode-icon=mode J: ${ITprefix}.basedOn.mode-text=mode K: L: ${ITprefix}.method.mode-icon=icon M: ${ITprefix}.icon.mode-icon.33188=/com/sgi/rhexamp/category/images/blue-ball.gif N: ${ITprefix}.icon.mode-icon.33060=/com/sgi/rhexamp/category/images/red-ball.gif O: ${ITprefix}.icon.mode-icon=/com/sgi/rhexamp/category/images/yellow-ball.gif
The example to the right shows the ItemTable that will result. Note
that because the mode needed to be displayed in two columns, once
as an icon and once as text, it was necessary to add a forth
column to the ItemTable and provide new names for the third and
forth columns. Also notice the "basedOn" properties that tell
ItemTable that the mode Attribute of the Item controls both columns.
A: ${ITprefix}.method.mode-text=stringRenderer B: ${ITprefix}.columnRenderer=${RHINO_EXAMPLE_CATEGORY}Renderers C: D: ${ITprefix}.modeStr.readWrite=Read/Write E: ${ITprefix}.modeStr.readOnly=Read Only
After adding the resources to use the string renderer, the ItemTable
looks like:
A: ${ITprefix}.width.name=100 B: ${ITprefix}.width.type=100 C: ${ITprefix}.width.mode-icon=10 D: ${ITprefix}.width.mode-text=100
After setting the widths, the ItemTable is as shown:
A: ${ITprefix}.alignment.type=right B: ${ITprefix}.alignment.mode-text=left
After setting the alignment resources as shown above, the ItemTable
looks like:
A: ${ITprefix}.sort.name=lexical B: ${ITprefix}.sort.type=lexical C: ${ITprefix}.sort.mode-icon=sorter D: ${ITprefix}.sort.mode-text=lexical
For example, to use the string "(Desconocido)" (Spanish for "Unknown") if the "type" Attribute is missing from the Item, add the following resource:
A: ${ITprefix}.method.type=lookup B: C: ${ITprefix}.lookup.type.Printer=Impresora D: ${ITprefix}.lookup.type.Clock=Reloj E: ${ITprefix}.lookup.type.NetscapeExecutable=Netscape F: ${ITprefix}.missing.type=(Desconocido)
A: ${ITprefix}.columnRenderer=${RHINO_EXAMPLE_CATEGORY}RenderersIf a column uses a renderer method, but no ItemTableColumnRenderer is defined with the "columnRenderer" property, then the ItemTable will attempt to load a class with the name <Category Name>ColumnRenderer. For example, for the rhinoExampleCategory, it would attempt to load the class com.sgi.rhexamp.category.rhexampRhinoExampleCategoryColumnRenderer. If the "columnRenderer" resource is not specified and the <Category Name>ColumnRenderer class is not found, then ItemTable will throw an assertion.
The ItemTableColumnRenderer has four methods that must be implemented: See the documentation for ItemTableColumnRenderer about the specifics of each method.
For the stringRenderer method, the ItemTable will call the getStringForCellOfItemTable method, and the method should compute the String to display and return it.
For the richTextRenderer method, the ItemTable will call the getRichTextForCellOfItemTable method, and the method should compute the String of HTML to display in a RichTextComponent and return it. To construct a URL that will launch an ItemView, use the createURLToLaunch method of ItemView.
For the componentRendrer method, the ItemTable will call the getComponentForCellOfItemTable, and the method should return a Component that the ItemTable should display in the appropriate cell.
The compareItemsForItemTable method is used to sort the ItemTable based on a column that is using the "sorter" method of sorting. The ItemTable will pass two Items and the name of the column to the method, and the method should return an integer representing which of the Items should come first in the sorted list. See the ItemTableColumnRenderer documentation for more information about these methods.
%> java com.sgi.sysadm.manager.RunItemTable <Category Name>
For example, to launch an ItemTable for Category "BarCategory", where the ItemTable's resource file is in /com/sgi/myProduct/category (relative to classpath), type:
%> java com.sgi.sysadm.manager.RunItemTable com.sgi.myProduct.category.BarCategory
To launch a no-code ItemTable, omit the name of the package:
%> java com.sgi.sysadm.manager.RunItemTable BarCategory
To programmatically launch an ItemTable, use one of two methods: To launch an ItemTable in a new frame (called an ItemTableFrame), use the launchItemTableFrame method in ItemTableFrame. The launchItemTableFrame method takes a ItemTableLaunchRequestEvent, which encapsulates all the information about which ItemTable to launch. For example:
1: ItemTableFrame.launchItemTableFrame( 2: new ItemTableLaunchRequestEvent(this, 3: "com.sgi.myProduct.category.BarCategory"), 4: new UIContext());
1: ItemTable it = ItemTable.createItemTable(_hostContext, 2: "com.sgi.myProduct.category.BarCategory"); 3: it.setCategory(_hostContext.getCategory("BarCategory")); 4: _panel.add(it.getItemTablePanel());
A: # Set up some macros to use in this resource file. See the B: # ResourceStack documentation for more about macros. C: RHINO_EXAMPLE_CATEGORY=com.sgi.rhexamp.category.rhexampRhinoExampleCategory D: ITprefix=${RHINO_EXAMPLE_CATEGORY}.ItemTable E: F: # Define the columns to displayed. Call them "mode", "type", G: # "mode-icon", and "mode-text". H: ${ITprefix}.column0=name I: ${ITprefix}.column1=type J: ${ITprefix}.column2=mode-icon K: ${ITprefix}.column3=mode-text L: M: # Tells the ItemTable which Attributes of the Item to use to show the N: # columns. It is not necessary to set a resource for mode-text because O: # it's using a "renderer" method, and basedOn is not used for the P: # "renderer" methods. Q: ${ITprefix}.basedOn.name=name R: ${ITprefix}.basedOn.type=type S: ${ITprefix}.basedOn.mode-icon=mode T: U: # Sets the method that the ItemTable will use to display the four columns V: ${ITprefix}.method.name=richText W: ${ITprefix}.method.type=lookup X: ${ITprefix}.method.mode-icon=icon Y: ${ITprefix}.method.mode-text=stringRenderer Z: AA: # Additional resources that are necessary because the "mode-icon" AB: # column is using the "icon" method. AC: ${ITprefix}.icon.mode-icon.33188=/com/sgi/rhexamp/category/images/blue-ball.gif AD: ${ITprefix}.icon.mode-icon.33060=/com/sgi/rhexamp/category/images/red-ball.gif AE: ${ITprefix}.icon.mode-icon=/com/sgi/rhexamp/category/images/yellow-ball.gif AF: AG: # Additional resources that are necessary because the "type" column AH: # is using the "lookup" method. AI: ${ITprefix}.lookup.type.Printer=Printer AJ: ${ITprefix}.lookup.type.Clock=Clock AK: ${ITprefix}.lookup.type.NetscapeExecutable=Netscape AL: AM: # Additional resources that are necessary because the "name" column AN: # is using a "richText" method. AO: ${ITprefix}.category.name=${RHINO_EXAMPLE_CATEGORY} AP: ${ITprefix}.selector.name=name AQ: AR: # Sets the labels that will be used for the columns. AS: ${ITprefix}.label.name=Name AT: ${ITprefix}.label.type=Type AU: ${ITprefix}.label.mode-icon= AV: ${ITprefix}.label.mode-text=Access AW: AX: # Sets the widths of the columns AY: ${ITprefix}.width.name=100 AZ: ${ITprefix}.width.type=100 BA: ${ITprefix}.width.mode-icon=10 BB: ${ITprefix}.width.mode-text=100 BC: BD: # Sets the alignment that will be used for the columns. There are BE: # no alignment resources for the name or mode-icon columns because BF: # alignment is only available on columns using the toString, lookup, and BG: # stringRenderer methods. BH: ${ITprefix}.alignment.type=left BI: ${ITprefix}.alignment.mode-text=left BJ: BK: # Sets the type of sort that will be used for the columns. BL: ${ITprefix}.sort.name=lexical BM: ${ITprefix}.sort.type=lexical BN: ${ITprefix}.sort.mode-icon=sorter BO: ${ITprefix}.sort.mode-text=lexical BP: BQ: # Tells the ItemTable what class to use as the ItemTableColumnRenderer. BR: ${ITprefix}.columnRenderer=${RHINO_EXAMPLE_CATEGORY}Renderers BS: BT: # Resources used by the ItemTableColumnRenderer. BU: ${ITprefix}.modeStr.readWrite=Read/Write BV: ${ITprefix}.modeStr.readOnly=Read Only