KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > ui > internal > ShowCapabilitiesPreferenceAction


1 /*******************************************************************************
2  * Copyright (c) 2005 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.help.ui.internal;
12
13 import org.eclipse.core.runtime.Platform;
14 import org.eclipse.help.ILiveHelpAction;
15 import org.eclipse.jface.preference.PreferenceDialog;
16 import org.eclipse.swt.widgets.Display;
17 import org.eclipse.swt.widgets.Shell;
18 import org.eclipse.ui.IWorkbenchWindow;
19 import org.eclipse.ui.PlatformUI;
20 import org.eclipse.ui.dialogs.PreferencesUtil;
21
22 public class ShowCapabilitiesPreferenceAction implements ILiveHelpAction {
23     private boolean narrow;
24
25     public void setInitializationString(String JavaDoc data) {
26         if (data!=null && data.equals("narrow")) //$NON-NLS-1$
27
narrow=true;
28     }
29
30     public void run() {
31         final Display display = PlatformUI.getWorkbench().getDisplay();
32         display.syncExec(new Runnable JavaDoc() {
33             public void run() {
34                 Shell windowShell=null;
35                 if (!narrow) {
36                     Shell[] shells = display.getShells();
37                     for (int i=0; i<shells.length; i++) {
38                         Object JavaDoc data = shells[i].getData();
39                         if (data!=null && data instanceof IWorkbenchWindow) {
40                             windowShell=shells[i];
41                             break;
42                         }
43                     }
44                 }
45                 if (windowShell!=null) {
46                     windowShell.forceActive();
47                     if (Platform.getWS().equals(Platform.WS_WIN32)) {
48                         // feature in Windows. Without this code,
49
// the window will only flash in the launch bar.
50
windowShell.setVisible(false);
51                         windowShell.setMinimized(true);
52                         windowShell.setVisible(true);
53                         windowShell.setMinimized(false);
54                     }
55                 }
56                 PreferenceDialog dialog = PreferencesUtil
57                         .createPreferenceDialogOn(windowShell, getCapabilityPageId(),
58                                 null, null);
59                 dialog.open();
60             }
61         });
62     }
63
64     private String JavaDoc getCapabilityPageId() {
65         return "org.eclipse.sdk.capabilities"; //$NON-NLS-1$
66
}
67 }
Popular Tags