Previous Page
Next Page

12.1. Creating a Preference Page

You need to contribute a preference page that will allow users to select the columns that will be visible to the Favorites product. To accomplish this, create an org.eclipse.ui.preferencePages extension in the plug-in manifest. Fortunately, Eclipse provides a wizard for creating preference pages.

Open the Favorites plugin.xml file and switch to the Extensions page. Click the Add... button to open the New Extension wizard, select org.eclipse.ui.preferencePages from the extension point list and Preference Page in the template list, and then click Next (see Figure 12-1). On the following page, modify the Page Class Name and Page Name to "FavoritesPreferencePage" and "Favorites," respectively (see Figure 12-2) and click Finish.

Figure 12-1. New Extension wizard.


Figure 12-2. Sample Preference Page wizard.


Click on the new Favorites (page) extension under the org.eclipse.ui.preferencePages extension on the Extensions page to reveal its properties. In the extension element details area, you'll see the following attributes as described in the Eclipse online help. Change the id attribute to "com.qualityeclipse.favorites.prefs.view".

idA unique name that will be used to identify this page.

nameA human-readable name that appears in the preference page hierarchy on the left side of the workbench Preferences dialog.

class The fully qualified name of the class that implements the org.eclipse.ui.IWorkbenchPreferencePage 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).

category The Preferences dialog box provides for a hierarchical grouping of the pages. For this reason, a page can optionally specify a category attribute. This attribute represents a path composed of parent page IDs separated by "/". If this attribute is omitted or if any of the parent nodes in the path cannot be found, the page will be added at the root level (see Section 12.2.6, Nested preference pages, on page 464).

If you launch the Runtime Workbench, open the workbench Preferences dialog, and select Favorites, you'll see the sample Favorites preference page created by the New Extension wizard (see Figure 12-3).

Figure 12-3. Sample Favorites preference page.



Previous Page
Next Page