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.texteditor;
11:
12: import java.util.ResourceBundle;
13:
14: /**
15: * Action for abandoning changes made in the text editor since the last save
16: * operation. The action is initially associated with a text editor via the
17: * constructor, but that can be subsequently changed using <code>setEditor</code>.
18: * <p>
19: * This class may be instantiated; it is not intended to be subclassed.
20: * </p>
21: */
22: public class RevertToSavedAction extends TextEditorAction {
23:
24: /**
25: * Creates a new action for the given text editor. The action configures its
26: * visual representation from the given resource bundle.
27: *
28: * @param bundle the resource bundle
29: * @param prefix a prefix to be prepended to the various resource keys
30: * (described in <code>ResourceAction</code> constructor), or
31: * <code>null</code> if none
32: * @param editor the text editor
33: * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
34: */
35: public RevertToSavedAction(ResourceBundle bundle, String prefix,
36: ITextEditor editor) {
37: super (bundle, prefix, editor);
38: }
39:
40: /*
41: * @see IAction#run()
42: */
43: public void run() {
44: getTextEditor().doRevertToSaved();
45: }
46:
47: /*
48: * @see TextEditorAction#update()
49: */
50: public void update() {
51: setEnabled(getTextEditor().isDirty());
52: }
53: }
|