KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > wizards > imports > ShowTargetPlatformAction


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

11 package org.eclipse.pde.internal.ui.wizards.imports;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.preference.*;
15 import org.eclipse.jface.preference.IPreferenceNode;
16 import org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferenceNode;
17 import org.eclipse.swt.custom.BusyIndicator;
18 import org.eclipse.swt.widgets.Shell;
19 import org.eclipse.ui.PlatformUI;
20
21 /**
22  * Action suitable for calling from cheat sheets and
23  * other places.
24  */

25 public class ShowTargetPlatformAction extends Action {
26     public void run() {
27         IPreferenceNode targetNode = new TargetPlatformPreferenceNode();
28         boolean result = showPreferencePage(targetNode);
29         notifyResult(result);
30     }
31     private boolean showPreferencePage(final IPreferenceNode targetNode) {
32         PreferenceManager manager = new PreferenceManager();
33         manager.addToRoot(targetNode);
34         Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
35         final PreferenceDialog dialog =
36             new PreferenceDialog(shell, manager);
37         final boolean[] result = new boolean[] { false };
38         BusyIndicator.showWhile(shell.getDisplay(), new Runnable JavaDoc() {
39             public void run() {
40                 dialog.create();
41                 dialog.setMessage(targetNode.getLabelText());
42                 if (dialog.open() == PreferenceDialog.OK)
43                     result[0] = true;
44             }
45         });
46         return result[0];
47     }
48 }
Popular Tags