KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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;
12
13 import org.eclipse.jface.action.Action;
14 import org.eclipse.ui.IWorkbenchPage;
15 import org.eclipse.ui.IWorkbenchWindow;
16 import org.eclipse.ui.actions.ActionFactory;
17 import org.eclipse.ui.internal.dialogs.WorkbenchEditorsDialog;
18
19 /**
20  * Implements an action to open a dialog showing all open editors
21  * and the recent closed editors.
22  */

23 public class WorkbenchEditorsAction extends Action implements
24         ActionFactory.IWorkbenchAction {
25
26     /**
27      * The workbench window; or <code>null</code> if this
28      * action has been <code>dispose</code>d.
29      */

30     private IWorkbenchWindow workbenchWindow;
31
32     /**
33      * Constructor for NavigateWorkbenchAction.
34      *
35      * @param window the window
36      */

37     public WorkbenchEditorsAction(IWorkbenchWindow window) {
38         super(WorkbenchMessages.WorkbenchEditorsAction_label);
39         if (window == null) {
40             throw new IllegalArgumentException JavaDoc();
41         }
42         this.workbenchWindow = window;
43         // @issue missing action id
44
workbenchWindow.getWorkbench().getHelpSystem().setHelp(this,
45                 IWorkbenchHelpContextIds.WORKBENCH_EDITORS_ACTION);
46         setActionDefinitionId("org.eclipse.ui.window.switchToEditor"); //$NON-NLS-1$
47
}
48
49     /* (non-Javadoc)
50      * Method declared on IAction.
51      */

52     public void run() {
53         if (workbenchWindow == null) {
54             // action has been disposed
55
return;
56         }
57         IWorkbenchPage page = workbenchWindow.getActivePage();
58         if (page != null) {
59             new WorkbenchEditorsDialog(workbenchWindow).open();
60         }
61     }
62
63     /* (non-Javadoc)
64      * Method declared on ActionFactory.IWorkbenchAction.
65      */

66     public void dispose() {
67         workbenchWindow = null;
68     }
69 }
70
Popular Tags