hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.16 -r1.17
--- MonitoringApplication.java 16 Apr 2012 23:51:52 -0000 1.16
+++ MonitoringApplication.java 17 Apr 2012 18:12:41 -0000 1.17
@@ -59,15 +59,10 @@
import org.lcsim.util.Driver;
import org.lcsim.util.aida.AIDA;
-// TODO: Make screenshot format selectable in combo box (png, jpeg, etc.).
-// TODO: Add some spacing/padding around the components in tabs.
-// TODO: Event refresh should be set via "Event -> Event Refresh..." which can check for validity and then push to GUI.
-// Disallow direct edits to Event Monitor GUI component.
// TODO: Move the parts of this class having to do with EtEvent/EvioEvent/LCSimEvent to separate classes.
// TODO: Move the Swing parts of this class to MonitoringGui class.
// TODO: Should have Timer to update elapsed time field independent of event processing.
// http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html
-// TODO: help menu
public class MonitoringApplication {
private JPanel mainPanel;
@@ -124,9 +119,10 @@
}
}
- private static final class MonitoringApplicationActionListener implements ActionListener
- {
+ private static final class MonitoringApplicationActionListener implements ActionListener {
+
MonitoringApplication app;
+
MonitoringApplicationActionListener(MonitoringApplication app) {
this.app = app;
}
@@ -604,6 +600,10 @@
private boolean warnOnDisconnect() {
return jobPanel.disconnectWarningCheckBox.isSelected();
}
+
+ private boolean disconnectOnError() {
+ return jobPanel.disconnectOnErrorCheckBox.isSelected();
+ }
/*
* Disconnect cleanly from an ET session.
@@ -692,43 +692,45 @@
eventBuilder.setDetectorName(getDetectorName());
}
- private void processEtEvent(EtEvent mev) {
-
- // Start of event GUI hook.
- startEvent();
+ private void processEtEvent(EtEvent mev) {
+ try {
+ // Start of event GUI hook.
+ startEvent();
- // Create EvioEvent from EtEvent and skip if failed.
- EvioEvent evioEvent = null;
- try {
- evioEvent = createEvioEvent(mev);
- } catch (Exception e) {
- badEvent();
- return;
- }
- if (evioEvent == null) {
- badEvent();
- return;
- }
-
- // Create LCSim event from EVIO data.
- EventHeader lcsimEvent = eventBuilder.makeLCSimEvent(evioEvent);
-
- if (lcsimEvent == null) {
- badEvent();
- return;
- }
-
- // Supply record to Driver Adapter.
- try {
+ // Create EvioEvent from EtEvent and skip if failed.
+ EvioEvent evioEvent = createEvioEvent(mev);
+
+ // Throw an error if EVIO event is null.
+ if (evioEvent == null)
+ throw new RuntimeException("Failed to create EVIO event.");
+
+ // Create the LCSim event.
+ EventHeader lcsimEvent = eventBuilder.makeLCSimEvent(evioEvent);
+
+ // Throw an error if LCSim event is null.
+ if (lcsimEvent == null)
+ throw new RuntimeException("Failed to create LCSim event.");
+
+ // Process the LCSim event.
jobManager.processEvent(lcsimEvent);
- } catch (Exception e) {
+
+ // End of event GUI hook.
+ endEvent();
+ }
+ // Catch event processing exceptions.
+ catch (Exception e) {
+
+ // Print a stack trace.
e.printStackTrace();
+
+ // Bad event GUI hook.
badEvent();
- return;
+
+ // If user wants to disconnect on error, then throw the exception to caller.
+ if (disconnectOnError()) {
+ throw new RuntimeException(e);
+ }
}
-
- // End of event GUI hook.
- endEvent();
}
private EvioEvent createEvioEvent(EtEvent etEvent) throws IOException, EvioException {
hps-java/src/main/java/org/lcsim/hps/monitoring
diff -u -r1.4 -r1.5
--- JobPanel.java 16 Apr 2012 23:13:37 -0000 1.4
+++ JobPanel.java 17 Apr 2012 18:12:41 -0000 1.5
@@ -1,7 +1,5 @@
package org.lcsim.hps.monitoring;
-import static org.lcsim.hps.monitoring.MonitoringCommands.warnOnDisconnectCmd;
-
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -17,7 +15,6 @@
import javax.swing.JPanel;
import javax.swing.JTextField;
-// TODO Add field for setting the class to do LCSim event building. Use EventBuilder interface to check if given class makes sense.
class JobPanel extends JPanel implements ActionListener {
JComboBox steeringComboBox;
@@ -27,6 +24,7 @@
JCheckBox logCheckBox;
JTextField logFileField;
JCheckBox disconnectWarningCheckBox;
+ JCheckBox disconnectOnErrorCheckBox;
String defaultEventBuilderClassName = "";
@@ -165,9 +163,28 @@
c.anchor = GridBagConstraints.EAST;
disconnectWarningCheckBox = new JCheckBox();
disconnectWarningCheckBox.setSelected(false);
- disconnectWarningCheckBox.addActionListener(this);
- disconnectWarningCheckBox.setActionCommand(warnOnDisconnectCmd);
add(disconnectWarningCheckBox, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 0;
+ c.gridy = 7;
+ c.anchor = GridBagConstraints.WEST;
+ JLabel disconnectOnErrorLabel = new JLabel("Disconnect on error:");
+ disconnectOnErrorLabel.setHorizontalAlignment(JLabel.LEFT);
+ disconnectOnErrorLabel.setToolTipText("Whether or not to disconnect if there is an error in event processing.");
+ add(disconnectOnErrorLabel, c);
+
+ c = new GridBagConstraints();
+ c.gridx = 1;
+ c.gridy = 7;
+ c.anchor = GridBagConstraints.EAST;
+ disconnectOnErrorCheckBox = new JCheckBox();
+ disconnectOnErrorCheckBox.setSelected(true);
+ add(disconnectOnErrorCheckBox, c);
+
+ /*
+ disconnectOnErrorCheckBox
+ */
}
public void actionPerformed(ActionEvent e) {