Lesson 2: Include the CustomContextProvider in the CARMADeveloperView class

In this lesson, you rewrite the createViewer method to include the CustomContentProvider.

About this task

To modify the CARMADeveloperView class:

Procedure

  1. Open the CARMADeveloperView class by double-clicking it in its package. The source should open in the editor.
  2. Scroll down to the createViewer method and change it so that it uses the CustomContextProvider. It is helpful to note that the CARMATreeViewer constructor allows for a context provider to be specified to the viewer.

    The following is example sample code:

    protected StructuredViewer createViewer(Composite parent)
    {
       /* Create the structure that you want to be present in the view here.
        * For this tutorial, you will use the CARMA tree model, like the repositories view.
        */
       CARMATreeViewer viewer = new CARMATreeViewer(parent, new CustomContextProvider());
       viewer.setLabelProvider(new CustomLabelProvider());
       return viewer;
    }
  3. Save the source and debug any errors.