From cfc56a7d3783f4db0b13b7e928e5e34e9d27e0d9 Mon Sep 17 00:00:00 2001 From: Mike Conway Date: Fri, 27 Jan 2012 20:35:54 +0000 Subject: [#551]-overwrite handling --- diff --git a/idrop-commons/pom.xml b/idrop-commons/pom.xml deleted file mode 100644 index 1798fbf..0000000 --- a/idrop-commons/pom.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - org.irods - idrop - 1.0.0-beta2-SNAPSHOT - - 4.0.0 - org.irods.idrop - idrop-commons - jar - idrop-commons - - - - - - - - - - org.swinglabs - swing-layout - - - org.irods.jargon - jargon-data-utils - compile - - - org.irods.jargon - jargon-test - compile - - - org.irods.jargon - jargon-user-tagging - compile - - - org.irods.jargon.transfer - jargon-transfer-engine - - - junit - junit - 4.8.2 - test - jar - - - - - diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteIRODSDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteIRODSDialog.form deleted file mode 100644 index c843416..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteIRODSDialog.form +++ /dev/null @@ -1,136 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteIRODSDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteIRODSDialog.java deleted file mode 100644 index 3aef527..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteIRODSDialog.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * DeleteIRODSDialog.java - * - * Created on Sep 4, 2010, 7:40:23 AM - */ -package org.irods.jargon.idrop.commons; - -import java.awt.Cursor; -import java.awt.Frame; -import javax.swing.Action; -import java.awt.event.ActionEvent; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.SwingWorker; -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.slf4j.LoggerFactory; - -/** - * - * @author mikeconway - */ -public class DeleteIRODSDialog extends javax.swing.JDialog { - - private final IdropClient idrop; - private final IRODSTree irodsTree; - private final IRODSNode deletedNode; - private final List deletedNodes; - public static org.slf4j.Logger log = LoggerFactory.getLogger(NewIRODSDirectoryDialog.class); - - /** Creates new form NewIRODSDirectoryDialog */ - public DeleteIRODSDialog(final IdropClient parent, final boolean modal, final IRODSTree irodsTree, final IRODSNode deletedNode) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.irodsTree = irodsTree; - this.deletedNode = deletedNode; - this.deletedNodes = null; - StringBuilder sb = new StringBuilder(); - CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) deletedNode.getUserObject(); - if (entry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) { - sb.append(entry.getPathOrName()); - } else { - sb.append(entry.getParentPath()); - sb.append('/'); - sb.append(entry.getPathOrName()); - } - - initialize(); - txtAreaFileToDelete.setText(sb.toString()); - } - - /** Creates new form NewIRODSDirectoryDialog */ - public DeleteIRODSDialog(final IdropClient parent, final boolean modal, final IRODSTree irodsTree, final List deletedNodes) { - // super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.irodsTree = irodsTree; - this.deletedNodes = deletedNodes; - this.deletedNode = null; - initialize(); - txtAreaFileToDelete.setText("multiple selections"); - } - - private void initialize() { - initComponents(); - registerKeystrokeListener(); - } - - /** - * 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) { - try { - processDelete(); - } catch (IdropException ex) { - Logger.getLogger(DeleteIRODSDialog.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException(ex); - } - } - }; - - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } - - /** 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") - // //GEN-BEGIN:initComponents - private void initComponents() { - - lblTitle = new javax.swing.JLabel(); - pnlFolderData = new javax.swing.JPanel(); - pnlCurrentParent = new javax.swing.JPanel(); - lblCurrentFolder = new java.awt.Label(); - scrollFileToDelete = new javax.swing.JScrollPane(); - txtAreaFileToDelete = new javax.swing.JTextArea(); - pnlBottom = new javax.swing.JPanel(); - btnCancel = new javax.swing.JButton(); - btnOK = new javax.swing.JButton(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - - lblTitle.setText("Please hit OK to delete the following file/folder from iRODS"); - getContentPane().add(lblTitle, java.awt.BorderLayout.NORTH); - - pnlFolderData.setLayout(new java.awt.GridLayout(0, 1)); - - lblCurrentFolder.setText("File/folder to delete:"); - - txtAreaFileToDelete.setColumns(20); - txtAreaFileToDelete.setEditable(false); - txtAreaFileToDelete.setLineWrap(true); - txtAreaFileToDelete.setRows(5); - scrollFileToDelete.setViewportView(txtAreaFileToDelete); - - 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(40, Short.MAX_VALUE) - .add(lblCurrentFolder, 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(scrollFileToDelete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 413, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - pnlCurrentParentLayout.setVerticalGroup( - pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(35, 35, 35) - .add(lblCurrentFolder, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(22, 22, 22) - .add(scrollFileToDelete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - 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(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - pnlBottom.add(btnCancel); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - pnlBottom.add(btnOK); - - getContentPane().add(pnlBottom, java.awt.BorderLayout.SOUTH); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - try { - processDelete(); - } catch (IdropException ex) { - Logger.getLogger(DeleteIRODSDialog.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException(ex); - } - -}//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton btnCancel; - private javax.swing.JButton btnOK; - private java.awt.Label lblCurrentFolder; - private javax.swing.JLabel lblTitle; - private javax.swing.JPanel pnlBottom; - private javax.swing.JPanel pnlCurrentParent; - private javax.swing.JPanel pnlFolderData; - private javax.swing.JScrollPane scrollFileToDelete; - private javax.swing.JTextArea txtAreaFileToDelete; - // End of variables declaration//GEN-END:variables - - 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)); - (new DeleteWorker(thisDialog)).execute(); - } - }); - } - - private void deleteASingleFile(final IRODSFileFactory irodsFileFactory, final IRODSNode deletedNode) throws IdropException { - - log.info("node to delete is: {}", deletedNode); - CollectionAndDataObjectListingEntry dataEntry = (CollectionAndDataObjectListingEntry) deletedNode.getUserObject(); - - //dialog uses absolute path, so munge it for files - StringBuilder sb = new StringBuilder(); - if (dataEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) { - sb.append(dataEntry.getPathOrName()); - } else { - sb.append(dataEntry.getParentPath()); - sb.append('/'); - sb.append(dataEntry.getPathOrName()); - } - - IRODSFile fileToDelete; - try { - fileToDelete = irodsFileFactory.instanceIRODSFile(sb.toString()); - fileToDelete.delete(); - final IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) irodsTree.getModel(); - irodsFileSystemModel.removeNodeFromParent(deletedNode); - } catch (JargonException ex) { - Logger.getLogger(DeleteIRODSDialog.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException(ex); - } - - } - - class DeleteWorker extends SwingWorker { - - 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; - - } - - @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); - } - } - - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteLocalFileDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteLocalFileDialog.form deleted file mode 100644 index 1db8d69..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteLocalFileDialog.form +++ /dev/null @@ -1,137 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteLocalFileDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteLocalFileDialog.java deleted file mode 100644 index 9351fa9..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/DeleteLocalFileDialog.java +++ /dev/null @@ -1,242 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * DeleteIRODSDialog.java - * - * Created on Sep 4, 2010, 7:40:23 AM - */ -package org.irods.jargon.idrop.commons; - -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.tree.TreePath; -import org.slf4j.LoggerFactory; - -/** - * - * @author mikeconway - */ -public class DeleteLocalFileDialog extends javax.swing.JDialog { - - private final IdropClient idrop; - private String directoryToDelete = ""; - private final LocalFileTree localFileTree; - private final LocalFileNode deletedNode; - public static org.slf4j.Logger log = LoggerFactory.getLogger(DeleteLocalFileDialog.class); - - /** Creates new form to delete a local file */ - public DeleteLocalFileDialog(final IdropClient parent, final boolean modal, final String directoryToDelete, final LocalFileTree localFileTree, final LocalFileNode deletedNode) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.directoryToDelete = directoryToDelete; - this.localFileTree = localFileTree; - this.deletedNode = deletedNode; - initComponents(); - txtAreaFileToDelete.setText(this.directoryToDelete); - registerKeystrokeListener(); - - } - - private void recursiveDelete(File fileToDelete) throws IOException { - if (fileToDelete.isDirectory()) { - for (File c : fileToDelete.listFiles()) { - recursiveDelete(c); - } - } - if (!fileToDelete.delete()) { - throw new FileNotFoundException("Failed to delete file: " + fileToDelete); - } - } - - /** 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") - // //GEN-BEGIN:initComponents - private void initComponents() { - - lblTitle = new javax.swing.JLabel(); - pnlFolderData = new javax.swing.JPanel(); - pnlCurrentParent = new javax.swing.JPanel(); - lblCurrentFolder = new java.awt.Label(); - scrollFileToDelete = new javax.swing.JScrollPane(); - txtAreaFileToDelete = new javax.swing.JTextArea(); - pnlBottom = new javax.swing.JPanel(); - btnCancel = new javax.swing.JButton(); - btnOK = new javax.swing.JButton(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("iDrop - Delete local file or folder"); - - lblTitle.setText("Please hit OK to delete the following file/folder from the local file syste"); - getContentPane().add(lblTitle, java.awt.BorderLayout.NORTH); - - pnlFolderData.setLayout(new java.awt.GridLayout(0, 1)); - - lblCurrentFolder.setText("File/folder to delete:"); - - txtAreaFileToDelete.setColumns(20); - txtAreaFileToDelete.setEditable(false); - txtAreaFileToDelete.setLineWrap(true); - txtAreaFileToDelete.setRows(5); - scrollFileToDelete.setViewportView(txtAreaFileToDelete); - - 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(40, Short.MAX_VALUE) - .add(lblCurrentFolder, 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(scrollFileToDelete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 413, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - pnlCurrentParentLayout.setVerticalGroup( - pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(35, 35, 35) - .add(lblCurrentFolder, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(22, 22, 22) - .add(scrollFileToDelete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - 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(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - pnlBottom.add(btnCancel); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - pnlBottom.add(btnOK); - - getContentPane().add(pnlBottom, java.awt.BorderLayout.SOUTH); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - processDelete(); - -}//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton btnCancel; - private javax.swing.JButton btnOK; - private java.awt.Label lblCurrentFolder; - private javax.swing.JLabel lblTitle; - private javax.swing.JPanel pnlBottom; - private javax.swing.JPanel pnlCurrentParent; - private javax.swing.JPanel pnlFolderData; - private javax.swing.JScrollPane scrollFileToDelete; - private javax.swing.JTextArea txtAreaFileToDelete; - // End of variables declaration//GEN-END:variables - - private void processDelete() { - - log.info("delete folder named:{}", txtAreaFileToDelete.getText()); - final DeleteLocalFileDialog thisDialog = this; - - - java.awt.EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - try { - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - TreePath deletedNodePath = new TreePath(deletedNode); - LocalFileNode parentNode = (LocalFileNode) deletedNode.getParent(); - File fileToDelete = (File) deletedNode.getUserObject(); - log.debug("deleting local file:{}", fileToDelete.getAbsolutePath()); - - recursiveDelete(fileToDelete); - LocalFileSystemModel localFileTreeModel = (LocalFileSystemModel) localFileTree.getModel(); - localFileTreeModel.removeNodeFromParent(deletedNode); - - idrop.showMessageFromOperation("delete successful"); - /* boolean deleted = fileToDelete.delete(); - - if (deleted == false) { - log.warn("delete unsuccessful for:{}", fileToDelete.getAbsolutePath()); - idrop.showIdropException(new IdropException("unable to delete file:" + fileToDelete.getAbsolutePath())); - - } else { - - LocalFileSystemModel localFileTreeModel = (LocalFileSystemModel) localFileTree.getModel(); - localFileTreeModel.removeNodeFromParent(deletedNode); - - idrop.showMessageFromOperation("delete successful"); - } - * */ - - } catch (Exception ex) { - Logger.getLogger(NewIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex); - idrop.showIdropException(ex); - } finally { - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - - 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); - Action enterAction = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - processDelete(); - } - }; - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } - - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSFileService.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSFileService.java deleted file mode 100644 index 4c25cd9..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSFileService.java +++ /dev/null @@ -1,575 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.CollectionAO; -import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO; -import org.irods.jargon.core.pub.DataObjectAO; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.ResourceAO; -import org.irods.jargon.core.pub.RuleProcessingAO; -import org.irods.jargon.core.pub.domain.Collection; -import org.irods.jargon.core.pub.domain.Resource; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.core.query.AVUQueryElement; -import org.irods.jargon.core.query.AVUQueryOperatorEnum; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.irods.jargon.core.query.JargonQueryException; -import org.irods.jargon.core.query.MetaDataAndDomainData; -import org.irods.jargon.core.query.RodsGenQueryEnum; -import org.irods.jargon.core.rule.IRODSRuleExecResult; -import org.slf4j.LoggerFactory; - -/** - * Delegate class that interacts with iRODS based on GUI interactions - * FIXME: this needs to be re-worked for connection handling (cache, or per-service scheme) right now it - * just opens connections per invocation. This was a shortcut to get a demo done and needs to be corrected. - * @author Mike Conway - DICE (www.irods.org) - */ -public class IRODSFileService { - - public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSFileService.class); - private final IRODSAccount irodsAccount; - private final IRODSFileSystem irodsFileSystem; - - private IRODSFileService() { - irodsAccount = null; - irodsFileSystem = null; - // not to be invoked, thus private - } - - public IRODSFileService(final IRODSAccount irodsAccount, final IRODSFileSystem irodsFileSystem) throws IdropException { - if (irodsAccount == null) { - throw new IdropException("null irodsAccount"); - } - - if (irodsFileSystem == null) { - throw new IdropException("null irodsFileSystem"); - } - - this.irodsAccount = irodsAccount; - this.irodsFileSystem = irodsFileSystem; - - } - - public List getCollectionsUnderParentCollection(final String parentCollectionAbsolutePath) throws IdropException { - - if (parentCollectionAbsolutePath == null || parentCollectionAbsolutePath.isEmpty()) { - throw new IdropException("null parentCollectionAbsolutePath"); - } - - try { - CollectionAndDataObjectListAndSearchAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAndDataObjectListAndSearchAO(irodsAccount); - return collectionAO.listCollectionsUnderPath(parentCollectionAbsolutePath, 0); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception getting collections under: {}" + parentCollectionAbsolutePath, ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - } - - public IRODSFile getIRODSFileForPath(final String irodsFilePath) throws IdropException { - - if (irodsFilePath == null || irodsFilePath.isEmpty()) { - throw new IdropException("null or empty irodsFilePath"); - } - - try { - return irodsFileSystem.getIRODSFileFactory(irodsAccount).instanceIRODSFile(irodsFilePath); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception getting collections under: {}" + irodsFilePath, ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - } - - public List getFilesAndCollectionsUnderParentCollection(final String parentCollectionAbsolutePath) throws IdropException { - - if (parentCollectionAbsolutePath == null || parentCollectionAbsolutePath.isEmpty()) { - throw new IdropException("null parentCollectionAbsolutePath"); - } - - try { - CollectionAndDataObjectListAndSearchAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAndDataObjectListAndSearchAO(irodsAccount); - return collectionAO.listDataObjectsAndCollectionsUnderPath(parentCollectionAbsolutePath); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception getting collections under: {}" + parentCollectionAbsolutePath, ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - } - - public Collection getParentCollection(final String parentCollectionAbsolutePath) throws IdropException { - - if (parentCollectionAbsolutePath == null || parentCollectionAbsolutePath.isEmpty()) { - throw new IdropException("null parentCollectionAbsolutePath"); - } - - try { - CollectionAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount); - return collectionAO.findByAbsolutePath(parentCollectionAbsolutePath); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception getting collections under: {}" + parentCollectionAbsolutePath, ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - } - - public String getStringFromSourcePaths(final List sourcePaths) throws IdropException { - if (sourcePaths == null || sourcePaths.isEmpty()) { - throw new IdropException("sourcePaths is null or empty"); - } - - StringBuilder sb = new StringBuilder(); - for (String path : sourcePaths) { - sb.append(path); - } - - return sb.toString(); - - } - - public IRODSRuleExecResult runIRODSRule(final String irodsRule) throws IdropException { - log.info("executing rule: {}", irodsRule); - - try { - final RuleProcessingAO ruleProcessingAO = irodsFileSystem.getIRODSAccessObjectFactory().getRuleProcessingAO(irodsAccount); - return ruleProcessingAO.executeRule(irodsRule); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception processing rule", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - public List getResources() throws IdropException { - log.info("getting resources"); - - IRODSFileSystem irodsFileSystem = null; - try { - irodsFileSystem = IRODSFileSystem.instance(); - final ResourceAO resourceAO = irodsFileSystem.getIRODSAccessObjectFactory().getResourceAO(irodsAccount); - return resourceAO.findAll(); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception processing rule", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * Method will return a listing of collections with a given metadata value, in this case the marker attribute - * for the result of a virus scan. - * @param parentCollectionAbsolutePath String with the absolute path to the parent collection. - * @return List with the results of the query. - * @throws IdropException - */ - public List getVirusStatusForParentCollection(final String parentCollectionAbsolutePath) throws IdropException { - return getProcessingResultMetadataForCollection(parentCollectionAbsolutePath, "PolicyDrivenService:PolicyProcessingResultAttribute:VirusScan"); - } - - /** - * Method will return a listing of the marker values for a data object for fixity check status - * @param parentCollectionAbsolutePath String with the absolute path to the parent collection. - * @return MetaDataAndDomainData with the results of the query or null. - * @throws IdropException - */ - public MetaDataAndDomainData getFixityStatusForDataObject(final String parentCollectionAbsolutePath, final String dataObjectName) throws IdropException { - List metaDataList = getProcessingResultMetadataForDataObject(parentCollectionAbsolutePath, dataObjectName, "CHECKSUM%"); - if (metaDataList.size() > 0) { - return metaDataList.get(0); - } else { - return null; - } - } - - /** - * Method will return a listing of the marker values for a data object for virus scan status - * @param parentCollectionAbsolutePath String with the absolute path to the parent collection. - * @return MetaDataAndDomainData with the results of the query or null. - * @throws IdropException - */ - public MetaDataAndDomainData getVirusStatusForDataObject(final String parentCollectionAbsolutePath, final String dataObjectName) throws IdropException { - List metaDataList = getProcessingResultMetadataForDataObject(parentCollectionAbsolutePath, dataObjectName, "VIRUS_SCAN%"); - if (metaDataList.size() > 0) { - return metaDataList.get(0); - } else { - return null; - } - } - - /** - * Get a list of the AVU metadata for the given collection - * @param irodsAbsolutePath String that is the absolute iRODS path to the collection. - * @return List with the query results. - * @throws IdropException - */ - public List getMetadataForCollection(final String irodsAbsolutePath) throws IdropException { - if (irodsAbsolutePath == null || irodsAbsolutePath.isEmpty()) { - throw new IdropException("null or empty irodsAbsolutePath"); - } - - log.info("getting metadata for collection:{}", irodsAbsolutePath); - - try { - final CollectionAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount); - return collectionAO.findMetadataValuesForCollection(irodsAbsolutePath, 0); - } catch (Exception ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception processing rule", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - } - - /** - * Get a list of the AVU metadata for the given collection - * @param irodsAbsolutePath String that is the absolute iRODS path to the collection. - * @return List with the query results. - * @throws IdropException - */ - public List getMetadataForDataObject(final String irodsAbsolutePath, final String fileName) throws IdropException { - if (irodsAbsolutePath == null || irodsAbsolutePath.isEmpty()) { - throw new IdropException("null or empty irodsAbsolutePath"); - } - - if (fileName == null || fileName.isEmpty()) { - throw new IdropException("null or empty fileName"); - } - - log.info("getting metadata for data object:{}", irodsAbsolutePath); - log.info("file name:{}", fileName); - - try { - final DataObjectAO dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount); - return dataObjectAO.findMetadataValuesForDataObject(irodsAbsolutePath, fileName); - } catch (Exception ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception processing rule", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - } - - /** - * Method will return a listing of collections with a given metadata value, in this case the marker attribute - * for the result of a fixity check. - * @param parentCollectionAbsolutePath String with the absolute path to the parent collection. - * @return List with the results of the query. - * @throws IdropException - */ - public List getFixityStatusForParentCollection(final String parentCollectionAbsolutePath) throws IdropException { - return getProcessingResultMetadataForCollection(parentCollectionAbsolutePath, "PolicyDrivenService:PolicyProcessingResultAttribute:FixityCheck"); - } - - public List getProcessingResultMetadataForCollection(final String parentCollectionAbsolutePath, final String markerAttribute) throws IdropException { - if (parentCollectionAbsolutePath == null || parentCollectionAbsolutePath.isEmpty()) { - throw new IdropException("null or empty parentCollectionAbsolutePath"); - } - - if (markerAttribute == null || markerAttribute.isEmpty()) { - throw new IdropException("null or empty markerAttribute"); - } - - List queryElements = new ArrayList(); - try { - queryElements.add(AVUQueryElement.instanceForValueQuery(AVUQueryElement.AVUQueryPart.ATTRIBUTE, AVUQueryOperatorEnum.EQUAL, markerAttribute)); - } catch (JargonQueryException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException(ex); - } - - StringBuilder sb = new StringBuilder(); - sb.append(RodsGenQueryEnum.COL_COLL_NAME.getName()); - sb.append(" LIKE "); - sb.append("'"); - sb.append(parentCollectionAbsolutePath); - sb.append("%"); - sb.append("'"); - - try { - final CollectionAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAO(irodsAccount); - return collectionAO.findMetadataValuesByMetadataQueryWithAdditionalWhere(queryElements, sb.toString()); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception processing rule", ex); - } catch (JargonQueryException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("query exception processing rule", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - public List getProcessingResultMetadataForDataObject(final String parentCollectionAbsolutePath, final String dataObjectName, final String markerAttribute) throws IdropException { - - if (parentCollectionAbsolutePath == null || parentCollectionAbsolutePath.isEmpty()) { - throw new IdropException("null or empty parentCollectionAbsolutePath"); - } - - if (dataObjectName == null || dataObjectName.isEmpty()) { - throw new IdropException("null or empty dataObjectName"); - } - - if (markerAttribute == null || markerAttribute.isEmpty()) { - throw new IdropException("null or empty markerAttribute"); - } - - List queryElements = new ArrayList(); - try { - queryElements.add(AVUQueryElement.instanceForValueQuery(AVUQueryElement.AVUQueryPart.ATTRIBUTE, AVUQueryOperatorEnum.LIKE, markerAttribute)); - } catch (JargonQueryException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException(ex); - } - - try { - final DataObjectAO dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount); - return dataObjectAO.findMetadataValuesForDataObjectUsingAVUQuery(queryElements, parentCollectionAbsolutePath, dataObjectName); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception processing rule", ex); - } catch (JargonQueryException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("query exception processing rule", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - /** - * For a given data object, get a list of the resources for that object - * @param irodsCollectionAbsolutePath String with the absolute path to the collection that holds the data object. - * @param dataObjectName String with the name of the data object. - * @return List - * @throws IdropException - */ - public List getResourcesForDataObject(final String irodsCollectionAbsolutePath, final String dataObjectName) throws IdropException { - try { - DataObjectAO dataObjectAO = irodsFileSystem.getIRODSAccessObjectFactory().getDataObjectAO(irodsAccount); - return dataObjectAO.getResourcesForDataObject(irodsCollectionAbsolutePath, dataObjectName); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception getting resources for a data object", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - public boolean createNewFolder(final String newFolderAbsolutePath) throws IdropException { - - log.info("createNewFolder"); - if (newFolderAbsolutePath == null || newFolderAbsolutePath.isEmpty()) { - throw new IdropException("null or empty newFolderAbsolutePath"); - } - - boolean createSuccessful = false; - - try { - IRODSFile newDirectory = irodsFileSystem.getIRODSFileFactory(irodsAccount).instanceIRODSFile(newFolderAbsolutePath); - createSuccessful = newDirectory.mkdirs(); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception creating new dir", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - return createSuccessful; - } - - public void deleteFileOrFolderNoForce(final String deleteFileAbsolutePath) throws IdropException { - - log.info("deleteFileOrFolderNoForce"); - - if (deleteFileAbsolutePath == null || deleteFileAbsolutePath.isEmpty()) { - throw new IdropException("null or empty deleteFileAbsolutePath"); - } - - log.info("delete path:{}", deleteFileAbsolutePath); - - - try { - IRODSFile deleteFileOrDir = irodsFileSystem.getIRODSFileFactory(irodsAccount).instanceIRODSFile(deleteFileAbsolutePath); - deleteFileOrDir.delete(); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception deleting dir:" + deleteFileAbsolutePath, ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - public void moveCollectionUnderneathNewParent(final String currentAbsolutePath, final String newAbsolutePath) throws IdropException { - - log.info("renameFileOrFolder"); - - if (currentAbsolutePath == null || currentAbsolutePath.isEmpty()) { - throw new IdropException("null or empty currentAbsolutePath"); - } - - if (newAbsolutePath == null || newAbsolutePath.isEmpty()) { - throw new IdropException("null or empty newAbsolutePath"); - } - - log.info("currentAbsolutePath:{}", currentAbsolutePath); - log.info("newAbsolutePath:{}", newAbsolutePath); - - try { - DataTransferOperations dataTransferOperations = irodsFileSystem.getIRODSAccessObjectFactory().getDataTransferOperations(irodsAccount); - dataTransferOperations.moveTheSourceCollectionUnderneathTheTargetCollectionUsingSourceParentCollectionName(currentAbsolutePath, newAbsolutePath); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception renaming file", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - public String renameIRODSFileOrDirectory(final String irodsCurrentAbsolutePath, final String newFileOrCollectionName) throws IdropException { - - if (irodsCurrentAbsolutePath == null || irodsCurrentAbsolutePath.isEmpty()) { - throw new IdropException("null or empty irodsCurrentAbsolutePath"); - } - - if (newFileOrCollectionName == null || newFileOrCollectionName.isEmpty()) { - throw new IdropException("null or empty newFileOrCollectionName"); - } - - log.info("rename of IRODSFileOrDirectory, current absPath:{}", irodsCurrentAbsolutePath); - log.info("newFileOrCollectionName:{}", newFileOrCollectionName); - - String newPath = ""; - - try { - - IRODSFileFactory irodsFileFactory = irodsFileSystem.getIRODSFileFactory(irodsAccount); - IRODSFile sourceFile = irodsFileFactory.instanceIRODSFile(irodsCurrentAbsolutePath); - StringBuilder newPathSb = new StringBuilder(); - newPathSb.append(sourceFile.getParent()); - newPathSb.append("/"); - newPathSb.append(newFileOrCollectionName); - - newPath = newPathSb.toString(); - - DataTransferOperations dataTransferOperations = irodsFileSystem.getIRODSAccessObjectFactory().getDataTransferOperations(irodsAccount); - dataTransferOperations.move(irodsCurrentAbsolutePath, newPath); - log.info("move completed"); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception moving file", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - - return newPath; - } - - public void moveIRODSFileUnderneathNewParent(final String currentAbsolutePath, final String newAbsolutePath) throws IdropException { - - log.info("moveIRODSFileUnderneathNewParent"); - - if (currentAbsolutePath == null || currentAbsolutePath.isEmpty()) { - throw new IdropException("null or empty currentAbsolutePath"); - } - - if (newAbsolutePath == null || newAbsolutePath.isEmpty()) { - throw new IdropException("null or empty newAbsolutePath"); - } - - log.info("currentAbsolutePath:{}", currentAbsolutePath); - log.info("newAbsolutePath:{}", newAbsolutePath); - - try { - DataTransferOperations dataTransferOperations = irodsFileSystem.getIRODSAccessObjectFactory().getDataTransferOperations(irodsAccount); - dataTransferOperations.move(currentAbsolutePath, newAbsolutePath); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("exception moving file", ex); - } finally { - try { - irodsFileSystem.close(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(IRODSFileService.class.getName()).log(Level.SEVERE, null, ex); - } - } - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSFileSystemModel.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSFileSystemModel.java deleted file mode 100644 index 8f0e392..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSFileSystemModel.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.event.TreeModelEvent; -import javax.swing.tree.DefaultTreeModel; -import javax.swing.tree.TreePath; -import org.irods.jargon.core.connection.IRODSAccount; -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.transfer.dao.domain.TransferType; -import org.slf4j.LoggerFactory; - -/** - * Model of an underlying file system for browsing in a tree view - * @author Mike Conway - DICE (www.irods.org) - */ -public class IRODSFileSystemModel extends DefaultTreeModel { - - public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSFileSystemModel.class); - - private static class TreeModelListener implements javax.swing.event.TreeModelListener { - - public TreeModelListener() { - } - - @Override - public void treeNodesChanged(TreeModelEvent tme) { - } - - @Override - public void treeNodesInserted(TreeModelEvent tme) { - } - - @Override - public void treeNodesRemoved(TreeModelEvent tme) { - } - - @Override - public void treeStructureChanged(TreeModelEvent tme) { - } - } - - @Override - public Object getChild(Object parent, int index) { - triggerLazyLoading(parent); - return super.getChild(parent, index); - } - - @Override - public int getChildCount(Object parent) { - triggerLazyLoading(parent); - return super.getChildCount(parent); - } - - private void triggerLazyLoading(Object parent) throws IdropRuntimeException { - // make sure children are loaded before counting - IRODSNode parentAsNode = (IRODSNode) parent; - try { - parentAsNode.lazyLoadOfChildrenOfThisNode(); - } catch (IdropException ex) { - Logger.getLogger(IRODSFileSystemModel.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException(ex); - } - } - private final IRODSAccount irodsAccount; - - public IRODSFileSystemModel(final IRODSNode rootNode, final IRODSAccount irodsAccount) throws IdropException { - super(rootNode); - - if (irodsAccount == null) { - throw new IdropRuntimeException("null irodsAccount"); - } - this.irodsAccount = irodsAccount; - - // pre-expand the child nodes of the root - - rootNode.lazyLoadOfChildrenOfThisNode(); - this.addTreeModelListener(new TreeModelListener() { - }); - - } - - 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"); - 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); - - } - - } - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSNode.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSNode.java deleted file mode 100644 index 510c541..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSNode.java +++ /dev/null @@ -1,167 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.util.List; -import java.util.Vector; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.tree.DefaultMutableTreeNode; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.CollectionAO; -import org.irods.jargon.core.pub.CollectionAndDataObjectListAndSearchAO; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.slf4j.LoggerFactory; - -/** - * tree node for iRODS file tree - * @author Mike Conway - DICE (www.irods.org) - */ -public class IRODSNode extends DefaultMutableTreeNode { - - private boolean cached = false; - public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSNode.class); - public final IRODSAccount irodsAccount; - public final IRODSFileSystem irodsFileSystem; - public boolean hasMore = true; - public boolean continuation = false; - private final IRODSTree irodsTree; - - public IRODSNode(final CollectionAndDataObjectListingEntry entry, final IRODSAccount irodsAccount, final IRODSFileSystem irodsFileSystem, final IRODSTree irodsTree) { - super(entry); - if (irodsAccount == null) { - throw new IdropRuntimeException("null irodsAccount"); - } - this.irodsAccount = irodsAccount; - this.irodsFileSystem = irodsFileSystem; - this.irodsTree = irodsTree; - } - - @Override - public boolean isLeaf() { - CollectionAndDataObjectListingEntry nodeToCheck = (CollectionAndDataObjectListingEntry) this.getUserObject(); - return (nodeToCheck.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.DATA_OBJECT); - } - - /** - * Load children of this node, and then close the connection (appropriate for the user expanding a node). - * @throws IdropException - */ - public void lazyLoadOfChildrenOfThisNode() throws IdropException { - boolean refreshing = false; - - if (irodsTree != null) { - refreshing = irodsTree.isRefreshingTree(); - } - lazyLoadOfChildrenOfThisNode(!refreshing); - } - - /** - * Load children of this node by accessing iRODS. Note that in a refresh situation, you do not want to continuously - * open and close the connection, so there is an option to defer closing the connection to the caller. - * @param closeTheConnectionAfterLoad boolean that indicates that the connection will be closed by this method. If true is - * passed, then this method will close the connection. If false is passed, then the caller must close the connection. - * @throws IdropException - */ - public void lazyLoadOfChildrenOfThisNode(final boolean closeTheConnectionAfterLoad) throws IdropException { - - if (cached) { - return; - } - - log.debug("lazily loading children of:{}", this); - log.debug("will I close this connection:{}", closeTheConnectionAfterLoad); - - CollectionAndDataObjectListingEntry parentObject = (CollectionAndDataObjectListingEntry) this.getUserObject(); - try { - - CollectionAndDataObjectListAndSearchAO collectionAO = irodsFileSystem.getIRODSAccessObjectFactory().getCollectionAndDataObjectListAndSearchAO(irodsAccount); - List childCache = collectionAO.listDataObjectsAndCollectionsUnderPath(parentObject.getPathOrName()); - - for (CollectionAndDataObjectListingEntry childEntry : childCache) { - insert(new IRODSNode(childEntry, irodsAccount, irodsFileSystem, irodsTree), getChildCount()); - } - - if (children == null) { - children = new Vector(); - } - - cached = true; - - } catch (Exception ex) { - Logger.getLogger(IRODSNode.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("error occurred accessing collection data", ex); - } finally { - if (closeTheConnectionAfterLoad) { - irodsFileSystem.closeAndEatExceptions(irodsAccount); - } - } - } - - public void forceReloadOfChildrenOfThisNode() { - cached = false; - this.removeAllChildren(); - } - - @Override - public String toString() { - CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) this.getUserObject(); - String returnedString = ""; - - if (entry.getPathOrName().equals("")) { - returnedString = "/"; - } else { - returnedString = entry.toString(); - } - return returnedString; - } - - @Override - public int hashCode() { - return this.getUserObject().hashCode(); - } - - @Override - public boolean equals(Object obj) { - - if (!(obj instanceof IRODSNode)) { - return false; - } - - - IRODSNode comparableAsNode = (IRODSNode) obj; - - CollectionAndDataObjectListingEntry thisFile = (CollectionAndDataObjectListingEntry) getUserObject(); - CollectionAndDataObjectListingEntry thatFile = (CollectionAndDataObjectListingEntry) comparableAsNode.getUserObject(); - return thisFile.equals(thatFile); - } - - List getChildren() throws IdropException { - lazyLoadOfChildrenOfThisNode(!irodsTree.isRefreshingTree()); - return children; - } - - /** - * Have the children nodes been cached? - * @return boolean if children nodes have been cached. - */ - public boolean isCached() { - return cached; - } - - /** - * Is this node a continuation of a previous query - * @return boolean - */ - public boolean isContinuation() { - return continuation; - } - - /** - * Are there more records (children) to be retrieved from iRODS? - * @return boolean if more records are available. - */ - public boolean isHasMore() { - return hasMore; - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTree.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTree.java deleted file mode 100644 index 775d559..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTree.java +++ /dev/null @@ -1,300 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JOptionPane; -import javax.swing.JPopupMenu; -import javax.swing.JTree; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeExpansionListener; -import javax.swing.event.TreeWillExpandListener; -import javax.swing.tree.ExpandVetoException; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreePath; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.slf4j.LoggerFactory; - -/** - * Swing JTree component for viewing iRODS server file system - * @author Mike Conway - DICE (www.irods.org) - */ -public abstract class IRODSTree extends JTree implements TreeWillExpandListener, TreeExpansionListener { - - public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSTree.class); - protected IdropClient idropParentGui = null; - protected JPopupMenu m_popup = null; - 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; - - public boolean isRefreshingTree() { - synchronized (this) { - return refreshingTree; - } - } - - public void setRefreshingTree(boolean refreshingTree) { - synchronized (this) { - this.refreshingTree = refreshingTree; - } - } - - public IRODSTree(TreeModel newModel, IdropClient idropParentGui) { - super(newModel); - this.idropParentGui = idropParentGui; - initializeMenusAndListeners(); - //this.setEditable(true); - } - - public IRODSTree() { - super(); - } - - public IRODSTree(IdropClient idropParentGui) { - super(); - this.idropParentGui = idropParentGui; - initializeMenusAndListeners(); - } - - private void initializeMenusAndListeners() { - setDragEnabled(true); - setDropMode(javax.swing.DropMode.ON); - //setTransferHandler(new IRODSTreeTransferHandler(idropParentGui, "selectionModel")); - setTransferHandler(idropParentGui.getIRODSTreeTransferHandler("selectionModel")); - setUpTreeMenu(); - // setUpDropListener(); - addTreeExpansionListener(this); - addTreeWillExpandListener(this); - } - - /** - * Set up context sensitive tree menu - */ - private void setUpTreeMenu() { - thisTree = this; - m_popup = new JPopupMenu(); - m_action = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - if (m_clickedPath == null) { - return; - } - - if (thisTree.isExpanded(m_clickedPath)) { - thisTree.collapsePath(m_clickedPath); - } else { - thisTree.expandPath(m_clickedPath); - } - } - }; - - m_popup.add(m_action); - - Action newAction = new AbstractAction("New Folder") { - - @Override - public void actionPerformed(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(); - 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); - 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); - newDirectoryDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2)); - newDirectoryDialog.setVisible(true); - } - }; - m_popup.add(newAction); - - m_popup.addSeparator(); - - Action a1 = new AbstractAction("Delete") { - - @Override - public void actionPerformed(ActionEvent e) { - log.info("deleting a node"); - - TreePath[] selects = thisTree.getSelectionPaths(); - DeleteIRODSDialog deleteDialog; - - if (selects.length == 1) { - IRODSNode toDelete = (IRODSNode) m_clickedPath.getLastPathComponent(); - log.info("deleting a single node: {}", toDelete); - deleteDialog = new DeleteIRODSDialog(idropParentGui, true, thisTree, toDelete); - } else { - List nodesToDelete = new ArrayList(); - for (TreePath treePath : selects) { - nodesToDelete.add((IRODSNode) treePath.getLastPathComponent()); - } - deleteDialog = new DeleteIRODSDialog(idropParentGui, true, thisTree, nodesToDelete); - } - - deleteDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2)); - deleteDialog.setVisible(true); - } - }; - - m_popup.add(a1); - Action a2 = new AbstractAction("Rename") { - - @Override - public void actionPerformed(ActionEvent e) { - log.info("renaming node"); - - IRODSNode toRename = (IRODSNode) m_clickedPath.getLastPathComponent(); - log.info("node to rename is: {}", toRename); - CollectionAndDataObjectListingEntry dataEntry = (CollectionAndDataObjectListingEntry) toRename.getUserObject(); - - //dialog uses absolute path, so munge it for files - StringBuilder sb = new StringBuilder(); - if (dataEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) { - sb.append(dataEntry.getPathOrName()); - } else { - sb.append(dataEntry.getParentPath()); - sb.append('/'); - sb.append(dataEntry.getPathOrName()); - } - - // 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)); - renameDialog.setVisible(true); - } - }; - m_popup.add(a2); - thisTree.add(m_popup); - thisTree.addMouseListener(new PopupTrigger()); - - } - - @Override - public void treeExpanded(TreeExpansionEvent event) { - } - - @Override - public void treeCollapsed(TreeExpansionEvent event) { - } - - class PopupTrigger extends MouseAdapter { - - @Override - public void mouseReleased(MouseEvent e) { - if (e.isPopupTrigger()) { - int x = e.getX(); - int y = e.getY(); - TreePath path = thisTree.getPathForLocation(x, y); - if (path != null) { - if (thisTree.isExpanded(path)) { - m_action.putValue(Action.NAME, "Collapse"); - } else { - m_action.putValue(Action.NAME, "Expand"); - } - m_popup.show(thisTree, x, y); - m_clickedPath = path; - } - } - } - - @Override - public void mousePressed(MouseEvent e) { - if (e.isPopupTrigger()) { - int x = e.getX(); - int y = e.getY(); - TreePath path = thisTree.getPathForLocation(x, y); - if (path != null) { - if (thisTree.isExpanded(path)) { - m_action.putValue(Action.NAME, "Collapse"); - } else { - m_action.putValue(Action.NAME, "Expand"); - } - m_popup.show(thisTree, x, y); - m_clickedPath = path; - } - } - } - } - - @Override - public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { - } - - @Override - public void treeWillExpand(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 doing the refreshing - try { - expandingNode.lazyLoadOfChildrenOfThisNode(!isRefreshingTree()); - } catch (IdropException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - idropParentGui.showIdropException(ex); - throw new IdropRuntimeException("error expanding irodsNode"); - } finally { - setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - } - - public void highlightPath(final TreePath pathToHighlight) { - final IRODSTree highlightTree = this; - java.awt.EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - highlightTree.expandPath(pathToHighlight); - highlightTree.scrollPathToVisible(pathToHighlight); - } - }); - } - - protected abstract void setTransferHandler(IRODSTreeTransferHandler irodsTree_TH); -} - diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTreeTransferHandler.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTreeTransferHandler.java deleted file mode 100644 index b3749fd..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTreeTransferHandler.java +++ /dev/null @@ -1,434 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.awt.Graphics; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.event.InputEvent; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTree; -import javax.swing.TransferHandler; -import javax.swing.tree.TreePath; -import javax.swing.tree.TreeSelectionModel; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.slf4j.LoggerFactory; - -/** - * Transfer handler to handle import/export from the IRODSTree that handles the Swing JTree depicting - * the iRODS file system - * @author Mike Conway - DICE (www.irods.org) - */ -public abstract class IRODSTreeTransferHandler extends TransferHandler { - - @Override - public void exportAsDrag(JComponent jc, InputEvent ie, int i) { - super.exportAsDrag(jc, ie, i); - } - - @Override - public void exportToClipboard(JComponent jc, Clipboard clpbrd, int i) throws IllegalStateException { - super.exportToClipboard(jc, clpbrd, i); - } - - public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSTreeTransferHandler.class); - public final IdropClient idropGui; - - public IRODSTreeTransferHandler(final IdropClient idropGui, final String string) { - super(string); - if (idropGui == null) { - throw new IdropRuntimeException("null idrop gui"); - } - this.idropGui = idropGui; - } - - - @Override - public boolean importData(TransferSupport ts) { - - 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(); - TreePath targetPath = tree.getClosestPathForLocation(pt.x, pt.y); - IRODSNode targetNode = (IRODSNode) targetPath.getLastPathComponent(); - log.info("drop node is: {}", targetNode); - - Transferable transferable = ts.getTransferable(); - - DataFlavor[] transferrableFlavors = transferable.getTransferDataFlavors(); - - // see if this is a phymove gesture or an iRODS copy - if (transferable.isDataFlavorSupported(IRODSTreeTransferable.irodsTreeDataFlavor)) { - log.info("drop accepted, process as a move or copy, based on the action"); - - if (ts.isDrop()) { - if (ts.getUserDropAction() == 1) { - // copy - processCopyGesture(transferable, targetNode); - return true; - } else { - processPhymoveGesture(transferable, targetNode); - return true; - } - } - - - } - - // not a phymove - - boolean accepted = false; - - for (DataFlavor flavor : transferrableFlavors) { - log.debug("flavor mime type:{}", flavor.getMimeType()); - log.debug("flavor human presentable name:{}", flavor.getHumanPresentableName()); - if (flavor.isFlavorJavaFileListType()) { - log.info("drop accepted...process drop as file list from desktop"); - //dtde.acceptDrop(dtde.getDropAction()); - processDropOfFileList(transferable, targetNode); - accepted = true; - break; - } else if (flavor.getMimeType().equals("application/x-java-jvm-local-objectref; class=javax.swing.tree.TreeSelectionModel")) { - log.info("drop accepted: process drop as serialized object"); - // dtde.acceptDrop(dtde.getDropAction()); - processDropOfTreeSelectionModel(transferable, targetNode, flavor); - accepted = true; - break; - } else { - log.debug("flavor not processed: {}", flavor); - } - } - - if (!accepted) { - log.info("drop rejected"); - accepted=false; - } - - return accepted; - - // return super.importData(ts); - } - - - @Override - 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()); - - // if (support.getComponent() instanceof IRODSTree) { - for (DataFlavor flavor : support.getDataFlavors()) { - if (flavor.equals(DataFlavor.javaFileListFlavor)) { - log.debug("found file list flavor, will import"); - return true; - } else if (flavor.getMimeType().equals("application/x-java-jvm-local-objectref; class=javax.swing.tree.TreeSelectionModel")) { - log.debug("found file list flavor, will import"); - return true; - } - } - //} - log.debug("cannot import"); - return false; - - } - - @Override - public void exportDone(JComponent comp, Transferable trans, int action) { - if (action != MOVE) { - return; - } - } - /** - * We support both copy and move actions. - */ - @Override - public int getSourceActions(JComponent c) { - return TransferHandler.COPY_OR_MOVE; - } - - @Override - protected Transferable createTransferable(JComponent c) { - log.debug("creating a transferrable from the irods tree view"); - - List transferFiles = new ArrayList(); - IRODSTree stagingViewTree = (IRODSTree) c; - // get the selected node (one for now) - - TreePath[] selectionPaths = stagingViewTree.getSelectionModel().getSelectionPaths(); - log.info("transferrable path:{}", selectionPaths); - - IRODSFileService irodsFileService; - try { - irodsFileService = new IRODSFileService(idropGui.getiDropCore().getIrodsAccount(), idropGui.getiDropCore().getIrodsFileSystem()); - } catch (IdropException ex) { - Logger.getLogger(IRODSTreeTransferHandler.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException(ex); - } - - IRODSNode listingEntryNode; - String objectPath; - for (TreePath selectionPath : selectionPaths) { - listingEntryNode = (IRODSNode) selectionPath.getLastPathComponent(); - CollectionAndDataObjectListingEntry listingEntry = (CollectionAndDataObjectListingEntry) listingEntryNode.getUserObject(); - if (listingEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) { - objectPath = listingEntry.getPathOrName(); - } else { - objectPath = listingEntry.getParentPath() + "/" + listingEntry.getPathOrName(); - } - - try { - transferFiles.add((File) irodsFileService.getIRODSFileForPath(objectPath)); - } catch (IdropException ex) { - Logger.getLogger(IRODSTreeTransferHandler.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException(ex); - } - } - - return new IRODSTreeTransferable(transferFiles, stagingViewTree); - } - - private void processDropOfTreeSelectionModel(final Transferable transferable, final IRODSNode parent, final DataFlavor dataFlavor) { - final List sourceFiles = new ArrayList(); - CollectionAndDataObjectListingEntry putTarget = (CollectionAndDataObjectListingEntry) parent.getUserObject(); - final String targetIrodsFileAbsolutePath; - - if (putTarget.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) { - targetIrodsFileAbsolutePath = putTarget.getPathOrName(); - } else { - targetIrodsFileAbsolutePath = putTarget.getParentPath(); - } - - - try { - // get the list of files - TreeSelectionModel transferableSelectionModel = (TreeSelectionModel) transferable.getTransferData(dataFlavor); - TreePath[] treePaths = transferableSelectionModel.getSelectionPaths(); - - for (TreePath treePath : treePaths) { - LocalFileNode lastPathComponent = (LocalFileNode) treePath.getLastPathComponent(); - sourceFiles.add((File) lastPathComponent.getUserObject()); - } - - } catch (UnsupportedFlavorException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("unsupported flavor getting data from transfer"); - } catch (IOException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("io exception getting data from transfer"); - } - - if (sourceFiles.isEmpty()) { - log.error("no source files in transfer"); - throw new IdropRuntimeException("no source files in transfer"); - } - - StringBuilder sb = new StringBuilder(); - - if (sourceFiles.size() > 1) { - sb.append("Would you like to put multiple files"); - sb.append(" to iRODS at "); - sb.append(targetIrodsFileAbsolutePath); - } else { - sb.append("Would you like to put the file "); - sb.append(sourceFiles.get(0).getAbsolutePath()); - sb.append(" to iRODS at "); - sb.append(targetIrodsFileAbsolutePath); - } - - //default icon, custom title - int n = idropGui.showConfirmDialog(sb.toString(), "Confirm a Put to iRODS ", JOptionPane.YES_NO_OPTION); - - - if (n == JOptionPane.YES_OPTION) { - - prosecuteTransfer(sourceFiles, idropGui.getiDropCore().getIrodsAccount().getDefaultStorageResource()); - - // process the drop as a put - - - } - - } - - private void processPhymoveGesture(Transferable transferable, IRODSNode targetNode) { - log.info("process as drop of file list"); - - List sourceFiles; - CollectionAndDataObjectListingEntry targetEntry = (CollectionAndDataObjectListingEntry) targetNode.getUserObject(); - if (targetEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.DATA_OBJECT) { - log.warn("attempt to move a file to a data object, must be a collection"); - idropGui.showMessageFromOperation("unable to move file, the target of the move is not a collection"); - return; - } - - try { - // get the list of files - sourceFiles = (List) transferable.getTransferData(IRODSTreeTransferable.irodsTreeDataFlavor); - } catch (UnsupportedFlavorException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("unsupported flavor getting data from transfer"); - } catch (IOException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("io exception getting data from transfer"); - } - - if (sourceFiles.isEmpty()) { - log.error("no source files in transfer"); - throw new IdropRuntimeException("no source files in transfer"); - } - - String targetFileAbsolutePath = targetEntry.getPathOrName(); - MoveOrCopyiRODSDialog moveIRODSFileOrDirectoryDialog; - if (sourceFiles.size() == 1) { - moveIRODSFileOrDirectoryDialog = new MoveOrCopyiRODSDialog(idropGui, true, targetNode, idropGui.getIrodsTree(), sourceFiles.get(0), targetFileAbsolutePath, false); - } else { - moveIRODSFileOrDirectoryDialog = new MoveOrCopyiRODSDialog(idropGui, true, targetNode, idropGui.getIrodsTree(), sourceFiles, targetFileAbsolutePath, false); - } - - moveIRODSFileOrDirectoryDialog.setLocation((int) (idropGui.getLocation().getX() + idropGui.getWidth() / 2), (int) (idropGui.getLocation().getY() + idropGui.getHeight() / 2)); - moveIRODSFileOrDirectoryDialog.setVisible(true); - - } - - // handle a drop from the local file system - private void processDropOfFileList(Transferable transferable, IRODSNode parent) throws IdropRuntimeException { - - log.info("process as drop of file list"); - - final String sourceResource = idropGui.getiDropCore().getIrodsAccount().getDefaultStorageResource(); - final List sourceFiles; - CollectionAndDataObjectListingEntry putTarget = (CollectionAndDataObjectListingEntry) parent.getUserObject(); - final String targetIrodsFileAbsolutePath = putTarget.getPathOrName(); - - try { - // get the list of files - sourceFiles = (List) transferable.getTransferData(DataFlavor.javaFileListFlavor); - } catch (UnsupportedFlavorException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("unsupported flavor getting data from transfer"); - } catch (IOException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("io exception getting data from transfer"); - } - - if (sourceFiles.isEmpty()) { - log.error("no source files in transfer"); - throw new IdropRuntimeException("no source files in transfer"); - } - - StringBuilder sb = new StringBuilder(); - - if (sourceFiles.size() > 1) { - sb.append("Would you like to put multiple files"); - sb.append(" to iRODS at "); - sb.append(putTarget.getPathOrName()); - } else { - sb.append("Would you like to put the file "); - sb.append(sourceFiles.get(0).getAbsolutePath()); - sb.append(" to iRODS at "); - sb.append(putTarget.getPathOrName()); - } - - //default icon, custom title - int n = idropGui.showConfirmDialog(sb.toString(), "Confirm a Put to iRODS ", JOptionPane.YES_NO_OPTION); - - if (n == JOptionPane.YES_OPTION) { - - // process the drop as a put - prosecuteTransfer(sourceFiles, idropGui.getiDropCore().getIrodsAccount().getDefaultStorageResource()); - - - } - - } - - private void processCopyGesture(Transferable transferable, IRODSNode targetNode) { - log.info("process as drop of file list"); - - List sourceFiles; - CollectionAndDataObjectListingEntry targetEntry = (CollectionAndDataObjectListingEntry) targetNode.getUserObject(); - if (targetEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.DATA_OBJECT) { - log.warn("attempt to copy a file to a data object, must be a collection"); - idropGui.showMessageFromOperation("unable to copy file, the target of the copy is not a collection"); - return; - } - - try { - // get the list of files - sourceFiles = (List) transferable.getTransferData(IRODSTreeTransferable.irodsTreeDataFlavor); - - /* for the source files, default to the resource that was specified at login,this might need to be reconsidered - * but can cause a -321000 no resc error if no default set in irods. - */ - - for (IRODSFile sourceFile : sourceFiles) { - sourceFile.setResource(idropGui.getiDropCore().getIrodsAccount().getDefaultStorageResource()); - } - - } catch (UnsupportedFlavorException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("unsupported flavor getting data from transfer"); - } catch (IOException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("io exception getting data from transfer"); - } - - if (sourceFiles.isEmpty()) { - log.error("no source files in transfer"); - throw new IdropRuntimeException("no source files in transfer"); - } - - String targetFileAbsolutePath = targetEntry.getPathOrName(); - MoveOrCopyiRODSDialog moveIRODSFileOrDirectoryDialog; - if (sourceFiles.size() == 1) { - moveIRODSFileOrDirectoryDialog = new MoveOrCopyiRODSDialog(idropGui, true, targetNode, idropGui.getIrodsTree(), sourceFiles.get(0), targetFileAbsolutePath, true); - } else { - moveIRODSFileOrDirectoryDialog = new MoveOrCopyiRODSDialog(idropGui, true, targetNode, idropGui.getIrodsTree(), sourceFiles, targetFileAbsolutePath,true); - } - - moveIRODSFileOrDirectoryDialog.setLocation((int) (idropGui.getLocation().getX() + idropGui.getWidth() / 2), (int) (idropGui.getLocation().getY() + idropGui.getHeight() / 2)); - moveIRODSFileOrDirectoryDialog.setVisible(true); - } - - protected abstract void prosecuteTransfer(List sourceFiles, String string); - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTreeTransferable.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTreeTransferable.java deleted file mode 100644 index 196b307..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IRODSTreeTransferable.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.irods.jargon.idrop.commons; - -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.io.File; -import java.io.IOException; -import java.util.List; -import org.slf4j.LoggerFactory; - -/** - * Transferrale coming from the swing tree depicting a remote iRODS file system - * @author Mike Conway - DICE (www.irods.org) - */ -public class IRODSTreeTransferable implements Transferable { - - private List files; - private IRODSTree stagingViewTree; - public static org.slf4j.Logger log = LoggerFactory.getLogger(IRODSTreeTransferable.class); - public static DataFlavor irodsTreeDataFlavor = null; - - static { - try { - - irodsTreeDataFlavor = new DataFlavor(org.irods.jargon.idrop.commons.IRODSTreeTransferable.class, - "Local phymove"); - } catch (Exception e) { - log.error("error creating transferrable", e); - } - } - - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("staging view tree transferrable:"); - if (files == null) { - sb.append("\n files is null!"); - } - - for (File file : files) { - sb.append("\n file:"); - sb.append(file.getAbsolutePath()); - } - - return sb.toString(); - - } - - IRODSTreeTransferable(final List transferFiles, final IRODSTree stagingViewTree) { - - if (transferFiles == null) { - throw new IllegalArgumentException("null files"); - } - - if (stagingViewTree == null) { - throw new IllegalArgumentException("null stagingViewTree"); - } - this.files = transferFiles; - this.stagingViewTree = stagingViewTree; - - } - - @Override - public DataFlavor[] getTransferDataFlavors() { - log.debug("getting data flavors from idrop series (will be a list with one iros file for file or collection"); - return new DataFlavor[]{DataFlavor.javaFileListFlavor, irodsTreeDataFlavor}; - } - - @Override - public boolean isDataFlavorSupported(DataFlavor flavor) { - return (flavor.equals(DataFlavor.javaFileListFlavor) || flavor.equals(irodsTreeDataFlavor)); - } - - @Override - public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { - log.info("getting files from transfer data:{}", files); - if (!isDataFlavorSupported(flavor)) { - throw new UnsupportedFlavorException(flavor); - } - - return files; - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropClient.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropClient.java deleted file mode 100644 index 5a96632..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.irods.jargon.idrop.commons; - -import java.awt.Point; -import javax.swing.TransferHandler; -import org.irods.jargon.core.exception.JargonException; - -/** - * - * @author lisa - */ -public interface IdropClient { - - public IRODSTree getIrodsTree(); - - public iDropCoreCommon getiDropCore(); - - public int showConfirmDialog(String toString, String string, int YES_NO_OPTION); - - public void showMessageFromOperation(String string); - - public void showIdropException(JargonException ex); - - public void showIdropException(Exception ex); - - public Point getLocation(); - - public int getWidth(); - - - public int getHeight(); - - public void showIdropException(IdropException ex); - - public LocalFileTree getFileTree(); - - public IRODSTreeTransferHandler getIRODSTreeTransferHandler(String modelType); - - public LocalTreeTransferHandler getLocalTreeTransferHandler(); - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropException.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropException.java deleted file mode 100644 index 4d551b2..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropException.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.irods.jargon.idrop.commons; - -/** - * @author Mike Conway - DICE (www.irods.org) - */ -public class IdropException extends Exception { - - public IdropException(Throwable cause) { - super(cause); - } - - public IdropException(String message, Throwable cause) { - super(message, cause); - } - - public IdropException(String message) { - super(message); - } - - public IdropException() { - } - - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropRuntimeException.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropRuntimeException.java deleted file mode 100644 index 5eb9360..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/IdropRuntimeException.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.irods.jargon.idrop.commons; - -/** - * @author Mike Conway - DICE (www.irods.org) - */ -public class IdropRuntimeException extends RuntimeException { - - public IdropRuntimeException(Throwable cause) { - super(cause); - } - - public IdropRuntimeException(String message, Throwable cause) { - super(message, cause); - } - - public IdropRuntimeException(String message) { - super(message); - } - - public IdropRuntimeException() { - } - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileNode.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileNode.java deleted file mode 100644 index b141cd3..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileNode.java +++ /dev/null @@ -1,114 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.io.File; -import java.util.Collections; -import java.util.Comparator; - -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.MutableTreeNode; - -import org.slf4j.LoggerFactory; - -/** - * (New) tree node for local file tree - * - * @author Mike Conway - DICE (www.irods.org) - */ -public class LocalFileNode extends DefaultMutableTreeNode { - - private boolean cached = false; - - public boolean isCached() { - return cached; - } - - public static org.slf4j.Logger log = LoggerFactory.getLogger(LocalFileNode.class); - - public LocalFileNode(final File file) { - super(file); - } - - @Override - public boolean isLeaf() { - File thisFile = (File) this.getUserObject(); - return thisFile.isFile(); - } - - public void lazyLoadOfChildrenOfThisNode() { - - if (cached) { - log.debug("already cached"); - return; - } - - log.debug("lazily loading children of:{}", this); - File parentFile = (File) this.getUserObject(); - File[] childFiles = parentFile.listFiles(); - - if (childFiles != null) { - for (File file : childFiles) { - this.insert(new LocalFileNode(file), this.getChildCount()); - } - } - - cached = true; - - } - - @Override - public void insert(MutableTreeNode arg0, int arg1) { - super.insert(arg0, arg1); - //Collections.sort(this.children, nodeComparator); - } - - protected static Comparator nodeComparator = new Comparator() { - @Override - public int compare(Object o1, Object o2) { - return o1.toString().compareToIgnoreCase(o2.toString()); - } - - @Override - public boolean equals(Object obj) { - return false; - } - }; - - public void forceReloadOfChildrenOfThisNode() { - cached = false; - this.removeAllChildren(); - } - - @Override - public String toString() { - File localFile = (File) this.getUserObject(); - String returnedString = ""; - - if (localFile.getName().equals("")) { - returnedString = "/"; - } else { - returnedString = localFile.getName(); - } - // log.debug("name for node is: {}", returnedString); - return returnedString; - } - - @Override - public int hashCode() { - return this.getUserObject().hashCode(); - } - - @Override - public boolean equals(Object obj) { - - if (!(obj instanceof LocalFileNode)) { - return false; - } - - LocalFileNode comparableAsNode = (LocalFileNode) obj; - - File thisFile = (File) getUserObject(); - File thatFile = (File) comparableAsNode.getUserObject(); - - return thisFile.getAbsolutePath().equals(thatFile.getAbsolutePath()); - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileSystemModel.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileSystemModel.java deleted file mode 100644 index dec9ec1..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileSystemModel.java +++ /dev/null @@ -1,21 +0,0 @@ - -package org.irods.jargon.idrop.commons; - -import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.DefaultTreeModel; - -/** - * (NEW) Implementation of the DefaultTreeModel for the local file system. - * @author Mike Conway - DICE (www.irods.org) - */ -public class LocalFileSystemModel extends DefaultTreeModel { - - public LocalFileSystemModel(DefaultMutableTreeNode node) { - super(node); - // pre-expand the child nodes of the root - LocalFileNode localFileNode = (LocalFileNode) node; - localFileNode.lazyLoadOfChildrenOfThisNode(); - } - - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileTree.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileTree.java deleted file mode 100644 index 44a2476..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalFileTree.java +++ /dev/null @@ -1,328 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.irods.jargon.idrop.commons; - -import java.awt.Color; -import java.awt.Rectangle; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.io.File; -import java.util.Enumeration; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JPopupMenu; -import javax.swing.JTree; -import javax.swing.event.TreeExpansionEvent; -import javax.swing.event.TreeWillExpandListener; -import javax.swing.tree.DefaultTreeCellRenderer; -import javax.swing.tree.ExpandVetoException; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreePath; -import org.slf4j.LoggerFactory; - -/** - * JTree for viewing local file system, includes DnD support from StagingViewTree. - * @author Mike Conway - DICE (www.irods.org) - */ -public class LocalFileTree extends JTree implements TreeWillExpandListener { - - public static org.slf4j.Logger log = LoggerFactory.getLogger(LocalFileTree.class); - private IdropClient idropParentGui = null; - protected JPopupMenu m_popup = null; - protected Action m_action; - protected TreePath m_clickedPath; - protected LocalFileTree thisTree; - private int highlightedRow = -1; - private Rectangle dirtyRegion = null; - private Color highlightColor = new Color(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue(), 100); - - 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; - } - - - public LocalFileTree(TreeModel newModel, IdropClient idropParentGui) { - super(newModel); - this.idropParentGui = idropParentGui; - setDragEnabled(true); - //this.setTransferHandler(new LocalTreeTransferHandler(idropParentGui)); - setTransferHandler(idropParentGui.getLocalTreeTransferHandler()); - this.setCellRenderer(new DefaultTreeCellRenderer()); - setUpTreeMenu(); - setDropMode(javax.swing.DropMode.ON); - - } - - /** - * Utility method takes an Enumeration of tree paths, such as would be returned - * by calling getExpandedDescendants() on the local file tree. This method will - * go through the tree paths and expand the nodes. Note that the nodes are lazily computed, so - * this method triggers that lazy access. - * @param currentPaths Enumeration with the previously expanded nodes - * @throws IdropException - */ - public void expandTreeNodesBasedOnListOfPreviouslyExpandedNodes(final Enumeration currentPaths) throws IdropException { - - log.info("expandTreeNodes()"); - - if (currentPaths == null) { - throw new IdropException("null currentPaths"); - } - - TreePath treePath = null; - while (currentPaths.hasMoreElements()) { - treePath = currentPaths.nextElement(); - log.debug("expanding treePath: {}", treePath); - this.findNodeInTreeGivenATreePathAndExpand(treePath); - } - - } - - /** - * Given a treePath, find that path in the tree model. In searching, the lazy loading - * behavior of the child nodes is triggered and the tree is expanded to the node. - * @param treePath TreePath that should be looked up in the tree. - * @return {@link LocalFileNode} that is the treeNode at the given path. - * @throws IdropException - */ - private LocalFileNode findNodeInTreeGivenATreePathAndExpand(final TreePath treePath) throws IdropException { - - if (treePath == null) { - throw new IdropException("treePath is null"); - } - - log.debug("findNodeInTreeGivenATreePath:{}", treePath); - LocalFileNode currentTreeNode = (LocalFileNode) this.getModel().getRoot(); - - TreePath intermediateTreePath = new TreePath(currentTreeNode); - boolean rootNodeSkippedInPathElement = false; - - // walk down the treeModel (which had been refreshed), and load and expand each path - for (Object pathElement : treePath.getPath()) { - if (!rootNodeSkippedInPathElement) { - rootNodeSkippedInPathElement = true; - continue; - } - - currentTreeNode = matchTreePathToANodeAndExpandLazyChildren(currentTreeNode, pathElement); - - // if null is returned, this means I did not find a matching node, this is ignored - if (currentTreeNode == null) { - log.info("no matching node found for {}, stopping search for this tree path", pathElement); - return null; - } else { - - // found a node, expand the tree down to this node - intermediateTreePath = intermediateTreePath.pathByAddingChild(currentTreeNode); - log.debug("found a node, expanding down to:{}", intermediateTreePath); - this.expandPath(intermediateTreePath); - } - } - - return currentTreeNode; - - } - - /** - * Given a nodeThatWasDropTargetAsFile node in the tree, search the children for the given path - * @param localFileNode {@link LocalFileNode} that is the nodeThatWasDropTargetAsFile node that should contain a child node - * with the given path - * @param pathElementIAmSearchingFor Object that is the TreePath of the child I am - * searching for within the given nodeThatWasDropTargetAsFile. - * @return {@link LocalFileNode} that is the matching child node, or null if no matching child node was discovered. - * @throws IdropException - */ - private LocalFileNode matchTreePathToANodeAndExpandLazyChildren(final LocalFileNode localFileNode, final Object pathElementIAmSearchingFor) throws IdropException { - - if (localFileNode == null) { - throw new IdropException("localFileNode is null"); - } - - LocalFileNode matchedChildNode = null; - - // trigger loading of children so I can search - localFileNode.lazyLoadOfChildrenOfThisNode(); - - LocalFileNode childNode = null; - Enumeration childNodeEnumeration = localFileNode.children(); - - while (childNodeEnumeration.hasMoreElements()) { - childNode = childNodeEnumeration.nextElement(); - if (childNode.equals(pathElementIAmSearchingFor)) { - log.debug("found a matching node:{}", childNode); - matchedChildNode = childNode; - break; - } - } - - // either I'm matched, or I didn't find the child (in which case null is returned). - return matchedChildNode; - - } - - private void setUpTreeMenu() { - this.thisTree = this; - m_popup = new JPopupMenu(); - m_action = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - if (m_clickedPath == null) { - return; - } - - if (thisTree.isExpanded(m_clickedPath)) { - thisTree.collapsePath(m_clickedPath); - } else { - thisTree.expandPath(m_clickedPath); - } - } - }; - - m_popup.add(m_action); - - Action newAction = new AbstractAction("New Folder") { - - @Override - public void actionPerformed(ActionEvent e) { - - java.awt.EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - - log.info("adding new node"); - LocalFileNode parentNode = (LocalFileNode) m_clickedPath.getLastPathComponent(); - File parentFile = (File) parentNode.getUserObject(); - - NewLocalDirectoryDialog newLocalDirectoryDialog = new NewLocalDirectoryDialog(idropParentGui, true, parentFile.getAbsolutePath(), thisTree, parentNode); - newLocalDirectoryDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2)); - newLocalDirectoryDialog.setVisible(true); - - } - }); - // thisTree.repaint(); - } - }; - - m_popup.add(newAction); - - m_popup.addSeparator(); - - Action a1 = new AbstractAction("Delete") { - - @Override - public void actionPerformed(ActionEvent e) { - log.info("deleting local node node"); - LocalFileNode parentNode = (LocalFileNode) m_clickedPath.getLastPathComponent(); - File parentFile = (File) parentNode.getUserObject(); - - DeleteLocalFileDialog deleteLocalFileDialog = new DeleteLocalFileDialog(idropParentGui, true, parentFile.getAbsolutePath(), thisTree, parentNode); - deleteLocalFileDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2)); - deleteLocalFileDialog.setVisible(true); - - } - }; - m_popup.add(a1); - - - Action a2 = new AbstractAction("Rename") { - - @Override - public void actionPerformed(ActionEvent e) { - log.info("renaming node"); - - LocalFileNode parentNode = (LocalFileNode) m_clickedPath.getLastPathComponent(); - File parentFile = (File) parentNode.getUserObject(); - - RenameLocalDirectoryDialog renameLocalDirectoryDialog = new RenameLocalDirectoryDialog(idropParentGui, true, parentFile.getAbsolutePath(), thisTree, parentNode); - renameLocalDirectoryDialog.setLocation((int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2)); - renameLocalDirectoryDialog.setVisible(true); - - } - }; - m_popup.add(a2); - thisTree.add(m_popup); - thisTree.addMouseListener(new PopupTrigger()); - thisTree.addTreeWillExpandListener(thisTree); - - } - - /** - * Tree expansion is used to lazily load children of the selected nodeThatWasDropTargetAsFile - * @param event - * @throws ExpandVetoException - */ - @Override - public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException { - log.debug("tree expansion event:{}", event); - LocalFileNode expandingNode = (LocalFileNode) event.getPath().getLastPathComponent(); - expandingNode.lazyLoadOfChildrenOfThisNode(); - } - - @Override - public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException { - } - - class PopupTrigger extends MouseAdapter { - - @Override - public void mouseReleased(MouseEvent e) { - if (e.isPopupTrigger()) { - int x = e.getX(); - int y = e.getY(); - TreePath path = thisTree.getPathForLocation(x, y); - if (path != null) { - if (thisTree.isExpanded(path)) { - m_action.putValue(Action.NAME, "Collapse"); - } else { - m_action.putValue(Action.NAME, "Expand"); - } - m_popup.show(thisTree, x, y); - m_clickedPath = path; - } - } - } - - @Override - public void mousePressed(MouseEvent e) { - if (e.isPopupTrigger()) { - int x = e.getX(); - int y = e.getY(); - TreePath path = thisTree.getPathForLocation(x, y); - if (path != null) { - if (thisTree.isExpanded(path)) { - m_action.putValue(Action.NAME, "Collapse"); - } else { - m_action.putValue(Action.NAME, "Expand"); - } - m_popup.show(thisTree, x, y); - m_clickedPath = path; - } - } - } - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalTreeTransferHandler.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalTreeTransferHandler.java deleted file mode 100644 index 4184dd8..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/LocalTreeTransferHandler.java +++ /dev/null @@ -1,209 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.awt.Graphics; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.datatransfer.Clipboard; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.Transferable; -import java.awt.datatransfer.UnsupportedFlavorException; -import java.awt.event.InputEvent; -import java.io.File; -import java.io.IOException; -import java.util.List; -import javax.swing.JComponent; -import javax.swing.JOptionPane; -import javax.swing.JTree; -import javax.swing.TransferHandler; -import javax.swing.tree.TreePath; -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.io.IRODSFile;import org.irods.jargon.transfer.engine.TransferManager; -; -import org.slf4j.LoggerFactory; - -/** - * A transfer handler for the local file tree - * @author Mike Conway - DICE (www.irods.org) - */ -public abstract class LocalTreeTransferHandler extends TransferHandler { - - public static org.slf4j.Logger log = LoggerFactory.getLogger(LocalTreeTransferHandler.class); - public final IdropClient idropGui; - - @Override - public boolean canImport(final TransferSupport support) { - Point location = support.getDropLocation().getDropPoint(); - LocalFileTree tree = (LocalFileTree) support.getComponent(); - - int closestRow = idropGui.getFileTree().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()); - - for (DataFlavor flavor : support.getDataFlavors()) { - if (flavor.equals(DataFlavor.javaFileListFlavor)) { - log.debug("found file list flavor, will import"); - return true; - } else if (flavor.getMimeType().equals("application/x-java-jvm-local-objectref; class=javax.swing.tree.TreeSelectionModel")) { - log.debug("found file list flavor, will import"); - return true; - } - } - - log.debug("cannot import"); - return false; - } - - @Override - public void exportAsDrag(final JComponent jc, final InputEvent ie, final int i) { - super.exportAsDrag(jc, ie, i); - } - - @Override - public void exportToClipboard(final JComponent jc, final Clipboard clpbrd, final int i) throws IllegalStateException { - super.exportToClipboard(jc, clpbrd, i); - } - - @Override - public boolean importData(final TransferSupport ts) { - log.info("importData event:{}", ts); - Point pt = ts.getDropLocation().getDropPoint(); - JTree tree = (JTree) ts.getComponent(); - TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y); - LocalFileNode nodeThatWasDropTarget = (LocalFileNode) parentpath.getLastPathComponent(); - final File nodeThatWasDropTargetAsFile = (File) nodeThatWasDropTarget.getUserObject(); - log.info("local file node is: {}", nodeThatWasDropTargetAsFile); - LocalFileSystemModel fileSystemModel = (LocalFileSystemModel) tree.getModel(); - - Transferable transferable = ts.getTransferable(); - - DataFlavor[] transferrableFlavors = transferable.getTransferDataFlavors(); - - boolean imported = false; - - for (DataFlavor flavor : transferrableFlavors) { - log.debug("flavor mime type:{}", flavor.getMimeType()); - if (flavor.isFlavorJavaFileListType()) { - log.info("process drop as file list"); - - processDropAfterAcceptingDataFlavor(transferable, nodeThatWasDropTargetAsFile); - imported = true; - break; - } else if (flavor.getMimeType().equals("application/x-java-jvm-local-objectref; class=javax.swing.tree.TreeSelectionModel")) { - log.info("process drop as serialized object"); - processDropFromSerializedObjectType(transferable, nodeThatWasDropTargetAsFile); - imported = true; - break; - } else { - log.debug("flavor not processed: {}", flavor); - } - } - return imported; - } - - private void processDropAfterAcceptingDataFlavor(final Transferable transferable, final File nodeThatWasDropTargetAsFile) throws IdropRuntimeException { - - final List sourceFiles; - - try { - // get the list of files - sourceFiles = (List) transferable.getTransferData(DataFlavor.javaFileListFlavor); - } catch (UnsupportedFlavorException ex) { - throw new IdropRuntimeException("unsupported flavor getting data from transfer"); - } catch (IOException ex) { - throw new IdropRuntimeException("io exception getting data from transfer"); - } - - if (sourceFiles.isEmpty()) { - log.error("no source files in transfer"); - throw new IdropRuntimeException("no source files in transfer"); - } - - final String tempTargetLocalFileAbsolutePath; - - if (nodeThatWasDropTargetAsFile.isDirectory()) { - tempTargetLocalFileAbsolutePath = nodeThatWasDropTargetAsFile.getAbsolutePath(); - } else { - log.info("drop target was a file, use the parent collection name for the transfer"); - tempTargetLocalFileAbsolutePath = nodeThatWasDropTargetAsFile.getParent(); - } - - StringBuilder sb = new StringBuilder(); - - if (sourceFiles.size() == 1) { - sb.append("Would you like to copy the remote file "); - sb.append(sourceFiles.get(0).getAbsolutePath()); - sb.append(" to "); - sb.append(tempTargetLocalFileAbsolutePath); - } else { - sb.append("Would you like to copy multiple files to "); - sb.append(tempTargetLocalFileAbsolutePath); - - } - - //default icon, custom title - int n = idropGui.showConfirmDialog(sb.toString(), "Confirm a Get ", JOptionPane.YES_NO_OPTION); - - if (n == JOptionPane.YES_OPTION) { - - prosecuteTransfer(sourceFiles, idropGui.getiDropCore().getTransferManager(), idropGui.getiDropCore().getIrodsAccount()); - - // process the drop as a get - - } - } - - private void processDropFromSerializedObjectType(final Transferable transferable, final File parent) { - log.debug("processing as a drop of a serialized object"); - } - - public LocalTreeTransferHandler(final IdropClient idropGui) { - super("selectionModel"); - if (idropGui == null) { - throw new IllegalArgumentException("null idropGui"); - } - this.idropGui = idropGui; - } - - /** - * We support both copy and move actions. - */ - @Override - public int getSourceActions(final JComponent c) { - return TransferHandler.COPY_OR_MOVE; - } - - @Override - protected void exportDone(final JComponent jc, final Transferable t, final int i) { - super.exportDone(jc, t, i); - } - - - protected abstract void prosecuteTransfer(List sourceFiles, TransferManager transferManager, IRODSAccount irodsAccount); - - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/MoveOrCopyiRODSDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/MoveOrCopyiRODSDialog.form deleted file mode 100644 index 41eb651..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/MoveOrCopyiRODSDialog.form +++ /dev/null @@ -1,216 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/MoveOrCopyiRODSDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/MoveOrCopyiRODSDialog.java deleted file mode 100644 index 08fedc3..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/MoveOrCopyiRODSDialog.java +++ /dev/null @@ -1,396 +0,0 @@ - -/* - * ReparentIRODSDirectoryDialog.java - * - * Created on Sep 3, 2010, 9:52:12 AM - */ -package org.irods.jargon.idrop.commons; - -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -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.exception.JargonException; -import org.irods.jargon.core.exception.JargonFileOrCollAlreadyExistsException; -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.slf4j.LoggerFactory; - -/** - * Dialog to confirm and process the move of a file to a new iRODS location (phymove gesture) - * @author mikeconway - */ -public class MoveOrCopyiRODSDialog extends javax.swing.JDialog { - - private final IdropClient idrop; - private final IRODSTree stagingViewTree; - private final IRODSNode targetNode; - private final String targetAbsolutePath; - private final IRODSFile sourceFile; - private final List sourceFiles; - public static org.slf4j.Logger log = LoggerFactory.getLogger(MoveOrCopyiRODSDialog.class); - private final boolean isCopy; - - public MoveOrCopyiRODSDialog(final IdropClient parent, final boolean modal, final IRODSNode targetNode, final IRODSTree stagingViewTree, final IRODSFile sourceFile, final String targetAbsolutePath, final boolean isCopy) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.targetNode = targetNode; - this.stagingViewTree = stagingViewTree; - this.targetAbsolutePath = targetAbsolutePath; - this.sourceFile = sourceFile; - this.sourceFiles = null; - this.isCopy = isCopy; - initializeDialog(); - } - - public MoveOrCopyiRODSDialog(final IdropClient parent, final boolean modal, final IRODSNode targetNode, final IRODSTree stagingViewTree, final List sourceFiles, final String targetAbsolutePath, final boolean isCopy) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.targetNode = targetNode; - this.stagingViewTree = stagingViewTree; - this.targetAbsolutePath = targetAbsolutePath; - this.sourceFile = null; - this.sourceFiles = sourceFiles; - this.isCopy = isCopy; - initializeDialog(); - } - - private void initializeDialog() { - initComponents(); - if (isCopy) { - lblTitle.setText("Do you wish to copy the iRODS file to the new iRODS location?"); - } else { - lblTitle.setText("Do you wish to move the iRODS file to the new iRODS location?"); - } - txtNewLocation.setText(targetAbsolutePath); - - if (sourceFile != null) { - this.txtCurrentParent.setText(sourceFile.getAbsolutePath()); - } else { - this.txtCurrentParent.setText("multiple files"); - } - - registerKeystrokeListener(); - } - - /** 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") - // //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(); - lblNewDiretoryName = new java.awt.Label(); - scrollCurrentParent = new javax.swing.JScrollPane(); - txtCurrentParent = new javax.swing.JTextArea(); - scrollNewLocation = new javax.swing.JScrollPane(); - txtNewLocation = new javax.swing.JTextArea(); - pnlBottom = new javax.swing.JPanel(); - btnCancel = new javax.swing.JButton(); - btnOK = new javax.swing.JButton(); - - setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("iRODS Move File - Confirmation Dialog"); - setName("NewParentDialog"); // NOI18N - - lblTitle.setText("Confirm the move of the iRODS File to a new collection"); - - lblCurrentParent.setText("Current location:"); - - lblNewDiretoryName.setText("New location:"); - - txtCurrentParent.setColumns(20); - txtCurrentParent.setEditable(false); - txtCurrentParent.setRows(5); - txtCurrentParent.setWrapStyleWord(true); - txtCurrentParent.setFocusable(false); - scrollCurrentParent.setViewportView(txtCurrentParent); - - txtNewLocation.setColumns(20); - txtNewLocation.setEditable(false); - txtNewLocation.setRows(5); - txtNewLocation.setWrapStyleWord(true); - txtNewLocation.setFocusable(false); - scrollNewLocation.setViewportView(txtNewLocation); - - org.jdesktop.layout.GroupLayout pnlCurrentParentLayout = new org.jdesktop.layout.GroupLayout(pnlCurrentParent); - pnlCurrentParent.setLayout(pnlCurrentParentLayout); - pnlCurrentParentLayout.setHorizontalGroup( - pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(44, 44, 44) - .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(20, 20, 20) - .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(scrollNewLocation, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE)) - .add(pnlCurrentParentLayout.createSequentialGroup() - .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(scrollCurrentParent, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 531, Short.MAX_VALUE))) - .addContainerGap()) - ); - pnlCurrentParentLayout.setVerticalGroup( - pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(51, 51, 51) - .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(lblNewDiretoryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(scrollNewLocation, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(21, 21, 21)) - ); - - lblNewDiretoryName.getAccessibleContext().setAccessibleName("New directory name:"); - - btnCancel.setText("Cancel"); - btnCancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - - org.jdesktop.layout.GroupLayout pnlBottomLayout = new org.jdesktop.layout.GroupLayout(pnlBottom); - pnlBottom.setLayout(pnlBottomLayout); - pnlBottomLayout.setHorizontalGroup( - pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlBottomLayout.createSequentialGroup() - .add(451, 451, 451) - .add(btnCancel) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(btnOK) - .add(4, 4, 4)) - ); - pnlBottomLayout.setVerticalGroup( - pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlBottomLayout.createSequentialGroup() - .add(5, 5, 5) - .add(pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(btnCancel) - .add(btnOK))) - ); - - org.jdesktop.layout.GroupLayout pnlFolderDataLayout = new org.jdesktop.layout.GroupLayout(pnlFolderData); - pnlFolderData.setLayout(pnlFolderDataLayout); - pnlFolderDataLayout.setHorizontalGroup( - pnlFolderDataLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlFolderDataLayout.createSequentialGroup() - .add(pnlCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(61, Short.MAX_VALUE)) - .add(org.jdesktop.layout.GroupLayout.TRAILING, pnlFolderDataLayout.createSequentialGroup() - .addContainerGap(134, Short.MAX_VALUE) - .add(pnlBottom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap()) - ); - pnlFolderDataLayout.setVerticalGroup( - pnlFolderDataLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlFolderDataLayout.createSequentialGroup() - .add(pnlCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(pnlBottom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(lblTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 622, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(pnlFolderData, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(lblTitle) - .add(pnlFolderData, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - ); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - processMoveOrCopy(); - }//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - 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.JScrollPane scrollNewLocation; - private javax.swing.JTextArea txtCurrentParent; - private javax.swing.JTextArea txtNewLocation; - // End of variables declaration//GEN-END:variables - - private void processMoveOrCopy() { - // add the new folder to irods, add to the tree, and scroll the tree into view - final MoveOrCopyiRODSDialog thisDialog = this; - log.info("processing move or copy"); - java.awt.EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - try { - log.info("procssing move of a file in iRODS tree"); - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - - DataTransferOperations dataTransferOperations; - try { - dataTransferOperations = idrop.getiDropCore().getIRODSAccessObjectFactory().getDataTransferOperations(idrop.getiDropCore().getIrodsAccount()); - } catch (Exception e) { - idrop.getiDropCore().closeIRODSConnection(idrop.getiDropCore().getIrodsAccount()); - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - throw new IdropRuntimeException(e); - } - - List filesThatHadOverwriteError = new ArrayList(); - - if (sourceFile != null) { - log.info("processing the move/copy for one file:{}", sourceFile); - try { - if (isCopy) { - processACopyOfAnIndividualFile(dataTransferOperations, sourceFile, targetAbsolutePath); - } else { - processAMoveOfAnIndividualFile(dataTransferOperations, sourceFile, targetAbsolutePath); - } - } catch (JargonFileOrCollAlreadyExistsException ex) { - Logger.getLogger(MoveOrCopyiRODSDialog.class.getName()).log(Level.SEVERE, null, ex); - filesThatHadOverwriteError.add(sourceFile); - } catch (JargonException je) { - if (je.getMessage().indexOf("-834000") > -1 || je.getMessage().indexOf("-833000") > -1) { - filesThatHadOverwriteError.add(sourceFile); - } else { - throw new IdropException(je); - } - } - } else if (sourceFiles != null) { - log.info("processing move/copy of multiple files"); - for (IRODSFile sourceFileEntry : sourceFiles) { - try { - if (isCopy) { - processACopyOfAnIndividualFile(dataTransferOperations, sourceFile, targetAbsolutePath); - } else { - processAMoveOfAnIndividualFile(dataTransferOperations, sourceFile, targetAbsolutePath); - } - } catch (JargonFileOrCollAlreadyExistsException ex) { - // FIXME: fix in jargon core to differentiate! - Logger.getLogger(MoveOrCopyiRODSDialog.class.getName()).log(Level.SEVERE, null, ex); - filesThatHadOverwriteError.add(sourceFile); - } catch (JargonException je) { - if (je.getMessage().indexOf("-834000") > -1 || je.getMessage().indexOf("-833000") > -1) { - filesThatHadOverwriteError.add(sourceFile); - } else { - throw new IdropException(je); - } - } - } - } - - log.debug("move done"); - IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel(); - targetNode.forceReloadOfChildrenOfThisNode(); - irodsFileSystemModel.reload(targetNode); - if (filesThatHadOverwriteError.isEmpty()) { - idrop.showMessageFromOperation("irods move/copy processed"); - } else { - idrop.showMessageFromOperation("irods move/copy processed, some files were not moved as files of the same name already existed"); - } - thisDialog.dispose(); - - } catch (IdropException ex) { - Logger.getLogger(IRODSTree.class.getName()).log(Level.SEVERE, null, ex); - idrop.showIdropException(ex); - return; - } finally { - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - idrop.getiDropCore().closeIRODSConnection(idrop.getiDropCore().getIrodsAccount()); - } - } - }); - } - - private void processAMoveOfAnIndividualFile(final DataTransferOperations dataTransferOperations, final IRODSFile sourceFile, final String targetAbsolutePath) throws JargonFileOrCollAlreadyExistsException, IdropException { - - try { - if (sourceFile.isFile()) { - log.debug("source file is a file, do a move"); - dataTransferOperations.move(sourceFile.getAbsolutePath(), targetAbsolutePath); - } else { - log.debug("source file is a collection, reparent it"); - dataTransferOperations.moveTheSourceCollectionUnderneathTheTargetCollectionUsingSourceParentCollectionName(sourceFile.getAbsolutePath(), targetAbsolutePath); - } - } catch (JargonFileOrCollAlreadyExistsException fcae) { - throw fcae; - } catch (JargonException je) { - throw new IdropException(je); - } - - TreePath sourceNodePath = TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, sourceFile.getAbsolutePath()); - IRODSNode sourceNode = (IRODSNode) sourceNodePath.getLastPathComponent(); - IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel(); - irodsFileSystemModel.removeNodeFromParent(sourceNode); - - } - - private void processACopyOfAnIndividualFile(DataTransferOperations dataTransferOperations, IRODSFile sourceFile, String targetAbsolutePath) throws IdropException { - try { - idrop.getiDropCore().getTransferManager().enqueueACopy(sourceFile.getAbsolutePath(), sourceFile.getResource(), targetAbsolutePath, idrop.getiDropCore().getIrodsAccount()); - } catch (JargonException ex) { - Logger.getLogger(MoveOrCopyiRODSDialog.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("unable to copy file due to JargonException", ex); - } - } - - /** - * 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) { - processMoveOrCopy(); - } - }; - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewIRODSDirectoryDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewIRODSDirectoryDialog.form deleted file mode 100644 index c9a2786..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewIRODSDirectoryDialog.form +++ /dev/null @@ -1,158 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewIRODSDirectoryDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewIRODSDirectoryDialog.java deleted file mode 100644 index 22d6615..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewIRODSDirectoryDialog.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * NewIRODSDirectoryDialog.java - * - * Created on Sep 3, 2010, 9:52:12 AM - */ -package org.irods.jargon.idrop.commons; - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.slf4j.LoggerFactory; - -/** - * Dialog to gather a new directory name - * @author mikeconway - */ -public class NewIRODSDirectoryDialog extends javax.swing.JDialog { - - private final IdropClient idrop; - private String parentDirectory = ""; - private final IRODSTree stagingViewTree; - private final IRODSNode parentNode; - public static org.slf4j.Logger log = LoggerFactory.getLogger(NewIRODSDirectoryDialog.class); - - public String getParentDirectory() { - return parentDirectory; - } - - public void setParentDirectory(String parentDirectory) { - this.parentDirectory = parentDirectory; - } - - /** Creates new form NewIRODSDirectoryDialog */ - public NewIRODSDirectoryDialog(final IdropClient parent, final boolean modal, final String parentDirectory, final IRODSTree stagingViewTree, final IRODSNode parentNode) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.parentDirectory = parentDirectory; - this.stagingViewTree = stagingViewTree; - this.parentNode = parentNode; - initComponents(); - txtAreaCurrentParent.setText(this.parentDirectory); - registerKeystrokeListener(); - - } - - /** 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") - // //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() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - pnlBottom.add(btnCancel); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - pnlBottom.add(btnOK); - - getContentPane().add(pnlBottom, java.awt.BorderLayout.SOUTH); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - processNew(); - }//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - 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//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); - idrop.showMessageFromOperation("please enter a new folder name"); - return; - } - - final NewIRODSDirectoryDialog thisDialog = this; - - java.awt.EventQueue.invokeLater(new Runnable() { - - @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()); - - StringBuilder sb = new StringBuilder(); - sb.append(parentDirectory); - sb.append('/'); - sb.append(txtNewFolder.getText()); - String newDirPath = sb.toString(); - - boolean created = irodsFileService.createNewFolder(newDirPath); - - IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) stagingViewTree.getModel(); - - if (!created) { - log.info("could not create new folder in:{}", newDirPath); - idrop.showMessageFromOperation("directory could not be created"); - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - - return; - } - - // directory created, add to tree and show as first node - CollectionAndDataObjectListingEntry entry = new CollectionAndDataObjectListingEntry(); - 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); - log.info("inserting node at 0"); - //parentNode.insertChildAt(0, newNode); - if (parentNode.isCached()) { - irodsFileSystemModel.insertNodeInto(newNode, parentNode, 0); - } else { - parentNode.forceReloadOfChildrenOfThisNode(); - irodsFileSystemModel.reload(parentNode); - stagingViewTree.expandPath(TreeUtils.buildTreePathForIrodsAbsolutePath(stagingViewTree, entry.getParentPath())); - } - - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - idrop.showMessageFromOperation("new folder created"); - - } - catch (IdropException ex) { - Logger.getLogger(NewIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex); - idrop.showIdropException(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); - Action enterAction = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - processNew(); - } - }; - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewLocalDirectoryDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewLocalDirectoryDialog.form deleted file mode 100644 index c9a2786..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewLocalDirectoryDialog.form +++ /dev/null @@ -1,158 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewLocalDirectoryDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewLocalDirectoryDialog.java deleted file mode 100644 index eb58866..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/NewLocalDirectoryDialog.java +++ /dev/null @@ -1,256 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.io.File; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.tree.TreePath; -import org.slf4j.LoggerFactory; - -/** - * Dialog to create a new local directory in the local file tree - * @author mikeconway - */ -public class NewLocalDirectoryDialog extends javax.swing.JDialog { - - private final IdropClient idrop; - private String parentDirectory = ""; - private final LocalFileTree localFileTree; - private final LocalFileNode parentNode; - public static org.slf4j.Logger log = LoggerFactory.getLogger(NewLocalDirectoryDialog.class); - - public String getParentDirectory() { - return parentDirectory; - } - - public void setParentDirectory(String parentDirectory) { - this.parentDirectory = parentDirectory; - } - - /** Creates new form NewIRODSDirectoryDialog */ - public NewLocalDirectoryDialog(final IdropClient parent, final boolean modal, final String parentDirectory, final LocalFileTree localFileTree, final LocalFileNode parentNode) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.parentDirectory = parentDirectory; - this.localFileTree = localFileTree; - this.parentNode = parentNode; - initComponents(); - txtAreaCurrentParent.setText(this.parentDirectory); - registerKeystrokeListener(); - - } - - /** 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") - // //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(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - pnlBottom.add(btnCancel); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - pnlBottom.add(btnOK); - - getContentPane().add(pnlBottom, java.awt.BorderLayout.SOUTH); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - processNew(); - }//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - 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//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); - idrop.showMessageFromOperation("please enter a new folder name"); - return; - } - - final NewLocalDirectoryDialog thisDialog = this; - - java.awt.EventQueue.invokeLater(new Runnable() { - - @Override - public void run() { - - log.info("adding new folder named:{}", txtNewFolder.getText()); - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); - try { - - StringBuilder sb = new StringBuilder(); - sb.append(parentDirectory); - sb.append('/'); - sb.append(txtNewFolder.getText()); - String newDirPath = sb.toString(); - - File newDir = new File(newDirPath); - - boolean created = newDir.mkdirs(); - - - if (!created) { - log.info("could not create new folder in:{}", newDirPath); - idrop.showMessageFromOperation("directory could not be created"); - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - return; - } - - log.info("new file was created, adding as a node in the local tree"); - LocalFileNode newLocalNode = new LocalFileNode(newDir); - LocalFileSystemModel localFileSystemModel = (LocalFileSystemModel) localFileTree.getModel(); - if (parentNode.isCached()) { - localFileSystemModel.insertNodeInto(newLocalNode, parentNode, parentNode.getChildCount()); - } else { - parentNode.lazyLoadOfChildrenOfThisNode(); - } - - TreePath scrollToPath = new TreePath(newLocalNode.getPath()); - localFileTree.expandPath(scrollToPath); - - localFileTree.scrollPathToVisible(scrollToPath); - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - idrop.showMessageFromOperation("new local folder created"); - - } catch (Exception ex) { - Logger.getLogger(NewLocalDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex); - idrop.showIdropException(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); - Action enterAction = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - processNew(); - } - }; - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameIRODSDirectoryDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameIRODSDirectoryDialog.form deleted file mode 100644 index 7a2ceda..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameIRODSDirectoryDialog.form +++ /dev/null @@ -1,196 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameIRODSDirectoryDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameIRODSDirectoryDialog.java deleted file mode 100644 index d2029fc..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameIRODSDirectoryDialog.java +++ /dev/null @@ -1,308 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -/* - * NewIRODSDirectoryDialog.java - * - * Created on Sep 3, 2010, 9:52:12 AM - */ -package org.irods.jargon.idrop.commons; - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.tree.TreePath; -import org.slf4j.LoggerFactory; - -/** - * Dialog to gather a new directory name - * @author mikeconway - */ -public class RenameIRODSDirectoryDialog extends javax.swing.JDialog { - - private final IdropClient 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 */ - public RenameIRODSDirectoryDialog(final IdropClient parent, final boolean modal, final String currentAbsolutePath, final IRODSTree stagingViewTree, final IRODSNode currentNode) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.currentAbsolutePath = currentAbsolutePath; - this.stagingViewTree = stagingViewTree; - this.currentNode = currentNode; - initComponents(); - int lastPathPartIdx = currentAbsolutePath.lastIndexOf("/"); - if (lastPathPartIdx == -1) { - String msg = "could not find last path component of absolute path:" + currentAbsolutePath; - log.error(msg); - 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(); - } - - /** 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") - // //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(); - lblNewDiretoryName = new java.awt.Label(); - txtCurrentFolder = new javax.swing.JTextField(); - 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("Rename iRODS File or Folder"); - setName("NewParentDialog"); // NOI18N - - lblTitle.setText("Please enter a new name for the file or collection"); - - lblCurrentParent.setText("Current name:"); - - lblNewDiretoryName.setText("New name:"); - - txtCurrentFolder.setColumns(50); - txtCurrentFolder.setEditable(false); - txtCurrentFolder.setToolTipText("A name for the new folder underneath the displayed parent"); - txtCurrentFolder.setFocusable(false); - - txtNewFolder.setColumns(50); - txtNewFolder.setToolTipText("A name for the new folder underneath the displayed parent"); - - btnCancel.setText("Cancel"); - btnCancel.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - - org.jdesktop.layout.GroupLayout pnlBottomLayout = new org.jdesktop.layout.GroupLayout(pnlBottom); - pnlBottom.setLayout(pnlBottomLayout); - pnlBottomLayout.setHorizontalGroup( - pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlBottomLayout.createSequentialGroup() - .add(576, 576, 576) - .add(btnCancel) - .add(5, 5, 5) - .add(btnOK)) - ); - pnlBottomLayout.setVerticalGroup( - pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlBottomLayout.createSequentialGroup() - .add(5, 5, 5) - .add(btnCancel)) - .add(pnlBottomLayout.createSequentialGroup() - .add(5, 5, 5) - .add(btnOK)) - ); - - 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(30, 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.TRAILING, false) - .add(txtNewFolder, 0, 0, Short.MAX_VALUE) - .add(txtCurrentFolder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)) - .add(213, 213, 213)) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(pnlBottom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 747, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - 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(lblCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(txtCurrentFolder, 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)) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE) - .add(pnlBottom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - ); - - lblNewDiretoryName.getAccessibleContext().setAccessibleName("New directory name:"); - - org.jdesktop.layout.GroupLayout pnlFolderDataLayout = new org.jdesktop.layout.GroupLayout(pnlFolderData); - pnlFolderData.setLayout(pnlFolderDataLayout); - pnlFolderDataLayout.setHorizontalGroup( - pnlFolderDataLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlFolderDataLayout.createSequentialGroup() - .add(pnlCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 757, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - pnlFolderDataLayout.setVerticalGroup( - pnlFolderDataLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlFolderDataLayout.createSequentialGroup() - .add(pnlCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(lblTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 747, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(pnlFolderData, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(lblTitle) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(pnlFolderData, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - ); - - getAccessibleContext().setAccessibleName("Rename file or folder dialog"); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - doRename(); - }//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - 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.JTextField txtCurrentFolder; - 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 - - if (txtNewFolder.getText().isEmpty()) { - txtNewFolder.setBackground(Color.red); - 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.getiDropCore().getIrodsAccount(), idrop.getiDropCore().getIrodsFileSystem()); - String newPath = irodsFileService.renameIRODSFileOrDirectory(currentAbsolutePath, txtNewFolder.getText()); - log.debug("New path:{}", newPath); - IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) 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) { - sb.append("/"); - } - 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(); - targetParentNode.forceReloadOfChildrenOfThisNode(); - irodsFileSystemModel.reload(targetParentNode); - stagingViewTree.expandPath(pathForNew); - - idrop.showMessageFromOperation("The rename was successful"); - - } catch (IdropException ex) { - Logger.getLogger(RenameIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex); - idrop.showIdropException(ex); - } finally { - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - - 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); - Action enterAction = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - doRename(); - } - }; - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameLocalDirectoryDialog.form b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameLocalDirectoryDialog.form deleted file mode 100644 index fa56f86..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameLocalDirectoryDialog.form +++ /dev/null @@ -1,196 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameLocalDirectoryDialog.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameLocalDirectoryDialog.java deleted file mode 100644 index bafe704..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/RenameLocalDirectoryDialog.java +++ /dev/null @@ -1,299 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - - -package org.irods.jargon.idrop.commons; - -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Frame; -import java.awt.event.ActionEvent; -import java.io.File; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.JComponent; -import javax.swing.KeyStroke; -import javax.swing.tree.TreePath; -import org.slf4j.LoggerFactory; - -/** - * Dialog to gather a new directory name and perform a rename operation on a local file. - * @author mikeconway - */ -public class RenameLocalDirectoryDialog extends javax.swing.JDialog { - - private final IdropClient idrop; - private String currentAbsolutePath = ""; - private final LocalFileTree localFileTree; - private final LocalFileNode currentNode; - public static org.slf4j.Logger log = LoggerFactory.getLogger(RenameLocalDirectoryDialog.class); - - /** Creates new form RenameLocalDirectoryDialog */ - public RenameLocalDirectoryDialog(final IdropClient parent, final boolean modal, final String currentAbsolutePath, final LocalFileTree localFileTree, final LocalFileNode currentNode) { - //super(parent, modal); FIX THIS??? - super((Frame)null, modal); - this.idrop = parent; - this.currentAbsolutePath = currentAbsolutePath; - this.localFileTree = localFileTree; - this.currentNode = currentNode; - initComponents(); - int lastPathPartIdx = currentAbsolutePath.lastIndexOf("/"); - if (lastPathPartIdx == -1) { - String msg = "could not find last path component of absolute path:" + currentAbsolutePath; - log.error(msg); - 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(); - } - - /** 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") - // //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(); - lblNewDiretoryName = new java.awt.Label(); - txtCurrentFolder = new javax.swing.JTextField(); - 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("iDrop - Rename local file or directory"); - setName("NewParentDialog"); // NOI18N - - lblTitle.setText("Please enter a new name for the file or collection"); - - lblCurrentParent.setText("Current name:"); - - lblNewDiretoryName.setText("New name:"); - - txtCurrentFolder.setColumns(50); - txtCurrentFolder.setEditable(false); - txtCurrentFolder.setToolTipText("A name for the new folder underneath the displayed parent"); - txtCurrentFolder.setFocusable(false); - - txtNewFolder.setColumns(50); - txtNewFolder.setToolTipText("A name for the new folder underneath the displayed parent"); - - btnCancel.setText("Cancel"); - btnCancel.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCancelActionPerformed(evt); - } - }); - - btnOK.setText("OK"); - btnOK.addActionListener(new java.awt.event.ActionListener() { - @Override - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnOKActionPerformed(evt); - } - }); - - org.jdesktop.layout.GroupLayout pnlBottomLayout = new org.jdesktop.layout.GroupLayout(pnlBottom); - pnlBottom.setLayout(pnlBottomLayout); - pnlBottomLayout.setHorizontalGroup( - pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlBottomLayout.createSequentialGroup() - .add(576, 576, 576) - .add(btnCancel) - .add(5, 5, 5) - .add(btnOK)) - ); - pnlBottomLayout.setVerticalGroup( - pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlBottomLayout.createSequentialGroup() - .add(5, 5, 5) - .add(pnlBottomLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(btnCancel) - .add(btnOK))) - ); - - 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(30, 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.TRAILING, false) - .add(txtNewFolder, 0, 0, Short.MAX_VALUE) - .add(txtCurrentFolder, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE)) - .add(213, 213, 213)) - .add(pnlCurrentParentLayout.createSequentialGroup() - .add(pnlBottom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 747, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - 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(lblCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(txtCurrentFolder, 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)) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE) - .add(pnlBottom, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - ); - - lblNewDiretoryName.getAccessibleContext().setAccessibleName("New directory name:"); - - org.jdesktop.layout.GroupLayout pnlFolderDataLayout = new org.jdesktop.layout.GroupLayout(pnlFolderData); - pnlFolderData.setLayout(pnlFolderDataLayout); - pnlFolderDataLayout.setHorizontalGroup( - pnlFolderDataLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlFolderDataLayout.createSequentialGroup() - .add(pnlCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 757, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - pnlFolderDataLayout.setVerticalGroup( - pnlFolderDataLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(pnlFolderDataLayout.createSequentialGroup() - .add(pnlCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(lblTitle, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 747, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(pnlFolderData, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .add(lblTitle) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(pnlFolderData, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - ); - - getAccessibleContext().setAccessibleName("Rename file or folder dialog"); - - pack(); - }// //GEN-END:initComponents - - private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed - this.dispose(); -}//GEN-LAST:event_btnCancelActionPerformed - - private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed - doRename(); - }//GEN-LAST:event_btnOKActionPerformed - // Variables declaration - do not modify//GEN-BEGIN:variables - 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.JTextField txtCurrentFolder; - 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 - - if (txtNewFolder.getText().isEmpty()) { - txtNewFolder.setBackground(Color.red); - idrop.showMessageFromOperation("please enter a new file or collection name"); - return; - } - - final RenameLocalDirectoryDialog 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 { - - TreePath currentNodePath = new TreePath(currentNode); - LocalFileNode parentNode = (LocalFileNode) currentNode.getParent(); - File fileToRename = (File) currentNode.getUserObject(); - log.debug("reanaming local file:{}", fileToRename.getAbsolutePath()); - File newFile = new File(fileToRename.getParent(), txtNewFolder.getText()); - log.debug("new file name is:{}", newFile.getAbsolutePath()); - - log.debug("renaming now..."); - fileToRename.renameTo(newFile); - - LocalFileSystemModel localFileTreeModel = (LocalFileSystemModel) localFileTree.getModel(); - log.debug("updating tree model, remove old and add new nodes"); - //localFileTreeModel.removeNodeFromParent(currentNode); - //localFileTreeModel.insertNodeInto(parentNode, new LocalFileNode(newFile), 0); - currentNode.setUserObject(newFile); - localFileTreeModel.reload(parentNode); - - idrop.showMessageFromOperation("rename successful"); - - } - catch (Exception ex) { - Logger.getLogger(RenameLocalDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex); - idrop.showIdropException(ex); - } - finally { - thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - - 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); - Action enterAction = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - doRename(); - } - }; - btnOK.registerKeyboardAction(enterAction, enter, - JComponent.WHEN_IN_FOCUSED_WINDOW); - - } - -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/TreeUtils.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/TreeUtils.java deleted file mode 100644 index b5f4d8d..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/TreeUtils.java +++ /dev/null @@ -1,195 +0,0 @@ -package org.irods.jargon.idrop.commons; - -import java.io.File; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.swing.JTree; -import javax.swing.tree.TreeNode; -import javax.swing.tree.TreePath; -import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry; -import org.slf4j.LoggerFactory; - -/** - * This is a set of utilities for manipulating a swing Jtree - * @author Mike Conway - DICE (www.irods.org) - */ -public class TreeUtils { - - public static org.slf4j.Logger log = LoggerFactory.getLogger(TreeUtils.class); - - public static IRODSNode findChild(IRODSNode parent, String userObject) throws IdropException { - log.debug("finding child of parent:{}", parent); - log.debug("user object:{}", userObject); - String childString = ""; - - // FIXME: children of archive1 is null, child count is empty so it does not look for nodes - - CollectionAndDataObjectListingEntry parentEntry = (CollectionAndDataObjectListingEntry) parent.getUserObject(); - CollectionAndDataObjectListingEntry childEntry = null; - - IRODSNode foundNode = null; - try { - parent.lazyLoadOfChildrenOfThisNode(); - } catch (IdropException ex) { - Logger.getLogger(TreeUtils.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropException("unable to load children of node"); - } - - for (int i = 0; i < parent.getChildCount(); i++) { - childEntry = (CollectionAndDataObjectListingEntry) ((IRODSNode) parent.getChildAt(i)).getUserObject(); - - if (childEntry.getObjectType() == CollectionAndDataObjectListingEntry.ObjectType.COLLECTION) { - log.debug("child entry is a collection"); - if (userObject.equals(childEntry.getPathOrName())) { - foundNode = (IRODSNode) parent.getChildAt(i); - break; - } - } else { - log.debug("child entry is a data object"); - StringBuilder sb = new StringBuilder(); - sb.append(childEntry.getParentPath()); - sb.append('/'); - sb.append(childEntry.getPathOrName()); - log.debug("looking for match when child entry is a file with abs path:{}", sb.toString()); - if (userObject.equals(sb.toString())) { - foundNode = (IRODSNode) parent.getChildAt(i); - break; - } - } - } - return foundNode; - } - - /** - * Given an absolute path to a file from the iRODS view, build the corresponding TreePath that points to the position - * in the tree model. - * @param tree JTree that depicts the iRODS file hierarchy. - * @param irodsAbsolutePath String that gives the absolute path to the iRODS file. - * @return TreePath to the given node at the given absolute path in iRODS. - * @throws IdropException - */ - public static TreePath buildTreePathForIrodsAbsolutePath(final JTree tree, final String irodsAbsolutePath) throws IdropException { - - IRODSFileSystemModel irodsFileSystemModel = (IRODSFileSystemModel) 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) { - throw new IdropException("cannot find node for path:" + searchRoot.toString()); - } else { - // root node is already part of the calculcated tree path - if (currentNode.getUserObject().toString().equals("/")) { - // ignore this node - } else { - calculatedTreePath = calculatedTreePath.pathByAddingChild(currentNode); - } - } - } - - return calculatedTreePath; - } - - public static void expandAll(JTree tree, TreePath parent, boolean expand) { - // Traverse 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); - expandAll(tree, path, expand); - } - } - - // Expansion or collapse must be done bottom-up - if (expand) { - tree.expandPath(parent); - } else { - tree.collapsePath(parent); - } - } - - /** - * Given a tree node, get the nodes that are in the given expansion state as a list of TreePath - * @param tree JTree that will be inspected - * @param expanded boolean that indicates the desired state that will be preserved in the tree paths - * @return TreePath[] with the list of paths in the given state - */ -public static TreePath[] getPaths(JTree tree, boolean expanded) { - TreeNode root = (TreeNode)tree.getModel().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 - 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-commons/src/main/java/org/irods/jargon/idrop/commons/iDropCoreCommon.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/iDropCoreCommon.java deleted file mode 100644 index 6e69a75..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/iDropCoreCommon.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package org.irods.jargon.idrop.commons; - -/** - * - * @author lisa - */ -import java.util.Timer; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.prefs.Preferences; - -import org.irods.jargon.core.connection.IRODSAccount; -import org.irods.jargon.core.exception.JargonException; -import org.irods.jargon.core.pub.IRODSAccessObjectFactory; -import org.irods.jargon.core.pub.IRODSFileSystem; -import org.irods.jargon.core.pub.io.IRODSFileFactory; -import org.irods.jargon.transfer.engine.TransferManager; -//import org.irods.jargon.idrop.desktop.systraygui.services.IconManager; -//import org.irods.jargon.idrop.desktop.systraygui.utils.IdropConfig; -import org.irods.jargon.transfer.engine.TransferManager; - -public class iDropCoreCommon { - - private IRODSAccount irodsAccount = null; - - private IRODSFileSystem irodsFileSystem = null; - - public IRODSFileSystem getIrodsFileSystem() { - return irodsFileSystem; - } - - public void setIrodsFileSystem(IRODSFileSystem irodsFileSystem) { - this.irodsFileSystem = irodsFileSystem; - } - -// private IdropConfig idropConfig = null; - - private TransferManager transferManager = null; - -// private IconManager iconManager = null; - - private Timer queueTimer = new Timer(); - - private Preferences preferences = Preferences.userRoot(); - - public iDropCoreCommon() { - super(); - } - - public IRODSAccount getIrodsAccount() { - return irodsAccount; - } - - public void setIrodsAccount(IRODSAccount irodsAccount) { - this.irodsAccount = irodsAccount; - } - - public void setIrodsAccount(String sessionID) { - // FIX ME: need to implement this - } - -// public IdropConfig getIdropConfig() { -// return idropConfig; -// } - -// public void setIdropConfig(IdropConfig idropConfig) { -// this.idropConfig = idropConfig; -// } - - public TransferManager getTransferManager() { - return transferManager; - } - - public void setTransferManager(TransferManager transferManager) { - this.transferManager = transferManager; - } - -// public IconManager getIconManager() { -// return iconManager; -// } -// -// public void setIconManager(IconManager iconManager) { -// this.iconManager = iconManager; -// } - -// public Timer getQueueTimer() { -// return queueTimer; -// } - -// public void setQueueTimer(Timer queueTimer) { -// this.queueTimer = queueTimer; -// } - -// @Deprecated -// public Preferences getPreferences() { -// return preferences; -// } -// -// @Deprecated -// public void setPreferences(Preferences preferences) { -// this.preferences = preferences; -// } - - /** - * Handy method that delegates the process of getting an IRODSAccessObjectFactory. - * @return {@link IRODSAccessObjectFactory} - */ - public IRODSAccessObjectFactory getIRODSAccessObjectFactory() { - if (irodsFileSystem == null) { - throw new IdropRuntimeException("No IRODSFileSystem set, cannot obtain the IRODSAccessObjectFactory"); - } - try { - return irodsFileSystem.getIRODSAccessObjectFactory(); - } catch (JargonException ex) { - Logger.getLogger(iDropCoreCommon.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("exception getting IRODSAccessObjectFactory"); - } - } - - /** - * Method to close any iRODS connections in the current thread. This delegates to the IRODSFileSystem. - */ - public void closeAllIRODSConnections() { - if (irodsFileSystem == null) { - throw new IdropRuntimeException("No IRODSFileSystem set, cannot obtain the IRODSAccessObjectFactory"); - } - irodsFileSystem.closeAndEatExceptions(); - } - - /** - * Method to close iRODS connection denoted by the logged in IRODSAccount. - */ - public void closeIRODSConnectionForLoggedInAccount() { - if (irodsFileSystem == null) { - throw new IdropRuntimeException("No IRODSFileSystem set, cannot obtain the IRODSAccessObjectFactory"); - } - irodsFileSystem.closeAndEatExceptions(irodsAccount); - } - - /** - * Method to close iRODS connection denoted by the given IRODSAccount in the current thread. This delegates to the IRODSFileSystem. - */ - public void closeIRODSConnection(final IRODSAccount irodsAccount) { - if (irodsFileSystem == null) { - throw new IdropRuntimeException("No IRODSFileSystem set, cannot obtain the IRODSAccessObjectFactory"); - } - irodsFileSystem.closeAndEatExceptions(irodsAccount); - } - /** - * Get the IRODSFileFactory for the given account - * @return {@link IRODSFileFactory} associated with the account currently logged in - */ - public IRODSFileFactory getIRODSFileFactory(final IRODSAccount irodsAccount) { - if (irodsFileSystem == null) { - throw new IdropRuntimeException("No IRODSFileSystem set, cannot obtain the IRODSAccessObjectFactory"); - } - if (irodsAccount == null) { - throw new IdropRuntimeException("No IRODSAccount set, cannot obtain the IRODSAccessObjectFactory"); - } - try { - return irodsFileSystem.getIRODSFileFactory(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(iDropCoreCommon.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("Exception getting iRODS file factory", ex); - } - - } - - /** - * Get the IRODSFileFactory for the current logged-in account. - * @return {@link IRODSFileFactory} associated with the account currently logged in - */ - public IRODSFileFactory getIRODSFileFactoryForLoggedInAccount() { - if (irodsFileSystem == null) { - throw new IdropRuntimeException("No IRODSFileSystem set, cannot obtain the IRODSAccessObjectFactory"); - } - if (irodsAccount == null) { - throw new IdropRuntimeException("No IRODSAccount set, cannot obtain the IRODSAccessObjectFactory"); - } - try { - return irodsFileSystem.getIRODSFileFactory(irodsAccount); - } catch (JargonException ex) { - Logger.getLogger(iDropCoreCommon.class.getName()).log(Level.SEVERE, null, ex); - throw new IdropRuntimeException("Exception getting iRODS file factory", ex); - } - - } -} diff --git a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/service/AbstractIRODSTransferService.java b/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/service/AbstractIRODSTransferService.java deleted file mode 100644 index 246de3b..0000000 --- a/idrop-commons/src/main/java/org/irods/jargon/idrop/commons/service/AbstractIRODSTransferService.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.irods.jargon.idrop.commons.service; - -import org.irods.jargon.core.pub.DataTransferOperations; -import org.irods.jargon.core.pub.io.IRODSFile; -import org.irods.jargon.idrop.commons.IdropException; - -/** - * @author Mike Conway - DICE (www.irods.org) - */ -public abstract class AbstractIRODSTransferService { - - /** - * Copy a file from source to target - * @param dataTransferOperations - * @param sourceFile - * @param targetAbsolutePath - * @throws IdropException - */ - public abstract void copyFile(DataTransferOperations dataTransferOperations, IRODSFile sourceFile, String targetAbsolutePath) throws IdropException; - - -} diff --git a/idrop-lite/pom.xml b/idrop-lite/pom.xml index e3056de..5813a4c 100644 --- a/idrop-lite/pom.xml +++ b/idrop-lite/pom.xml @@ -4,13 +4,13 @@ idrop org.irods - 1.0.0-beta2-SNAPSHOT + 1.0.0-SNAPSHOT org.irods.idrop idrop-lite jar idrop-lite - 1.0.0-beta3-SNAPSHOT + 1.0.0-SNAPSHOT junit diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/Version.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/Version.java index 7217286..142ffe6 100644 --- a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/Version.java +++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/Version.java @@ -1,4 +1,4 @@ package org.irods.jargon.idrop.lite; public final class Version { - public static String VERSION="20120112-1258"; + public static String VERSION="20120127-1533"; } diff --git a/idrop-swing/pom.xml b/idrop-swing/pom.xml index 79ec42a..e3fc967 100644 --- a/idrop-swing/pom.xml +++ b/idrop-swing/pom.xml @@ -3,7 +3,7 @@ org.irods idrop - 1.0.0-beta2-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 org.irods.idrop @@ -205,4 +205,4 @@ - \ No newline at end of file + diff --git a/idrop-web/application.properties b/idrop-web/application.properties index 2e14123..bb9afb5 100644 --- a/idrop-web/application.properties +++ b/idrop-web/application.properties @@ -3,7 +3,7 @@ app.grails.version=1.3.7 app.name=idrop-web app.servlet.version=2.4 -app.version=1.0.0-beta2-SNAPSHOT +app.version=1.0.0-SNAPSHOT plugins.hibernate=1.3.7 plugins.test-template=1.3.2 plugins.testing=0.5 diff --git a/idrop-web/grails-app/conf/BuildConfig.groovy b/idrop-web/grails-app/conf/BuildConfig.groovy index 35d7227..c7dbae9 100644 --- a/idrop-web/grails-app/conf/BuildConfig.groovy +++ b/idrop-web/grails-app/conf/BuildConfig.groovy @@ -24,13 +24,13 @@ grails.project.dependency.resolution = { } dependencies { // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg. - test 'org.irods.jargon:jargon-test:3.0.1-SNAPSHOT' + test 'org.irods.jargon:jargon-test:3.0.0.2-SNAPSHOT' test 'org.mockito:mockito-all:1.8.1' provided 'junit:junit:4.8.1' - compile 'org.irods.jargon:jargon-core:3.0.1-SNAPSHOT' - compile 'org.irods.jargon:jargon-security:3.0.1-SNAPSHOT' - compile 'org.irods.jargon:jargon-data-utils:3.0.1-SNAPSHOT' - compile ('org.irods.jargon:jargon-user-tagging:3.0.1-SNAPSHOT') { exclude 'junit' } + compile 'org.irods.jargon:jargon-core:3.0.0.2-SNAPSHOT' + compile 'org.irods.jargon:jargon-security:3.0.0.2-SNAPSHOT' + compile 'org.irods.jargon:jargon-data-utils:3.0.0.2-SNAPSHOT' + compile ('org.irods.jargon:jargon-user-tagging:3.0.0.2-SNAPSHOT') { exclude 'junit' } compile 'org.springframework.security:spring-security-core:3.0.5.RELEASE' compile 'org.springframework.security:spring-security-web:3.0.5.RELEASE' compile 'org.springframework.security:spring-security-config:3.0.5.RELEASE' diff --git a/idrop-web/pom.xml b/idrop-web/pom.xml index 747dc99..c0b316c 100644 --- a/idrop-web/pom.xml +++ b/idrop-web/pom.xml @@ -2,7 +2,7 @@ org.irods idrop - 1.0.0-beta2-SNAPSHOT + 1.0.0-SNAPSHOT 4.0.0 idrop-web diff --git a/pom.xml b/pom.xml index 112f3fe..1a22a84 100644 --- a/pom.xml +++ b/pom.xml @@ -4,13 +4,13 @@ org.irods idrop pom - 1.0.0-beta2-SNAPSHOT + 1.0.0-SNAPSHOT iRODS iDrop iRODS iDrop - personal web and desktop grid access clients https://code.renci.org/gf/project/irodsidrop/ UTF-8 - 3.0.1-SNAPSHOT + 3.0.0.2-SNAPSHOT 3.0.5.RELEASE 2.0.1 RELEASE701 @@ -405,6 +405,5 @@ idrop-swing idrop-web idrop-lite - idrop-commons -- cgit