01: /*******************************************************************************
02: * Copyright (c) 2002, 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.internal.cheatsheets.actions;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.jface.resource.ImageDescriptor;
14: import org.eclipse.jface.window.Window;
15: import org.eclipse.ui.PlatformUI;
16: import org.eclipse.ui.internal.cheatsheets.dialogs.CheatSheetCategoryBasedSelectionDialog;
17: import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetCollectionElement;
18: import org.eclipse.ui.internal.cheatsheets.registry.CheatSheetRegistryReader;
19:
20: /**
21: * Action to programmatically open the CheatSheet selection dialog.
22: *
23: * <p>
24: * This class may be instantiated; it is not intended to be subclassed.
25: * </p>
26: *
27: */
28: public class CheatSheetCategoryBasedSelectionAction extends Action {
29:
30: /**
31: * Create a new <code>CheatSheetCategoryBasedSelectionAction</code> action.
32: */
33: public CheatSheetCategoryBasedSelectionAction() {
34: }
35:
36: /**
37: * Constructor for CheatSheetCategoryBasedSelectionAction.
38: * @param text
39: */
40: public CheatSheetCategoryBasedSelectionAction(String text) {
41: super (text);
42: }
43:
44: /**
45: * Constructor for CheatSheetCategoryBasedSelectionAction.
46: * @param text
47: * @param image
48: */
49: public CheatSheetCategoryBasedSelectionAction(String text,
50: ImageDescriptor image) {
51: super (text, image);
52: }
53:
54: /**
55: * @see Action#run()
56: */
57: public void run() {
58: CheatSheetCollectionElement cheatSheets = (CheatSheetCollectionElement) CheatSheetRegistryReader
59: .getInstance().getCheatSheets();
60:
61: CheatSheetCategoryBasedSelectionDialog dialog = new CheatSheetCategoryBasedSelectionDialog(
62: PlatformUI.getWorkbench().getActiveWorkbenchWindow()
63: .getShell(), cheatSheets);
64:
65: if (dialog.open() != Window.OK || !dialog.getStatus().isOK()) {
66: notifyResult(false);
67: return;
68: }
69:
70: notifyResult(true);
71: }
72: }
|