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 saving recent changes made in the text editor. The action is
16: * initially associated with a text editor via the constructor, but that can be
17: * 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 SaveAction 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 SaveAction(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().getSite().getPage().saveEditor(getTextEditor(),
45: false);
46: }
47:
48: /*
49: * @see TextEditorAction#update()
50: */
51: public void update() {
52: setEnabled(getTextEditor().isDirty());
53: }
54: }
|