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.AbstractAction;
027: import javax.swing.JOptionPane;
028: import org.skunk.dav.client.DAVFile;
029: import org.skunk.dav.client.gui.Explorer;
030: import org.skunk.dav.client.gui.DAVTreeNode;
031: import org.skunk.dav.client.gui.ResourceManager;
032: import org.skunk.trace.Debug;
033:
034: /**
035: *
036: */
037: public class NewCollectionAction extends AbstractAction {
038: private Explorer ex;
039: private DAVTreeNode node;
040: private String collName;
041:
042: public NewCollectionAction(Explorer explorer) {
043: this (explorer, null, null);
044: }
045:
046: public NewCollectionAction(Explorer explorer, DAVTreeNode node) {
047: this (explorer, node, null);
048: }
049:
050: public NewCollectionAction(Explorer explorer, DAVTreeNode node,
051: String collName) {
052: this .ex = explorer;
053: this .node = node;
054: this .collName = collName;
055: }
056:
057: public void actionPerformed(ActionEvent ae) {
058: DAVTreeNode localNode = null;
059: String localCollName = null;
060: if (node == null) {
061: //obtain current path from explorer, and collection name from user through dialog
062: localNode = ex.getSelectedNode();
063: if (localNode == null) {
064: //the action should actually be disabled in this case.
065: Debug
066: .trace(this , Debug.DP3,
067: "error -- new collection action requested outside of DAV connection");
068: return;
069: }
070: } else
071: localNode = node;
072: if (collName == null) {
073: String message = ResourceManager
074: .getMessage(ResourceManager.NEW_COLLECTION_PROMPT);
075: String title = ResourceManager
076: .getMessage(ResourceManager.NEW_COLLECTION_DIALOG_TITLE);
077: localCollName = JOptionPane.showInputDialog(ex, message,
078: title, JOptionPane.QUESTION_MESSAGE);
079: } else
080: localCollName = collName;
081:
082: if (localCollName == null || localCollName.trim().length() == 0) {
083: Debug.trace(this , Debug.DP3,
084: "user has cancelled or submitted whitespace");
085: return;
086: }
087: ex.createCollection(localNode, localCollName);
088: }
089: }
090:
091: /* $Log: NewCollectionAction.java,v $
092: /* Revision 1.7 2000/12/19 22:36:05 smulloni
093: /* adjustments to preamble.
094: /*
095: /* Revision 1.6 2000/12/03 23:53:26 smulloni
096: /* added license and copyright preamble to java files.
097: /*
098: /* Revision 1.5 2000/11/09 23:35:03 smullyan
099: /* log added to every Java file, with the help of python. Lock stealing
100: /* implemented, and treatment of locks made more robust.
101: /* */
|