1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.ui.texteditor;
15 
16 
17 
18 import java.util.ResourceBundle;
19 
20 
21 /**
22  * Action for abandoning changes made in the text editor since the last save
23  * operation. The action is initially associated with a text editor via the
24  * constructor, but that can be subsequently changed using <code>setEditor</code>.
25  * <p>
26  * This class may be instantiated; it is not intended to be subclassed.
27  * </p>
28  * @noextend This class is not intended to be subclassed by clients.
29  */
30 public class RevertToSavedAction extends TextEditorAction {
31 
32 	/**
33 	 * Creates a new action for the given text editor. The action configures its
34 	 * visual representation from the given resource bundle.
35 	 *
36 	 * @param bundle the resource bundle
37 	 * @param prefix a prefix to be prepended to the various resource keys
38 	 *   (described in <code>ResourceAction</code> constructor), or
39 	 *   <code>null</code> if none
40 	 * @param editor the text editor
41 	 * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
42 	 */
RevertToSavedAction(ResourceBundle bundle, String prefix, ITextEditor editor)43 	public RevertToSavedAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
44 		super(bundle, prefix, editor);
45 	}
46 
47 	@Override
run()48 	public void run() {
49 		getTextEditor().doRevertToSaved();
50 	}
51 
52 	@Override
update()53 	public void update() {
54 		setEnabled(getTextEditor().isDirty());
55 	}
56 }
57