Previous Page
Next Page

7.1. View Declaration

Three steps are involved in creating a new view:

  • Define the view category in the plug-in manifest file.

  • Define the view in the plug-in manifest file.

  • Create the view part containing the code.

One way to do all this at once is to create the view when the plug-in itself is being created (see Section 2.2.3, Define the view, on page 69). If the plug-in already exists, then this becomes a three-step process.

7.1.1. Declaring a view category

First, to define a new view category, edit the plug-in manifest and navigate to the Extensions page. Click the Add... button to add the org.eclipse.ui.views extension if it is not already present (see Figure 7-2). Right-click the org.eclipse.ui.views extension and select New > category to add a new category if one does not exist already.

Figure 7-2. The New Extension wizard with the org.eclipse.ui.views extension point selected.


The properties for this category can be modified in the plug-in manifest editor (see Figure 7-3). For the category containing the Favorites view, the attributes would be as follows:

id"com.qualityeclipse.favorites"

The unique identifier for the category.

name"Quality Eclipse"

The human-readable name for the category that appears in the Show View dialog (see Figure 2-20 on page 87).

Figure 7-3. The Plug-in manifest editor showing the Quality Eclipse view category.


7.1.2. Declaring a view

When the view category has been defined, right-click again on the org.eclipse.ui.views extension in the Extensions page and select New > view to define a new view. Use the Extension Element Details section of the editor (see Figure 7-4) to modify the attributes of the view. For the Favorites view, the attributes would be as follows:

category"com.qualityeclipse.favorites"

The unique identifier for the view category that contains this view.

class"com.qualityeclipse.favorites.views.FavoritesView"

The fully qualified name of the class defining the view and implementing the org.eclipse.ui.IViewPart interface. The class is instantiated using its no argument constructor, but can be parameterized using the IExecutableExtension interface (see Section 20.5, Types Specified in an Extension Point, on page 723).

icon"icons/sample.gif"

The image displayed in the upper left corner of the view and in the Show View dialog (see Figure 2-20 on page 87). Similar to an action image (see Section 6.2.4, Action images, on page 214), this path is relative to the plug-in's installation directory.

id"com.qualityeclipse.favorites.views.FavoritesView"

The unique identifier for this view.

name"Favorites"

The human-readable name for the view displayed in the view's title bar and the Show View dialog (see Figure 2-20 on page 87).

Figure 7-4. The Plug-in manifest editor view showing the Favorites view.



Previous Page
Next Page