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.Component;
26: import java.awt.event.ActionEvent;
27: import java.io.IOException;
28: import javax.swing.AbstractAction;
29: import javax.swing.JOptionPane;
30: import javax.swing.SwingUtilities;
31: import org.skunk.dav.client.gui.Explorer;
32: import org.skunk.dav.client.gui.ExplorerMenuBar;
33: import org.skunk.dav.client.gui.ResourceManager;
34: import org.skunk.dav.client.gui.ServerData;
35: import org.skunk.trace.Debug;
36:
37: public class RemoveConnectionAction extends AbstractAction {
38: private Explorer ex;
39:
40: public static final String REMOVE_CONNECTION_TITLE = ResourceManager
41: .getMessage(ResourceManager.REMOVE_CONNECTION_TITLE);
42: public static final String REMOVE_CONNECTION_PROMPT = ResourceManager
43: .getMessage(ResourceManager.REMOVE_CONNECTION_PROMPT)
44: + " ";
45: public static final String REMOVE_CONNECTION_LABEL = ResourceManager
46: .getMessage(ResourceManager.REMOVE_CONNECTION_LABEL);
47:
48: public RemoveConnectionAction(Explorer ex) {
49: this .ex = ex;
50: }
51:
52: public void actionPerformed(ActionEvent ae) {
53: Object[] serverArray = ServerData.getServers().toArray();
54: Object srcObj = ae.getSource();
55: Component parent = (srcObj instanceof Component) ? SwingUtilities
56: .getRoot((Component) srcObj)
57: : null;
58: Object value = JOptionPane.showInputDialog(parent,
59: REMOVE_CONNECTION_PROMPT, REMOVE_CONNECTION_TITLE,
60: JOptionPane.PLAIN_MESSAGE, null, serverArray,
61: serverArray[0]);
62: if (value != null && ServerData.getServers().contains(value)) {
63: try {
64: ServerData sd = (ServerData) value;
65: if (ex.isConnected(sd))
66: ex.removeConnectionNode(sd);
67: ServerData.removeServer(sd);
68: ExplorerMenuBar.refreshMenus();
69: } catch (IOException oyVeh) {
70: Debug.trace(this , Debug.DP2, oyVeh);
71: }
72: }
73: }
74: }
75:
76: /* $Log: RemoveConnectionAction.java,v $
77: /* Revision 1.5 2000/12/19 22:36:05 smulloni
78: /* adjustments to preamble.
79: /*
80: /* Revision 1.4 2000/12/03 23:53:26 smulloni
81: /* added license and copyright preamble to java files.
82: /*
83: /* Revision 1.3 2000/11/09 23:35:05 smullyan
84: /* log added to every Java file, with the help of python. Lock stealing
85: /* implemented, and treatment of locks made more robust.
86: /* */
|