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 javax.swing.JOptionPane;
28: import org.skunk.dav.client.gui.DAVTreeNode;
29: import org.skunk.dav.client.gui.Explorer;
30: import org.skunk.dav.client.gui.ResourceManager;
31: import org.skunk.trace.Debug;
32:
33: public class DeleteAction extends AbstractAction {
34: private Explorer ex;
35: private DAVTreeNode node;
36: private String fileName;
37:
38: public DeleteAction(Explorer ex) {
39: this (ex, null, null);
40: }
41:
42: public DeleteAction(Explorer ex, String fileName) {
43: this (ex, null, fileName);
44: }
45:
46: public DeleteAction(Explorer ex, DAVTreeNode node, String fileName) {
47: this .ex = ex;
48: this .node = node;
49: this .fileName = fileName;
50: }
51:
52: public void actionPerformed(ActionEvent ae) {
53: DAVTreeNode localNode = null;
54: String localFileName = null;
55: if (node == null) {
56: localNode = ex.getSelectedNode();
57: if (localNode == null) {
58: //the action should actually be disabled in this case.
59: Debug
60: .trace(this , Debug.DP3,
61: "error -- delete action requested outside of DAV connection");
62: return;
63: }
64: } else
65: localNode = node;
66: if (fileName == null) {
67: localFileName = ex.getSelectedTableFile().getFileName();
68: if (localFileName == null) {
69: handleNoFileSelectedError();
70: return;
71: }
72: } else
73: localFileName = fileName;
74: ex.delete(localNode, localFileName);
75: }
76:
77: private void handleNoFileSelectedError() {
78: Debug.trace(this , Debug.DP2, "no file selected in delete");
79: String message = ResourceManager
80: .getMessage(ResourceManager.DELETE_ERROR_MESSAGE);
81: String title = ResourceManager
82: .getMessage(ResourceManager.ERROR_DIALOG_TITLE);
83: JOptionPane.showMessageDialog(ex, message, title,
84: JOptionPane.ERROR_MESSAGE);
85: }
86: }
87:
88: /* $Log: DeleteAction.java,v $
89: /* Revision 1.5 2000/12/19 22:36:05 smulloni
90: /* adjustments to preamble.
91: /*
92: /* Revision 1.4 2000/12/03 23:53:26 smulloni
93: /* added license and copyright preamble to java files.
94: /*
95: /* Revision 1.3 2000/11/09 23:35:02 smullyan
96: /* log added to every Java file, with the help of python. Lock stealing
97: /* implemented, and treatment of locks made more robust.
98: /* */
|