Time for action – adding keywords

Eclipse had a search field in the preferences list since version 3.1. This is defined not from UI but from a separate keyword extension instead. The keyword has an ID and a label, but the label isn't shown; rather, it's a space separated list of words which can be used in the filtering dialog. Perform the following steps:

  1. To add the keywords offset and timezone to the ClockPreferencePage, create a new extension point in plugin.xml for org.eclipse.ui.keywords:
    <extension point="org.eclipse.ui.keywords">
      <keyword id="com.packtpub.e4.clock.ui.keywords"label="offset timezone"/>
    </extension>
  2. Now associate these keywords with the preference page itself as follows:
    <extension point="org.eclipse.ui.preferencePages">
      <page name="Clock" ... >
        <keywordReference id="com.packtpub.e4.clock.ui.keywords"/>
      </page>
    </extension>
  3. Run the Eclipse instance, go to the Preferences page and type timezone and offset in the search box. The Clock preference page should be shown in both cases:
    Time for action – adding keywords

What just happened?

By providing a list of keywords and associating them with the preferences page the user can search for the item in the preferences tree. The same keyword support is used to search for items in other places such as the New dialog wizards and the properties page.

Furthermore, these keywords are internationalizable. By specifying a key with a % name, Eclipse can load the keywords from an externalized file called plugin.properties. If %clock.keywords was used as the label and plugin.properties had an entry clock.keywords=timezone offset, then a French translation of the keywords could be provided in a plugin_fr.properties file.

..................Content has been hidden....................

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