KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 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 package org.eclipse.ui.internal;
12
13 import org.eclipse.ui.IEditorPart;
14 import org.eclipse.ui.IWorkbenchWindow;
15
16 /**
17  * Closes the active editor.
18  */

19 public class CloseEditorAction extends ActiveEditorAction {
20     /**
21      * Create an instance of this class.
22      *
23      * @param window the window
24      */

25     public CloseEditorAction(IWorkbenchWindow window) {
26         super(WorkbenchMessages.CloseEditorAction_text, window);
27         setToolTipText(WorkbenchMessages.CloseEditorAction_toolTip);
28         setId("close"); //$NON-NLS-1$
29
window.getWorkbench().getHelpSystem().setHelp(this,
30                 IWorkbenchHelpContextIds.CLOSE_PART_ACTION);
31         setActionDefinitionId("org.eclipse.ui.file.close"); //$NON-NLS-1$
32
}
33
34     /* (non-Javadoc)
35      * Method declared on IAction.
36      */

37     public void run() {
38         IEditorPart part = getActiveEditor();
39         if (part != null) {
40             getActivePage().closeEditor(part, true);
41         }
42     }
43 }
44
Popular Tags