KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > handlers > OpenCheatSheetHandler


1 /*******************************************************************************
2  * Copyright (c) 2006, 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.handlers;
12
13 import org.eclipse.core.commands.AbstractHandler;
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.ui.cheatsheets.OpenCheatSheetAction;
17 import org.eclipse.ui.internal.cheatsheets.actions.CheatSheetCategoryBasedSelectionAction;
18
19 /**
20  * Opens the cheatsheet identified by the parameter, or if no parameter is given
21  * opens the dialog that allows the user to choose a cheatsheet.
22  *
23  * @since 3.2
24  */

25 public class OpenCheatSheetHandler extends AbstractHandler {
26
27     private static final String JavaDoc PARAM_ID_CHEAT_SHEET_ID = "cheatSheetId"; //$NON-NLS-1$
28

29     public Object JavaDoc execute(ExecutionEvent event) throws ExecutionException {
30
31         String JavaDoc cheatSheetId = event.getParameter(PARAM_ID_CHEAT_SHEET_ID);
32
33         if (cheatSheetId == null) {
34             CheatSheetCategoryBasedSelectionAction action = new CheatSheetCategoryBasedSelectionAction();
35             action.run();
36         } else {
37             OpenCheatSheetAction action = new OpenCheatSheetAction(cheatSheetId);
38             action.run();
39         }
40
41         return null;
42     }
43
44 }
45
Popular Tags