Community
Participate
Working Groups
There is no way for a plugin to open the (workbench) preference dialog with a certain peference page selected. Enabling this would allow plugins to refer the user to a certain preference page, for example when a misconfiguration is detected during execution of an action. Also this enables developers to write a new search panel to find a text in the preference pages and get the user right there. A method select(IPreferencePage page), select(IPreferenceNode node) or select(String path) in org.eclipse.jface.preference.PreferenceDialog would help.
Will consider an API for 2.2 where you can specify the id of the preference page to select when opening the dialog.
Showing a specific preference page using the current API (2.1, 3.0M8) can be achieved by subclassing the PreferenceDialog and making one method public: public class MyWorkbenchPreferenceDialog extends WorkbenchPreferenceDialog { public MyWorkbenchPreferenceDialog(Shell parentShell, PreferenceManager manager) { super(parentShell, manager); } public void setSelectedNodePreference(String pageId) { super.setSelectedNodePreference(pageId); } } Invokation of the dialog must then be done the following way: public void showPreferencePage(String pageId, Shell shell) { /* code taken from OpenPreferencesAction */ PreferenceManager pm = WorkbenchPlugin.getDefault().getPreferenceManager(); MyWorkbenchPreferenceDialog d = new MyWorkbenchPreferenceDialog(shell, pm); d.setSelectedNodePreference(pageId); d.create(); WorkbenchHelp.setHelp(d.getShell(), IHelpContextIds.PREFERENCE_DIALOG); d.open(); } I am using the API that way in my new 'Search Preferences Page' plugin (http: //www.jave.de/eclipse/searchpreferencespage/index.html) and it seems to work quite well. However using an official API I would feel much better.
Are you trying to select a specific page in your own preference dialog, or select a page contributed to the workbench preference dialog? We've added the following, which addresses your concern above, but not the workbench preference dialog case. /** * Sets the name of the selected item preference. * Public equivalent to <code>setSelectedNodePreference</code>. * * @param pageId * The identifier for the page * @since 3.0 */ public void setSelectedNode(String pageId) { setSelectedNodePreference(pageId); }
Closing. If other API is needed, please file a separate bug report.