summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-06-20 15:05:45 (GMT)
committer Mike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-06-20 15:05:45 (GMT)
commit716fdb32d5594d2cab773df024331920524b143a (patch)
treeaf0e51396f0966e1cc35ee64e6b7df2af5d9c644
parent6406be2fd4511c2e592867420e37dc52a527ae8f (diff)
downloadQCG-Data-716fdb32d5594d2cab773df024331920524b143a.zip
QCG-Data-716fdb32d5594d2cab773df024331920524b143a.tar.gz
QCG-Data-716fdb32d5594d2cab773df024331920524b143a.tar.bz2
move to tree table for idrop view - working on cleanup
-rw-r--r--idrop-swing/pom.xml24
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/DeleteIRODSDialog.java100
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/MoveOrCopyiRODSDialog.java38
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java111
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/TreeUtils.java101
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSFileSystemModel.java46
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java173
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSRowModel.java72
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTree.java83
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTreeTransferHandler.java52
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsSelectionListenerForBuildingInfoPanel.java161
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsTreeListenerForBuildingInfoPanel.java7
-rw-r--r--pom.xml2
13 files changed, 734 insertions, 236 deletions
diff --git a/idrop-swing/pom.xml b/idrop-swing/pom.xml
index ad85fbf..9602306 100644
--- a/idrop-swing/pom.xml
+++ b/idrop-swing/pom.xml
@@ -107,18 +107,7 @@
<scope>runtime</scope>
</dependency>
-->
- <dependency>
- <groupId>org.swinglabs</groupId>
- <artifactId>swing-layout</artifactId>
- </dependency>
- <dependency>
- <groupId>cookxml</groupId>
- <artifactId>cookswing</artifactId>
- </dependency>
- <dependency>
- <groupId>cookxml</groupId>
- <artifactId>cookxml</artifactId>
- </dependency>
+
<dependency>
<groupId>org.irods.jargon</groupId>
<artifactId>jargon-data-utils</artifactId>
@@ -145,6 +134,17 @@
<scope>test</scope>
<type>jar</type>
</dependency>
+ <dependency>
+ <groupId>org.netbeans.api</groupId>
+ <artifactId>org-netbeans-swing-outline</artifactId>
+ <version>RELEASE70</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.swinglabs</groupId>
+ <artifactId>swing-layout</artifactId>
+ <version>1.0.3</version>
+ </dependency>
</dependencies>
</project>
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/DeleteIRODSDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/DeleteIRODSDialog.java
index 8b01af2..e1c9fc0 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/DeleteIRODSDialog.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/DeleteIRODSDialog.java
@@ -21,6 +21,7 @@ import org.irods.jargon.core.pub.io.IRODSFileFactory;
import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
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;
@@ -36,7 +37,7 @@ public class DeleteIRODSDialog extends javax.swing.JDialog {
private final IRODSTree irodsTree;
private final IRODSNode deletedNode;
private final List<IRODSNode> deletedNodes;
- public static org.slf4j.Logger log = LoggerFactory.getLogger(NewIRODSDirectoryDialog.class);
+ public static org.slf4j.Logger log = LoggerFactory.getLogger(DeleteIRODSDialog.class);
/** Creates new form NewIRODSDirectoryDialog */
public DeleteIRODSDialog(final iDrop parent, final boolean modal, final IRODSTree irodsTree, final IRODSNode deletedNode) {
@@ -54,9 +55,9 @@ public class DeleteIRODSDialog extends javax.swing.JDialog {
sb.append('/');
sb.append(entry.getPathOrName());
}
-
+
initialize();
- txtAreaFileToDelete.setText(sb.toString());
+ txtAreaFileToDelete.setText(sb.toString());
}
/** Creates new form NewIRODSDirectoryDialog */
@@ -93,7 +94,7 @@ public class DeleteIRODSDialog extends javax.swing.JDialog {
}
}
};
-
+
btnOK.registerKeyboardAction(enterAction, enter,
JComponent.WHEN_IN_FOCUSED_WINDOW);
@@ -214,12 +215,12 @@ public class DeleteIRODSDialog extends javax.swing.JDialog {
private void processDelete() throws IdropException {
log.info("delete folder named:{}", txtAreaFileToDelete.getText());
final DeleteIRODSDialog thisDialog = this;
-
+
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
- thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
(new DeleteWorker(thisDialog)).execute();
}
});
@@ -244,65 +245,66 @@ public class DeleteIRODSDialog extends javax.swing.JDialog {
try {
fileToDelete = irodsFileFactory.instanceIRODSFile(sb.toString());
fileToDelete.delete();
- final IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) irodsTree.getModel();
- irodsFileSystemModel.removeNodeFromParent(deletedNode);
+ final IRODSOutlineModel irodsFileSystemModel = (IRODSOutlineModel) irodsTree.getModel();
+
+ irodsFileSystemModel.notifyFileShouldBeRemoved(deletedNode);
} catch (JargonException ex) {
Logger.getLogger(DeleteIRODSDialog.class.getName()).log(Level.SEVERE, null, ex);
throw new IdropException(ex);
+ } finally {
+ idrop.getiDropCore().closeIRODSConnectionForLoggedInAccount();
}
}
-
+
class DeleteWorker extends SwingWorker<String, Object> {
-
- public static final String DELETE_SUCCESSFUL = "Deletion complete";
+
+ public static final String DELETE_SUCCESSFUL = "Deletion complete";
public static final String DELETE_ERRORS = "The deletion was not successful";
private DeleteIRODSDialog dialog;
private String message = "";
-
+
DeleteWorker(DeleteIRODSDialog dialog) {
if (dialog == null) {
throw new IllegalArgumentException("null dialog");
}
-
- this.dialog=dialog;
-
+
+ this.dialog = dialog;
+
}
-
- @Override
- public String doInBackground() {
-
- try {
- IRODSFileFactory irodsFileFactory = idrop.getiDropCore().getIRODSFileFactoryForLoggedInAccount();
- if (deletedNode != null) {
- log.info("deleting a single node");
- deleteASingleFile(irodsFileFactory, deletedNode);
- } else if (deletedNodes != null) {
- log.info("deleting multiple nodes");
- for (IRODSNode deletedNodeEntry : deletedNodes) {
- deleteASingleFile(irodsFileFactory, deletedNodeEntry);
- }
+ @Override
+ public String doInBackground() {
+
+ try {
+
+ IRODSFileFactory irodsFileFactory = idrop.getiDropCore().getIRODSFileFactoryForLoggedInAccount();
+ if (deletedNode != null) {
+ log.info("deleting a single node");
+ deleteASingleFile(irodsFileFactory, deletedNode);
+ } else if (deletedNodes != null) {
+ log.info("deleting multiple nodes");
+ for (IRODSNode deletedNodeEntry : deletedNodes) {
+ deleteASingleFile(irodsFileFactory, deletedNodeEntry);
}
- message = DELETE_SUCCESSFUL;
- } catch (Exception ex) {
- Logger.getLogger(NewIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex);
- idrop.showIdropException(ex);
- message = DELETE_ERRORS;
- } finally {
- idrop.getiDropCore().closeAllIRODSConnections();
}
-
- return null;
- }
-
- @Override
- protected void done() {
- dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
- dialog.dispose();
- idrop.showMessageFromOperation(message);
- }
- }
-
-
+ message = DELETE_SUCCESSFUL;
+ } catch (Exception ex) {
+ Logger.getLogger(NewIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex);
+ idrop.showIdropException(ex);
+ message = DELETE_ERRORS;
+ } finally {
+ idrop.getiDropCore().closeAllIRODSConnections();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void done() {
+ dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ dialog.dispose();
+ idrop.showMessageFromOperation(message);
+ }
+ }
}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/MoveOrCopyiRODSDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/MoveOrCopyiRODSDialog.java
index 2631167..8230245 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/MoveOrCopyiRODSDialog.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/MoveOrCopyiRODSDialog.java
@@ -24,6 +24,7 @@ import org.irods.jargon.core.pub.io.IRODSFile;
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;
@@ -37,7 +38,7 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
private final iDrop idrop;
private final IRODSTree stagingViewTree;
- private final IRODSFileSystemModel irodsFileSystemModel;
+ private final IRODSOutlineModel irodsFileSystemModel;
private final IRODSNode targetNode;
private final String targetAbsolutePath;
private final IRODSFile sourceFile;
@@ -50,7 +51,7 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
this.idrop = parent;
this.targetNode = targetNode;
this.stagingViewTree = stagingViewTree;
- this.irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel();
+ this.irodsFileSystemModel = (IRODSOutlineModel) stagingViewTree.getOutlineModel();
this.targetAbsolutePath = targetAbsolutePath;
this.sourceFile = sourceFile;
this.sourceFiles = null;
@@ -63,7 +64,7 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
this.idrop = parent;
this.targetNode = targetNode;
this.stagingViewTree = stagingViewTree;
- this.irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel();
+ this.irodsFileSystemModel = (IRODSOutlineModel) stagingViewTree.getModel();
this.targetAbsolutePath = targetAbsolutePath;
this.sourceFile = null;
this.sourceFiles = sourceFiles;
@@ -330,9 +331,6 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
}
log.debug("move done");
- IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel();
- targetNode.forceReloadOfChildrenOfThisNode();
- irodsFileSystemModel.reload(targetNode);
if (filesThatHadOverwriteError.isEmpty()) {
idrop.showMessageFromOperation("irods move/copy processed");
} else {
@@ -358,19 +356,21 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
if (sourceFile.isFile()) {
log.debug("source file is a file, do a move");
dataTransferOperations.move(sourceFile.getAbsolutePath(), targetAbsolutePath);
-
- // remove from the tree
- TreePath sourceTreePath = TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, sourceFile.getAbsolutePath());
- if (sourceTreePath == null) {
- log.warn("no tree path found for:{}, will not delete node ", sourceFile.getAbsolutePath());
+
+ IRODSFile targetFile = idrop.getiDropCore().getIRODSFileFactoryForLoggedInAccount().instanceIRODSFile(targetAbsolutePath);
+ String targetPathForNotify = null;
+ if (targetFile.isDirectory()) {
+ targetPathForNotify = targetFile.getAbsolutePath() + "/" + sourceFile.getName();
} else {
- log.debug("removing node since I moved the file:{}", sourceTreePath.getLastPathComponent());
- irodsFileSystemModel.removeNodeFromParent((IRODSNode)sourceTreePath.getLastPathComponent());
+ targetPathForNotify = targetFile.getAbsolutePath();
}
-
+
+ irodsFileSystemModel.notifyFileShouldBeAdded(stagingViewTree, targetPathForNotify);
+
} else {
log.debug("source file is a collection, reparent it");
dataTransferOperations.moveTheSourceCollectionUnderneathTheTargetCollectionUsingSourceParentCollectionName(sourceFile.getAbsolutePath(), targetAbsolutePath);
+ irodsFileSystemModel.notifyFileShouldBeAdded(stagingViewTree, targetAbsolutePath);
}
} catch (JargonFileOrCollAlreadyExistsException fcae) {
throw fcae;
@@ -379,10 +379,12 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
}
TreePath sourceNodePath = TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, sourceFile.getAbsolutePath());
+ if (sourceNodePath == null) {
+ log.info("could not find tree path for source node, ignore");
+ return;
+ }
IRODSNode sourceNode = (IRODSNode) sourceNodePath.getLastPathComponent();
- IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel();
- irodsFileSystemModel.removeNodeFromParent(sourceNode);
-
+ irodsFileSystemModel.notifyFileShouldBeRemoved(sourceNode);
}
private void processACopyOfAnIndividualFile(DataTransferOperations dataTransferOperations, IRODSFile sourceFile, String targetAbsolutePath) throws IdropException {
@@ -392,6 +394,8 @@ public class MoveOrCopyiRODSDialog extends javax.swing.JDialog {
Logger.getLogger(MoveOrCopyiRODSDialog.class.getName()).log(Level.SEVERE, null, ex);
throw new IdropException("unable to copy file due to JargonException", ex);
}
+
+ // notifications are done at completion of transfer using status callbacks
}
/**
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java
index 7d83dda..6f796ef 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java
@@ -78,8 +78,12 @@ import org.irods.jargon.usertagging.domain.IRODSTagGrouping;
import org.irods.jargon.usertagging.domain.TagQuerySearchResult;
import org.slf4j.LoggerFactory;
-import cookxml.cookswing.CookSwing;
import org.irods.jargon.idrop.desktop.systraygui.utils.iDropUtils;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSOutlineModel;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSRowModel;
+import org.netbeans.swing.outline.DefaultOutlineModel;
+import org.netbeans.swing.outline.Outline;
+import org.netbeans.swing.outline.OutlineModel;
/**
* Main system tray and GUI. Create system tray menu, start timer process for queue.
@@ -159,11 +163,16 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
int showX = (width / 2) - (this.getWidth() / 2);
int showY = (height / 2) - (this.getHeight() / 2);
this.setLocation(showX, showY);
+ /*
+ * FIXME: remove cookswing deps for issues
+
CookSwing cookSwing = new CookSwing(this);
newPreferencesDialog = (JDialog) cookSwing.render("org/irods/jargon/idrop/preferencesDialog.xml");
boolean showGUI = getiDropCore().getPreferences().getBoolean("showGUI", true);
showGUICheckBox.setSelected(showGUI);
+ *
+ */
if (!getiDropCore().getIdropConfig().isAdvancedView()) {
toolBarInfo.setVisible(false);
}
@@ -254,13 +263,13 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
*/
@Override
public void overallStatusCallback(final TransferStatus ts) {
-
- IRODSFileSystemModel irodsTreeModel = (IRODSFileSystemModel) irodsTree.getModel();
+
+ IRODSOutlineModel irodsTreeModel = (IRODSOutlineModel) irodsTree.getModel();
try {
irodsTreeModel.notifyCompletionOfOperation(irodsTree, ts);
// if a get callback on completion, notify the local tree model
if (ts.getTransferType() == TransferStatus.TransferType.GET && ts.getTransferState() == TransferStatus.TransferState.OVERALL_COMPLETION) {
- ((LocalFileSystemModel)getFileTree().getModel()).notifyCompletionOfOperation(getFileTree(), ts);
+ ((LocalFileSystemModel) getFileTree().getModel()).notifyCompletionOfOperation(getFileTree(), ts);
}
} catch (IdropException ex) {
Logger.getLogger(iDrop.class.getName()).log(Level.SEVERE, null, ex);
@@ -589,7 +598,7 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
*
* @return <code>JTree</code> visual representation of the remote iRODS resource
*/
- public javax.swing.JTree getTreeStagingResource() {
+ public Outline getTreeStagingResource() {
return irodsTree;
}
@@ -655,24 +664,28 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
// if info is being opened, initialize to the first selected item, or the root of the iRODS tree if none
// selected
IRODSNode node;
+ /* FIXME: implement
if (!(irodsTree.getLastSelectedPathComponent() instanceof IRODSNode)) {
- log.info("last selected is not a Node, using root node");
- node = (IRODSNode) irodsTree.getModel().getRoot();
+ log.info("last selected is not a Node, using root node");
+ node = (IRODSNode) irodsTree.getModel().getRoot();
} else {
- log.info("initializing with last selected node");
- node = (IRODSNode) irodsTree.getLastSelectedPathComponent();
+ log.info("initializing with last selected node");
+ node = (IRODSNode) irodsTree.getLastSelectedPathComponent();
}
try {
- IrodsTreeListenerForBuildingInfoPanel treeBuilder = new IrodsTreeListenerForBuildingInfoPanel(
- idropGuiReference);
- treeBuilder.identifyNodeTypeAndInitializeInfoPanel(node);
+ IrodsTreeListenerForBuildingInfoPanel treeBuilder = new IrodsTreeListenerForBuildingInfoPanel(
+ idropGuiReference);
+ treeBuilder.identifyNodeTypeAndInitializeInfoPanel(node);
} catch (Exception ex) {
- Logger.getLogger(IrodsTreeListenerForBuildingInfoPanel.class.getName()).log(Level.SEVERE, null, ex);
- throw new IdropRuntimeException("exception processing valueChanged() event for IRODSNode selection");
+ Logger.getLogger(IrodsTreeListenerForBuildingInfoPanel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("exception processing valueChanged() event for IRODSNode selection");
}
if (pnlIrodsInfo.isVisible()) {
- splitTargetCollections.setDividerLocation(0.5d);
+ splitTargetCollections.setDividerLocation(0.5d);
}
+
+ *
+ */
}
});
}
@@ -780,25 +793,27 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
@Override
public void run() {
+
+ /*
log.debug("refreshing series panel");
Enumeration<TreePath> currentPaths = null;
TreePath firstVisibleRow = null;
TreePath rootPath = null;
-
+
if (getTreeStagingResource() != null) {
- TreePath[] expandedPaths = TreeUtils.getPaths(getTreeStagingResource(), true);
- //FIXME: get this code out of idrop and put into iRODS tree
- log.info("expanded paths:{}", expandedPaths);
- rootPath = getTreeStagingResource().getPathForRow(0);
- // Rectangle nodeRectangle = scrollIrodsTree.getViewport().getViewRect();
- // TreeModel treeModel = getTreeStagingResource().getModel();
- // TreeNode root = (TreeNode) treeModel.getRoot();
- currentPaths = getTreeStagingResource().getExpandedDescendants(rootPath);
- //firstVisibleRow = getTreeStagingResource().getClosestPathForLocation(0, 0);
- log.debug("selected tree node, paths are:{}", currentPaths);
- log.debug("first visible row is:{}", firstVisibleRow);
+ TreePath[] expandedPaths = TreeUtils.getPaths(getTreeStagingResource(), true);
+ //FIXME: get this code out of idrop and put into iRODS tree
+ log.info("expanded paths:{}", expandedPaths);
+ rootPath = getTreeStagingResource().get getPathForRow(0);
+ // Rectangle nodeRectangle = scrollIrodsTree.getViewport().getViewRect();
+ // TreeModel treeModel = getTreeStagingResource().getModel();
+ // TreeNode root = (TreeNode) treeModel.getRoot();
+ currentPaths = getTreeStagingResource().getExpandedDescendants(rootPath);
+ //firstVisibleRow = getTreeStagingResource().getClosestPathForLocation(0, 0);
+ log.debug("selected tree node, paths are:{}", currentPaths);
+ log.debug("first visible row is:{}", firstVisibleRow);
}
-
+ */
CollectionAndDataObjectListingEntry root = new CollectionAndDataObjectListingEntry();
if (iDropCore.getIdropConfig().isLoginPreset()) {
@@ -814,33 +829,44 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
log.info("using root path, no login preset");
root.setPathOrName("/");
}
-
+
log.info("building new iRODS tree");
try {
+ if (irodsTree == null) {
+ irodsTree = new IRODSTree(gui);
+ IRODSNode rootNode = new IRODSNode(root, getIrodsAccount(), getiDropCore().getIrodsFileSystem(), irodsTree);
+ irodsTree.setRefreshingTree(true);
+ // irodsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
+ }
IRODSNode rootNode = new IRODSNode(root, getIrodsAccount(), getiDropCore().getIrodsFileSystem(), irodsTree);
- irodsTree = new IRODSTree(new IRODSFileSystemModel(rootNode, getIrodsAccount()), gui);
- irodsTree.setRefreshingTree(true);
- irodsTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
- IrodsTreeListenerForBuildingInfoPanel treeListener = new IrodsTreeListenerForBuildingInfoPanel(gui);
+
+ IRODSFileSystemModel irodsFileSystemModel = new IRODSFileSystemModel(rootNode, getIrodsAccount());
+ IRODSOutlineModel mdl = new IRODSOutlineModel(gui,
+ irodsFileSystemModel, new IRODSRowModel(), true, "File System");
+ irodsTree.setModel(mdl);
+
+ /* IrodsTreeListenerForBuildingInfoPanel treeListener = new IrodsTreeListenerForBuildingInfoPanel(gui);
irodsTree.addTreeExpansionListener(treeListener);
irodsTree.addTreeSelectionListener(treeListener);
// preset to display root tree node
irodsTree.setSelectionRow(0);
+ *
+ */
} catch (Exception ex) {
Logger.getLogger(iDrop.class.getName()).log(Level.SEVERE, null, ex);
throw new IdropRuntimeException(ex);
}
scrollIrodsTree.setViewportView(getTreeStagingResource());
- TreePath currentPath;
-
+ /* TreePath currentPath;
+
if (currentPaths != null) {
- while (currentPaths.hasMoreElements()) {
- currentPath = (TreePath) currentPaths.nextElement();
- log.debug("expanding tree path:{}", currentPath);
- irodsTree.expandPath(currentPath);
- }
+ while (currentPaths.hasMoreElements()) {
+ currentPath = (TreePath) currentPaths.nextElement();
+ log.debug("expanding tree path:{}", currentPath);
+ irodsTree.expandPath(currentPath);
}
+ }*/
irodsTree.setRefreshingTree(false);
getiDropCore().getIrodsFileSystem().closeAndEatExceptions(iDropCore.getIrodsAccount());
@@ -2142,9 +2168,10 @@ public class iDrop extends javax.swing.JFrame implements ActionListener, ItemLis
return;
}
+ //FIXME: reimplement
// select the path in the tree and show the hierarchy tab
- TreeUtils.expandAll(irodsTree, selPath, true);
- irodsTree.scrollPathToVisible(selPath);
+ // TreeUtils.expandAll(irodsTree, selPath, true);
+ // irodsTree.scrollPathToVisible(selPath);
tabIrodsViews.setSelectedComponent(pnlTabHierarchicalView);
}// GEN-LAST:event_menuItemShowInHierarchyActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/TreeUtils.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/TreeUtils.java
index 9a19bcc..37d0c76 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/TreeUtils.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/TreeUtils.java
@@ -12,9 +12,11 @@ import javax.swing.tree.TreePath;
import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
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.LocalFileNode;
import org.irods.jargon.idrop.desktop.systraygui.viscomponents.LocalFileSystemModel;
import org.irods.jargon.idrop.exceptions.IdropException;
+import org.netbeans.swing.outline.Outline;
import org.slf4j.LoggerFactory;
/**
@@ -153,6 +155,8 @@ public class TreeUtils {
return calculatedTreePath;
}
+
+
/**
* Given an absolute path to a file from the iRODS view, build the corresponding <code>TreePath</code> that points to the position
@@ -225,6 +229,70 @@ public class TreeUtils {
}
return calculatedTreePath;
}
+
+ public static TreePath buildTreePathForIrodsAbsolutePath(final Outline tree, final String irodsAbsolutePath) throws IdropException {
+
+ IRODSOutlineModel irodsFileSystemModel = (IRODSOutlineModel) tree.getModel();
+ // the root of the model, which may not be a path underneath the root of the irods resource
+ IRODSNode rootNode = (IRODSNode) irodsFileSystemModel.getRoot();
+ TreePath calculatedTreePath = new TreePath(rootNode);
+ CollectionAndDataObjectListingEntry rootEntry = (CollectionAndDataObjectListingEntry) rootNode.getUserObject();
+ String[] irodsPathComponents = irodsAbsolutePath.split("/");
+
+ /* get an array that has the path components that descend from the root of the iRODS file system to
+ * the subdirectory which the tree model considers the root of the tree
+ */
+ String[] irodsRootNodePathComponents = rootEntry.getPathOrName().split("/");
+
+ /* determine the relative calculatedTreePath of the given iRODS file underneath the root. There are cases where
+ * the root is not '/'.
+ */
+
+ StringBuilder searchRoot = new StringBuilder();
+ IRODSNode currentNode = (IRODSNode) irodsFileSystemModel.getRoot();
+ CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) currentNode.getUserObject();
+ searchRoot.append(entry.getPathOrName());
+
+
+ /* calculatedTreePath now holds the path from the root of iRODS to the root of the tree, now accumulate any
+ * TreePath entries that represent the path below the root of the tree contained in the
+ * absolute path. The relative path starts at the path component in the position after
+ * the length of the root path.
+ */
+
+ int relativePathStartsAfter = irodsRootNodePathComponents.length - 1;
+ String nextPathComponent;
+
+ for (int i = (relativePathStartsAfter + 1); i < irodsPathComponents.length; i++) {
+ // next element from userObjects is the child of the current node, note that for the first node (typically '/') a delimiting slash is not needed
+ if (searchRoot.length() > 1) {
+ searchRoot.append('/');
+ }
+
+ nextPathComponent = irodsPathComponents[i];
+ searchRoot.append(nextPathComponent);
+ if (i > 0) {
+ currentNode =
+ findChild(currentNode, searchRoot.toString());
+ }
+
+ if (currentNode == null) {
+ log.warn("cannot find node for path, will attempt to return parent {}:", searchRoot.toString());
+ break;
+ } else {
+ // root node is already part of the calculcated tree path
+ if (currentNode.getUserObject().toString().equals("/")) {
+ // ignore this node
+ } else {
+ calculatedTreePath = calculatedTreePath.pathByAddingChild(currentNode);
+ }
+ }
+ }
+ if (calculatedTreePath == null) {
+ throw new IdropException("cannot find path to node:" + irodsAbsolutePath);
+ }
+ return calculatedTreePath;
+ }
public static void expandAll(JTree tree, TreePath parent, boolean expand) {
// Traverse children
@@ -263,6 +331,19 @@ public class TreeUtils {
// Convert list to array
return (TreePath[]) list.toArray(new TreePath[list.size()]);
}
+
+ public static TreePath[] getPaths(Outline tree, boolean expanded) {
+ TreeNode root = (TreeNode) tree.getOutlineModel().getRoot();
+
+ // Create array to hold the treepaths
+ List list = new ArrayList();
+
+ // Traverse tree from root adding treepaths for all nodes to list
+ getPaths(tree, new TreePath(root), expanded, list);
+
+ // Convert list to array
+ return (TreePath[]) list.toArray(new TreePath[list.size()]);
+ }
private static void getPaths(JTree tree, TreePath parent, boolean expanded, List list) {
// Return if node is not expanded
@@ -283,4 +364,24 @@ public class TreeUtils {
}
}
}
+
+ private static void getPaths(Outline tree, TreePath parent, boolean expanded, List list) {
+ // Return if node is not expanded
+ if (expanded && !tree.isVisible(parent)) {
+ return;
+ }
+
+ // Add node to list
+ list.add(parent);
+
+ // Create paths for all children
+ TreeNode node = (TreeNode) parent.getLastPathComponent();
+ if (node.getChildCount() >= 0) {
+ for (Enumeration e = node.children(); e.hasMoreElements();) {
+ TreeNode n = (TreeNode) e.nextElement();
+ TreePath path = parent.pathByAddingChild(n);
+ getPaths(tree, path, expanded, list);
+ }
+ }
+ }
}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSFileSystemModel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSFileSystemModel.java
index 3c32e05..d284930 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSFileSystemModel.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSFileSystemModel.java
@@ -89,42 +89,20 @@ public class IRODSFileSystemModel extends DefaultTreeModel {
});
}
-
- public void notifyFileShouldBeRemoved(final IRODSTree irodsTree, final String nodeAbsolutePath) throws IdropException {
-
- }
- public void notifyCompletionOfOperation(final IRODSTree irodsTree, final TransferStatus transferStatus) throws IdropException {
- log.info("tree model notified of status:{}", transferStatus);
-
- if (transferStatus.getTransferState() != TransferState.OVERALL_COMPLETION) {
- return;
+ public IRODSFileSystemModel(final IRODSAccount irodsAccount) throws IdropException {
+ super(null);
+ if (irodsAccount == null) {
+ throw new IdropRuntimeException("null irodsAccount");
}
-
- // for put or copy operation, highlight the new node
- if (transferStatus.getTransferType() == TransferStatus.TransferType.PUT
- || transferStatus.getTransferType() == TransferStatus.TransferType.COPY) {
- log.info("successful put transfer, find the parent tree node, and clear the children");
-
- TreePath parentNodePath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree, transferStatus.getTargetFileAbsolutePath());
- log.debug("tree path for put: {}", parentNodePath);
- IRODSNode targetNode = (IRODSNode) parentNodePath.getLastPathComponent();
- CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) targetNode.getUserObject();
- if (entry.isDataObject()) {
- log.info("substitute parent as target, as given node was a leaf");
- targetNode = (IRODSNode) targetNode.getParent();
- }
- targetNode.forceReloadOfChildrenOfThisNode();
- targetNode.lazyLoadOfChildrenOfThisNode();
- this.reload(targetNode);
- if (entry.isDataObject()) {
- parentNodePath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree, entry.getParentPath());
- irodsTree.highlightPath(parentNodePath);
- } else {
- irodsTree.highlightPath(parentNodePath);
-
- }
+ this.irodsAccount = irodsAccount;
+
+ this.addTreeModelListener(new TreeModelListener() {
+ });
- }
}
+
+
+
+
}
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
new file mode 100644
index 0000000..c78dd70
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSOutlineModel.java
@@ -0,0 +1,173 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.irods.jargon.idrop.desktop.systraygui.viscomponents;
+
+import java.util.Date;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.table.TableModel;
+import javax.swing.tree.TreeModel;
+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.pub.io.IRODSFileFactory;
+import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
+import org.irods.jargon.core.transfer.TransferStatus;
+import org.irods.jargon.core.transfer.TransferStatus.TransferState;
+import org.irods.jargon.idrop.desktop.systraygui.iDrop;
+import org.irods.jargon.idrop.desktop.systraygui.utils.TreeUtils;
+import org.irods.jargon.idrop.exceptions.IdropException;
+import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.netbeans.swing.outline.DefaultOutlineModel;
+import org.netbeans.swing.outline.RowModel;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Mike Conway - DICE (www.irods.org)
+ */
+public class IRODSOutlineModel extends DefaultOutlineModel {
+
+ public static final org.slf4j.Logger log = LoggerFactory.getLogger(IRODSOutlineModel.class);
+ private iDrop idrop;
+
+ public IRODSOutlineModel(iDrop idrop, TreeModel tm, TableModel tm1, boolean bln, String string) {
+ super(tm, tm1, bln, string);
+ this.idrop = idrop;
+ }
+
+ public IRODSOutlineModel(iDrop idrop, TreeModel tm, RowModel rm, boolean bln, String string) {
+ super(tm, rm, bln, string);
+ this.idrop = idrop;
+ }
+
+ public void notifyFileShouldBeRemoved(final IRODSTree irodsTree, final String nodeAbsolutePath) throws IdropException {
+ }
+
+ public void notifyFileShouldBeRemoved(final IRODSNode deletedNode) throws IdropException {
+ log.info("deleting node from parent:{}", deletedNode);
+ final IRODSNode parent = (IRODSNode) deletedNode.getParent();
+
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ parent.remove(deletedNode);
+ }
+ });
+
+ }
+
+ public void notifyCompletionOfOperation(final IRODSTree irodsTree, final TransferStatus transferStatus) throws IdropException {
+ log.info("tree model notified of status:{}", transferStatus);
+
+ if (transferStatus.getTransferState() != TransferState.OVERALL_COMPLETION) {
+ return;
+ }
+
+ // for put or copy operation, highlight the new node
+ if (transferStatus.getTransferType() == TransferStatus.TransferType.PUT
+ || transferStatus.getTransferType() == TransferStatus.TransferType.COPY) {
+ log.info("successful put transfer, find the parent tree node, and clear the children");
+ final IRODSOutlineModel thisOutlineModel = this;
+
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ TreePath parentNodePath;
+ try {
+ parentNodePath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree, transferStatus.getTargetFileAbsolutePath());
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("error building tree path", ex);
+ }
+ log.debug("tree path for put: {}", parentNodePath);
+ IRODSNode targetNode = (IRODSNode) parentNodePath.getLastPathComponent();
+ CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) targetNode.getUserObject();
+ if (entry.isDataObject()) {
+ log.info("substitute parent as target, as given node was a leaf");
+ targetNode = (IRODSNode) targetNode.getParent();
+ }
+
+ IRODSNode newNode = new IRODSNode(entry, idrop.getiDropCore().getIrodsAccount(),
+ idrop.getiDropCore().getIrodsFileSystem(), irodsTree);
+ targetNode.add(newNode);
+ //targetNode.forceReloadOfChildrenOfThisNode();
+ //targetNode.lazyLoadOfChildrenOfThisNode();
+
+ thisOutlineModel.getTreePathSupport().expandPath(parentNodePath);
+ if (entry.isDataObject()) {
+ try {
+ parentNodePath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree, entry.getParentPath());
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("error building tree path", ex);
+
+ }
+ irodsTree.highlightPath(parentNodePath);
+ } else {
+ irodsTree.highlightPath(parentNodePath);
+
+ }
+ }
+ });
+
+ }
+ }
+
+ public void notifyFileShouldBeAdded(final IRODSTree irodsTree, final String irodsFileAbsolutePath) {
+ log.info("notifyFileShouldBeAdded() for node:{}", irodsFileAbsolutePath);
+
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ IRODSFileFactory irodsFileFactory = idrop.getiDropCore().getIRODSFileFactoryForLoggedInAccount();
+ try {
+ IRODSFile addedFile = irodsFileFactory.instanceIRODSFile(irodsFileAbsolutePath);
+ if (!addedFile.exists()) {
+ log.info("looking for file that was added, I don't find it, so just move on: {}", irodsFileAbsolutePath);
+ return;
+ }
+ TreePath parentPath;
+ try {
+ parentPath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree, addedFile.getParent());
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ }
+
+ if (parentPath == null) {
+ log.info("null path for lookup, just move on");
+ return;
+ }
+ log.info("building a new node");
+ CollectionAndDataObjectListingEntry newEntry = new CollectionAndDataObjectListingEntry();
+ newEntry.setCreatedAt(new Date(addedFile.lastModified()));
+ newEntry.setDataSize(addedFile.length());
+ newEntry.setModifiedAt(new Date(addedFile.lastModified()));
+
+ if (addedFile.isDirectory()) {
+ newEntry.setObjectType(CollectionAndDataObjectListingEntry.ObjectType.COLLECTION);
+ newEntry.setParentPath(addedFile.getParent());
+ newEntry.setPathOrName(addedFile.getAbsolutePath());
+ } else {
+ newEntry.setObjectType(CollectionAndDataObjectListingEntry.ObjectType.DATA_OBJECT);
+ newEntry.setParentPath(addedFile.getParent());
+ newEntry.setPathOrName(addedFile.getName());
+ }
+
+ IRODSNode newNode = new IRODSNode(newEntry, idrop.getiDropCore().getIrodsAccount(), idrop.getiDropCore().getIrodsFileSystem(), irodsTree);
+ ((IRODSNode) parentPath.getLastPathComponent()).add(newNode);
+ } catch (JargonException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(Level.SEVERE, null, ex);
+ } finally {
+ idrop.getiDropCore().closeIRODSConnectionForLoggedInAccount();
+ }
+ }
+ });
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSRowModel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSRowModel.java
new file mode 100644
index 0000000..a610086
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSRowModel.java
@@ -0,0 +1,72 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.irods.jargon.idrop.desktop.systraygui.viscomponents;
+
+import java.util.Date;
+import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
+import org.netbeans.swing.outline.RowModel;
+
+/**
+ * @author Mike Conway - DICE (www.irods.org)
+ */
+public class IRODSRowModel implements RowModel {
+
+ @Override
+ public int getColumnCount() {
+ return 2;
+ }
+
+ @Override
+ public Object getValueFor(Object node, int column) {
+ IRODSNode f = (IRODSNode) node;
+ CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) f.getUserObject();
+ switch (column) {
+
+ case 0:
+ return entry.getDataSize();
+ case 1:
+ return entry.getModifiedAt();
+ default:
+ assert false;
+ }
+ return null;
+ }
+
+ @Override
+ public Class getColumnClass(int i) {
+ switch (i) {
+
+ case 0:
+ return Long.class;
+ case 1:
+ return Date.class;
+ default:
+ assert false;
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isCellEditable(Object o, int i) {
+ return false;
+ }
+
+ @Override
+ public void setValueFor(Object o, int i, Object o1) {
+ }
+
+ @Override
+ public String getColumnName(int i) {
+ switch (i) {
+ case 0:
+ return "size";
+ case 1:
+ return "last modified";
+ default:
+ assert false;
+ }
+ return null;
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTree.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTree.java
index e5636ef..48abe07 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTree.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTree.java
@@ -28,13 +28,17 @@ import org.irods.jargon.idrop.desktop.systraygui.RenameIRODSDirectoryDialog;
import org.irods.jargon.idrop.desktop.systraygui.iDrop;
import org.irods.jargon.idrop.exceptions.IdropException;
import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.netbeans.swing.outline.DefaultOutlineModel;
+import org.netbeans.swing.outline.Outline;
+import org.netbeans.swing.outline.OutlineModel;
+import org.netbeans.swing.outline.TreePathSupport;
import org.slf4j.LoggerFactory;
/**
* Swing JTree component for viewing iRODS server file system
* @author Mike Conway - DICE (www.irods.org)
*/
-public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpansionListener {
+public class IRODSTree extends Outline implements TreeWillExpandListener, TreeExpansionListener {
public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSTree.class);
protected iDrop idropParentGui = null;
@@ -42,34 +46,9 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
protected Action m_action;
protected TreePath m_clickedPath;
protected IRODSTree thisTree;
- private int highlightedRow = -1;
- public Rectangle getDirtyRegion() {
- return dirtyRegion;
- }
-
- public void setDirtyRegion(Rectangle dirtyRegion) {
- this.dirtyRegion = dirtyRegion;
- }
-
- public Color getHighlightColor() {
- return highlightColor;
- }
-
- public void setHighlightColor(Color highlightColor) {
- this.highlightColor = highlightColor;
- }
-
- public int getHighlightedRow() {
- return highlightedRow;
- }
-
- public void setHighlightedRow(int highlightedRow) {
- this.highlightedRow = highlightedRow;
- }
- private Rectangle dirtyRegion = null;
- private Color highlightColor = new Color(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue(), 100);
private boolean refreshingTree = false;
+ TreePathSupport tps;
public boolean isRefreshingTree() {
synchronized (this) {
@@ -84,10 +63,16 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
}
public IRODSTree(TreeModel newModel, iDrop idropParentGui) {
- super(newModel);
+ super();
+
+ OutlineModel mdl = DefaultOutlineModel.createOutlineModel(
+ newModel, new IRODSRowModel(), true, "File System");
this.idropParentGui = idropParentGui;
+ tps = new TreePathSupport(mdl, this.getLayoutCache());
+
+ tps.addTreeExpansionListener(this);
+ tps.addTreeWillExpandListener(this);
initializeMenusAndListeners();
- //this.setEditable(true);
}
public IRODSTree() {
@@ -105,9 +90,15 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
setDropMode(javax.swing.DropMode.ON);
setTransferHandler(new IRODSTreeTransferHandler(idropParentGui, "selectionModel"));
setUpTreeMenu();
- // setUpDropListener();
- addTreeExpansionListener(this);
- addTreeWillExpandListener(this);
+ IrodsSelectionListenerForBuildingInfoPanel treeListener;
+ try {
+ treeListener = new IrodsSelectionListenerForBuildingInfoPanel(idropParentGui);
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("error initializing selection listener", ex);
+ }
+ this.getSelectionModel().addListSelectionListener(treeListener);
+
}
/**
@@ -119,7 +110,7 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
m_action = new AbstractAction() {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e) {
if (m_clickedPath == null) {
return;
}
@@ -137,7 +128,7 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
Action newAction = new AbstractAction("New Folder") {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e) {
log.info("adding new node");
@@ -166,19 +157,23 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
@Override
public void actionPerformed(ActionEvent e) {
log.info("deleting a node");
+ int[] rows = thisTree.getSelectedRows();
+ log.debug("selected rows for delete:{}", rows);
- TreePath[] selects = thisTree.getSelectionPaths();
DeleteIRODSDialog deleteDialog;
- if (selects.length == 1) {
- IRODSNode toDelete = (IRODSNode) m_clickedPath.getLastPathComponent();
+ if (rows.length == 1) {
+
+ IRODSNode toDelete = (IRODSNode) thisTree.getValueAt(rows[0], 0);
log.info("deleting a single node: {}", toDelete);
deleteDialog = new DeleteIRODSDialog(idropParentGui, true, thisTree, toDelete);
} else {
List<IRODSNode> nodesToDelete = new ArrayList<IRODSNode>();
- for (TreePath treePath : selects) {
- nodesToDelete.add((IRODSNode) treePath.getLastPathComponent());
+ for (int row : rows) {
+ nodesToDelete.add((IRODSNode) thisTree.getValueAt(row, 0));
+
}
+
deleteDialog = new DeleteIRODSDialog(idropParentGui, true, thisTree, nodesToDelete);
}
@@ -191,7 +186,7 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
Action a2 = new AbstractAction("Rename") {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e) {
log.info("renaming node");
IRODSNode toRename = (IRODSNode) m_clickedPath.getLastPathComponent();
@@ -235,7 +230,8 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
if (e.isPopupTrigger()) {
int x = e.getX();
int y = e.getY();
- TreePath path = thisTree.getPathForLocation(x, y);
+
+ TreePath path = thisTree.getClosestPathForLocation(x, y);
if (path != null) {
if (thisTree.isExpanded(path)) {
m_action.putValue(Action.NAME, "Collapse");
@@ -253,7 +249,7 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
if (e.isPopupTrigger()) {
int x = e.getX();
int y = e.getY();
- TreePath path = thisTree.getPathForLocation(x, y);
+ TreePath path = thisTree.getClosestPathForLocation(x, y);
if (path != null) {
if (thisTree.isExpanded(path)) {
m_action.putValue(Action.NAME, "Collapse");
@@ -295,7 +291,8 @@ public class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpa
@Override
public void run() {
highlightTree.expandPath(pathToHighlight);
- highlightTree.scrollPathToVisible(pathToHighlight);
+ // highlightTree.sc
+ // highlightTree.scrollPathToVisible(pathToHighlight);
}
});
}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTreeTransferHandler.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTreeTransferHandler.java
index bb156e3..ccd80a4 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTreeTransferHandler.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IRODSTreeTransferHandler.java
@@ -39,6 +39,7 @@ public class IRODSTreeTransferHandler extends TransferHandler {
@Override
public void exportAsDrag(JComponent jc, InputEvent ie, int i) {
+ log.info("export as drag");
super.exportAsDrag(jc, ie, i);
}
@@ -65,7 +66,7 @@ public class IRODSTreeTransferHandler extends TransferHandler {
log.info("importData in irods:{}", ts);
// mac opt = 1 w/o = 2 (no plus icon for a 2 so it's a move) / for drag from local is 1 (copy)
Point pt = ts.getDropLocation().getDropPoint();
- JTree tree = (JTree) ts.getComponent();
+ IRODSTree tree = (IRODSTree) ts.getComponent();
TreePath targetPath = tree.getClosestPathForLocation(pt.x, pt.y);
IRODSNode targetNode = (IRODSNode) targetPath.getLastPathComponent();
log.info("drop node is: {}", targetNode);
@@ -131,32 +132,7 @@ public class IRODSTreeTransferHandler extends TransferHandler {
public boolean canImport(TransferSupport support) {
Point location = support.getDropLocation().getDropPoint();
IRODSTree tree = (IRODSTree) support.getComponent();
-
- int closestRow = idropGui.getIrodsTree().getClosestRowForLocation((int) location.getX(), (int) location.getY());
- boolean highlighted = false;
-
- Graphics g = tree.getGraphics();
-
- // row changed
-
- if (tree.getHighlightedRow() != closestRow) {
- if (null != tree.getDirtyRegion()) {
- tree.paintImmediately(tree.getDirtyRegion());
- }
-
- for (int j = 0; j < tree.getRowCount(); j++) {
- if (closestRow == j) {
-
- Rectangle firstRowRect = tree.getRowBounds(closestRow);
- tree.setDirtyRegion(firstRowRect);
- g.setColor(tree.getHighlightColor());
-
- g.fillRect((int) tree.getDirtyRegion().getX(), (int) tree.getDirtyRegion().getY(), (int) tree.getDirtyRegion().getWidth(), (int) tree.getDirtyRegion().getHeight());
- tree.setHighlightedRow(closestRow);
- }
- }
-
- }
+
log.warn("transferFlavors:{}", support.getDataFlavors());
@@ -193,14 +169,18 @@ public class IRODSTreeTransferHandler extends TransferHandler {
@Override
protected Transferable createTransferable(JComponent c) {
log.debug("creating a transferrable from the irods tree view");
-
+
List<File> transferFiles = new ArrayList<File>();
IRODSTree stagingViewTree = (IRODSTree) c;
// get the selected node (one for now)
-
- TreePath[] selectionPaths = stagingViewTree.getSelectionModel().getSelectionPaths();
- log.info("transferrable path:{}", selectionPaths);
-
+ int[] rows = idropGui.getIrodsTree().getSelectedRows();
+ log.debug("selected rows for delete:{}", rows);
+
+ List<IRODSNode> nodesToTransfer = new ArrayList<IRODSNode>();
+ for (int row : rows) {
+ nodesToTransfer.add((IRODSNode) idropGui.getIrodsTree().getValueAt(row, 0));
+ }
+
IRODSFileService irodsFileService;
try {
irodsFileService = new IRODSFileService(idropGui.getIrodsAccount(), idropGui.getiDropCore().getIrodsFileSystem());
@@ -209,11 +189,9 @@ public class IRODSTreeTransferHandler extends TransferHandler {
throw new IdropRuntimeException(ex);
}
- IRODSNode listingEntryNode;
String objectPath;
- for (TreePath selectionPath : selectionPaths) {
- listingEntryNode = (IRODSNode) selectionPath.getLastPathComponent();
- CollectionAndDataObjectListingEntry listingEntry = (CollectionAndDataObjectListingEntry) listingEntryNode.getUserObject();
+ for (IRODSNode nodeToTransfer : nodesToTransfer) {
+ CollectionAndDataObjectListingEntry listingEntry = (CollectionAndDataObjectListingEntry) nodeToTransfer.getUserObject();
if (listingEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) {
objectPath = listingEntry.getPathOrName();
} else {
@@ -229,6 +207,7 @@ public class IRODSTreeTransferHandler extends TransferHandler {
}
return new IRODSTreeTransferable(transferFiles, stagingViewTree);
+
}
private void processDropOfTreeSelectionModel(final Transferable transferable, final IRODSNode parent, final DataFlavor dataFlavor) {
@@ -242,7 +221,6 @@ public class IRODSTreeTransferHandler extends TransferHandler {
targetIrodsFileAbsolutePath = putTarget.getParentPath();
}
-
try {
// get the list of files
TreeSelectionModel transferableSelectionModel = (TreeSelectionModel) transferable.getTransferData(dataFlavor);
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsSelectionListenerForBuildingInfoPanel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsSelectionListenerForBuildingInfoPanel.java
new file mode 100644
index 0000000..ddd0b32
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsSelectionListenerForBuildingInfoPanel.java
@@ -0,0 +1,161 @@
+/*
+ *A listener for iRODS tree selected
+ */
+package org.irods.jargon.idrop.desktop.systraygui.viscomponents;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.swing.event.ListSelectionEvent;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.event.TreeExpansionEvent;
+import javax.swing.event.TreeExpansionListener;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import org.irods.jargon.core.pub.CollectionAO;
+import org.irods.jargon.core.pub.DataObjectAO;
+import org.irods.jargon.core.pub.domain.Collection;
+import org.irods.jargon.core.pub.domain.DataObject;
+import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
+import org.irods.jargon.idrop.desktop.systraygui.iDrop;
+import org.irods.jargon.idrop.exceptions.IdropException;
+import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class to encapsulate handling of info panel. This object will listen to tree selection events in the iDROP
+ * iRODS tree, and initialize the info panel.
+ *
+ *
+ *
+ * @author Mike Conway - DICE (www.irods.org)
+ */
+public class IrodsSelectionListenerForBuildingInfoPanel implements ListSelectionListener {
+
+ public static org.slf4j.Logger log = LoggerFactory.getLogger(IrodsSelectionListenerForBuildingInfoPanel.class);
+ private final iDrop idrop;
+ private IRODSOutlineModel irodsFileSystemModel = null;
+
+ public IrodsSelectionListenerForBuildingInfoPanel(final iDrop idrop) throws IdropException {
+ if (idrop == null) {
+ throw new IdropException("null iDrop");
+ }
+
+ this.idrop = idrop;
+
+ }
+
+ public void valueChanged(TreeSelectionEvent e) {
+//FIXME: reimplement
+
+ /*
+ if (!(idrop.getIrodsTree().getLastSelectedPathComponent() instanceof IRODSNode)) {
+ log.info("last selected is not a Node");
+ return;
+ }
+
+
+ final IRODSNode node = (IRODSNode) idrop.getIrodsTree().getLastSelectedPathComponent();
+ try {
+ identifyNodeTypeAndInitializeInfoPanel(node);
+ } catch (IdropException ex) {
+ Logger.getLogger(IrodsTreeListenerForBuildingInfoPanel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("exception processing valueChanged() event for IRODSNode selection");
+ }
+
+ * *
+ */
+ }
+
+ public void treeExpanded(TreeExpansionEvent event) {
+ /*TreePath expandedTreePath = event.getPath();
+ IRODSNode expandedNode = (IRODSNode) expandedTreePath.getLastPathComponent();
+ try {
+ identifyNodeTypeAndInitializeInfoPanel(expandedNode);
+ } catch (IdropException ex) {
+ Logger.getLogger(IrodsTreeListenerForBuildingInfoPanel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("exception processing treeExpanded() event for IRODSNode selection");
+ }*/
+ }
+
+ public void treeCollapsed(TreeExpansionEvent event) {
+ // operation not needed, left for interface contract
+ }
+
+ /**
+ * Look at the kind of irods node and handle appropriately
+ * @param irodsNode
+ * @throws IdropException
+ */
+ public void identifyNodeTypeAndInitializeInfoPanel(final IRODSNode irodsNode) throws IdropException {
+
+ if (!idrop.getToggleIrodsDetails().isSelected()) {
+ return;
+ }
+
+ if (irodsNode.isLeaf()) {
+ log.info("selected node is a leaf, get a data object");
+ buildDataObjectFromSelectedIRODSNodeAndGiveToInfoPanel(irodsNode);
+ } else {
+ log.info("selected node is a collection, get a collection object");
+ buildCollectionFromSelectedIRODSNodeAndGiveToInfoPanel(irodsNode);
+ }
+ }
+
+ /**
+ * When a selected node in the iRODS tree is a data object, put the data object info in the info panel
+ * @param irodsNode
+ */
+ private void buildDataObjectFromSelectedIRODSNodeAndGiveToInfoPanel(final IRODSNode irodsNode) throws IdropException {
+ try {
+ CollectionAndDataObjectListingEntry collectionAndDataObjectListingEntry = (CollectionAndDataObjectListingEntry) irodsNode.getUserObject();
+ log.info("will be getting a data object based on entry in IRODSNode:{}", irodsNode);
+ DataObjectAO dataObjectAO = idrop.getiDropCore().getIRODSAccessObjectFactory().getDataObjectAO(idrop.getIrodsAccount());
+ DataObject dataObject = dataObjectAO.findByCollectionNameAndDataName(collectionAndDataObjectListingEntry.getParentPath(), collectionAndDataObjectListingEntry.getPathOrName());
+ idrop.initializeInfoPanel(dataObject);
+ } catch (Exception e) {
+ log.error("error building data object for: {}", irodsNode);
+ throw new IdropException(e);
+ }
+ }
+
+ /**
+ * When a selected node in the iRODS tree is a collection, put the collection info into the info panel
+ * @param irodsNode
+ */
+ private void buildCollectionFromSelectedIRODSNodeAndGiveToInfoPanel(final IRODSNode irodsNode) throws IdropException {
+ try {
+ CollectionAndDataObjectListingEntry collectionAndDataObjectListingEntry = (CollectionAndDataObjectListingEntry) irodsNode.getUserObject();
+ log.info("will be getting a collection based on entry in IRODSNode:{}", irodsNode);
+ CollectionAO collectionAO = idrop.getiDropCore().getIRODSAccessObjectFactory().getCollectionAO(idrop.getIrodsAccount());
+ Collection collection = collectionAO.findByAbsolutePath(collectionAndDataObjectListingEntry.getPathOrName());
+ idrop.initializeInfoPanel(collection);
+ } catch (Exception e) {
+ log.error("error building collection objectt for: {}", irodsNode);
+ throw new IdropException(e);
+
+ }
+ }
+
+ @Override
+ public void valueChanged(ListSelectionEvent lse) {
+ if (lse.getValueIsAdjusting()) {
+ return;
+ }
+ log.info("lse: {}", lse);
+
+ if (irodsFileSystemModel == null) {
+ irodsFileSystemModel = (IRODSOutlineModel) idrop.getIrodsTree().getModel();
+ }
+
+ // use first selection for info
+ int idx = lse.getLastIndex();
+ IRODSNode selectedNode = (IRODSNode) irodsFileSystemModel.getValueAt(idx, 0);
+ log.info("selected node to initialize info panel:{}", selectedNode);
+ try {
+ identifyNodeTypeAndInitializeInfoPanel(selectedNode);
+ } catch (IdropException ex) {
+ Logger.getLogger(IrodsSelectionListenerForBuildingInfoPanel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException("error initializing info panel for selected irods node");
+ }
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsTreeListenerForBuildingInfoPanel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsTreeListenerForBuildingInfoPanel.java
index 6860be7..cbfb67d 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsTreeListenerForBuildingInfoPanel.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/IrodsTreeListenerForBuildingInfoPanel.java
@@ -43,12 +43,14 @@ public class IrodsTreeListenerForBuildingInfoPanel implements TreeSelectionListe
@Override
public void valueChanged(TreeSelectionEvent e) {
+//FIXME: reimplement
-
+ /*
if (!(idrop.getIrodsTree().getLastSelectedPathComponent() instanceof IRODSNode)) {
log.info("last selected is not a Node");
return;
}
+
final IRODSNode node = (IRODSNode) idrop.getIrodsTree().getLastSelectedPathComponent();
try {
@@ -58,6 +60,9 @@ public class IrodsTreeListenerForBuildingInfoPanel implements TreeSelectionListe
throw new IdropRuntimeException("exception processing valueChanged() event for IRODSNode selection");
}
+ * *
+ */
+
}
@Override
diff --git a/pom.xml b/pom.xml
index d9e3aac..d3790a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -58,7 +58,7 @@
<name>jboss.repository</name>
<url>http://repository.jboss.com/maven2/</url>
<releases>
- <enabled>true</enabled>
+ <enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>