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:
- 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
- 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.
- 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.
- 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.
- In the Name text field, enter CustomLabelProvider.
- 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.
- 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.