01: /*******************************************************************************
02: * Copyright (c) 2005, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.preferences;
11:
12: import org.eclipse.jface.preference.IPreferenceNode;
13: import org.eclipse.jface.preference.PreferenceDialog;
14: import org.eclipse.jface.preference.PreferenceManager;
15: import org.eclipse.jface.window.Window;
16: import org.eclipse.pde.internal.ui.PDEPlugin;
17: import org.eclipse.swt.custom.BusyIndicator;
18: import org.eclipse.swt.widgets.Shell;
19: import org.eclipse.ui.dialogs.PreferencesUtil;
20:
21: public class PDEPreferencesUtil {
22:
23: public static boolean showPreferencePage(String[] pageIds,
24: final Shell shell) {
25: final PreferenceDialog dialog = PreferencesUtil
26: .createPreferenceDialogOn(shell, pageIds[0], pageIds,
27: null);
28: return dialog.open() == Window.OK;
29: }
30:
31: public static boolean showPreferencePage(
32: final IPreferenceNode targetNode) {
33: PreferenceManager manager = new PreferenceManager();
34: manager.addToRoot(targetNode);
35: final Shell shell = PDEPlugin.getActiveWorkbenchShell();
36: final PreferenceDialog dialog = new PreferenceDialog(shell,
37: manager);
38: final boolean[] result = new boolean[] { false };
39: BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
40: public void run() {
41: dialog.create();
42: dialog.setMessage(targetNode.getLabelText());
43: if (dialog.open() == Window.OK)
44: result[0] = true;
45: }
46: });
47: return result[0];
48: }
49:
50: }
|