Rational Developer for System z, Version 7.6

Getting the lists of categories, properties, and category instances

This sample demonstrates how to programmatically obtain the list of registered categories and properties. Currently, the names of the registered categories and properties can be obtained. For each category, the instances of that category can be obtained, and the property values in each instance can be obtained.

Sample Scenario

To retrieve information about the categories, properties, and instances, select the API Samples > Properties Information action.

Artwork for listProperties

For each category that is registered, the name of the category, the properties in the category, and any instances of the category are displayed in the standard output associated with the workbench. This can be found in the DOS window from which the workbench was started, or in the Console view of the hosting workbench in the case of the runtime workbench.

Note: The standard output for a workbench started with the standard Eclipse icon may not be visible depending on the runtime settings for the workbench.

Artwork for listPropertiesResults

Sample Code Walk-through

Retrieving Registered Categories

The following code snippet from the ListPropertiesAction class demonstrates how to retrieve the registered categories:
  
ZOSPropertyGroupManager manager = ZOSPropertyGroupManager.getZOSPropertyGroupManager();
// Retrieve registered categories
List<ICategory> categories = manager.getCategories();

It starts by using the ZOSPropertyGroupManager class, obtained using the getZOSPropertyGroupManager method of the ZOSPropertyGroupManager class, to retrieve the ICategory objects representing the registered categories. The registered categories can also be obtained by using the ( LocalPropertyGroupManager) class, since both managers share the same Eclipse extension point to register properties.

Using Category Objects

The following code snippet from the ListPropertiesAction class demonstrates how to use ICategory objects:
 
for (ICategory category : categories) {
  System.out.println("---------------");
  System.out.println("Category: " + category.getName());
  // Retrieve registered properties for this category.
  List<IPropertyInfo> infos = category.getPropertyInformation();
  for (IPropertyInfo info : infos) {
    System.out.println("  Property: " + info.getName());
  }
  // Retrieve category instances for each registered category, and print
  // the properties and values for each instance.
  List<ICategoryInstance> instances = category.getInstances();
  for (ICategoryInstance instance : instances) {
    System.out.println("  Instance: ");
    List<IProperty> properties = instance.getProperties();
    for (IProperty property : properties) {
    System.out.println("    ----");
    System.out.println("    Property name: " + property.getName());
    System.out.println("    Property value: " + property.getValue());
  }
}

Each category has a name and enables retrieval of IPropertyInfo objects, which have the names of the registered properties for that category.

Each category enables retrieval of ICategoryInstance objects, which hold property values. Finally, the IProperty objects retrieved from a ICategoryInstance object have the name of the property and the property value.

The menu item is contributed to the workbench through an Eclipse action set:
  <extension
         id="com.ibm.ftt.api.samples.actionSets"
         name="%apiSample.actionSets"
         point="org.eclipse.ui.actionSets">
      <actionSet label="com.ibm.ftt.api.samples.actionSet1"
            description="Action set for the API samples"
            visible="true"
            id="com.ibm.ftt.api.samples.actionSet1">
         <menu label="%apiMenu.title"
               id="com.ibm.ftt.api.samples.apiMenu">
            <separator name="com.ibm.ftt.api.samples.apiMenu.resourcesAPI"/>
         </menu>
         <action label="%apiMenu.samples.listProperties"
               class="com.ibm.ftt.api.samples.resources.ListPropertiesAction"
               style="push" menubarPath=
    "com.ibm.ftt.api.samples.apiMenu/com.ibm.ftt.api.samples.apiMenu.resourcesAPI"
               id="com.ibm.ftt.api.samples.listPropertiesAction"/>
               ......
      </actionSet>
   </extension>

Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)