Lesson 4: Edit the CARMADeveloperView class to use the CustomLabelProvider

Now that you have created the CustomLabelProvider, you want the CARMADeveloperView class to use it. You have to edit the createViewer method to add the CustomLabelProvider object to the viewer.

About this task

To edit the CARMADeveloperView:

Procedure

  1. Open the CARMADeveloperView, by double-clicking on the class in the view package of the com.ibm.carma.plugin.view Eclipse plug-in project. It opens in the editor.
  2. You want to modify the createViewer method so that it creates the view from the content provider and then adds the CustomLabelProvider to the viewer.
    Ensure that your method looks the same as the source code below.
    protected StructuredViewer createViewer(Composite parent)
    {
       /* 
        * Create the structure you want to be present in the view here.
        * For this tutorial, the CARMA tree model will be used, similar to what is used in the CARMA Repositories view.
        */
       CARMATreeViewer viewer = new CARMATreeViewer(parent);
       viewer.setLabelProvider(new CustomLabelProvider());
       return viewer;
    }
  3. Save the source and debug any errors.