KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > QuickAccessMenu


1 /*******************************************************************************
2  * Copyright (c) 2006 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
12 package org.eclipse.ui.internal;
13
14 import org.eclipse.jface.action.Action;
15 import org.eclipse.ui.IWorkbenchWindow;
16 import org.eclipse.ui.actions.ActionFactory;
17 import org.eclipse.ui.handlers.IHandlerService;
18
19 public class QuickAccessMenu extends Action implements
20         ActionFactory.IWorkbenchAction {
21     private IWorkbenchWindow workbenchWindow;
22
23     public QuickAccessMenu(IWorkbenchWindow window) {
24         super(WorkbenchMessages.QuickAccessAction_text);
25         workbenchWindow = window;
26         setToolTipText(WorkbenchMessages.QuickAccessAction_toolTip);
27         setActionDefinitionId("org.eclipse.ui.window.quickAccess"); //$NON-NLS-1$
28
}
29
30     /*
31      * (non-Javadoc)
32      *
33      * @see org.eclipse.jface.action.Action#run()
34      */

35     public void run() {
36         if (workbenchWindow == null) {
37             return;
38         }
39
40         IHandlerService handlerService = (IHandlerService) workbenchWindow
41                 .getService(IHandlerService.class);
42         try {
43             handlerService.executeCommand(getActionDefinitionId(),
44                     null);
45         } catch (Exception JavaDoc e) {
46             WorkbenchPlugin.log(e);
47         }
48     }
49
50     /*
51      * (non-Javadoc)
52      *
53      * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()
54      */

55     public void dispose() {
56         workbenchWindow = null;
57     }
58 }
59
Popular Tags