summaryrefslogtreecommitdiffstats
path: root/idrop-lite
diff options
context:
space:
mode:
authorLISA STILLWELL <lisa@simon.local>2011-08-17 13:55:37 (GMT)
committer LISA STILLWELL <lisa@simon.local>2011-08-17 13:55:37 (GMT)
commit674b80123925b14bb8d492382a0732f78988a5d0 (patch)
tree3db667c30effacc2884eba3abe2d905995087481 /idrop-lite
parent8ee1318263a14a821f4d7c6415f291486e1b42c4 (diff)
downloadQCG-Data-674b80123925b14bb8d492382a0732f78988a5d0.zip
QCG-Data-674b80123925b14bb8d492382a0732f78988a5d0.tar.gz
QCG-Data-674b80123925b14bb8d492382a0732f78988a5d0.tar.bz2
[#427] Add Local Tree to main mode and add functionality for Upload mode
Diffstat (limited to 'idrop-lite')
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTree.java119
1 files changed, 64 insertions, 55 deletions
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTree.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTree.java
index 13bc7c9..be814c4 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTree.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/IRODSTree.java
@@ -26,6 +26,8 @@ import javax.swing.tree.TreeModel;
import javax.swing.tree.TreePath;
import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
+import org.irods.jargon.idrop.lite.finder.IRODSTreeContainingComponent;
+import org.irods.jargon.idrop.lite.finder.IrodsSelectionListenerForBuildingInfoPanel;
import org.netbeans.swing.outline.DefaultOutlineModel;
import org.netbeans.swing.outline.Outline;
import org.netbeans.swing.outline.OutlineModel;
@@ -34,48 +36,41 @@ import org.slf4j.LoggerFactory;
/**
* Swing JTree component for viewing iRODS server file system
- *
+ *
* @author Mike Conway - DICE (www.irods.org)
*/
-public class IRODSTree extends Outline implements TreeWillExpandListener, TreeExpansionListener {
+public class IRODSTree extends Outline implements TreeWillExpandListener,
+ TreeExpansionListener, IRODSTreeContainingComponent {
public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSTree.class);
-
protected iDropLiteApplet idropParentGui = null;
-
protected JPopupMenu m_popup = null;
-
protected Action m_action;
-
protected TreePath m_clickedPath;
-
protected IRODSTree thisTree;
-
private boolean refreshingTree = false;
-
TreePathSupport tps;
+ @Override
public boolean isRefreshingTree() {
synchronized (this) {
return refreshingTree;
}
}
- public void setRefreshingTree(boolean refreshingTree) {
+ public void setRefreshingTree(final boolean refreshingTree) {
synchronized (this) {
this.refreshingTree = refreshingTree;
}
}
- public IRODSTree(TreeModel newModel, iDropLiteApplet idropParentGui) {
+ public IRODSTree(final TreeModel newModel, final iDropLiteApplet idropParentGui) {
super();
- OutlineModel mdl = DefaultOutlineModel.createOutlineModel(newModel, new IRODSRowModel(), true, "File System");
+ 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();
}
@@ -83,27 +78,34 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
super();
}
- public IRODSTree(iDropLiteApplet idropParentGui) {
+ public IRODSTree(final iDropLiteApplet idropParentGui) {
super();
this.idropParentGui = idropParentGui;
initializeMenusAndListeners();
}
private void initializeMenusAndListeners() {
+ tps = new TreePathSupport(this.getOutlineModel(), this.getLayoutCache());
+ tps.addTreeExpansionListener(this);
+ tps.addTreeWillExpandListener(this);
setDragEnabled(true);
+ setTransferHandler(new IRODSTreeTransferHandler(idropParentGui,
+ "selectionModel"));
setDropMode(javax.swing.DropMode.ON);
- setTransferHandler(new IRODSTreeTransferHandler(idropParentGui, "selectionModel"));
+
setUpTreeMenu();
- /*
IrodsSelectionListenerForBuildingInfoPanel treeListener;
try {
- treeListener = new IrodsSelectionListenerForBuildingInfoPanel(idropParentGui);
+ 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);
+ Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null,
+ ex);
+ throw new IdropRuntimeException(
+ "error initializing selection listener", ex);
}
+
this.getSelectionModel().addListSelectionListener(treeListener);
- */
}
@@ -116,7 +118,7 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
m_action = new AbstractAction() {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
if (m_clickedPath == null) {
return;
}
@@ -134,27 +136,27 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
Action newAction = new AbstractAction("New Folder") {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
log.info("adding new node");
IRODSNode parent = (IRODSNode) m_clickedPath.getLastPathComponent();
log.info("parent of new node is: {}", parent);
- CollectionAndDataObjectListingEntry dataEntry = (CollectionAndDataObjectListingEntry) parent
- .getUserObject();
+ CollectionAndDataObjectListingEntry dataEntry = (CollectionAndDataObjectListingEntry) parent.getUserObject();
if (dataEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.DATA_OBJECT) {
- JOptionPane.showMessageDialog(thisTree,
- "The selected item is not a folder, cannot create a new directory", "Info",
- JOptionPane.INFORMATION_MESSAGE);
+ JOptionPane.showMessageDialog(
+ thisTree,
+ "The selected item is not a folder, cannot create a new directory",
+ "Info", JOptionPane.INFORMATION_MESSAGE);
log.info("new folder not created, the selected parent is not a collection");
return;
}
// show a dialog asking for the new directory name...
- NewIRODSDirectoryDialog newDirectoryDialog = new NewIRODSDirectoryDialog(idropParentGui, true,
- dataEntry.getPathOrName(), thisTree, parent);
+ NewIRODSDirectoryDialog newDirectoryDialog = new NewIRODSDirectoryDialog(
+ idropParentGui, true, dataEntry.getPathOrName(),
+ thisTree, parent);
newDirectoryDialog.setLocation(
- (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2),
- (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
+ (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
newDirectoryDialog.setVisible(true);
}
};
@@ -165,7 +167,7 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
Action a1 = new AbstractAction("Delete") {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
log.info("deleting a node");
int[] rows = thisTree.getSelectedRows();
log.debug("selected rows for delete:{}", rows);
@@ -174,21 +176,25 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
if (rows.length == 1) {
- IRODSNode toDelete = (IRODSNode) thisTree.getValueAt(rows[0], 0);
+ IRODSNode toDelete = (IRODSNode) thisTree.getValueAt(
+ rows[0], 0);
log.info("deleting a single node: {}", toDelete);
- deleteDialog = new DeleteIRODSDialog(idropParentGui, true, thisTree, toDelete);
+ deleteDialog = new DeleteIRODSDialog(idropParentGui, true,
+ thisTree, toDelete);
} else {
List<IRODSNode> nodesToDelete = new ArrayList<IRODSNode>();
for (int row : rows) {
- nodesToDelete.add((IRODSNode) thisTree.getValueAt(row, 0));
+ nodesToDelete.add((IRODSNode) thisTree.getValueAt(row,
+ 0));
}
- deleteDialog = new DeleteIRODSDialog(idropParentGui, true, thisTree, nodesToDelete);
+ deleteDialog = new DeleteIRODSDialog(idropParentGui, true,
+ thisTree, nodesToDelete);
}
- deleteDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2),
- (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
+ deleteDialog.setLocation(
+ (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
deleteDialog.setVisible(true);
}
};
@@ -197,13 +203,12 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
Action a2 = new AbstractAction("Rename") {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
log.info("renaming node");
IRODSNode toRename = (IRODSNode) m_clickedPath.getLastPathComponent();
log.info("node to rename is: {}", toRename);
- CollectionAndDataObjectListingEntry dataEntry = (CollectionAndDataObjectListingEntry) toRename
- .getUserObject();
+ CollectionAndDataObjectListingEntry dataEntry = (CollectionAndDataObjectListingEntry) toRename.getUserObject();
// dialog uses absolute path, so munge it for files
StringBuilder sb = new StringBuilder();
@@ -216,10 +221,10 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
}
// show a dialog asking for the new directory name...
- RenameIRODSDirectoryDialog renameDialog = new RenameIRODSDirectoryDialog(idropParentGui, true,
- sb.toString(), thisTree, toRename);
- renameDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2),
- (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
+ RenameIRODSDirectoryDialog renameDialog = new RenameIRODSDirectoryDialog(
+ idropParentGui, true, sb.toString(), thisTree, toRename);
+ renameDialog.setLocation(
+ (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
renameDialog.setVisible(true);
}
};
@@ -230,17 +235,17 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
}
@Override
- public void treeExpanded(TreeExpansionEvent event) {
+ public void treeExpanded(final TreeExpansionEvent event) {
}
@Override
- public void treeCollapsed(TreeExpansionEvent event) {
+ public void treeCollapsed(final TreeExpansionEvent event) {
}
class PopupTrigger extends MouseAdapter {
@Override
- public void mouseReleased(MouseEvent e) {
+ public void mouseReleased(final MouseEvent e) {
if (e.isPopupTrigger()) {
int x = e.getX();
int y = e.getY();
@@ -259,7 +264,7 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
}
@Override
- public void mousePressed(MouseEvent e) {
+ public void mousePressed(final MouseEvent e) {
if (e.isPopupTrigger()) {
int x = e.getX();
int y = e.getY();
@@ -278,20 +283,24 @@ public class IRODSTree extends Outline implements TreeWillExpandListener, TreeEx
}
@Override
- public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
+ public void treeWillCollapse(final TreeExpansionEvent event)
+ throws ExpandVetoException {
}
@Override
- public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
+ public void treeWillExpand(final TreeExpansionEvent event)
+ throws ExpandVetoException {
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
log.debug("tree expansion event:{}", event);
IRODSNode expandingNode = (IRODSNode) event.getPath().getLastPathComponent();
- // If I am refreshing the tree, then do not close the connection after each load. It will be closed in the thing
+ // If I am refreshing the tree, then do not close the connection after
+ // each load. It will be closed in the thing
// doing the refreshing
try {
expandingNode.lazyLoadOfChildrenOfThisNode(!isRefreshingTree());
} catch (IdropException ex) {
- Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex);
+ Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null,
+ ex);
idropParentGui.showIdropException(ex);
throw new IdropRuntimeException("error expanding irodsNode");
} finally {