01: /*******************************************************************************
02: * Copyright (c) 2004, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.cheatsheets;
11:
12: import org.eclipse.help.ILiveHelpAction;
13: import org.eclipse.swt.widgets.Display;
14:
15: /**
16: * Live help action for launching a cheat sheet from a help book.
17: * <p>
18: * The initialization string passed to {@link #setInitializationString(String)}
19: * is the id of a cheat sheet contributed to the <code>cheatsheetContent</code>
20: * extension point.
21: * </p>
22: *
23: * @since 3.0
24: */
25: public final class OpenCheatSheetFromHelpAction implements
26: ILiveHelpAction {
27:
28: /**
29: * Cheat sheet id; null until initialized.
30: */
31: private String 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 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() {
55: public void run() {
56: new OpenCheatSheetAction(cheatsheetID).run();
57: }
58: });
59: }
60: }
|