KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > actions > CheatSheetSelectionAction


1 /*******************************************************************************
2  * Copyright (c) 2002, 2004 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.internal.cheatsheets.actions;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.jface.resource.ImageDescriptor;
15 import org.eclipse.jface.window.Window;
16 import org.eclipse.ui.PlatformUI;
17
18 import org.eclipse.ui.cheatsheets.*;
19 import org.eclipse.ui.internal.cheatsheets.dialogs.CheatSheetSelectionDialog;
20 import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetElement;
21
22 /**
23  * Action to programmatically open the CheatSheet selection dialog.
24  *
25  * <p>
26  * This class may be instantiated; it is not intended to be subclassed.
27  * </p>
28  *
29  */

30 public class CheatSheetSelectionAction extends Action {
31
32     /**
33      * Create a new <code>CheatSheetSelectionAction</code> action.
34      */

35     public CheatSheetSelectionAction() {
36     }
37
38     /**
39      * Constructor for CheatSheetSelectionAction.
40      * @param text
41      */

42     public CheatSheetSelectionAction(String JavaDoc text) {
43         super(text);
44     }
45
46     /**
47      * Constructor for CheatSheetSelectionAction.
48      * @param text
49      * @param image
50      */

51     public CheatSheetSelectionAction(String JavaDoc text, ImageDescriptor image) {
52         super(text, image);
53     }
54
55     /**
56      * @see Action#run()
57      */

58     public void run() {
59         CheatSheetSelectionDialog dialog = new CheatSheetSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
60
61         if(dialog.open() != Window.OK || dialog.getResult().length != 1) {
62             notifyResult(false);
63             return;
64         }
65
66         notifyResult(true);
67
68         new OpenCheatSheetAction(((CheatSheetElement)dialog.getResult()[0]).getID()).run();
69     }
70 }
71
72
Popular Tags