KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > platform > doc > isv > activeHelp > ActiveHelpOpenDialogAction


1 /*******************************************************************************
2  * Copyright (c) 2002, 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.platform.doc.isv.activeHelp;
12
13 import org.eclipse.help.ILiveHelpAction;
14 import org.eclipse.jface.dialogs.MessageDialog;
15 import org.eclipse.swt.widgets.Display;
16 import org.eclipse.swt.widgets.Shell;
17 import org.eclipse.ui.IWorkbenchWindow;
18 import org.eclipse.ui.PlatformUI;
19
20 /**
21  * Sample Active Help action. This is the source code for the sample
22  * active help action that is shown in the Platform Plug-in Developer Guide
23  * in the Programmer's Guide. This class is marked public because
24  * it must be called from the active help servlet. However, this class
25  * is not intended to be used as API and should not be called by clients.
26  */

27 public class ActiveHelpOpenDialogAction implements ILiveHelpAction {
28
29      public void setInitializationString(String JavaDoc data) {
30           // ignore the data. We do not use any javascript parameters.
31
}
32
33      public void run() {
34           // Active help does not run on the UI thread, so we must use syncExec
35
Display.getDefault().syncExec(new Runnable JavaDoc() {
36                public void run() {
37                     IWorkbenchWindow window =
38                          PlatformUI.getWorkbench().getActiveWorkbenchWindow();
39                     if (window != null) {
40                          // Bring the Workbench window to the top of other windows;
41
// On some Windows systems, it will only flash the Workbench
42
// icon on the task bar
43
Shell shell = window.getShell();
44                          shell.setMinimized(false);
45                          shell.forceActive();
46                          // Open a message dialog
47
MessageDialog.openInformation(
48                               window.getShell(),
49                               "Hello World.", //$NON-NLS-1$
50
"Hello World."); //$NON-NLS-1$
51
}
52                }
53           });
54      }
55 }
56
Popular Tags