summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-08-02 11:14:17 (GMT)
committer Mike Conway <mikeconway@Mike-Conways-MacBook-Pro.local>2011-08-02 11:14:17 (GMT)
commit6ef4dc78cd315177c4485b0e73577e685303af6b (patch)
treea7e5c5c8a78f3b0809b94b374730739b10869a19
parent26468140cd8e95bbaa324ebbb6c35cc219216d70 (diff)
downloadQCG-Data-6ef4dc78cd315177c4485b0e73577e685303af6b.zip
QCG-Data-6ef4dc78cd315177c4485b0e73577e685303af6b.tar.gz
QCG-Data-6ef4dc78cd315177c4485b0e73577e685303af6b.tar.bz2
add new synch
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java83
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java20
-rw-r--r--idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/viscomponents/SetupWizard.java57
3 files changed, 122 insertions, 38 deletions
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java
index 2a10c22..34dad5b 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/IDROPConfigurationPanel.java
@@ -18,6 +18,7 @@ import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
+import org.irods.jargon.core.connection.IRODSAccount;
import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.idrop.desktop.systraygui.services.IdropConfigurationService;
import org.irods.jargon.idrop.desktop.systraygui.utils.IdropConfig;
@@ -31,6 +32,7 @@ import org.irods.jargon.transfer.dao.domain.SynchronizationType;
import org.irods.jargon.transfer.engine.synch.ConflictingSynchException;
import org.irods.jargon.transfer.engine.synch.SynchException;
import org.irods.jargon.transfer.engine.synch.SynchManagerService;
+import org.irods.jargon.transfer.util.HibernateUtil;
import org.openide.util.Exceptions;
import org.slf4j.LoggerFactory;
@@ -490,8 +492,15 @@ public class IDROPConfigurationPanel extends javax.swing.JDialog {
// TODO add your handling code here:
}//GEN-LAST:event_btnDeleteSelectedActionPerformed
+ /**
+ * Called to clear and prepare for adding a new synchronization
+ * @param evt
+ */
private void btnNewSynchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewSynchActionPerformed
- // TODO add your handling code here:
+ clearAndResetSynchPanel();
+ jTableSynch.getSelectionModel().removeIndexInterval(0,jTableSynch.getModel().getRowCount() -1);
+ selectedSynchronization = new Synchronization();
+ MessageManager.showMessage(this, "Enter the data for the new Synchronization and press Update to save", MessageManager.TITLE_MESSAGE);
}//GEN-LAST:event_btnNewSynchActionPerformed
/**
@@ -531,6 +540,10 @@ public class IDROPConfigurationPanel extends javax.swing.JDialog {
return;
}
+ boolean isNew = (selectedSynchronization.getId() == null);
+ if (isNew) {
+ log.info("adding new synch");
+ }
// edits pass, do update
log.info("saving synch data");
Synchronization synchronization = selectedSynchronization;
@@ -541,6 +554,21 @@ public class IDROPConfigurationPanel extends javax.swing.JDialog {
synchronization.setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); // FIXME: set properly from radio
synchronization.setLocalSynchDirectory(txtLocalPath.getText().trim());
synchronization.setIrodsSynchDirectory(txtIrodsPath.getText().trim());
+ IRODSAccount irodsAccount = idropCore.getIrodsAccount();
+ synchronization.setIrodsHostName(irodsAccount.getHost());
+ try {
+ synchronization.setIrodsPassword(HibernateUtil.obfuscate(irodsAccount.getPassword()));
+ } catch (JargonException ex) {
+ log.error("exception obfuscating password", ex);
+ MessageManager.showError(thisPanel, ex.getMessage(), MessageManager.TITLE_MESSAGE);
+ throw new IdropRuntimeException(ex);
+ }
+
+ synchronization.setIrodsPort(irodsAccount.getPort());
+ synchronization.setIrodsUserName(irodsAccount.getUserName());
+ synchronization.setIrodsZone(irodsAccount.getZone());
+ synchronization.setDefaultResourceName(irodsAccount.getDefaultStorageResource());
+ synchronization.setCreatedAt(new Date());
selectedSynchronization = synchronization;
try {
@@ -548,27 +576,42 @@ public class IDROPConfigurationPanel extends javax.swing.JDialog {
idropCore.getIdropConfigurationService().updateSynchronization(synchronization);
ListSelectionModel lsm = (ListSelectionModel) thisPanel.getSynchTable().getSelectionModel();
+ SynchConfigTableModel model = (SynchConfigTableModel) thisPanel.getSynchTable().getModel();
+
+ if (isNew) {
+ SynchManagerService synchConfigurationService = idropCore.getTransferManager().getTransferServiceFactory().instanceSynchManagerService();
+
- if (lsm.isSelectionEmpty()) {
- return;
+ List<Synchronization> synchronizations = synchConfigurationService.listAllSynchronizations();
+
+ model.setSynchronizations(synchronizations);
+ model.fireTableDataChanged();
} else {
- // Find out which indexes are selected.
- int minIndex = lsm.getMinSelectionIndex();
- int maxIndex = lsm.getMaxSelectionIndex();
- for (int i = minIndex; i <= maxIndex; i++) {
- if (lsm.isSelectedIndex(i)) {
- int modelIdx = thisPanel.getSynchTable().convertRowIndexToModel(i);
- SynchConfigTableModel model = (SynchConfigTableModel) thisPanel.getSynchTable().getModel();
- model.getSynchronizations().set(modelIdx, synchronization);
- model.fireTableDataChanged();
- break;
+ if (lsm.isSelectionEmpty()) {
+ return;
+ } else {
+ // Find out which indexes are selected.
+ int minIndex = lsm.getMinSelectionIndex();
+ int maxIndex = lsm.getMaxSelectionIndex();
+ for (int i = minIndex; i <= maxIndex; i++) {
+ if (lsm.isSelectedIndex(i)) {
+ int modelIdx = thisPanel.getSynchTable().convertRowIndexToModel(i);
+
+ model.getSynchronizations().set(modelIdx, synchronization);
+ model.fireTableDataChanged();
+ break;
+ }
}
}
}
+
+ MessageManager.showMessage(thisPanel, "Configuration updated", MessageManager.TITLE_MESSAGE);
+
} catch (IdropException ex) {
MessageManager.showError(thisPanel, ex.getMessage(), MessageManager.TITLE_MESSAGE);
- } catch (ConflictingSynchException ex) {
+
+ } catch (SynchException ex) {
MessageManager.showError(thisPanel, ex.getMessage(), MessageManager.TITLE_MESSAGE);
} finally {
thisPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
@@ -679,6 +722,18 @@ public class IDROPConfigurationPanel extends javax.swing.JDialog {
txtSynchName.setBackground(Color.WHITE);
}
+ /**
+ * Clear synch panel values and colors
+ */
+ private void clearAndResetSynchPanel() {
+ resetSynchPanel();
+ txtLocalPath.setText("");
+ txtIrodsPath.setText("");
+ txtSynchName.setText("");
+ radioBackup.setSelected(true);
+ jcomboSynchFrequency.setSelectedIndex(0);
+ }
+
class SynchListSelectionHandler implements ListSelectionListener {
private final IDROPConfigurationPanel idropConfigurationPanel;
diff --git a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java
index 05eae73..fadd46d 100644
--- a/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java
+++ b/idrop-swing/src/main/java/org/irods/jargon/idrop/desktop/systraygui/iDrop.java
@@ -301,6 +301,7 @@ public class iDrop extends javax.swing.JFrame implements ActionListener,
@Override
public void run() {
if (ts.getTransferState() == TransferStatus.TransferState.OVERALL_INITIATION) {
+ clearProgressBar();
// on initiation, clear and reset the status bar info
lblTransferType.setText(ts.getTransferType().name());
lblTransferFilesCounts.setText("Files: "
@@ -314,13 +315,14 @@ public class iDrop extends javax.swing.JFrame implements ActionListener,
transferStatusProgressBar.setMaximum(ts.getTotalFilesToTransfer());
transferStatusProgressBar.setValue(0);
} else if (ts.getTransferState() == TransferStatus.TransferState.SYNCH_INITIALIZATION) {
+ clearProgressBar();
lblTransferStatusMessage.setText("Synchronization Initializing");
} else if (ts.getTransferState() == TransferStatus.TransferState.SYNCH_DIFF_GENERATION) {
lblTransferStatusMessage.setText("Synchronization looking for updates");
} else if (ts.getTransferState() == TransferStatus.TransferState.SYNCH_DIFF_STEP) {
lblTransferStatusMessage.setText("Synchronizing differences");
} else if (ts.getTransferState() == TransferStatus.TransferState.SYNCH_COMPLETION) {
- lblTransferStatusMessage.setText("");
+ lblTransferStatusMessage.setText("Synchronization complete");
} else if (ts.getTransferEnclosingType() == TransferStatus.TransferType.SYNCH) {
lblTransferStatusMessage.setText("Transfer to synchronize local and iRODS");
}
@@ -2784,4 +2786,20 @@ public class iDrop extends javax.swing.JFrame implements ActionListener,
public void setFileTree(final LocalFileTree fileTree) {
this.fileTree = fileTree;
}
+
+ /**
+ * Call from a swing event queue runnable
+ */
+ private void clearProgressBar() {
+ lblTransferType.setText("");
+ lblTransferFilesCounts.setText("Files: / ");
+
+ lblTransferByteCounts.setText("Bytes (kb): / ");
+
+ lblCurrentFile.setText("");
+ transferStatusProgressBar.setMinimum(0);
+ transferStatusProgressBar.setMaximum(100);
+ transferStatusProgressBar.setValue(0);
+
+ }
}
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 2e7aa86..0f40b9f 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
@@ -13,6 +13,7 @@ import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
+import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.idrop.desktop.systraygui.IDROPCore;
import org.irods.jargon.idrop.desktop.systraygui.MessageManager;
import org.irods.jargon.idrop.desktop.systraygui.iDrop;
@@ -25,6 +26,7 @@ import org.irods.jargon.transfer.dao.domain.Synchronization;
import org.irods.jargon.transfer.dao.domain.SynchronizationType;
import org.irods.jargon.transfer.engine.synch.ConflictingSynchException;
import org.irods.jargon.transfer.engine.synch.SynchException;
+import org.irods.jargon.transfer.util.HibernateUtil;
import org.openide.util.Exceptions;
import org.slf4j.LoggerFactory;
@@ -365,7 +367,7 @@ public class SetupWizard extends javax.swing.JDialog {
saveSeeSystemTrayYes();
}
- private void saveSeeSystemTrayYes () throws IdropRuntimeException {
+ private void saveSeeSystemTrayYes() throws IdropRuntimeException {
log.info("indicates system try shown, set to not load gui");
try {
idropConfigurationService.updateConfig(IdropConfigurationService.SHOW_GUI, "false");
@@ -380,7 +382,7 @@ public class SetupWizard extends javax.swing.JDialog {
private void saveDeviceName() {
if (txtDeviceName.getText().length() == 0) {
txtDeviceName.setBackground(Color.red);
- MessageManager.showError(this, "Device name is not entered", SETUP_ERROR_TITLE);
+ MessageManager.showError(this, "Device name is not entered", SETUP_ERROR_TITLE);
return;
}
try {
@@ -506,10 +508,10 @@ public class SetupWizard extends javax.swing.JDialog {
finishWizard();
return;
}
-
+
tabAdvancing = true;
tabWizardTabs.setSelectedIndex(currentTab);
-
+
// for synch setup, if a synch exists, do not allow setup
if (currentTab == 2) {
try {
@@ -522,10 +524,10 @@ public class SetupWizard extends javax.swing.JDialog {
}
} catch (SynchException ex) {
log.error("error looking for existing synchs", ex);
- throw new IdropRuntimeException(ex);
+ throw new IdropRuntimeException(ex);
}
}
-
+
tabStep = currentTab;
}
@@ -590,28 +592,37 @@ public class SetupWizard extends javax.swing.JDialog {
log.info("retry setup of synch");
}
} else {
- log.info("saving synch data");
- Synchronization synchronization = new Synchronization();
- synchronization.setCreatedAt(new Date());
- synchronization.setDefaultResourceName(idropCore.getIrodsAccount().getDefaultStorageResource());
- synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); // FIXME: create code to set this viz the combo
- synchronization.setIrodsHostName(idropCore.getIrodsAccount().getHost());
- synchronization.setIrodsPassword(idropCore.getIrodsAccount().getPassword()); // FIXME: obfuscate
- synchronization.setIrodsPort(idropCore.getIrodsAccount().getPort());
- synchronization.setIrodsSynchDirectory(txtIrodsPath.getText());
- synchronization.setLocalSynchDirectory(txtLocalPath.getText());
- synchronization.setIrodsUserName(idropCore.getIrodsAccount().getUserName());
- synchronization.setIrodsZone(idropCore.getIrodsAccount().getZone());
- synchronization.setName("Default");
- synchronization.setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); // FIXME: set properly from radio
try {
+ log.info("saving synch data");
+ Synchronization synchronization = new Synchronization();
+ synchronization.setCreatedAt(new Date());
+ synchronization.setDefaultResourceName(idropCore.getIrodsAccount().getDefaultStorageResource());
+ synchronization.setFrequencyType(FrequencyType.EVERY_HOUR); // FIXME: create code to set this viz the combo
+ synchronization.setIrodsHostName(idropCore.getIrodsAccount().getHost());
+
+ synchronization.setIrodsPassword(HibernateUtil.obfuscate(idropCore.getIrodsAccount().getPassword()));
+
+ synchronization.setIrodsPort(idropCore.getIrodsAccount().getPort());
+ synchronization.setIrodsSynchDirectory(txtIrodsPath.getText());
+ synchronization.setLocalSynchDirectory(txtLocalPath.getText());
+ synchronization.setIrodsUserName(idropCore.getIrodsAccount().getUserName());
+ synchronization.setIrodsZone(idropCore.getIrodsAccount().getZone());
+ synchronization.setName("Default");
+ synchronization.setSynchronizationMode(SynchronizationType.ONE_WAY_LOCAL_TO_IRODS); // FIXME: set properly from radio
+
this.idropConfigurationService.createNewSynchronization(synchronization);
advanceTab();
+ } catch (JargonException ex) {
+ MessageManager.showError(this, ex.getMessage(), SETUP_ERROR_TITLE);
+ throw new IdropRuntimeException(ex);
} catch (IdropException ex) {
- MessageManager.showError(this, ex.getMessage(), SETUP_ERROR_TITLE);
+ MessageManager.showError(this, ex.getMessage(), SETUP_ERROR_TITLE);
+ throw new IdropRuntimeException(ex);
} catch (ConflictingSynchException ex) {
- MessageManager.showError(this, ex.getMessage(), SETUP_ERROR_TITLE);
- }
+ MessageManager.showError(this, ex.getMessage(), SETUP_ERROR_TITLE);
+ throw new IdropRuntimeException(ex);
+
+ }
}
}
}