summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-07-17 03:34:23 (GMT)
committer Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-07-17 03:34:23 (GMT)
commitfbc1b511718146a4982c01f5858075b135b82e55 (patch)
tree9684a42ba733e6f3d4a5ab1613c5995881096005
parent1390d84c15f52e179cd3ebb0f054f35b3f933a8f (diff)
downloadQCG-Data-fbc1b511718146a4982c01f5858075b135b82e55.zip
QCG-Data-fbc1b511718146a4982c01f5858075b135b82e55.tar.gz
QCG-Data-fbc1b511718146a4982c01f5858075b135b82e55.tar.bz2
irods finder dialog add new,rename,delete
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPGui.java13
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/StartupSequencer.java27
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/MessageUtil.java (renamed from idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/util/MessageUtil.java)2
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.form5
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.java12
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.form136
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.java330
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.form158
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.java298
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.form196
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.java345
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderUtils.java187
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.form56
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.java67
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderOutlineModel.java135
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderTree.java35
-rw-r--r--idrop-swing/src/main/resources/org/irods/jargon/idrop/desktop/systraygui/viscomponents/Bundle.properties1
17 files changed, 1894 insertions, 109 deletions
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPGui.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPGui.java
new file mode 100644
index 0000000..c9be74c
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPGui.java
@@ -0,0 +1,13 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.irods.jargon.idrop.desktop.systraygui;
+
+/**
+ *
+ * @author mikeconway
+ */
+public interface IDROPGui {
+ IDROPCore getiDropCore();
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/StartupSequencer.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/StartupSequencer.java
index ebdc687..62504c7 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/StartupSequencer.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/StartupSequencer.java
@@ -1,6 +1,7 @@
package org.irods.jargon.idrop.desktop.systraygui;
import java.awt.Component;
+import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.List;
import java.util.Properties;
@@ -130,7 +131,7 @@ public class StartupSequencer {
log.info("config properties derived...");
idropCore.setIdropConfig(new IdropConfig(derivedProperties));
idropCore.getIdropConfig().setUpLogging();
-
+
log.info("setting initial look and feel");
LookAndFeelManager laf = new LookAndFeelManager(idropCore);
laf.setLookAndFeel(idropCore.getIdropConfig().getPropertyForKey(IdropConfigurationService.LOOK_AND_FEEL));
@@ -143,11 +144,11 @@ public class StartupSequencer {
int x = (tk.getScreenSize().width - loginDialog.getWidth()) / 2;
int y = (tk.getScreenSize().height - loginDialog.getHeight()) / 2;
loginDialog.setLocation(x, y);
-
+
loginDialog.setAlwaysOnTop(true);
-
+
loginDialog.setVisible(true);
- loginDialog.toFront();
+ loginDialog.toFront();
idropSplashWindow.toBack();
if (idropCore.getIrodsAccount() == null) {
@@ -211,7 +212,7 @@ public class StartupSequencer {
Timer timer = new Timer();
timer.scheduleAtFixedRate(queueSchedulerTimerTask, 10000, 120000);
idropCore.setQueueTimer(timer);
-
+
} catch (IdropException ex) {
@@ -237,7 +238,7 @@ public class StartupSequencer {
log.info("first time running idrop, starting configuration wizard");
log.info("showing gui first time run");
doFirstTimeConfigurationWizard();
- idrop.showIdropGui();
+ idrop.showIdropGui();
} else {
// see if I show the gui at startup or show a message
if (idropCore.getIdropConfig().isShowGuiAtStartup()) {
@@ -259,7 +260,7 @@ public class StartupSequencer {
log.info("switching to show GUI at startup");
try {
idropCore.getIdropConfigurationService().updateConfig(IdropConfigurationService.SHOW_GUI, "true");
- idrop.showIdropGui();
+ idrop.showIdropGui();
} catch (IdropException ex) {
log.error("error setting show GUI at startup", ex);
throw new IdropRuntimeException(ex);
@@ -270,7 +271,11 @@ public class StartupSequencer {
log.info("signal that the startup sequence is complete");
try {
-
+ try {
+ Thread.sleep(STARTUP_SEQUENCE_PAUSE_INTERVAL * 2);
+ } catch (InterruptedException e) {
+ throw new IdropRuntimeException(e);
+ }
idropSplashWindow.setVisible(false);
idropSplashWindow = null;
} catch (Exception e) {
@@ -310,6 +315,12 @@ public class StartupSequencer {
idrop.setVisible(false);
SetupWizard setupWizard = new SetupWizard(idrop, true);
setupWizard.toFront();
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ final Dimension screenSize = toolkit.getScreenSize();
+ final int x = (screenSize.width - setupWizard.getWidth()) / 2;
+ final int y = (screenSize.height - setupWizard.getHeight()) / 2;
+ setupWizard.setLocation(x, y);
+
setupWizard.setVisible(true);
idrop.setVisible(true);
}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/util/MessageUtil.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/MessageUtil.java
index b45cd69..146a2fe 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/util/MessageUtil.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/utils/MessageUtil.java
@@ -1,4 +1,4 @@
-package org.irods.jargon.idrop.desktop.systraygui.util;
+package org.irods.jargon.idrop.desktop.systraygui.utils;
import java.awt.Component;
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.form
index 0630b6c..852e825 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.form
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.form
@@ -2,7 +2,10 @@
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
- <Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="defaultCloseOperation" type="int" value="0"/>
+ <Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/irods/jargon/idrop/desktop/systraygui/viscomponents/Bundle.properties" key="SetupWizard.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
+ </Property>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.java
index 9da01c3..0933b7d 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.java
@@ -6,6 +6,8 @@
package org.irods.jargon.idrop.desktop.systraygui.viscomponents;
import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Toolkit;
import javax.swing.JFileChooser;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
@@ -28,7 +30,7 @@ public class SetupWizard extends javax.swing.JDialog {
private final IDROPCore idropCore;
private final IdropConfigurationService idropConfigurationService;
private static final org.slf4j.Logger log = LoggerFactory.getLogger(SetupWizard.class);
- public final String SETUP_ERROR_TITLE = "iDrop - Setup Error";
+ public final String SETUP_ERROR_TITLE = "iDrop - Setup";
private int tabStep = 0;
private boolean tabAdvancing = false;
@@ -98,7 +100,8 @@ public class SetupWizard extends javax.swing.JDialog {
btnBack = new javax.swing.JButton();
btnLater = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
+ setTitle(org.openide.util.NbBundle.getMessage(SetupWizard.class, "SetupWizard.title")); // NOI18N
panelTop.setFont(new java.awt.Font("Lucida Grande", 0, 12));
@@ -368,6 +371,11 @@ public class SetupWizard extends javax.swing.JDialog {
private void btnChooseIrodsSynchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnChooseIrodsSynchActionPerformed
try {
IRODSFinderDialog irodsFileSystemChooserView = new IRODSFinderDialog(null, true, idropCore);
+ final Toolkit toolkit = Toolkit.getDefaultToolkit();
+ final Dimension screenSize = toolkit.getScreenSize();
+ final int x = (screenSize.width - irodsFileSystemChooserView.getWidth()) / 2;
+ final int y = (screenSize.height - irodsFileSystemChooserView.getHeight()) / 2;
+ irodsFileSystemChooserView.setLocation(x, y);
irodsFileSystemChooserView.setVisible(true);
// int returnVal = irodsFileChooser.showSaveDialog(this);
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.form
new file mode 100644
index 0000000..c843416
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.form
@@ -0,0 +1,136 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-75,0,0,2,104"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblTitle">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Please hit OK to delete the following file/folder from iRODS"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="North"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JPanel" name="pnlFolderData">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
+ <Property name="columns" type="int" value="1"/>
+ <Property name="rows" type="int" value="0"/>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="pnlCurrentParent">
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace pref="40" max="32767" attributes="0"/>
+ <Component id="lblCurrentFolder" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="scrollFileToDelete" min="-2" pref="413" max="-2" attributes="1"/>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="35" max="-2" attributes="0"/>
+ <Component id="lblCurrentFolder" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
+ <Component id="scrollFileToDelete" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="java.awt.Label" name="lblCurrentFolder">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="File/folder to delete:"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="scrollFileToDelete">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextArea" name="txtAreaFileToDelete">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="lineWrap" type="boolean" value="true"/>
+ <Property name="rows" type="int" value="5"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="pnlBottom">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="South"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
+ <Property name="alignment" type="int" value="2"/>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="btnCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Cancel"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="btnOK">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="OK"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.java
new file mode 100644
index 0000000..552e647
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderDeleteIRODSDialog.java
@@ -0,0 +1,330 @@
+/*
+ * FinderDeleteIRODSDialog.java
+ *
+ * Created on Sep 4, 2010, 7:40:23 AM
+ */
+package org.irods.jargon.idrop.finder;
+
+import java.awt.Cursor;
+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.Action;
+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.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSNode;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSOutlineModel;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSTree;
+import org.irods.jargon.idrop.exceptions.IdropException;
+import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author mikeconway
+ */
+public class FinderDeleteIRODSDialog extends javax.swing.JDialog {
+
+
+ private final IRODSFinderTree irodsTree;
+ private final IRODSNode deletedNode;
+ private final List<IRODSNode> deletedNodes;
+ private final IRODSFinderDialog irodsFinderDialog;
+ public static org.slf4j.Logger log = LoggerFactory.getLogger(FinderDeleteIRODSDialog.class);
+
+ /** Creates new form NewIRODSDirectoryDialog */
+ public FinderDeleteIRODSDialog(final IRODSFinderDialog parent, final boolean modal,
+ final IRODSFinderTree irodsTree, final IRODSNode deletedNode) {
+ super(parent, modal);
+ this.irodsFinderDialog = 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 FinderDeleteIRODSDialog(final IRODSFinderDialog parent, final boolean modal,
+ final IRODSFinderTree irodsTree, final List<IRODSNode> deletedNodes) {
+ super(parent, modal);
+ this.irodsFinderDialog = 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(final ActionEvent e) {
+ try {
+ processDelete();
+ } catch (IdropException ex) {
+ Logger.getLogger(FinderDeleteIRODSDialog.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")
+ // <editor-fold defaultstate="collapsed"
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblTitle = new javax.swing.JLabel();
+ pnlFolderData = new javax.swing.JPanel();
+ pnlCurrentParent = new javax.swing.JPanel();
+ 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() {
+ 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();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void btnCancelActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnCancelActionPerformed
+ this.dispose();
+ }// GEN-LAST:event_btnCancelActionPerformed
+
+ private void btnOKActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnOKActionPerformed
+ try {
+ processDelete();
+ } catch (IdropException ex) {
+ Logger.getLogger(FinderDeleteIRODSDialog.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 FinderDeleteIRODSDialog 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();
+
+ } catch (JargonException ex) {
+ Logger.getLogger(FinderDeleteIRODSDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+ throw new IdropException(ex);
+ } finally {
+ irodsFinderDialog.getIdropCore().closeIRODSConnectionForLoggedInAccount();
+ }
+
+ }
+
+ class DeleteWorker extends SwingWorker<String, Object> {
+
+ public static final String DELETE_SUCCESSFUL = "Deletion complete";
+ public static final String DELETE_ERRORS = "The deletion was not successful";
+ private FinderDeleteIRODSDialog dialog;
+ private String message = "";
+
+ DeleteWorker(final FinderDeleteIRODSDialog dialog) {
+ if (dialog == null) {
+ throw new IllegalArgumentException("null dialog");
+ }
+
+ this.dialog = dialog;
+
+ }
+
+ @Override
+ public String doInBackground() {
+
+ try {
+
+ IRODSFileFactory irodsFileFactory = irodsFinderDialog.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(FinderDeleteIRODSDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+
+ throw new IdropRuntimeException(ex);
+ } finally {
+ irodsFinderDialog.getIdropCore().closeAllIRODSConnections();
+ }
+
+ return null;
+ }
+
+ @Override
+ protected void done() {
+ dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ final IRODSFinderOutlineModel irodsFileSystemModel = (IRODSFinderOutlineModel) irodsTree.getModel();
+ try {
+ if (deletedNode != null) {
+ irodsFileSystemModel.notifyFileShouldBeRemoved(deletedNode);
+ } else if (deletedNodes != null) {
+ for (IRODSNode deletedNode : deletedNodes) {
+ irodsFileSystemModel.notifyFileShouldBeRemoved(deletedNode);
+ }
+ }
+ } catch (IdropException ex) {
+ Logger.getLogger(FinderDeleteIRODSDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ }
+ dialog.dispose();
+
+ }
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.form
new file mode 100644
index 0000000..c9a2786
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.form
@@ -0,0 +1,158 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="title" type="java.lang.String" value="Create New Folder Dialog"/>
+ <Property name="name" type="java.lang.String" value="NewParentDialog" noResource="true"/>
+ </Properties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,47,0,0,2,110"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblTitle">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Please enter a name for the new folder"/>
+ </Properties>
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="North"/>
+ </Constraint>
+ </Constraints>
+ </Component>
+ <Container class="javax.swing.JPanel" name="pnlFolderData">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
+ <Property name="columns" type="int" value="1"/>
+ <Property name="rows" type="int" value="0"/>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="pnlCurrentParent">
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace pref="20" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="lblCurrentParent" min="-2" max="-2" attributes="0"/>
+ <Component id="lblNewDiretoryName" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" max="-2" attributes="0">
+ <Component id="txtNewFolder" max="32767" attributes="1"/>
+ <Component id="scrollCurrentParent" alignment="0" pref="413" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="58" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="scrollCurrentParent" alignment="0" min="-2" max="-2" attributes="0"/>
+ <Component id="lblCurrentParent" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="txtNewFolder" min="-2" max="-2" attributes="0"/>
+ <Component id="lblNewDiretoryName" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="68" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="java.awt.Label" name="lblCurrentParent">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Current parent directory:"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JScrollPane" name="scrollCurrentParent">
+ <AuxValues>
+ <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+ </AuxValues>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+ <SubComponents>
+ <Component class="javax.swing.JTextArea" name="txtAreaCurrentParent">
+ <Properties>
+ <Property name="columns" type="int" value="20"/>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="lineWrap" type="boolean" value="true"/>
+ <Property name="rows" type="int" value="5"/>
+ <Property name="focusable" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ <Component class="java.awt.Label" name="lblNewDiretoryName">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="New folder name:"/>
+ </Properties>
+ <AccessibilityProperties>
+ <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="New directory name:"/>
+ </AccessibilityProperties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="txtNewFolder">
+ <Properties>
+ <Property name="toolTipText" type="java.lang.String" value="A name for the new folder underneath the displayed parent"/>
+ </Properties>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ <Container class="javax.swing.JPanel" name="pnlBottom">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="South"/>
+ </Constraint>
+ </Constraints>
+
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout">
+ <Property name="alignment" type="int" value="2"/>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="btnCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Cancel"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="btnOK">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="OK"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.java
new file mode 100644
index 0000000..ad1cd5f
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderNewIRODSDirectoryDialog.java
@@ -0,0 +1,298 @@
+
+
+/*
+ * NewIRODSDirectoryDialog.java
+ *
+ * Created on Sep 3, 2010, 9:52:12 AM
+ */
+package org.irods.jargon.idrop.finder;
+
+import org.irods.jargon.idrop.desktop.systraygui.*;
+import java.awt.Color;
+import java.awt.Cursor;
+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.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
+import org.irods.jargon.idrop.desktop.systraygui.services.IRODSFileService;
+import org.irods.jargon.idrop.desktop.systraygui.utils.TreeUtils;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSNode;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSTree;
+import org.irods.jargon.idrop.exceptions.IdropException;
+import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dialog to gather a new directory name
+ *
+ * @author mikeconway
+ */
+public class FinderNewIRODSDirectoryDialog extends javax.swing.JDialog {
+
+ private final IRODSFinderDialog irodsFinderDialog;
+ private String parentDirectory = "";
+ private final IRODSFinderTree irodsTree;
+ private final IRODSNode parentNode;
+ public static org.slf4j.Logger log = LoggerFactory.getLogger(FinderNewIRODSDirectoryDialog.class);
+
+ public String getParentDirectory() {
+ return parentDirectory;
+ }
+
+ public void setParentDirectory(final String parentDirectory) {
+ this.parentDirectory = parentDirectory;
+ }
+
+ /** Creates new form NewIRODSDirectoryDialog */
+ public FinderNewIRODSDirectoryDialog(final IRODSFinderDialog parent, final boolean modal,
+ final String parentDirectory, final IRODSFinderTree stagingViewTree,
+ final IRODSNode parentNode) {
+ super(parent, modal);
+ this.irodsFinderDialog = parent;
+ this.parentDirectory = parentDirectory;
+ this.irodsTree = 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")
+ // <editor-fold defaultstate="collapsed"
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblTitle = new javax.swing.JLabel();
+ pnlFolderData = new javax.swing.JPanel();
+ pnlCurrentParent = new javax.swing.JPanel();
+ lblCurrentParent = new java.awt.Label();
+ scrollCurrentParent = new javax.swing.JScrollPane();
+ txtAreaCurrentParent = new javax.swing.JTextArea();
+ lblNewDiretoryName = new java.awt.Label();
+ txtNewFolder = new javax.swing.JTextField();
+ pnlBottom = new javax.swing.JPanel();
+ btnCancel = new javax.swing.JButton();
+ btnOK = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Create New Folder Dialog");
+ setName("NewParentDialog"); // NOI18N
+
+ lblTitle.setText("Please enter a name for the new folder");
+ getContentPane().add(lblTitle, java.awt.BorderLayout.NORTH);
+
+ pnlFolderData.setLayout(new java.awt.GridLayout(0, 1));
+
+ lblCurrentParent.setText("Current parent directory:");
+
+ txtAreaCurrentParent.setColumns(20);
+ txtAreaCurrentParent.setEditable(false);
+ txtAreaCurrentParent.setLineWrap(true);
+ txtAreaCurrentParent.setRows(5);
+ txtAreaCurrentParent.setFocusable(false);
+ scrollCurrentParent.setViewportView(txtAreaCurrentParent);
+
+ lblNewDiretoryName.setText("New folder name:");
+
+ txtNewFolder.setToolTipText("A name for the new folder underneath the displayed parent");
+
+ org.jdesktop.layout.GroupLayout pnlCurrentParentLayout = new org.jdesktop.layout.GroupLayout(pnlCurrentParent);
+ pnlCurrentParent.setLayout(pnlCurrentParentLayout);
+ pnlCurrentParentLayout.setHorizontalGroup(
+ pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(org.jdesktop.layout.GroupLayout.TRAILING, pnlCurrentParentLayout.createSequentialGroup()
+ .addContainerGap(20, Short.MAX_VALUE)
+ .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(lblCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblNewDiretoryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+ .add(txtNewFolder)
+ .add(scrollCurrentParent, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 413, Short.MAX_VALUE))
+ .addContainerGap())
+ );
+ pnlCurrentParentLayout.setVerticalGroup(
+ pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(pnlCurrentParentLayout.createSequentialGroup()
+ .add(58, 58, 58)
+ .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(scrollCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblCurrentParent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(pnlCurrentParentLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(txtNewFolder, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(lblNewDiretoryName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(68, Short.MAX_VALUE))
+ );
+
+ lblNewDiretoryName.getAccessibleContext().setAccessibleName("New directory name:");
+
+ pnlFolderData.add(pnlCurrentParent);
+
+ getContentPane().add(pnlFolderData, java.awt.BorderLayout.CENTER);
+
+ pnlBottom.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
+
+ btnCancel.setText("Cancel");
+ btnCancel.addActionListener(new java.awt.event.ActionListener() {
+ 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();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void btnCancelActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnCancelActionPerformed
+ this.dispose();
+ }// GEN-LAST:event_btnCancelActionPerformed
+
+ private void btnOKActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnOKActionPerformed
+ processNew();
+ }// GEN-LAST:event_btnOKActionPerformed
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ 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);
+ MessageManager.showError(this, "please enter a new folder name", MessageManager.TITLE_MESSAGE);
+ return;
+ }
+
+ final FinderNewIRODSDirectoryDialog thisDialog = this;
+
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ log.info("adding new folder named:{}",
+ txtNewFolder.getText());
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+
+ IRODSFileService irodsFileService;
+ try {
+ irodsFileService = new IRODSFileService(irodsFinderDialog.getIdropCore().getIrodsAccount(), irodsFinderDialog.getIdropCore().getIrodsFileSystem());
+ } catch (IdropException ex) {
+ Logger.getLogger(
+ FinderNewIRODSDirectoryDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ } finally {
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+
+ }
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(parentDirectory);
+ sb.append('/');
+ sb.append(txtNewFolder.getText());
+ String newDirPath = sb.toString();
+
+ boolean created = irodsFileService.createNewFolder(newDirPath);
+
+ irodsTree.getModel();
+
+ if (!created) {
+ log.info("could not create new folder in:{}",
+ newDirPath);
+ MessageManager.showError(thisDialog, "directory could not be created", MessageManager.TITLE_MESSAGE);
+ 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, irodsFinderDialog.getIdropCore().getIrodsAccount(), irodsFinderDialog.getIdropCore().getIrodsFileSystem(), irodsFinderDialog.getIrodsTree());
+ log.info("inserting node at 0");
+ if (parentNode.isCached()) {
+ parentNode.insert(newNode, parentNode.getChildCount());
+ } else {
+ parentNode.forceReloadOfChildrenOfThisNode();
+ }
+
+ try {
+ TreePath path = FinderUtils.buildTreePathForIrodsAbsolutePath(
+ irodsFinderDialog.getIrodsTree(), entry.getParentPath());
+ irodsFinderDialog.getIrodsTree().collapsePath(path);
+ irodsFinderDialog.getIrodsTree().expandPath(path);
+ } catch (IdropException ex) {
+ Logger.getLogger(
+ FinderNewIRODSDirectoryDialog.class.getName()).log(
+ Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ } finally {
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+
+ MessageManager.showMessage(thisDialog, "new folder created", MessageManager.TITLE_MESSAGE);
+
+ thisDialog.dispose();
+ } catch (IdropException ex) {
+ Logger.getLogger(FinderNewIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(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(final ActionEvent e) {
+ processNew();
+ }
+ };
+ btnOK.registerKeyboardAction(enterAction, enter,
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.form
new file mode 100644
index 0000000..7a2ceda
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.form
@@ -0,0 +1,196 @@
+<?xml version="1.1" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+ <Properties>
+ <Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="title" type="java.lang.String" value="Rename iRODS File or Folder"/>
+ <Property name="name" type="java.lang.String" value="NewParentDialog" noResource="true"/>
+ </Properties>
+ <AccessibilityProperties>
+ <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="Rename file or folder dialog"/>
+ </AccessibilityProperties>
+ <SyntheticProperties>
+ <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+ </SyntheticProperties>
+ <AuxValues>
+ <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+ <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
+ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+ <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+ <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+ </AuxValues>
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblTitle" min="-2" pref="747" max="-2" attributes="0"/>
+ <Component id="pnlFolderData" alignment="0" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <Component id="lblTitle" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="pnlFolderData" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JLabel" name="lblTitle">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Please enter a new name for the file or collection"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JPanel" name="pnlFolderData">
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pnlCurrentParent" min="-2" pref="757" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pnlCurrentParent" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Container class="javax.swing.JPanel" name="pnlCurrentParent">
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="1" attributes="0">
+ <EmptySpace pref="30" max="32767" attributes="0"/>
+ <Group type="103" groupAlignment="1" attributes="0">
+ <Component id="lblCurrentParent" min="-2" max="-2" attributes="0"/>
+ <Component id="lblNewDiretoryName" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="1" max="-2" attributes="0">
+ <Component id="txtNewFolder" min="0" pref="0" max="32767" attributes="1"/>
+ <Component id="txtCurrentFolder" alignment="1" pref="421" max="32767" attributes="1"/>
+ </Group>
+ <EmptySpace min="-2" pref="213" max="-2" attributes="0"/>
+ </Group>
+ <Group type="102" alignment="0" attributes="0">
+ <Component id="pnlBottom" min="-2" pref="747" max="-2" attributes="0"/>
+ <EmptySpace max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace min="-2" pref="58" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="lblCurrentParent" min="-2" max="-2" attributes="0"/>
+ <Component id="txtCurrentFolder" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="txtNewFolder" min="-2" max="-2" attributes="0"/>
+ <Component id="lblNewDiretoryName" min="-2" max="-2" attributes="0"/>
+ </Group>
+ <EmptySpace pref="22" max="32767" attributes="0"/>
+ <Component id="pnlBottom" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="java.awt.Label" name="lblCurrentParent">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Current name:"/>
+ </Properties>
+ </Component>
+ <Component class="java.awt.Label" name="lblNewDiretoryName">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="New name:"/>
+ </Properties>
+ <AccessibilityProperties>
+ <Property name="AccessibleContext.accessibleName" type="java.lang.String" value="New directory name:"/>
+ </AccessibilityProperties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="txtCurrentFolder">
+ <Properties>
+ <Property name="columns" type="int" value="50"/>
+ <Property name="editable" type="boolean" value="false"/>
+ <Property name="toolTipText" type="java.lang.String" value="A name for the new folder underneath the displayed parent"/>
+ <Property name="focusable" type="boolean" value="false"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JTextField" name="txtNewFolder">
+ <Properties>
+ <Property name="columns" type="int" value="50"/>
+ <Property name="toolTipText" type="java.lang.String" value="A name for the new folder underneath the displayed parent"/>
+ </Properties>
+ </Component>
+ <Container class="javax.swing.JPanel" name="pnlBottom">
+
+ <Layout>
+ <DimensionLayout dim="0">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="576" pref="576" max="576" attributes="0"/>
+ <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="5" pref="5" max="5" attributes="0"/>
+ <Component id="btnOK" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ <DimensionLayout dim="1">
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="5" pref="5" max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
+ <Component id="btnOK" min="-2" max="-2" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
+ </DimensionLayout>
+ </Layout>
+ <SubComponents>
+ <Component class="javax.swing.JButton" name="btnCancel">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="Cancel"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
+ </Events>
+ </Component>
+ <Component class="javax.swing.JButton" name="btnOK">
+ <Properties>
+ <Property name="text" type="java.lang.String" value="OK"/>
+ </Properties>
+ <Events>
+ <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
+ </Events>
+ </Component>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+ </Container>
+ </SubComponents>
+</Form>
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.java
new file mode 100644
index 0000000..e132229
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderRenameIRODSDirectoryDialog.java
@@ -0,0 +1,345 @@
+
+/*
+ * NewIRODSDirectoryDialog.java
+ *
+ * Created on Sep 3, 2010, 9:52:12 AM
+ */
+package org.irods.jargon.idrop.finder;
+
+import java.awt.Color;
+import java.awt.Cursor;
+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.irods.jargon.core.pub.io.IRODSFile;
+import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
+import org.irods.jargon.idrop.desktop.systraygui.MessageManager;
+import org.irods.jargon.idrop.desktop.systraygui.services.IRODSFileService;
+import org.irods.jargon.idrop.desktop.systraygui.utils.TreeUtils;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSFileSystemModel;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSNode;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSOutlineModel;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSTree;
+import org.irods.jargon.idrop.exceptions.IdropException;
+import org.irods.jargon.idrop.exceptions.IdropRuntimeException;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Dialog to gather a new directory name
+ *
+ * @author mikeconway
+ */
+public class FinderRenameIRODSDirectoryDialog extends javax.swing.JDialog {
+
+ private final IRODSFinderDialog irodsFinderDialog;
+ private final String currentAbsolutePath;
+ private final IRODSFinderTree irodsTree;
+ private final IRODSNode currentNode;
+ public static org.slf4j.Logger log = LoggerFactory.getLogger(FinderRenameIRODSDirectoryDialog.class);
+
+ /** Creates new form NewIRODSDirectoryDialog */
+ public FinderRenameIRODSDirectoryDialog(final IRODSFinderDialog parent, final boolean modal,
+ final String currentAbsolutePath, final IRODSFinderTree irodsTree,
+ final IRODSNode currentNode) {
+ super(parent, modal);
+ this.irodsFinderDialog = parent;
+ this.currentAbsolutePath = currentAbsolutePath;
+ this.irodsTree = irodsTree;
+ this.currentNode = currentNode;
+ initComponents();
+ int lastPathPartIdx = currentAbsolutePath.lastIndexOf("/");
+ if (lastPathPartIdx == -1) {
+ String msg = "could not find last path component of absolute path:"
+ + currentAbsolutePath;
+ throw new IdropRuntimeException("could not find last path component of absolute path");
+ }
+
+ 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")
+ // <editor-fold defaultstate="collapsed"
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ lblTitle = new javax.swing.JLabel();
+ pnlFolderData = new javax.swing.JPanel();
+ pnlCurrentParent = new javax.swing.JPanel();
+ lblCurrentParent = new java.awt.Label();
+ 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(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();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void btnCancelActionPerformed(final java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnCancelActionPerformed
+ this.dispose();
+ }// GEN-LAST:event_btnCancelActionPerformed
+
+ private void btnOKActionPerformed(final 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);
+ MessageManager.showError(this, "please enter a new file or collection name", MessageManager.TITLE_MESSAGE);
+ return;
+ }
+
+ final FinderRenameIRODSDirectoryDialog 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(
+ irodsFinderDialog.getIdropCore().getIrodsAccount(), irodsFinderDialog.getIdropCore().getIrodsFileSystem());
+ String newPath = irodsFileService.renameIRODSFileOrDirectory(currentAbsolutePath,
+ txtNewFolder.getText());
+
+ log.debug("New path:{}", newPath);
+ IRODSFinderOutlineModel irodsOutlineModel = (IRODSFinderOutlineModel) irodsTree.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 pathForOld = FinderUtils.buildTreePathForIrodsAbsolutePath(irodsTree,
+ currentAbsolutePath);
+
+ if (pathForOld == null) {
+ log.warn(
+ "could not find old path for node:{}, ignoring",
+ currentAbsolutePath);
+ } else {
+ IRODSFileSystemModel irodsFileSystemModel = irodsOutlineModel.getTreeModel();
+ IRODSNode oldNode = (IRODSNode) pathForOld.getLastPathComponent();
+ CollectionAndDataObjectListingEntry nodesEntry = (CollectionAndDataObjectListingEntry) oldNode.getUserObject();
+ IRODSFile newEntryAsFile = irodsFinderDialog.getIdropCore().getIRODSFileFactoryForLoggedInAccount().instanceIRODSFile(newPath);
+ if (newEntryAsFile.isDirectory()) {
+ nodesEntry.setParentPath(newEntryAsFile.getParent());
+ nodesEntry.setPathOrName(newEntryAsFile.getAbsolutePath());
+ } else {
+ nodesEntry.setParentPath(newEntryAsFile.getParent());
+ nodesEntry.setPathOrName(newEntryAsFile.getName());
+ }
+
+ oldNode.setUserObject(nodesEntry);
+ irodsFileSystemModel.nodeChanged(oldNode);
+
+ }
+
+
+
+ MessageManager.showMessage(irodsFinderDialog, "The rename was successful", MessageManager.TITLE_MESSAGE);
+
+ } catch (Exception ex) {
+ Logger.getLogger(FinderRenameIRODSDirectoryDialog.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ } finally {
+ thisDialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ irodsFinderDialog.getIdropCore().closeIRODSConnectionForLoggedInAccount();
+ }
+
+ 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(final ActionEvent e) {
+ doRename();
+ }
+ };
+ btnOK.registerKeyboardAction(enterAction, enter,
+ JComponent.WHEN_IN_FOCUSED_WINDOW);
+
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderUtils.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderUtils.java
new file mode 100644
index 0000000..4cac80f
--- /dev/null
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/FinderUtils.java
@@ -0,0 +1,187 @@
+package org.irods.jargon.idrop.finder;
+
+import org.irods.jargon.idrop.desktop.systraygui.utils.*;
+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.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSFileSystemModel;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSNode;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.IRODSOutlineModel;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.LocalFileNode;
+import org.irods.jargon.idrop.desktop.systraygui.viscomponents.LocalFileSystemModel;
+import org.irods.jargon.idrop.exceptions.IdropException;
+import org.netbeans.swing.outline.Outline;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This is a set of utilities for manipulating a swing Jtree
+ *
+ * @author Mike Conway - DICE (www.irods.org)
+ */
+public class FinderUtils {
+
+ public static org.slf4j.Logger log = LoggerFactory.getLogger(FinderUtils.class);
+
+ public static IRODSNode findChild(final IRODSNode parent,
+ final String userObject) throws IdropException {
+ log.debug("finding child of parent:{}", parent);
+ log.debug("user object:{}", userObject);
+ parent.getUserObject();
+ CollectionAndDataObjectListingEntry childEntry = null;
+
+ IRODSNode foundNode = null;
+ try {
+ parent.lazyLoadOfChildrenOfThisNode();
+ } catch (IdropException ex) {
+ Logger.getLogger(FinderUtils.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;
+ }
+
+ public static TreePath buildTreePathForIrodsAbsolutePath(
+ final Outline tree, final String irodsAbsolutePath)
+ throws IdropException {
+
+ IRODSFinderOutlineModel irodsFileSystemModel = (IRODSFinderOutlineModel) tree.getModel();
+ // the root of the model, which may not be a path underneath the root of
+ // the irods resource
+ IRODSNode rootNode = (IRODSNode) irodsFileSystemModel.getRoot();
+ TreePath calculatedTreePath = new TreePath(rootNode);
+ CollectionAndDataObjectListingEntry rootEntry = (CollectionAndDataObjectListingEntry) rootNode.getUserObject();
+ String[] irodsPathComponents = irodsAbsolutePath.split("/");
+
+ /*
+ * get an array that has the path components that descend from the root
+ * of the iRODS file system to the subdirectory which the tree model
+ * considers the root of the tree
+ */
+ String[] irodsRootNodePathComponents = rootEntry.getPathOrName().split(
+ "/");
+
+ /*
+ * determine the relative calculatedTreePath of the given iRODS file
+ * underneath the root. There are cases where the root is not '/'.
+ */
+
+ StringBuilder searchRoot = new StringBuilder();
+ IRODSNode currentNode = (IRODSNode) irodsFileSystemModel.getRoot();
+ CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) currentNode.getUserObject();
+ searchRoot.append(entry.getPathOrName());
+
+ /*
+ * calculatedTreePath now holds the path from the root of iRODS to the
+ * root of the tree, now accumulate any TreePath entries that represent
+ * the path below the root of the tree contained in the absolute path.
+ * The relative path starts at the path component in the position after
+ * the length of the root path.
+ */
+
+ int relativePathStartsAfter = irodsRootNodePathComponents.length - 1;
+ String nextPathComponent;
+
+ for (int i = (relativePathStartsAfter + 1); i < irodsPathComponents.length; i++) {
+ // next element from userObjects is the child of the current node,
+ // note that for the first node (typically
+ // '/') a delimiting slash is not needed
+ if (searchRoot.length() > 1) {
+ searchRoot.append('/');
+ }
+
+ nextPathComponent = irodsPathComponents[i];
+ searchRoot.append(nextPathComponent);
+ if (i > 0) {
+ currentNode = findChild(currentNode, searchRoot.toString());
+ }
+
+ if (currentNode == null) {
+ log.warn(
+ "cannot find node for path, will attempt to return parent {}:",
+ searchRoot.toString());
+ break;
+ } else {
+ // root node is already part of the calculcated tree path
+ if (currentNode.getUserObject().toString().equals("/")) {
+ // ignore this node
+ } else {
+ calculatedTreePath = calculatedTreePath.pathByAddingChild(currentNode);
+ }
+ }
+ }
+ if (calculatedTreePath == null) {
+ throw new IdropException("cannot find path to node:"
+ + irodsAbsolutePath);
+ }
+ return calculatedTreePath;
+ }
+
+
+ public static TreePath[] getPaths(final Outline tree, final boolean expanded) {
+ TreeNode root = (TreeNode) tree.getOutlineModel().getRoot();
+
+ // Create array to hold the treepaths
+ List list = new ArrayList();
+
+ // Traverse tree from root adding treepaths for all nodes to list
+ getPaths(tree, new TreePath(root), expanded, list);
+
+ // Convert list to array
+ return (TreePath[]) list.toArray(new TreePath[list.size()]);
+ }
+
+ private static void getPaths(final Outline tree, final TreePath parent,
+ final boolean expanded, final List list) {
+ // Return if node is not expanded
+ if (expanded && !tree.isVisible(parent)) {
+ return;
+ }
+
+ // Add node to list
+ list.add(parent);
+
+ // Create paths for all children
+ TreeNode node = (TreeNode) parent.getLastPathComponent();
+ if (node.getChildCount() >= 0) {
+ for (Enumeration e = node.children(); e.hasMoreElements();) {
+ TreeNode n = (TreeNode) e.nextElement();
+ TreePath path = parent.pathByAddingChild(n);
+ getPaths(tree, path, expanded, list);
+ }
+ }
+ }
+}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.form b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.form
index 4a2b0a0..6cae3e6 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.form
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.form
@@ -3,6 +3,7 @@
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
+ <Property name="modal" type="boolean" value="true"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
@@ -17,7 +18,7 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
- <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,54,0,0,1,-15"/>
+ <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,54,0,0,2,81"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
@@ -32,12 +33,12 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
- <EmptySpace min="0" pref="497" max="32767" attributes="0"/>
+ <EmptySpace min="0" pref="593" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
- <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+ <EmptySpace min="0" pref="484" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
@@ -49,38 +50,14 @@
</Constraint>
</Constraints>
- <Layout>
- <DimensionLayout dim="0">
- <Group type="103" groupAlignment="0" attributes="0">
- <EmptySpace min="0" pref="497" max="32767" attributes="0"/>
- <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
- <Group type="102" attributes="0">
- <EmptySpace min="0" pref="60" max="32767" attributes="0"/>
- <Group type="103" groupAlignment="0" attributes="0">
- <Component id="pnlIrodsTreeToolbar" min="-2" pref="377" max="-2" attributes="0"/>
- <Component id="pnlIrodsTreeMaster" min="-2" pref="377" max="-2" attributes="0"/>
- </Group>
- <EmptySpace min="0" pref="60" max="32767" attributes="0"/>
- </Group>
- </Group>
- </Group>
- </DimensionLayout>
- <DimensionLayout dim="1">
- <Group type="103" groupAlignment="0" attributes="0">
- <EmptySpace min="0" pref="527" max="32767" attributes="0"/>
- <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
- <Group type="102" attributes="0">
- <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
- <Component id="pnlIrodsTreeToolbar" min="-2" max="-2" attributes="0"/>
- <Component id="pnlIrodsTreeMaster" min="-2" pref="488" max="-2" attributes="0"/>
- <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
- </Group>
- </Group>
- </Group>
- </DimensionLayout>
- </Layout>
+ <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="pnlIrodsTreeToolbar">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="North"/>
+ </Constraint>
+ </Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
@@ -104,10 +81,23 @@
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="pnlIrodsTreeMaster">
+ <Constraints>
+ <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
+ <BorderConstraints direction="Center"/>
+ </Constraint>
+ </Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="scrollIrodsTree">
+ <Properties>
+ <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="null"/>
+ </Property>
+ <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
+ <Dimension value="null"/>
+ </Property>
+ </Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.java
index d2c1483..db80082 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderDialog.java
@@ -29,6 +29,14 @@ import org.slf4j.LoggerFactory;
public class IRODSFinderDialog extends javax.swing.JDialog {
private final IDROPCore idropCore;
+
+ public IDROPCore getIdropCore() {
+ return idropCore;
+ }
+
+ public IRODSFinderTree getIrodsTree() {
+ return irodsTree;
+ }
private static final org.slf4j.Logger log = LoggerFactory.getLogger(IRODSFinderDialog.class);
private IRODSFinderTree irodsTree = null;
@@ -88,34 +96,21 @@ public class IRODSFinderDialog extends javax.swing.JDialog {
IRODSFileSystemModel irodsFileSystemModel = new IRODSFileSystemModel(
rootNode, idropCore.getIrodsAccount());
- IRODSFinderOutlineModel mdl = new IRODSFinderOutlineModel(
+ IRODSFinderOutlineModel mdl = new IRODSFinderOutlineModel(idropCore, irodsTree,
irodsFileSystemModel, new IRODSRowModel(), true,
"File System");
irodsTree.setModel(mdl);
- /*
- * IrodsTreeListenerForBuildingInfoPanel treeListener = new
- * IrodsTreeListenerForBuildingInfoPanel(gui);
- * irodsTree.addTreeExpansionListener(treeListener);
- * irodsTree.addTreeSelectionListener(treeListener); //
- * preset to display root tree node
- * irodsTree.setSelectionRow(0);
- */
+
} catch (Exception ex) {
log.error("exception building finder tree", ex);
throw new IdropRuntimeException(ex);
}
scrollIrodsTree.setViewportView(irodsTree);
- /*
- * TreePath currentPath;
- *
- * if (currentPaths != null) { while
- * (currentPaths.hasMoreElements()) { currentPath = (TreePath)
- * currentPaths.nextElement();
- * log.debug("expanding tree path:{}", currentPath);
- * irodsTree.expandPath(currentPath); } }
- */
+ scrollIrodsTree.validate();
+ gui.validate();
+
irodsTree.setRefreshingTree(false);
idropCore.getIrodsFileSystem().closeAndEatExceptions(
@@ -146,20 +141,23 @@ public class IRODSFinderDialog extends javax.swing.JDialog {
btnSelectFolder = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setModal(true);
org.jdesktop.layout.GroupLayout topPanelLayout = new org.jdesktop.layout.GroupLayout(topPanel);
topPanel.setLayout(topPanelLayout);
topPanelLayout.setHorizontalGroup(
topPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(0, 497, Short.MAX_VALUE)
+ .add(0, 593, Short.MAX_VALUE)
);
topPanelLayout.setVerticalGroup(
topPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(0, 0, Short.MAX_VALUE)
+ .add(0, 484, Short.MAX_VALUE)
);
getContentPane().add(topPanel, java.awt.BorderLayout.CENTER);
+ treePanel.setLayout(new java.awt.BorderLayout());
+
btnRefreshTargetTree.setMnemonic('r');
btnRefreshTargetTree.setText(org.openide.util.NbBundle.getMessage(IRODSFinderDialog.class, "IRODSFinderDialog.btnRefreshTargetTree.text")); // NOI18N
btnRefreshTargetTree.setToolTipText(org.openide.util.NbBundle.getMessage(IRODSFinderDialog.class, "IRODSFinderDialog.btnRefreshTargetTree.toolTipText")); // NOI18N
@@ -173,32 +171,15 @@ public class IRODSFinderDialog extends javax.swing.JDialog {
});
pnlIrodsTreeToolbar.add(btnRefreshTargetTree);
+ treePanel.add(pnlIrodsTreeToolbar, java.awt.BorderLayout.NORTH);
+
pnlIrodsTreeMaster.setLayout(new java.awt.BorderLayout());
+
+ scrollIrodsTree.setMinimumSize(null);
+ scrollIrodsTree.setPreferredSize(null);
pnlIrodsTreeMaster.add(scrollIrodsTree, java.awt.BorderLayout.CENTER);
- org.jdesktop.layout.GroupLayout treePanelLayout = new org.jdesktop.layout.GroupLayout(treePanel);
- treePanel.setLayout(treePanelLayout);
- treePanelLayout.setHorizontalGroup(
- treePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(0, 497, Short.MAX_VALUE)
- .add(treePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(treePanelLayout.createSequentialGroup()
- .add(0, 60, Short.MAX_VALUE)
- .add(treePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(pnlIrodsTreeToolbar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 377, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(pnlIrodsTreeMaster, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 377, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(0, 60, Short.MAX_VALUE)))
- );
- treePanelLayout.setVerticalGroup(
- treePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(0, 527, Short.MAX_VALUE)
- .add(treePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(treePanelLayout.createSequentialGroup()
- .add(0, 0, Short.MAX_VALUE)
- .add(pnlIrodsTreeToolbar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(pnlIrodsTreeMaster, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 488, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(0, 0, Short.MAX_VALUE)))
- );
+ treePanel.add(pnlIrodsTreeMaster, java.awt.BorderLayout.CENTER);
getContentPane().add(treePanel, java.awt.BorderLayout.PAGE_START);
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderOutlineModel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderOutlineModel.java
index 09f443e..fb180ee 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderOutlineModel.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderOutlineModel.java
@@ -19,6 +19,7 @@ import org.irods.jargon.core.pub.io.IRODSFileFactory;
import org.irods.jargon.core.query.CollectionAndDataObjectListingEntry;
import org.irods.jargon.core.transfer.TransferStatus;
import org.irods.jargon.core.transfer.TransferStatus.TransferState;
+import org.irods.jargon.idrop.desktop.systraygui.IDROPCore;
import org.irods.jargon.idrop.desktop.systraygui.iDrop;
import org.irods.jargon.idrop.desktop.systraygui.utils.TreeUtils;
import org.irods.jargon.idrop.exceptions.IdropException;
@@ -34,21 +35,151 @@ public class IRODSFinderOutlineModel extends DefaultOutlineModel {
public static final org.slf4j.Logger log = LoggerFactory.getLogger(IRODSFinderOutlineModel.class);
private final IRODSFileSystemModel treeModel;
+ private final IRODSFinderTree irodsFinderTree;
+ private final IDROPCore idropCore;
public IRODSFileSystemModel getTreeModel() {
return treeModel;
}
- public IRODSFinderOutlineModel(final TreeModel tm,
+ public IRODSFinderOutlineModel(final IDROPCore idropCore, final IRODSFinderTree irodsFinderTree, final TreeModel tm,
final TableModel tm1, final boolean bln, final String string) {
super(tm, tm1, bln, string);
this.treeModel = (IRODSFileSystemModel) tm;
+ this.irodsFinderTree = irodsFinderTree;
+ this.idropCore = idropCore;
}
- public IRODSFinderOutlineModel(final TreeModel tm,
+ public IRODSFinderOutlineModel(final IDROPCore idropCore,final IRODSFinderTree irodsFinderTree,final TreeModel tm,
final RowModel rm, final boolean bln, final String string) {
super(tm, rm, bln, string);
this.treeModel = (IRODSFileSystemModel) tm;
+ this.irodsFinderTree = irodsFinderTree;
+ this.idropCore = idropCore;
+ }
+
+ public void notifyFileShouldBeRemoved(final IRODSNode deletedNode)
+ throws IdropException {
+
+ if (deletedNode == null) {
+ return;
+ }
+ log.info("deleting node from parent:{}", deletedNode);
+ final IRODSNode parent = (IRODSNode) deletedNode.getParent();
+
+ if (parent == null) {
+ return;
+ }
+
+ final IRODSFinderOutlineModel thisModel = this;
+
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ deletedNode.getUserObject();
+ CollectionAndDataObjectListingEntry entry = (CollectionAndDataObjectListingEntry) (parent).getUserObject();
+
+ try {
+ FinderUtils.buildTreePathForIrodsAbsolutePath(
+ irodsFinderTree, entry.getFormattedAbsolutePath());
+
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(
+ Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ }
+
+ treeModel.removeNodeFromParent(deletedNode);
+
+ }
+ });
+ }
+
+
+ public void notifyFileShouldBeAdded(final IRODSTree irodsTree,
+ final String irodsFileAbsolutePath) {
+ log.info("notifyFileShouldBeAdded() for node:{}", irodsFileAbsolutePath);
+
+ java.awt.EventQueue.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+
+ IRODSFileFactory irodsFileFactory = idropCore.getIRODSFileFactoryForLoggedInAccount();
+ try {
+ try {
+ // if the node already exists (e.g. an overwrite, don'
+ // add it
+
+ TreePath currentPath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree,
+ irodsFileAbsolutePath);
+ // build treePath will return parent if child not found
+ if (currentPath == null) {
+ log.warn(
+ "null tree path found for:{} logged and ignored as a warning",
+ irodsFileAbsolutePath);
+ return;
+ }
+ IRODSNode irodsNode = (IRODSNode) currentPath.getLastPathComponent();
+ CollectionAndDataObjectListingEntry lastPathNodeEntry = (CollectionAndDataObjectListingEntry) irodsNode.getUserObject();
+ if (irodsFileAbsolutePath.equals(lastPathNodeEntry.getFormattedAbsolutePath())) {
+ log.info("path already exists, do not double-add");
+ return;
+ }
+
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ }
+
+ IRODSFile addedFile = irodsFileFactory.instanceIRODSFile(irodsFileAbsolutePath);
+ if (!addedFile.exists()) {
+ log.info(
+ "looking for file that was added, I don't find it, so just move on: {}",
+ irodsFileAbsolutePath);
+ return;
+ }
+ TreePath parentPath;
+ try {
+ parentPath = TreeUtils.buildTreePathForIrodsAbsolutePath(irodsTree,
+ addedFile.getParent());
+ } catch (IdropException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(Level.SEVERE, null, ex);
+ throw new IdropRuntimeException(ex);
+ }
+
+ if (parentPath == null) {
+ log.info("null path for lookup, just move on");
+ return;
+ }
+ log.info("building a new node");
+ CollectionAndDataObjectListingEntry newEntry = new CollectionAndDataObjectListingEntry();
+ newEntry.setCreatedAt(new Date(addedFile.lastModified()));
+ newEntry.setDataSize(addedFile.length());
+ newEntry.setModifiedAt(new Date(addedFile.lastModified()));
+
+ if (addedFile.isDirectory()) {
+ newEntry.setObjectType(CollectionAndDataObjectListingEntry.ObjectType.COLLECTION);
+ newEntry.setParentPath(addedFile.getParent());
+ newEntry.setPathOrName(addedFile.getAbsolutePath());
+ } else {
+ newEntry.setObjectType(CollectionAndDataObjectListingEntry.ObjectType.DATA_OBJECT);
+ newEntry.setParentPath(addedFile.getParent());
+ newEntry.setPathOrName(addedFile.getName());
+ }
+
+ IRODSNode newNode = new IRODSNode(newEntry, idropCore.getIrodsAccount(), idropCore.getIrodsFileSystem(), irodsTree);
+ ((IRODSNode) parentPath.getLastPathComponent()).add(newNode);
+ irodsTree.highlightPath(parentPath);
+ } catch (JargonException ex) {
+ Logger.getLogger(IRODSOutlineModel.class.getName()).log(
+ Level.SEVERE, null, ex);
+ } finally {
+ idropCore.closeIRODSConnectionForLoggedInAccount();
+ }
+ }
+ });
}
}
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderTree.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderTree.java
index a05edbe..07d1fe3 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderTree.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/finder/IRODSFinderTree.java
@@ -99,6 +99,7 @@ public class IRODSFinderTree extends Outline implements TreeWillExpandListener,
*/
private void setUpTreeMenu() {
thisTree = this;
+
m_popup = new JPopupMenu();
m_action = new AbstractAction() {
@@ -137,15 +138,14 @@ public class IRODSFinderTree extends Outline implements TreeWillExpandListener,
return;
}
// show a dialog asking for the new directory name...
- /* FIXME: implement
- NewIRODSDirectoryDialog newDirectoryDialog = new NewIRODSDirectoryDialog(
- idropParentGui, true, dataEntry.getPathOrName(),
+
+ FinderNewIRODSDirectoryDialog newDirectoryDialog = new FinderNewIRODSDirectoryDialog(
+ irodsFinderDialog, true, dataEntry.getPathOrName(),
thisTree, parent);
newDirectoryDialog.setLocation(
- (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
+ (int) (irodsFinderDialog.getLocation().getX() + irodsFinderDialog.getWidth() / 2), (int) (irodsFinderDialog.getLocation().getY() + irodsFinderDialog.getHeight() / 2));
newDirectoryDialog.setVisible(true);
- *
- */
+
}
};
m_popup.add(newAction);
@@ -160,8 +160,8 @@ public class IRODSFinderTree extends Outline implements TreeWillExpandListener,
int[] rows = thisTree.getSelectedRows();
log.debug("selected rows for delete:{}", rows);
- /* FIXME: redo
- DeleteIRODSDialog deleteDialog;
+
+ FinderDeleteIRODSDialog deleteDialog;
if (rows.length == 1) {
@@ -169,7 +169,7 @@ public class IRODSFinderTree extends Outline implements TreeWillExpandListener,
rows[0], 0);
log.info("deleting a single node: {}", toDelete);
- deleteDialog = new DeleteIRODSDialog(idropParentGui, true,
+ deleteDialog = new FinderDeleteIRODSDialog(irodsFinderDialog, true,
thisTree, toDelete);
} else {
List<IRODSNode> nodesToDelete = new ArrayList<IRODSNode>();
@@ -179,15 +179,14 @@ public class IRODSFinderTree extends Outline implements TreeWillExpandListener,
}
- deleteDialog = new DeleteIRODSDialog(idropParentGui, true,
+ deleteDialog = new FinderDeleteIRODSDialog(irodsFinderDialog, true,
thisTree, nodesToDelete);
}
deleteDialog.setLocation(
- (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
+ (int) (irodsFinderDialog.getLocation().getX() + irodsFinderDialog.getWidth() / 2), (int) (irodsFinderDialog.getLocation().getY() + irodsFinderDialog.getHeight() / 2));
deleteDialog.setVisible(true);
- *
- */
+
}
};
@@ -211,15 +210,13 @@ public class IRODSFinderTree extends Outline implements TreeWillExpandListener,
sb.append('/');
sb.append(dataEntry.getPathOrName());
}
-/* FIXME redo
+
// show a dialog asking for the new directory name...
- RenameIRODSDirectoryDialog renameDialog = new RenameIRODSDirectoryDialog(
- idropParentGui, true, sb.toString(), thisTree, toRename);
+ FinderRenameIRODSDirectoryDialog renameDialog = new FinderRenameIRODSDirectoryDialog(
+ irodsFinderDialog, true, sb.toString(), thisTree, toRename);
renameDialog.setLocation(
- (int) (idropParentGui.getLocation().getX() + idropParentGui.getWidth() / 2), (int) (idropParentGui.getLocation().getY() + idropParentGui.getHeight() / 2));
+ (int) (irodsFinderDialog.getLocation().getX() + irodsFinderDialog.getWidth() / 2), (int) (irodsFinderDialog.getLocation().getY() + irodsFinderDialog.getHeight() / 2));
renameDialog.setVisible(true);
- *
- */
}
};
m_popup.add(a2);
diff --git a/idrop-swing/src/main/resources/org/irods/jargon/idrop/desktop/systraygui/viscomponents/Bundle.properties b/idrop-swing/src/main/resources/org/irods/jargon/idrop/desktop/systraygui/viscomponents/Bundle.properties
index 4830328..3ac7782 100644
--- a/idrop-swing/src/main/resources/org/irods/jargon/idrop/desktop/systraygui/viscomponents/Bundle.properties
+++ b/idrop-swing/src/main/resources/org/irods/jargon/idrop/desktop/systraygui/viscomponents/Bundle.properties
@@ -22,3 +22,4 @@ SetupWizard.btnChooseLocalSynch.text=Choose Local Folder
SetupWizard.btnChooseLocalSynch.toolTipText=Choose the local folder
SetupWizard.btnChooseIrodsSynch.text=Choose iRODS Folder
SetupWizard.btnChooseIrodsSynch.toolTipText=Choose an iRODS synch folder
+SetupWizard.title=iDrop Setup Wizard