Eclipse RCP: How is OpenPreferencesAction on a specific page?

How do I configure the settings dialog to open on a specific page? Doing so opens pref. dialog box on the first page by default:

OpenPreferencesAction action = new OpenPreferencesAction(); action.run(); 

How can I say to display another page from the settings tree?

+4
source share
2 answers

You need to create your own action that extends OpenPreferencesAction and overrides the run () method, passing in the identifier of the page you want to open. If you look at OpenPreferencesAction, you will see that the launch method looks like this:

 public void run() { if (workbenchWindow == null) { // action has been dispose return; } PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null, null, null, null); dialog.open(); } 

The second and third parameters determine the identifier of the displayed page and filtering criteria.

+9
source

Open Preferences Page Dialog Box (Click Button) in Eclipse RCP.

 import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.jface.preference.PreferenceDialog; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; import com_demo.PreferencePage.PreferencePage_Dialog; public class Preferences_Dialog_cmd extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { PreferenceDialog pref = PreferencesUtil.createPreferenceDialogOn(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),PreferencePage_Dialog.ID , null, null); if (pref != null) pref.open(); return null; } } 

 public class PreferencePage_Dialog extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { public static final String ID="custom_bill.PreferencePage_Dialog"; @Override protected void createFieldEditors() { //.......... } @Override public void init(IWorkbench workbench) { setPreferenceStore(Activator.getDefault().getPreferenceStore()); } } 
0
source

All Articles