1 11 package org.eclipse.pde.internal.ui.preferences; 12 13 import org.eclipse.jface.preference.IPreferenceNode; 14 import org.eclipse.jface.preference.PreferenceDialog; 15 import org.eclipse.jface.preference.PreferenceManager; 16 import org.eclipse.jface.window.Window; 17 import org.eclipse.pde.internal.ui.PDEPlugin; 18 import org.eclipse.swt.custom.BusyIndicator; 19 import org.eclipse.swt.widgets.Shell; 20 import org.eclipse.ui.dialogs.PreferencesUtil; 21 22 public class PDEPreferencesUtil { 23 24 public static boolean showPreferencePage(String [] pageIds, final Shell shell) { 25 final PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(shell, pageIds[0], pageIds, null); 26 return dialog.open() == Window.OK; 27 } 28 29 public static boolean showPreferencePage(final IPreferenceNode targetNode) { 30 PreferenceManager manager = new PreferenceManager(); 31 manager.addToRoot(targetNode); 32 final Shell shell = PDEPlugin.getActiveWorkbenchShell(); 33 final PreferenceDialog dialog = new PreferenceDialog(shell, manager); 34 final boolean[] result = new boolean[] { false }; 35 BusyIndicator.showWhile(shell.getDisplay(), new Runnable () { 36 public void run() { 37 dialog.create(); 38 dialog.setMessage(targetNode.getLabelText()); 39 if (dialog.open() == Window.OK) 40 result[0] = true; 41 } 42 }); 43 return result[0]; 44 } 45 46 47 } 48 | Popular Tags |