01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.IWorkbenchPage;
14: import org.eclipse.ui.IWorkbenchWindow;
15: import org.eclipse.ui.actions.ActionFactory;
16: import org.eclipse.ui.internal.dialogs.WorkbenchEditorsDialog;
17:
18: /**
19: * Implements an action to open a dialog showing all open editors
20: * and the recent closed editors.
21: */
22: public class WorkbenchEditorsAction extends Action implements
23: ActionFactory.IWorkbenchAction {
24:
25: /**
26: * The workbench window; or <code>null</code> if this
27: * action has been <code>dispose</code>d.
28: */
29: private IWorkbenchWindow workbenchWindow;
30:
31: /**
32: * Constructor for NavigateWorkbenchAction.
33: *
34: * @param window the window
35: */
36: public WorkbenchEditorsAction(IWorkbenchWindow window) {
37: super (WorkbenchMessages.WorkbenchEditorsAction_label);
38: if (window == null) {
39: throw new IllegalArgumentException();
40: }
41: this .workbenchWindow = window;
42: // @issue missing action id
43: workbenchWindow.getWorkbench().getHelpSystem().setHelp(this ,
44: IWorkbenchHelpContextIds.WORKBENCH_EDITORS_ACTION);
45: setActionDefinitionId("org.eclipse.ui.window.switchToEditor"); //$NON-NLS-1$
46: }
47:
48: /* (non-Javadoc)
49: * Method declared on IAction.
50: */
51: public void run() {
52: if (workbenchWindow == null) {
53: // action has been disposed
54: return;
55: }
56: IWorkbenchPage page = workbenchWindow.getActivePage();
57: if (page != null) {
58: new WorkbenchEditorsDialog(workbenchWindow).open();
59: }
60: }
61:
62: /* (non-Javadoc)
63: * Method declared on ActionFactory.IWorkbenchAction.
64: */
65: public void dispose() {
66: workbenchWindow = null;
67: }
68: }
|