Ria_546
Ria_546

Reputation: 65

How to change title of preference page in eclipse RCP application?

How to change the default title of preferences page from "Preferences" to "Settings" in Eclipse RCP?

Upvotes: 2

Views: 1434

Answers (1)

Favonius
Favonius

Reputation: 13974

If you are using the org.eclipse.ui.preferencePages then I think it is not possible. The help of the same says:

The workbench provides one common dialog box for preferences. The purpose of this extension point is to allow plug-ins to add pages to the preference dialog box. When preference dialog box is opened (initiated from the menu bar), pages contributed in this way will be added to the dialog box.

But there is a way round. Follow the below steps (This is just showing how you can change the title text):

  1. Create an action for opening the preference dialog
  2. Make a new class extending the org.eclipse.jface.preference.PreferenceDialog
  3. In the sub-class override the configureShell method
  4. Invoke the PreferenceDialog from the above created action

Extended Class

class MyPreferenceDialog extends PreferenceDialog
{
    public MyPreferenceDialog(Shell parentShell, PreferenceManager manager) {
        super(parentShell, manager);
    }

    protected void configureShell(Shell newShell) {
        super.configureShell(newShell);
        newShell.setText("Settings"); 
    }
}

Code For Invocation

Button prefButton = new Button(top, SWT.PUSH);
prefButton.setText("Preference");
prefButton.addSelectionListener(new SelectionListener() {
    public void widgetSelected(SelectionEvent e) {
        final PreferenceManager preferenceManager = PlatformUI.getWorkbench().getPreferenceManager();
        MyPreferenceDialog dialog = new MyPreferenceDialog(top.getShell(), preferenceManager);
        dialog.create();
        dialog.open();
    }
    public void widgetDefaultSelected(SelectionEvent e) {
    }
});

The resultant preference dialog looks like this:

enter image description here

Upvotes: 5

Related Questions