Bug 33628 - [Preferences] provide API for showing a specified preference page
Summary: [Preferences] provide API for showing a specified preference page
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2003-03-02 12:45 EST by Markus Gebhard CLA
Modified: 2004-05-09 02:26 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Gebhard CLA 2003-03-02 12:45:26 EST
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.
Comment 1 Nick Edgar CLA 2003-03-16 14:04:19 EST
Will consider an API for 2.2 where you can specify the id of the preference 
page to select when opening the dialog.
Comment 2 Markus Gebhard CLA 2004-04-13 14:41:01 EDT
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.
Comment 3 Nick Edgar CLA 2004-05-07 10:52:30 EDT
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);
	}

Comment 4 Nick Edgar CLA 2004-05-09 02:26:43 EDT
Closing.  If other API is needed, please file a separate bug report.