summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLISA STILLWELL <lisa@simon.local>2011-08-17 13:55:57 (GMT)
committer LISA STILLWELL <lisa@simon.local>2011-08-17 13:55:57 (GMT)
commit33df19e82d77d84b7ad7593a673c4ac165b3b5a5 (patch)
treee98253214b1c57600f26eeea0e6547faad86ab46
parent674b80123925b14bb8d492382a0732f78988a5d0 (diff)
downloadQCG-Data-33df19e82d77d84b7ad7593a673c4ac165b3b5a5.zip
QCG-Data-33df19e82d77d84b7ad7593a673c4ac165b3b5a5.tar.gz
QCG-Data-33df19e82d77d84b7ad7593a673c4ac165b3b5a5.tar.bz2
[#427] Add Local Tree to main mode and add functionality for Upload mode
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/NewIRODSDirectoryDialog.java368
1 files changed, 223 insertions, 145 deletions
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/NewIRODSDirectoryDialog.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/NewIRODSDirectoryDialog.java
index 2267b49..08e6169 100644
--- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/NewIRODSDirectoryDialog.java
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/NewIRODSDirectoryDialog.java
@@ -15,6 +15,8 @@ import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
+import javax.swing.tree.TreePath;
+
import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
import org.slf4j.LoggerFactory;
@@ -24,7 +26,7 @@ import org.slf4j.LoggerFactory;
*/
public class NewIRODSDirectoryDialog extends javax.swing.JDialog {
- private final iDropLiteApplet idrop;
+ private final iDropLiteApplet idrop;
private String parentDirectory = "";
private final IRODSTree stagingViewTree;
private final IRODSNode parentNode;
@@ -34,14 +36,16 @@ public class NewIRODSDirectoryDialog extends javax.swing.JDialog {
return parentDirectory;
}
- public void setParentDirectory(String parentDirectory) {
+ public void setParentDirectory(final String parentDirectory) {
this.parentDirectory = parentDirectory;
}
/** Creates new form NewIRODSDirectoryDialog */
- public NewIRODSDirectoryDialog(final iDropLiteApplet parent, final boolean modal, final String parentDirectory, final IRODSTree stagingViewTree, final IRODSNode parentNode) {
- //super(parent, modal); FIX THIS???
- super((Frame)null, modal);
+ public NewIRODSDirectoryDialog(final iDropLiteApplet parent, final boolean modal,
+ final String parentDirectory, final IRODSTree stagingViewTree,
+ final IRODSNode parentNode) {
+ //super(parent, modal);
+ super((java.awt.Frame)null, modal);
this.idrop = parent;
this.parentDirectory = parentDirectory;
this.stagingViewTree = stagingViewTree;
@@ -52,130 +56,184 @@ public class NewIRODSDirectoryDialog extends javax.swing.JDialog {
}
- /** This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
+ /**
+ * This method is called from within the constructor to initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is always
+ * regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
-
- lblTitle = new javax.swing.JLabel();
- pnlFolderData = new javax.swing.JPanel();
- pnlCurrentParent = new javax.swing.JPanel();
- lblCurrentParent = new java.awt.Label();
- scrollCurrentParent = new javax.swing.JScrollPane();
- txtAreaCurrentParent = new javax.swing.JTextArea();
- lblNewDiretoryName = new java.awt.Label();
- txtNewFolder = new javax.swing.JTextField();
- pnlBottom = new javax.swing.JPanel();
- btnCancel = new javax.swing.JButton();
- btnOK = new javax.swing.JButton();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
- setTitle("Create New Folder Dialog");
- setName("NewParentDialog"); // NOI18N
-
- lblTitle.setText("Please enter a name for the new folder");
- getContentPane().add(lblTitle, java.awt.BorderLayout.NORTH);
-
- pnlFolderData.setLayout(new java.awt.GridLayout(0, 1));
-
- lblCurrentParent.setText("Current parent directory:");
-
- txtAreaCurrentParent.setColumns(20);
- txtAreaCurrentParent.setEditable(false);
- txtAreaCurrentParent.setLineWrap(true);
- txtAreaCurrentParent.setRows(5);
- txtAreaCurrentParent.setFocusable(false);
- scrollCurrentParent.setViewportView(txtAreaCurrentParent);
-
- lblNewDiretoryName.setText("New folder name:");
-
- txtNewFolder.setToolTipText("A name for the new folder underneath the displayed parent");
-
- org.jdesktop.layout.GroupLayout pnlCurrentParentLayout = new org.jdesktop.layout.GroupLayout(pnlCurrentParent);
- pnlCurrentParent.setLayout(pnlCurrentParentLayout);
- pnlCurrentParentLayout.setHorizontalGroup(
- pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(org.jdesktop.layout.GroupLayout.TRAILING, pnlCurrentParentLayout.createSequentialGroup()
- .addContainerGap(20, Short.MAX_VALUE)
- .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(lblCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(lblNewDiretoryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
- .add(txtNewFolder)
- .add(scrollCurrentParent, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE))
- .addContainerGap())
- );
- pnlCurrentParentLayout.setVerticalGroup(
- pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(pnlCurrentParentLayout.createSequentialGroup()
- .add(58, 58, 58)
- .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(scrollCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(lblCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(txtNewFolder, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(lblNewDiretoryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(68, Short.MAX_VALUE))
- );
-
- lblNewDiretoryName.getAccessibleContext().setAccessibleName("New directory name:");
-
- pnlFolderData.add(pnlCurrentParent);
-
- getContentPane().add(pnlFolderData, java.awt.BorderLayout.CENTER);
-
- pnlBottom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
-
- btnCancel.setText("Cancel");
- btnCancel.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnCancelActionPerformed(evt);
- }
- });
- pnlBottom.add(btnCancel);
+ // <editor-fold defaultstate="collapsed"
+ // desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblTitle = new javax.swing.JLabel();
+ pnlFolderData = new javax.swing.JPanel();
+ pnlCurrentParent = new javax.swing.JPanel();
+ lblCurrentParent = new java.awt.Label();
+ scrollCurrentParent = new javax.swing.JScrollPane();
+ txtAreaCurrentParent = new javax.swing.JTextArea();
+ lblNewDiretoryName = new java.awt.Label();
+ txtNewFolder = new javax.swing.JTextField();
+ pnlBottom = new javax.swing.JPanel();
+ btnCancel = new javax.swing.JButton();
+ btnOK = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Create New Folder Dialog");
+ setName("NewParentDialog"); // NOI18N
+
+ lblTitle.setText("Please enter a name for the new folder");
+ getContentPane().add(lblTitle, java.awt.BorderLayout.NORTH);
+
+ pnlFolderData.setLayout(new java.awt.GridLayout(0, 1));
+
+ lblCurrentParent.setText("Current parent directory:");
+
+ txtAreaCurrentParent.setColumns(20);
+ txtAreaCurrentParent.setEditable(false);
+ txtAreaCurrentParent.setLineWrap(true);
+ txtAreaCurrentParent.setRows(5);
+ txtAreaCurrentParent.setFocusable(false);
+ scrollCurrentParent.setViewportView(txtAreaCurrentParent);
+
+ lblNewDiretoryName.setText("New folder name:");
+
+ txtNewFolder
+ .setToolTipText("A name for the new folder underneath the displayed parent");
+
+ org.jdesktop.layout.GroupLayout pnlCurrentParentLayout = new org.jdesktop.layout.GroupLayout(
+ pnlCurrentParent);
+ pnlCurrentParent.setLayout(pnlCurrentParentLayout);
+ pnlCurrentParentLayout
+ .setHorizontalGroup(pnlCurrentParentLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING,
+ pnlCurrentParentLayout
+ .createSequentialGroup()
+ .addContainerGap(20, Short.MAX_VALUE)
+ .add(pnlCurrentParentLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(lblCurrentParent,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblNewDiretoryName,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pnlCurrentParentLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING,
+ false)
+ .add(txtNewFolder)
+ .add(scrollCurrentParent,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ 413, Short.MAX_VALUE))
+ .addContainerGap()));
+ pnlCurrentParentLayout
+ .setVerticalGroup(pnlCurrentParentLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(pnlCurrentParentLayout
+ .createSequentialGroup()
+ .add(58, 58, 58)
+ .add(pnlCurrentParentLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(scrollCurrentParent,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblCurrentParent,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(
+ org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pnlCurrentParentLayout
+ .createParallelGroup(
+ org.jdesktop.layout.GroupLayout.LEADING)
+ .add(txtNewFolder,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblNewDiretoryName,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
+ org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
+ org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(68, Short.MAX_VALUE)));
+
+ lblNewDiretoryName.getAccessibleContext().setAccessibleName(
+ "New directory name:");
+
+ pnlFolderData.add(pnlCurrentParent);
+
+ getContentPane().add(pnlFolderData, java.awt.BorderLayout.CENTER);
+
+ pnlBottom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
+
+ btnCancel.setText("Cancel");
+ btnCancel.addActionListener(new java.awt.event.ActionListener() {
+ @Override
+ public void actionPerformed(final java.awt.event.ActionEvent evt) {
+ btnCancelActionPerformed(evt);
+ }
+ });
+ pnlBottom.add(btnCancel);
+
+ btnOK.setText("OK");
+ btnOK.addActionListener(new java.awt.event.ActionListener() {
+ @Override
+ public void actionPerformed(final java.awt.event.ActionEvent evt) {
+ btnOKActionPerformed(evt);
+ }
+ });
+ pnlBottom.add(btnOK);
+
+ getContentPane().add(pnlBottom, java.awt.BorderLayout.SOUTH);
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void btnCancelActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnCancelActionPerformed
+ this.dispose();
+ }// GEN-LAST:event_btnCancelActionPerformed
- btnOK.setText("OK");
- btnOK.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnOKActionPerformed(evt);
- }
- });
- pnlBottom.add(btnOK);
+ private void btnOKActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnOKActionPerformed
+ processNew();
+ }// GEN-LAST:event_btnOKActionPerformed
+ // Variables declaration - do not modify//GEN-BEGIN:variables
- getContentPane().add(pnlBottom, java.awt.BorderLayout.SOUTH);
+ private javax.swing.JButton btnCancel;
- pack();
- }// </editor-fold>
+ private javax.swing.JButton btnOK;
- private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {
- this.dispose();
-}
+ private java.awt.Label lblCurrentParent;
- private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {
- processNew();
- }
- // Variables declaration - do not modify
- private javax.swing.JButton btnCancel;
- private javax.swing.JButton btnOK;
- private java.awt.Label lblCurrentParent;
- private java.awt.Label lblNewDiretoryName;
- private javax.swing.JLabel lblTitle;
- private javax.swing.JPanel pnlBottom;
- private javax.swing.JPanel pnlCurrentParent;
- private javax.swing.JPanel pnlFolderData;
- private javax.swing.JScrollPane scrollCurrentParent;
- private javax.swing.JTextArea txtAreaCurrentParent;
- private javax.swing.JTextField txtNewFolder;
- // End of variables declaration
-
- private void processNew() {
- // add the new folder to irods, add to the tree, and scroll the tree into view
+ private java.awt.Label lblNewDiretoryName;
+
+ private javax.swing.JLabel lblTitle;
+
+ private javax.swing.JPanel pnlBottom;
+
+ private javax.swing.JPanel pnlCurrentParent;
+
+ private javax.swing.JPanel pnlFolderData;
+
+ private javax.swing.JScrollPane scrollCurrentParent;
+
+ private javax.swing.JTextArea txtAreaCurrentParent;
+
+ private javax.swing.JTextField txtNewFolder;
+
+ // End of variables declaration//GEN-END:variables
+ private void processNew() {
+ // add the new folder to irods, add to the tree, and scroll the tree
+ // into view
if (txtNewFolder.getText().isEmpty()) {
txtNewFolder.setBackground(Color.red);
@@ -189,10 +247,23 @@ public class NewIRODSDirectoryDialog extends javax.swing.JDialog {
@Override
public void run() {
- log.info("adding new folder named:{}", txtNewFolder.getText());
- thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
- IRODSFileService irodsFileService = new IRODSFileService(idrop.getiDropCore().getIrodsAccount(),idrop.getiDropCore().getIrodsFileSystem());
+ log.info("adding new folder named:{}",
+ txtNewFolder.getText());
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ IRODSFileService irodsFileService;
+ try {
+ irodsFileService = new IRODSFileService(idrop.getIrodsAccount(), idrop.getiDropCore().getIrodsFileSystem());
+ } catch (IdropException ex) {
+ Logger.getLogger(
+ NewIRODSDirectoryDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ } finally {
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+
+ }
StringBuilder sb = new StringBuilder();
sb.append(parentDirectory);
@@ -202,13 +273,13 @@ public class NewIRODSDirectoryDialog extends javax.swing.JDialog {
boolean created = irodsFileService.createNewFolder(newDirPath);
- IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel();
+ stagingViewTree.getModel();
if (!created) {
- log.info("could not create new folder in:{}", newDirPath);
+ log.info("could not create new folder in:{}",
+ newDirPath);
idrop.showMessageFromOperation("directory could not be created");
thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-
return;
}
@@ -217,43 +288,50 @@ public class NewIRODSDirectoryDialog extends javax.swing.JDialog {
entry.setObjectType(CollectionAndDataObjectListingEntry.ObjectType.COLLECTION);
entry.setParentPath(parentDirectory);
entry.setPathOrName(newDirPath);
- IRODSNode newNode = new IRODSNode(entry, idrop.getiDropCore().getIrodsAccount(),idrop.getiDropCore().getIrodsFileSystem() , idrop.getIrodsTree());
- //newNode.setParent(parentNode);
+ IRODSNode newNode = new IRODSNode(entry, idrop.getIrodsAccount(), idrop.getiDropCore().getIrodsFileSystem(), idrop.getIrodsTree());
log.info("inserting node at 0");
- //parentNode.insertChildAt(0, newNode);
if (parentNode.isCached()) {
- irodsFileSystemModel.insertNodeInto(newNode, parentNode, 0);
+ parentNode.insert(newNode, parentNode.getChildCount());
} else {
parentNode.forceReloadOfChildrenOfThisNode();
- irodsFileSystemModel.reload(parentNode);
- stagingViewTree.expandPath(TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, entry.getParentPath()));
}
- thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ try {
+ TreePath path = TreeUtils.buildTreePathForIrodsAbsolutePath(
+ stagingViewTree, entry.getParentPath());
+ stagingViewTree.collapsePath(path);
+ stagingViewTree.expandPath(path);
+ } catch (IdropException ex) {
+ Logger.getLogger(
+ NewIRODSDirectoryDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+ idrop.showIdropException(ex);
+ } finally {
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+
idrop.showMessageFromOperation("new folder created");
- }
- catch (IdropException ex) {
+ thisDialog.dispose();
+ } catch (IdropException ex) {
Logger.getLogger(NewIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex);
- idrop.showIdropException(ex);
+ throw new IdropRuntimeException(ex);
}
-
- thisDialog.dispose();
}
});
- }
-
+ }
- /**
+ /**
* 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);
+ KeyStroke enter = KeyStroke.getKeyStroke(
+ java.awt.event.KeyEvent.VK_ENTER, 0);
Action enterAction = new AbstractAction() {
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(final ActionEvent e) {
processNew();
}
};