01: /*
02: * Copyright (c) 2000, Jacob Smullyan.
03: *
04: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
05: * for the latest version.
06: *
07: * SkunkDAV is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License as published
09: * by the Free Software Foundation; either version 2, or (at your option)
10: * any later version.
11: *
12: * SkunkDAV is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with SkunkDAV; see the file COPYING. If not, write to the Free
19: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
20: * 02111-1307, USA.
21: */
22:
23: package org.skunk.dav.client.gui.action;
24:
25: import java.awt.event.ActionEvent;
26: import javax.swing.AbstractAction;
27: import org.skunk.dav.client.gui.Buffer;
28: import org.skunk.dav.client.gui.ExplorerApp;
29: import org.skunk.dav.client.gui.editor.DAVEditor;
30: import org.skunk.trace.Debug;
31:
32: public class SaveAction extends AbstractAction {
33: private DAVEditor editor;
34:
35: public SaveAction(DAVEditor editor) {
36: this .editor = editor;
37: }
38:
39: public SaveAction() {
40: this (null);
41: }
42:
43: private DAVEditor getLocalEditor() {
44: DAVEditor localEditor = null;
45: if (editor != null)
46: localEditor = editor;
47: else {
48: Buffer b = ExplorerApp.getAppContext().getCurrentView()
49: .getFocussedBuffer();
50: if (b instanceof DAVEditor)
51: localEditor = (DAVEditor) b;
52: }
53: return localEditor;
54: }
55:
56: protected void executeSave(DAVEditor editor) {
57: editor.save();
58: }
59:
60: public void actionPerformed(ActionEvent ae) {
61: DAVEditor localEditor = getLocalEditor();
62: if (localEditor != null) {
63: executeSave(localEditor);
64: } else
65: Debug.trace(this , Debug.DP2, "editor is null for save");
66: }
67: }
|