KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > preferences > PDEPreferencesUtil


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 JavaDoc[] 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 JavaDoc() {
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