summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-07-06 13:11:04 (GMT)
committer Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-07-06 13:11:04 (GMT)
commit3a30bb6146065ceaaf1324fa8f9c552c20298913 (patch)
tree41f15d1727626841b45886c86136b0c16ce7d4c8
parent0c8b4b286f8be3100105bc80ed63578d5ce296f7 (diff)
downloadQCG-Data-3a30bb6146065ceaaf1324fa8f9c552c20298913.zip
QCG-Data-3a30bb6146065ceaaf1324fa8f9c552c20298913.tar.gz
QCG-Data-3a30bb6146065ceaaf1324fa8f9c552c20298913.tar.bz2
[#317] rename irods file (in windows xp) completes but throws up an 'exception moving file' dialog
-rw-r--r--idrop-swing/release_notes.txt4
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/RenameIRODSDirectoryDialog.java82
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java4
3 files changed, 60 insertions, 30 deletions
diff --git a/idrop-swing/release_notes.txt b/idrop-swing/release_notes.txt
index b23a782..5904212 100644
--- a/idrop-swing/release_notes.txt
+++ b/idrop-swing/release_notes.txt
@@ -5,11 +5,13 @@ iDrop Desktop Client
work in progress -- Milestone 0.9.8
*[#308] irods tree does not refresh when deleting a directory
-* [#61] delete local file multi-select
+* [#61] delete local file multi-select
*[#254] drag and drop, desktop to irods file should use irods parent as target
*[#153] local file dir copy/move
* [#316] feedback on tree node expansion
*[#313] info not synchronizing on tree select
*[#315] delete nodes in ll, refresh issue?
*[#321] progress bar not clearing at begin of txfr
+* [#317] rename irods file (in windows xp) completes but throws up an 'exception moving file' dialog
+
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/RenameIRODSDirectoryDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/RenameIRODSDirectoryDialog.java
index b57cf6c..130e5ea 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/RenameIRODSDirectoryDialog.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/RenameIRODSDirectoryDialog.java
@@ -21,14 +21,19 @@ import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
+import org.irods.jargon.core.exception.JargonException;
+import org.irods.jargon.core.pub.io.IRODSFile;
+import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
import org.irods.jargon.idrop.desktop.systraygui.services.IRODSFileService;
import org.irods.jargon.idrop.desktop.systraygui.utils.TreeUtils;
import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSFileSystemModel;
import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSNode;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSOutlineModel;
import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSTree;
import org.irods.jargon.idrop.exceptions.IdropException;
import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.openide.util.Exceptions;
import org.slf4j.LoggerFactory;
/**
@@ -37,15 +42,11 @@ import org.slf4j.LoggerFactory;
* @author mikeconway
*/
public class RenameIRODSDirectoryDialog extends javax.swing.JDialog {
-
+
private final IDROPDesktop idrop;
-
private final String currentAbsolutePath;
-
private final IRODSTree stagingViewTree;
-
private final IRODSNode currentNode;
-
public static org.slf4j.Logger log = LoggerFactory.getLogger(RenameIRODSDirectoryDialog.class);
/** Creates new form NewIRODSDirectoryDialog */
@@ -64,13 +65,13 @@ public class RenameIRODSDirectoryDialog extends javax.swing.JDialog {
idrop.showIdropException(new IdropException(msg));
return;
}
-
+
String parentAbsPath = currentAbsolutePath.substring(0, lastPathPartIdx);
String currentCollectionOrFileName = currentAbsolutePath.substring(lastPathPartIdx + 1);
-
+
log.debug("computed parent abs path as:{}", parentAbsPath);
log.debug("computed current file or collection name as:{}", currentCollectionOrFileName);
-
+
txtCurrentFolder.setText(currentCollectionOrFileName);
registerKeystrokeListener();
}
@@ -267,7 +268,6 @@ public class RenameIRODSDirectoryDialog extends javax.swing.JDialog {
private javax.swing.JTextField txtNewFolder;
// End of variables declaration//GEN-END:variables
-
private void doRename() {
// add the new folder to irods, add to the tree, and scroll the tree into view
@@ -276,29 +276,29 @@ public class RenameIRODSDirectoryDialog extends javax.swing.JDialog {
idrop.showMessageFromOperation("please enter a new file or collection name");
return;
}
-
+
final RenameIRODSDirectoryDialog thisDialog = this;
-
+
java.awt.EventQueue.invokeLater(new Runnable() {
-
+
@Override
public void run() {
log.info("renaming a file named:{}", txtCurrentFolder.getText());
thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
-
- IRODSFileService irodsFileService = new IRODSFileService(idrop.getIrodsAccount(), idrop
- .getiDropCore().getIrodsFileSystem());
+
+ IRODSFileService irodsFileService = new IRODSFileService(idrop.getIrodsAccount(), idrop.getiDropCore().getIrodsFileSystem());
String newPath = irodsFileService.renameIRODSFileOrDirectory(currentAbsolutePath,
txtNewFolder.getText());
+
log.debug("New path:{}", newPath);
- IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel();
+ IRODSOutlineModel irodsOutlineModel = (IRODSOutlineModel) stagingViewTree.getModel();
// get the parent of the new directory, and force a reload of that parent
String[] dirs = newPath.split("/");
if (dirs.length == 0) {
throw new IdropRuntimeException("unable to find dir components");
}
-
+
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dirs.length - 1; i++) {
if (i > 0) {
@@ -306,26 +306,50 @@ public class RenameIRODSDirectoryDialog extends javax.swing.JDialog {
}
sb.append(dirs[i]);
}
-
+
String parentOfNewDir = sb.toString();
log.info("parent of new dir:{}", parentOfNewDir);
-
- TreePath pathForNew = TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, parentOfNewDir);
- log.debug("computed new path:{}", pathForNew);
- IRODSNode targetParentNode = (IRODSNode) pathForNew.getParentPath().getLastPathComponent();
+
+ TreePath pathForOld = TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, currentAbsolutePath);
+
+ if (pathForOld == null) {
+ log.warn("could not find old path for node:{}, ignoring", currentAbsolutePath);
+ } else {
+ IRODSFileSystemModel irodsFileSystemModel = irodsOutlineModel.getTreeModel();
+ IRODSNode oldNode = (IRODSNode) pathForOld.getLastPathComponent();
+ CollectionAndDataObjectListingEntry nodesEntry = (CollectionAndDataObjectListingEntry) oldNode.getUserObject();
+ IRODSFile newEntryAsFile = idrop.getiDropCore().getIRODSFileFactoryForLoggedInAccount().instanceIRODSFile(newPath);
+ if (newEntryAsFile.isDirectory()) {
+ nodesEntry.setParentPath(newEntryAsFile.getParent());
+ nodesEntry.setPathOrName(newEntryAsFile.getAbsolutePath());
+ } else {
+ nodesEntry.setParentPath(newEntryAsFile.getParent());
+ nodesEntry.setPathOrName(newEntryAsFile.getName());
+ }
+
+ oldNode.setUserObject(nodesEntry);
+ irodsFileSystemModel.nodeChanged(oldNode);
+
+ }
+
+ // TreePath pathForNew = TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, parentOfNewDir);
+ // log.debug("computed new path:{}", pathForNew);
+ /*IRODSNode targetParentNode = (IRODSNode) pathForNew.getParentPath().getLastPathComponent();
targetParentNode.forceReloadOfChildrenOfThisNode();
- irodsFileSystemModel.reload(targetParentNode);
+ irodsOutlineModel.reload(targetParentNode);
stagingViewTree.expandPath(pathForNew);
+ * */
- // idrop.showMessageFromOperation("The rename was successful");
- } catch (IdropException ex) {
+ idrop.showMessageFromOperation("The rename was successful");
+
+ } catch (Exception ex) {
Logger.getLogger(RenameIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex);
idrop.showIdropException(ex);
} finally {
thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
-
+
thisDialog.dispose();
}
});
@@ -335,16 +359,16 @@ public class RenameIRODSDirectoryDialog extends javax.swing.JDialog {
* Register a listener for the enter event, so login can occur.
*/
private void registerKeystrokeListener() {
-
+
KeyStroke enter = KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ENTER, 0);
Action enterAction = new AbstractAction() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
doRename();
}
};
btnOK.registerKeyboardAction(enterAction, enter, JComponent.WHEN_IN_FOCUSED_WINDOW);
-
+
}
}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java
index 66dbd55..63315d5 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java
@@ -33,6 +33,10 @@ public class IRODSOutlineModel extends DefaultOutlineModel {
public static final org.slf4j.Logger log = LoggerFactory.getLogger(IRODSOutlineModel.class);
private final IRODSFileSystemModel treeModel;
+
+ public IRODSFileSystemModel getTreeModel() {
+ return treeModel;
+ }
private IDROPDesktop idrop;
public IRODSOutlineModel(IDROPDesktop idrop, TreeModel tm, TableModel tm1, boolean bln, String string) {