KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > texteditor > SaveAction


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.texteditor;
12
13
14
15 import java.util.ResourceBundle JavaDoc;
16
17
18 /**
19  * Action for saving recent changes made in the text editor. The action is
20  * initially associated with a text editor via the constructor, but that can be
21  * subsequently changed using <code>setEditor</code>.
22  * <p>
23  * This class may be instantiated; it is not intended to be subclassed.
24  * </p>
25  */

26 public class SaveAction extends TextEditorAction {
27
28     /**
29      * Creates a new action for the given text editor. The action configures its
30      * visual representation from the given resource bundle.
31      *
32      * @param bundle the resource bundle
33      * @param prefix a prefix to be prepended to the various resource keys
34      * (described in <code>ResourceAction</code> constructor), or
35      * <code>null</code> if none
36      * @param editor the text editor
37      * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
38      */

39     public SaveAction(ResourceBundle JavaDoc bundle, String JavaDoc prefix, ITextEditor editor) {
40         super(bundle, prefix, editor);
41     }
42
43     /*
44      * @see IAction#run()
45      */

46     public void run() {
47         getTextEditor().getSite().getPage().saveEditor(getTextEditor(), false);
48     }
49
50     /*
51      * @see TextEditorAction#update()
52      */

53     public void update() {
54         setEnabled(getTextEditor().isDirty());
55     }
56 }
57
Popular Tags