Search code examples
javaeclipseeclipse-pluginpreference

How to add keywords to search preferences in Eclipse


I added a preference by using this example: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.ui.examples.readmetool/Eclipse%20UI%20Examples%20Readme%20Tool/org/eclipse/ui/examples/readmetool/

For the actual reference refer to this page: http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.ui.examples.readmetool/Eclipse%20UI%20Examples%20Readme%20Tool/org/eclipse/ui/examples/readmetool/ReadmePreferencePage.java )

I only added one checkbox to test it, when I search any word in the checkbox in Preferences I do not see my view coming up but if I type something that currently Eclipse has, then it comes up (i.e. I type background and I can see the General tab staying and being bold).

I guess I somehow need to add search keywords to point to the current page (or something else). But I couldn't find how to add that, or what causes this problem.

So how can I perform searches within the Preferences window for preferences that I have created?


Solution

  • There is a org.eclipse.ui.keywords extension point that allows to define keywords that can be assigned to a preference page.

    For example:

    <extension point="org.eclipse.ui.preferencePages"> 
      <page id="com.xyz.prefpage1" name="XYZ" class="..."> 
         <keywordReference id="xyz.Keyword"/>
      </page> 
    </extension> 
    <extension point="org.eclipse.ui.keywords">
      <keyword label="foo" id="xyz.Keyword"/>
    </extension>    
    

    With the above extension, the XYZ preference page can also be found under the keyword foo, i.e. it will be listed when you type foo in the search field.