Sprint 12/21
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
|
||||
import ch.psi.pshell.core.Configuration.NotificationLevel;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionResult;
|
||||
import ch.psi.utils.swing.SwingUtils.OptionType;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -18,6 +21,7 @@ public class Experiment extends Panel {
|
||||
public Experiment() {
|
||||
initComponents();
|
||||
updateRsync();
|
||||
SwingUtils.setEnumCombo(comboNotification, NotificationLevel.class);
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@@ -31,7 +35,8 @@ public class Experiment extends Panel {
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
updateControls();
|
||||
updateControls();
|
||||
updateNotify();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,11 +98,11 @@ public class Experiment extends Panel {
|
||||
undo();
|
||||
}
|
||||
|
||||
boolean updatingRsync;
|
||||
boolean updatingControls;
|
||||
|
||||
void updateRsync() {
|
||||
try {
|
||||
updatingRsync = true;
|
||||
updatingControls = true;
|
||||
String user = null;
|
||||
String host = null;
|
||||
String path = null;
|
||||
@@ -122,9 +127,21 @@ public class Experiment extends Panel {
|
||||
buttonSetFolder.setEnabled(false);
|
||||
|
||||
} finally {
|
||||
updatingRsync = false;
|
||||
updatingControls = false;
|
||||
}
|
||||
}
|
||||
|
||||
void updateNotify() {
|
||||
try {
|
||||
updatingControls = true;
|
||||
comboNotification.setSelectedItem(getContext().getConfig().notificationLevel);
|
||||
textRecipients.setText(getContext().getNotificationManager().getConfig().to);
|
||||
} finally {
|
||||
updatingControls = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void updateControls() {
|
||||
boolean editable = getState().isInitialized() && !getState().isProcessing();
|
||||
@@ -183,6 +200,13 @@ public class Experiment extends Panel {
|
||||
textRsyncHost = new javax.swing.JTextField();
|
||||
checkRsyncRemove = new javax.swing.JCheckBox();
|
||||
buttonUndoFolder = new javax.swing.JButton();
|
||||
jPanel7 = new javax.swing.JPanel();
|
||||
jLabel13 = new javax.swing.JLabel();
|
||||
jLabel14 = new javax.swing.JLabel();
|
||||
textRecipients = new javax.swing.JTextField();
|
||||
comboNotification = new javax.swing.JComboBox<>();
|
||||
buttonNotificationApply = new javax.swing.JButton();
|
||||
buttonNotificationUndo = new javax.swing.JButton();
|
||||
|
||||
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Metadata"));
|
||||
|
||||
@@ -520,6 +544,66 @@ public class Experiment extends Panel {
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("Notification"));
|
||||
|
||||
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel13.setText("Mode:");
|
||||
|
||||
jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel14.setText("Recipients:");
|
||||
|
||||
comboNotification.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
|
||||
|
||||
buttonNotificationApply.setText("Set");
|
||||
buttonNotificationApply.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonNotificationApplyActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonNotificationUndo.setText("Undo");
|
||||
buttonNotificationUndo.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonNotificationUndoActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
|
||||
jPanel7.setLayout(jPanel7Layout);
|
||||
jPanel7Layout.setHorizontalGroup(
|
||||
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel7Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel13)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(comboNotification, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jLabel14)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(textRecipients)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(buttonNotificationApply)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(buttonNotificationUndo)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonNotificationApply, buttonNotificationUndo});
|
||||
|
||||
jPanel7Layout.setVerticalGroup(
|
||||
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel7Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel13)
|
||||
.addComponent(jLabel14)
|
||||
.addComponent(textRecipients, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonNotificationApply)
|
||||
.addComponent(buttonNotificationUndo)
|
||||
.addComponent(comboNotification, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -535,6 +619,7 @@ public class Experiment extends Panel {
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(panelDataFile, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonApply, buttonClear, buttonUndo});
|
||||
@@ -547,6 +632,8 @@ public class Experiment extends Panel {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
@@ -639,7 +726,13 @@ public class Experiment extends Panel {
|
||||
}//GEN-LAST:event_textNamePatternKeyReleased
|
||||
|
||||
private void checkRsyncEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkRsyncEnableActionPerformed
|
||||
if (!updatingRsync) {
|
||||
if (!updatingControls) {
|
||||
if (!checkRsyncEnable.isSelected()) {
|
||||
if (SwingUtils.showOption(getTopLevel(), "Disable Data Transfer", "Do you want to disable data transfer and remove the user authentication?", OptionType.YesNo) != OptionResult.Yes) {
|
||||
updateRsync();
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
setSetting("RSYNC_USER", "");
|
||||
//setSetting("RSYNC_PATH", "");
|
||||
@@ -698,7 +791,7 @@ public class Experiment extends Panel {
|
||||
}//GEN-LAST:event_buttonSetFolderActionPerformed
|
||||
|
||||
private void checkRsyncRemoveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkRsyncRemoveActionPerformed
|
||||
if (!updatingRsync) {
|
||||
if (!updatingControls) {
|
||||
try {
|
||||
setSetting("RSYNC_DEL", checkRsyncRemove.isSelected());
|
||||
} catch (Exception ex) {
|
||||
@@ -720,10 +813,37 @@ public class Experiment extends Panel {
|
||||
buttonSetFolder.setEnabled(checkRsyncEnable.isSelected());
|
||||
}//GEN-LAST:event_textRsyncPathKeyReleased
|
||||
|
||||
private void buttonNotificationUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNotificationUndoActionPerformed
|
||||
try {
|
||||
updateNotify();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonNotificationUndoActionPerformed
|
||||
|
||||
private void buttonNotificationApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonNotificationApplyActionPerformed
|
||||
try {
|
||||
NotificationLevel level = (NotificationLevel) comboNotification.getSelectedItem();
|
||||
String to = textRecipients.getText().trim();
|
||||
if (level!=NotificationLevel.Off){
|
||||
if (to.isEmpty()){
|
||||
throw new Exception("To enable notifications please set the recepient list.");
|
||||
}
|
||||
}
|
||||
getContext().getConfig().notificationLevel =level;
|
||||
getContext().getNotificationManager().setRecipients(to.split(";"));
|
||||
getContext().getNotificationManager().initialize(); //Remove this when fix setRecipients
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}//GEN-LAST:event_buttonNotificationApplyActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonApply;
|
||||
private javax.swing.JButton buttonClear;
|
||||
private javax.swing.JButton buttonDefaultPath;
|
||||
private javax.swing.JButton buttonNotificationApply;
|
||||
private javax.swing.JButton buttonNotificationUndo;
|
||||
private javax.swing.JButton buttonSetFolder;
|
||||
private javax.swing.JButton buttonSetPath;
|
||||
private javax.swing.JButton buttonSetSeq;
|
||||
@@ -733,9 +853,12 @@ public class Experiment extends Panel {
|
||||
private javax.swing.JButton buttonUndoSeq;
|
||||
private javax.swing.JCheckBox checkRsyncEnable;
|
||||
private javax.swing.JCheckBox checkRsyncRemove;
|
||||
private javax.swing.JComboBox<String> comboNotification;
|
||||
private javax.swing.JLabel jLabel10;
|
||||
private javax.swing.JLabel jLabel11;
|
||||
private javax.swing.JLabel jLabel12;
|
||||
private javax.swing.JLabel jLabel13;
|
||||
private javax.swing.JLabel jLabel14;
|
||||
private javax.swing.JLabel jLabel18;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
@@ -746,6 +869,7 @@ public class Experiment extends Panel {
|
||||
private javax.swing.JLabel jLabel9;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel6;
|
||||
private javax.swing.JPanel jPanel7;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JPanel panelDataFile;
|
||||
private javax.swing.JSpinner spinnerSeq;
|
||||
@@ -755,6 +879,7 @@ public class Experiment extends Panel {
|
||||
private javax.swing.JTextField textPGroup;
|
||||
private javax.swing.JTextField textProposal;
|
||||
private javax.swing.JTextField textProposer;
|
||||
private javax.swing.JTextField textRecipients;
|
||||
private javax.swing.JTextField textRsyncHost;
|
||||
private javax.swing.JTextField textRsyncPath;
|
||||
private javax.swing.JTextField textRsyncUser;
|
||||
|
||||
Reference in New Issue
Block a user