Rational Developer for System z


Lesson 2: Create the CustomLabelProvider class

In this lesson, you will create a CustomLabelProvider class which will handle how each item in the CARMA Developer View is displayed.

To create the CustomLabelProvider class:

  1. To start, add the getImageDecorator() method to the Activator class. Expand com.ibm.carma.plugin.view > src > com.ibm.carma.plugin.view, and double click on the Activator class. It should open in the editor
  2. Add the following method to the Activator class:
    public static ImageDescriptor getImageDescriptor(String path)
    {
    	return imageDescriptorFromPlugin(PLUGIN_ID, path);
    }
    This static method allows the image descriptor or decorator to be retrieved from the appropriate location in the plug-in project.
  3. Add the following import at the top of the Activator class: import org.eclipse.jface.resource.ImageDescriptor;. Save and debug any errors in the source.
  4. Next, you want to create the CustomLabelProvider class. In the Package Explorer view, expand the com.ibm.carma.plugin.view plug-in project. Right click on the view package you created in Exercise 5, and select New > Class. The New Java Class dialog box will open.
  5. In the Name text field, enter CustomLabelProvider.
  6. Select the Browse button to the right of the Superclass text field. In the Superclass Selection dialog box that opens, type CARMALabelProvider as the filter text, select the class from the list of matching items, and click OK.
  7. Mark the Constructors from superclass and Inherited abstract methods check boxes. Click Finish to close the New Java Class dialog box and create the Java™ class.

Feedback