Time for action – placing the preferences page

When the preference page is created, if it does not specify a location (known as a category in the plugin.xml file and manifest editor), it is inserted into the top level. This is appropriate for some kinds of project (for example, Mylyn, Java, and Plug-in Development); but many plug-ins should contribute into an existing location in the preference page tree.

  1. Preference pages can be nested by specifying the parent preference page's ID. To move the Clock preference page underneath the General preference page, specify org.eclipse.ui.preferencePages.Workbench as the category:
    <extension point="org.eclipse.ui.preferencePages">
    <page name="Clock"id="com.packtpub.e4.clock.ui.preference.page"category="org.eclipse.ui.preferencePages.Workbench"class="com.packtpub.e4.clock.ui.ClockPreferencePage"/>
    </extension>
  2. Run the target Eclipse instance and look at the Preferences. The Clock preference page should now be under the General tree node instead:
    Time for action – placing the preferences page

What just happened?

The preference page can be placed anywhere in the hierarchy by specifying the parent page's ID in the category attribute. The parent pages can be listed by navigating to Window | Show View | Other | Console and opening a Host OSGI Console, followed by running the following command:

osgi> pt -v org.eclipse.ui.preferencePages
Extension point: org.eclipse.ui.preferencePages [from org.eclipse.ui]

Extension(s):
-------------------
null [from org.eclipse.ant.ui]
   <page>
      name = Ant
      class = org.eclipse.ant.internal.ui.preferences.AntPreferencePage
      id = org.eclipse.ant.ui.AntPreferencePage
   </page>
...

Another way of listing the IDs is to use the Browse button via the plugin.xml editor. From the extension point defining the Clock preference page, the Browse button next to the category field will bring up a dialog containing all the valid IDs, including a search filter to reduce the number of matches:

What just happened?
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.39.74