All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sgi.sysadm.ui.ItemViewController

java.lang.Object
   |
   +----com.sgi.sysadm.ui.ItemViewController

public class ItemViewController
extends Object
implements ItemViewProperties
There are three ways to use this class. The first is a default version. In this version it is not necessary to write any Item-specific code, or any Item specific resource files. The second method is to add some resources that give the ItemViewController hints on what type of display is desired. The third way is to subclass this class and provide code to achieve the desired results.

The first method is to simply create the object by calling the constructor, pass a ItemViewPanel to the setItemViewPanel method, and then pass the ItemViewController a Item selector to display via the setItem method. All of these details are handled automatically by calling ItemView's createItemView method. In this default version of an ItemView, all of the Attributes in the Item that is being shown will be converted to strings with the toString method and displayed in the ItemViewPanel.

To provide more flexibility, this ItemViewController will also attempt to use a ResourceStack to obtain display information. To use this feature, you must add some resources to the Category's resource file that is contained in the ResourceStack that's contained in the ItemViewContext that is passed to the constructor. This ResourceStack is build automatically when calling ItemView's createItemView method. The resources that can be used to control the ItemViewController are outlined below. For more information, see the ItemViewProperties documentation. For information about ItemViews in general, see the ItemView documentation.

To use the resources, there are three types of resources to add the the resource files:

First, there must be a set of resources called FIELDS. The strings in this string array are names that you give each of the fields to display in the "fields" section ItemView. The order of strings in the set will determine the order in which the fields will be displayed. For example, an ItemView that is displaying user accounts might have a properties file that contains:

 com.sgi.product.MyCategory.ItemView.fields0=name
 com.sgi.product.MyCategory.ItemView.fileds1=gecos
 com.sgi.product.MyCategory.ItemView.fields2=uid
 com.sgi.product.MyCategory.ItemView.fields3=shell
 

Second, for each field that will be displayed, there may also be a resource that specifies the string to use as the label for that field. The resource specifying the label is LABEL. For example, to label the field "type", add a resource com.sgi.product.MyCategory.ItemView.label.type. If this resource is not specified, the name of the field will be used as the label.

Finally, each field may have a resource METHOD that specifies the manner in which a particular field of the Item will be generated for display in the ItemView. All of the methods of rendering cells except for the "renderer" method assume that the name of the column is the same as the name of the Attribute in the Item that the column is representing. 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 specify the method in which an attribue "type" is displayed, add a resource with the name com.sgi.product.MyCategory.ItemView.method.type and give it one of the values mentioned below. The methods are:

toString
Specifies that the value of an Attribute should be converted into a string using the toString() method on the Attribute's value. This is the default method if no conversion is specified. If the name of the field is not the key of an Attribute in the Item, you must provide a resource BASED_ON which specifies the name of the Attribute in the Item to use.
renderer
Specifies that field should be derived by using an ItemViewFieldRenderer object. The ItemViewFieldRenderer object used is the one that was passed to the setItemViewFieldRenderer method of this class
lookup
Specifies that the value of an Attribute should be converted into a String by appending the value of the Attribute as returned by the toString method to the resource key defined by LOOKUP and then using that string as a resource key specifying the string to display. For example, if an Attribute ("type","23") is displayed with the lookup method, the resource com.sgi.product.MyCategory.ItemView.lookup.type.23 will be used to get the string to display for the value of that Attribute. If the name of the field is not the key of an Attribute in the Item, you must provide a resource BASED_ON which specifies the name of the Attribute in the Item to use.

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.ItemView.lookup.turnedOn.true = True
 com.sgi.product.UserCategory.ItemView.lookup.turnedOn.false = False
 
The values displayed for true and false can now be localized or modified easily.
richText
Specifies that the value of the Attribute is the selector of an Item in a particular Category. The Attribute will be displayed as a RichText component that will launch an ItemView. See the CATEGORY field for details on how to specify which Category the Item belongs to. See the SELECTOR field for details on how to specify the selector of the Item to show. If the name of the field is not the key of an Attribute in the Item, you must provide a resource BASED_ON which specifies the name of the Attribute in the Item to use.

Sometimes, an Attribute will be missing from an Item, and in this case the ItemView should display a particular string. For example, consider an Item that can optionally contain an Attribute "name". If the Item contains that Attribute, then the ItemView should display the name, otherwise, it should display "(None)". For this situation, you can use the MISSING resource. The MISSING resource allows you to specify a string that will be displayed if an Attribute is missing from an Item. The MISSING resource can be used with the toString, lookup, or richText methods. See the MISSING resource for information about using the MISSING resource.

Sometimes, an Attribute will be present in an Item, but its value is the empty string (""). In this case you might want the the ItemView to display a particular string. For example, consider an Item that can contains an Attribute "nickname". If that Attribute is set to a non-zero length string, then the ItemView should display that string, otherwise, it should display "(None)". For this situation, you can use the EMPTY resource. The EMPTY resource allows you to specify a string that will be displayed if an Attribute is present but contains the empty string. The EMPTY resource can be used with the toString or richText methods. See the EMPTY resource for information about using the EMPTY resource.

See Also:
FIELDS, LABEL, BASED_ON, METHOD, CATEGORY, SELECTOR, MISSING, EMPTY, ItemViewProperties, ItemView

Constructor Index

 o ItemViewController(Category, String, ItemViewContext)
Constructor for ItemViewController

Method Index

 o addItemViewLaunchRequestListener(ItemViewLaunchRequestListener)
Adds a ItemViewLaunchRequestListener to the list of listeners that will be notified when a user clicks on a hyperlink to launch a new ItemView.
 o destroy()
Removes any CategoryListeners that have been installed
 o fireFieldChanged(String)
A method for ItemViewFieldRenderers to call if an field they're rendering changes after the renderFields or renderFieldsAgain methods return.
 o getDefaultLinkListener()
Returns the LinkListener that the ItemViewController uses to handle clicks on RichTextComponents that contain links to launch ItemViews, where the link was created by ItemView's createURLToLaunch.
 o getItemViewPanel()
Returns the ItemViewPanel that was passed to setItemPanel
 o getRichTextForFieldRenderer(String)
A utility method that returns a RichTextComponent for an ItemViewFieldRenderers' use.
 o getRLabelForFieldRenderer()
A utility method that returns a RLabel for a ItemViewFieldRenderer's use.
 o refresh()
Refresh the view.
 o removeItemViewLaunchRequestListener(ItemViewLaunchRequestListener)
Remove a ItemViewLaunchRequestListener from the list of listeners
 o setItem(String)
Set the Item that is displayed in the ItemView
 o setItemViewAdditionalInfoRenderer(ItemViewAdditionalInfoRenderer)
Sets the ItemViewAdditionalInfoRenderer to use with this ItemView
 o setItemViewFieldRenderer(ItemViewFieldRenderer)
Sets the ItemViewFieldRenderer to use with this ItemView
 o setItemViewPanel(ItemViewPanel)
Sets the ItemViewPanel to use with this ItemViewController.
 o setTaskShelfPanel(TaskShelfPanel)
Sets the TaskShelfPanel to place in the ItemView

Constructors

 o ItemViewController
 public ItemViewController(Category category,
                           String name,
                           ItemViewContext ivc)
Constructor for ItemViewController

Parameters:
category - The category that contains the Item to view
name - The name of this ItemView. This name is prepended to all the resources keys. This should be the package qualified name of the Category that this ItemView will display Items of.
ivc - The ItemViewContext for the ItemView.

Methods

 o setItemViewPanel
 public void setItemViewPanel(ItemViewPanel ivp)
Sets the ItemViewPanel to use with this ItemViewController. If this ItemView will be using an ItemViewFieldRenderer, it needs to be set via the setItemViewFieldRenderer method before this method is called.

Parameters:
ivp - The ItemViewPanel to control.
See Also:
setItemViewFieldRenderer
 o setTaskShelfPanel
 public void setTaskShelfPanel(TaskShelfPanel tsp)
Sets the TaskShelfPanel to place in the ItemView

Parameters:
tsp - The TaskShelfPanel
 o setItemViewFieldRenderer
 public void setItemViewFieldRenderer(ItemViewFieldRenderer renderer)
Sets the ItemViewFieldRenderer to use with this ItemView

Parameters:
renderer - The ItemViewFieldRenderer
 o setItemViewAdditionalInfoRenderer
 public void setItemViewAdditionalInfoRenderer(ItemViewAdditionalInfoRenderer renderer)
Sets the ItemViewAdditionalInfoRenderer to use with this ItemView

Parameters:
renderer - The ItemViewAdditionalInfoRenderer
 o setItem
 public void setItem(String selector)
Set the Item that is displayed in the ItemView

Parameters:
selector - The Item whose selector matches this parameter will be displayed. Any Item that was previously being displayed will be forgotton.
 o destroy
 public void destroy()
Removes any CategoryListeners that have been installed

 o refresh
 public void refresh()
Refresh the view. Forces a repaint of the ItemView, taking into account any changes that have been made. It refreshes only if we're not in a change block.

 o getItemViewPanel
 public ItemViewPanel getItemViewPanel()
Returns the ItemViewPanel that was passed to setItemPanel

Returns:
an ItemViewPanel
 o addItemViewLaunchRequestListener
 public void addItemViewLaunchRequestListener(ItemViewLaunchRequestListener listener)
Adds a ItemViewLaunchRequestListener to the list of listeners that will be notified when a user clicks on a hyperlink to launch a new ItemView. If no listeners are added, then the default behavior is to start the ItemView in a new ItemViewFrame.

Parameters:
listener - The ItemViewLaunchRequestListener to add.
 o removeItemViewLaunchRequestListener
 public void removeItemViewLaunchRequestListener(ItemViewLaunchRequestListener listener)
Remove a ItemViewLaunchRequestListener from the list of listeners

Parameters:
listener - The ItemViewLaunchRequestListener to remove
 o fireFieldChanged
 public void fireFieldChanged(String field)
A method for ItemViewFieldRenderers to call if an field they're rendering changes after the renderFields or renderFieldsAgain methods return. This forces a redraw of the field specified by field.

Parameters:
field - The string identifying the field that changed. This should match a string defined in the FIELDS resource set.
See Also:
ItemViewFieldRenderer, FIELDS
 o getRichTextForFieldRenderer
 public RichTextComponent getRichTextForFieldRenderer(String name)
A utility method that returns a RichTextComponent for an ItemViewFieldRenderers' use. The RichTextComponent is all set up to look like other RichTextComponents in the ItemView, and has a link listener set appropriately. To launch an ItemView when clicked, the text of the RichTextComponent should contain a link that was formed from ItemView's createURLToLaunch.

Parameters:
name - The name that will be passed the the RichTextComponent constructor
Returns:
The RichTextComponent
See Also:
ItemViewFieldRenderer, createURLToLaunch
 o getRLabelForFieldRenderer
 public RLabel getRLabelForFieldRenderer()
A utility method that returns a RLabel for a ItemViewFieldRenderer's use. The RLabel is all set up to look like other RLabels in the ItemView.

Returns:
The RLabel.
See Also:
ItemViewFieldRenderer
 o getDefaultLinkListener
 public LinkListener getDefaultLinkListener()
Returns the LinkListener that the ItemViewController uses to handle clicks on RichTextComponents that contain links to launch ItemViews, where the link was created by ItemView's createURLToLaunch. The AdditionalInfoRenderer can use this if it wishes to let the ItemViewController handle launching the ItemViews.

See Also:
createURLToLaunch

All Packages  Class Hierarchy  This Package  Previous  Next  Index