KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2002, 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.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 import org.eclipse.ui.internal.cheatsheets.dialogs.CheatSheetCategoryBasedSelectionDialog;
18 import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetCollectionElement;
19 import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader;
20
21 /**
22  * Action to programmatically open the CheatSheet selection dialog.
23  *
24  * <p>
25  * This class may be instantiated; it is not intended to be subclassed.
26  * </p>
27  *
28  */

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

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

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

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

57     public void run() {
58         CheatSheetCollectionElement cheatSheets = (CheatSheetCollectionElement)CheatSheetRegistryReader.getInstance().getCheatSheets();
59
60         CheatSheetCategoryBasedSelectionDialog dialog = new CheatSheetCategoryBasedSelectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), cheatSheets);
61
62         if(dialog.open() != Window.OK || !dialog.getStatus().isOK()) {
63             notifyResult(false);
64             return;
65         }
66         
67         notifyResult(true);
68     }
69 }
70
71
Popular Tags