01: /*******************************************************************************
02: * Copyright (c) 2006 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;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.ui.IWorkbenchWindow;
14: import org.eclipse.ui.actions.ActionFactory;
15: import org.eclipse.ui.handlers.IHandlerService;
16:
17: public class QuickAccessMenu extends Action implements
18: ActionFactory.IWorkbenchAction {
19: private IWorkbenchWindow workbenchWindow;
20:
21: public QuickAccessMenu(IWorkbenchWindow window) {
22: super (WorkbenchMessages.QuickAccessAction_text);
23: workbenchWindow = window;
24: setToolTipText(WorkbenchMessages.QuickAccessAction_toolTip);
25: setActionDefinitionId("org.eclipse.ui.window.quickAccess"); //$NON-NLS-1$
26: }
27:
28: /*
29: * (non-Javadoc)
30: *
31: * @see org.eclipse.jface.action.Action#run()
32: */
33: public void run() {
34: if (workbenchWindow == null) {
35: return;
36: }
37:
38: IHandlerService handlerService = (IHandlerService) workbenchWindow
39: .getService(IHandlerService.class);
40: try {
41: handlerService
42: .executeCommand(getActionDefinitionId(), null);
43: } catch (Exception e) {
44: WorkbenchPlugin.log(e);
45: }
46: }
47:
48: /*
49: * (non-Javadoc)
50: *
51: * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose()
52: */
53: public void dispose() {
54: workbenchWindow = null;
55: }
56: }
|