Archive for the ‘preference’ Category
Eclipse RCP: Opening Certain Preference Page
The best thing about programming is there are a lot of way to get what you want. But it is desirable that we used the best way to get there. The fastest and clearest solution is what some programmers want. And in that respect, that what makes some programmers artists while the others not.
In this article, I will try to explain the best way to open certain preference page in Eclipse RCP. This shortcut is sometimes needed to avoid questions from users about how to customize certain aspects of the application while in fact the possibility is already offered… via a preference.
To open certain preference page, one can create an entirely new handler by knowing how to do that programmatically. This is a way to do that programmatically:
final PreferenceDialog dialog = PreferencesUtil .createPreferenceDialogOn(shell, preferencePageId, null, null); dialog.open();
A smarter way is to check if Eclipse has provided a handler for that and then create a command for that handler. And indeed, Eclipse has it. The id of the handler is: org.eclipse.ui.internal.handlers.ShowPreferencePageHandler.
The thinking goes further and we need to check also if Eclipse has provided a command for that. While the id is not obvious, the command id for that is: org.eclipse.ui.window.preferences.
After we know that the command is available, what we need is to configure the menu. This is how to do that:
<command commandId="org.eclipse.ui.window.preferences" label="label you want" style="push"> <parameter name="preferencePageId" value="idofpreferecepage"> </parameter> </command>
And so that is!
Related posts:
- Embedding Jetty Server in Eclipse RCP
- Eclipse RCP: ISharedImages
- Eclipse 3.3 Live Rename Refactoring
Eclipse RCP: Opening Certain Preference Page originally appeared on satukubik on June 14, 2010.