KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > cheatsheets > OpenCheatSheetFromHelpAction


1 /*******************************************************************************
2  * Copyright (c) 2004, 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.ui.cheatsheets;
12
13 import org.eclipse.help.ILiveHelpAction;
14 import org.eclipse.swt.widgets.Display;
15
16 /**
17  * Live help action for launching a cheat sheet from a help book.
18  * <p>
19  * The initialization string passed to {@link #setInitializationString(String)}
20  * is the id of a cheat sheet contributed to the <code>cheatsheetContent</code>
21  * extension point.
22  * </p>
23  *
24  * @since 3.0
25  */

26 public final class OpenCheatSheetFromHelpAction implements ILiveHelpAction {
27     
28     /**
29      * Cheat sheet id; null until initialized.
30      */

31     private String JavaDoc cheatsheetID = null;
32
33     /**
34      * Creates a new live help action.
35      */

36     public OpenCheatSheetFromHelpAction() {
37         super();
38     }
39
40     /* (non-javadoc)
41      * This method is called by the eclipse framework. The initialization string must be the id of a
42      * registered cheat sheet in order for the action to work.
43      * @see ILiveHelpAction#setInitializationString(String)
44      */

45     public void setInitializationString(String JavaDoc data) {
46         cheatsheetID = data;
47     }
48
49     /* (non-javadoc)
50      * @see java.lang.Runnable#run()
51      */

52     public void run() {
53         // Active help does not run on the UI thread, so we must use syncExec
54
Display.getDefault().syncExec(new Runnable JavaDoc() {
55             public void run() {
56                 new OpenCheatSheetAction(cheatsheetID).run();
57             }
58         });
59     }
60 }
61
Popular Tags