001: /*
002: * Copyright (c) 2000, Jacob Smullyan.
003: *
004: * This is part of SkunkDAV, a WebDAV client. See http://skunkdav.sourceforge.net/
005: * for the latest version.
006: *
007: * SkunkDAV is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License as published
009: * by the Free Software Foundation; either version 2, or (at your option)
010: * any later version.
011: *
012: * SkunkDAV is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with SkunkDAV; see the file COPYING. If not, write to the Free
019: * Software Foundation, 59 Temple Place - Suite 330, Boston, MA
020: * 02111-1307, USA.
021: */
022:
023: package org.skunk.dav.client.gui.action;
024:
025: import java.awt.event.ActionEvent;
026: import javax.swing.JOptionPane;
027: import org.skunk.dav.client.DAVConstants;
028: import org.skunk.dav.client.DAVFile;
029: import org.skunk.dav.client.gui.DAVTreeNode;
030: import org.skunk.dav.client.gui.Explorer;
031: import org.skunk.dav.client.gui.ResourceManager;
032: import org.skunk.trace.Debug;
033:
034: public class RenameAction extends MoveAction {
035: public RenameAction(Explorer ex, DAVTreeNode node, DAVFile file,
036: String destinationURL) {
037: super (ex, node, file, destinationURL);
038: }
039:
040: public RenameAction(Explorer ex, DAVFile file) {
041: super (ex, null, file, null);
042: }
043:
044: public RenameAction(Explorer ex) {
045: super (ex, null, null, null);
046: }
047:
048: protected String getDialogMessage() {
049: return ResourceManager
050: .getMessage(ResourceManager.RENAME_DIALOG_MESSAGE);
051: }
052:
053: protected String getDialogTitle() {
054: return ResourceManager
055: .getMessage(ResourceManager.RENAME_DIALOG_TITLE);
056: }
057:
058: protected String obtainDestination(String filename, DAVTreeNode node) {
059: String title = getDialogTitle();
060: String message = getDialogMessage();
061: Object newName = JOptionPane.showInputDialog(getExplorer(),
062: message, title, JOptionPane.QUESTION_MESSAGE, null,
063: null, filename);
064: if (newName == null)
065: return null;
066: newName = newName.toString().trim();
067: if (newName.equals(filename) || newName.equals(""))
068: return null;
069: String protocol = node.getDAVFile().getProtocol();
070: if (protocol == null
071: || (protocol != DAVConstants.HTTP && protocol != DAVConstants.HTTPS))
072: protocol = DAVConstants.HTTP;
073: String s = new StringBuffer(protocol).append("://").append(
074: node.getDAVFile().getFullName()).append(newName)
075: .toString();
076: Debug.trace(this , Debug.DP3, "destination is {0}", s);
077: return s;
078: }
079: }
080:
081: /*
082: $Log: RenameAction.java,v $
083: Revision 1.6 2001/05/29 19:38:23 smulloni
084: support for https; sanity checks added for renaming to "" or to the existing
085: filename.
086:
087: Revision 1.5 2001/05/29 19:21:09 smulloni
088: Rename dialogs now default to the original file name.
089:
090: Revision 1.4 2000/12/19 22:36:05 smulloni
091: adjustments to preamble.
092:
093: Revision 1.3 2000/12/03 23:53:26 smulloni
094: added license and copyright preamble to java files.
095:
096: Revision 1.2 2000/11/08 23:29:12 smullyan
097: numerous changes: put actions now check for locktokens; right-click upload;
098: fixes to lock renderer.
099:
100: */
|