KickJava   Java API By Example, From Geeks To Geeks.

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


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 abandoning changes made in the text editor since the last save
20  * operation. The action is initially associated with a text editor via the
21  * constructor, but that can be 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 RevertToSavedAction 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 RevertToSavedAction(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().doRevertToSaved();
48     }
49
50     /*
51      * @see TextEditorAction#update()
52      */

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