Tuesday, July 08, 2008

Adding keywords to eclipse rcp preferences lookup (search text field)

One might need to add more words to eclipse preference search bar while developing an RCP application. By default, it only looks up for the preference page title. In order to add new keywords, one needs to add a keyword reference and a keyword extension point.
Supposing the plugin.xml has the following sample page:

<extension point="org.eclipse.ui.preferencePages">
<page class="testercp.preferences.SamplePreferencePage" id="testercp.preferences.SamplePreferencePage" name="Sample Preferences">
</page>
</extension>

Add a keyword reference through:

<extension point="org.eclipse.ui.preferencePages">
<page class="testercp.preferences.SamplePreferencePage" id="testercp.preferences.SamplePreferencePage" name="Sample Preferences">
<keywordreference id="marte.keywords.preferences">
</keywordreference>
</page></extension>

And then, add the keyword extension point as:

<extension point="org.eclipse.ui.keywords">
<keyword id="marte.keywords.preferences" label="velocity stopping point">
</keyword></extension>

Now, if anyone types velocity, stopping, or point it will bring the SamplePreferencePage.

There's also a way to add these extensions through the wizards.

1 comment:

David França said...

Me ajudou muito esse post, já que o responsavél pela tarefa saiu de núpcias e deixou todo mundo na mão por aqui. Um tal de Daniel.