Author: [log in to unmask]
Date: Mon Nov 10 11:20:53 2014
New Revision: 1473
Log:
Apply code formatting to all Java files in the monitoring-app module.
Modified:
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/AbstractFieldsPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ApplicationWindow.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Commands.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionSettingsPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DatePanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DialogUtil.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettingsPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Main.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotInfoWindow.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotWindow.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/RunPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ScreenUtil.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusWindow.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/WindowConfiguration.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/HasConfigurationModel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/RunModel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/SystemStatusTableModel.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringAnalysisFactory.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUtil.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/StatusCode.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/Subsystem.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusListener.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal/EcalStripChartTestDriver.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java
java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/ConnectionStatus.java Mon Nov 10 11:20:53 2014
@@ -3,11 +3,6 @@
/**
* Status of the connection to the ET server from the monitoring client.
*/
-public enum ConnectionStatus {
- DISCONNECTED,
- DISCONNECTING,
- ERROR,
- CONNECTION_REQUESTED,
- CONNECTED,
- PAUSED
+public enum ConnectionStatus {
+ DISCONNECTED, DISCONNECTING, ERROR, CONNECTION_REQUESTED, CONNECTED, PAUSED
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/enums/SteeringType.java Mon Nov 10 11:20:53 2014
@@ -4,6 +4,5 @@
* The type of steering to use for event processing.
*/
public enum SteeringType {
- RESOURCE,
- FILE;
+ RESOURCE, FILE;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/AbstractFieldsPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/AbstractFieldsPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/AbstractFieldsPanel.java Mon Nov 10 11:20:53 2014
@@ -20,18 +20,17 @@
import org.hps.monitoring.gui.model.HasConfigurationModel;
/**
- * A <code>JPanel</code> which has a number of fields with the labels
- * in the first column and the components for showing/editing the fields
- * in the second. It uses <code>GridBagConstraints</code> for layout.
+ * A <code>JPanel</code> which has a number of fields with the labels in the first column and the
+ * components for showing/editing the fields in the second. It uses <code>GridBagConstraints</code>
+ * for layout.
*/
// TODO: This should use features of JFormattedTextField instead of plain JTextField.
-abstract class AbstractFieldsPanel extends JPanel
- implements PropertyChangeListener, HasConfigurationModel, ActionListener {
-
- private int currY = 0;
+abstract class AbstractFieldsPanel extends JPanel implements PropertyChangeListener, HasConfigurationModel, ActionListener {
+
+ private int currY = 0;
private Insets insets;
private boolean editable = false;
-
+
/**
* Class constructor.
* @param insets The insets for the panel.
@@ -41,14 +40,14 @@
this.insets = insets;
this.editable = editable;
}
-
+
/**
* Class constructor.
*/
AbstractFieldsPanel() {
this.insets = new Insets(1, 1, 1, 1);
}
-
+
/**
* Add a field.
* @param name The name of the field.
@@ -69,7 +68,7 @@
protected final JTextField addField(String name, String value, int size) {
return addField(name, value, size, this.editable);
}
-
+
/**
* Add a field.
* @param name The name of the field.
@@ -84,11 +83,11 @@
f.setToolTipText(tooltip);
return f;
}
-
- /**
- * Add a field.
- * @param name The name of the field.
- * @param value The default value of the field.
+
+ /**
+ * Add a field.
+ * @param name The name of the field.
+ * @param value The default value of the field.
* @param size The size of the field.
* @param editable The editable setting.
* @return The JTextField component.
@@ -101,25 +100,25 @@
c.anchor = GridBagConstraints.WEST;
JLabel label = new JLabel(name + ":");
add(label, c);
-
+
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = currY;
c.insets = insets;
c.anchor = GridBagConstraints.EAST;
- //JFormattedTextField field = new JFormattedTextField(value, size);
+ // JFormattedTextField field = new JFormattedTextField(value, size);
JFormattedTextField field = new JFormattedTextField(value);
field.setColumns(size);
field.setHorizontalAlignment(JTextField.RIGHT);
field.setEditable(editable);
field.setBackground(Color.WHITE);
add(field, c);
-
- ++currY;
-
+
+ ++currY;
+
return field;
}
-
+
/**
* Add a combo box.
* @param name The name of the combo box.
@@ -127,9 +126,9 @@
* @return The JComboBox component.
*/
protected final JComboBox addComboBox(String name, String[] values) {
-
- //System.out.println("addComboBox = " + name);
-
+
+ // System.out.println("addComboBox = " + name);
+
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = currY;
@@ -145,16 +144,16 @@
c.insets = insets;
c.anchor = GridBagConstraints.EAST;
JComboBox combo = new JComboBox(values);
- //System.out.println("combo width = " + combo.getWidth());
- //System.out.println("combo width = " + combo.getSize().getWidth());
+ // System.out.println("combo width = " + combo.getWidth());
+ // System.out.println("combo width = " + combo.getSize().getWidth());
combo.setEditable(editable);
add(combo, c);
-
- ++currY;
-
+
+ ++currY;
+
return combo;
}
-
+
/**
* Add a multiline combo box.
* @param name The name of the combo box.
@@ -162,7 +161,7 @@
* @return The JComboBox component.
*/
protected final JComboBox addComboBoxMultiline(String name, String[] values) {
-
+
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
@@ -173,7 +172,7 @@
waitModeLabel.setHorizontalAlignment(JLabel.LEFT);
add(waitModeLabel, c);
++currY;
-
+
c = new GridBagConstraints();
c.gridx = 0;
c.gridwidth = GridBagConstraints.REMAINDER;
@@ -181,16 +180,16 @@
c.insets = insets;
c.anchor = GridBagConstraints.WEST;
JComboBox combo = new JComboBox(values);
- //System.out.println("combo width = " + combo.getWidth());
- //System.out.println("combo width = " + combo.getSize().getWidth());
+ // System.out.println("combo width = " + combo.getWidth());
+ // System.out.println("combo width = " + combo.getSize().getWidth());
combo.setEditable(editable);
add(combo, c);
-
- ++currY;
-
+
+ ++currY;
+
return combo;
}
-
+
/**
* Add a check box.
* @param name The name of the check box.
@@ -204,7 +203,7 @@
c.setToolTipText(tooltip);
return c;
}
-
+
/**
* Add a check box.
* @param name The name of the check box.
@@ -213,7 +212,7 @@
* @return The JCheckBox component.
*/
protected final JCheckBox addCheckBox(String name, boolean selected, boolean enabled) {
-
+
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = currY;
@@ -221,7 +220,7 @@
c.anchor = GridBagConstraints.WEST;
JLabel label = new JLabel(name + ":");
add(label, c);
-
+
c = new GridBagConstraints();
c.gridx = 1;
c.gridy = currY;
@@ -231,12 +230,12 @@
checkbox.setSelected(selected);
checkbox.setEnabled(enabled);
add(checkbox, c);
-
- ++currY;
-
+
+ ++currY;
+
return checkbox;
}
-
+
protected final JButton addButton(String text) {
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
@@ -250,10 +249,10 @@
++currY;
return button;
}
-
- /**
- * Add an ActionListener to this component. By default this does nothing, but
- * individual sub-components should attach this to individual components.
+
+ /**
+ * Add an ActionListener to this component. By default this does nothing, but individual
+ * sub-components should attach this to individual components.
* @param listener The AcitonListener to add.
*/
void addActionListener(ActionListener listener) {
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ApplicationWindow.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ApplicationWindow.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ApplicationWindow.java Mon Nov 10 11:20:53 2014
@@ -8,25 +8,25 @@
* An abstract class for windows in the monitoring application.
*/
abstract class ApplicationWindow extends JFrame {
-
+
WindowConfiguration defaultWindowConfiguration;
WindowConfiguration currentWindowConfiguration;
-
+
ApplicationWindow(String title) {
this.setTitle(title);
}
-
+
final void updateWindowConfiguration(WindowConfiguration windowConfiguration) {
currentWindowConfiguration = windowConfiguration;
setSize(new Dimension(windowConfiguration.width, windowConfiguration.height));
setLocation(windowConfiguration.x, windowConfiguration.y);
}
-
+
final void setDefaultWindowConfiguration(WindowConfiguration windowConfiguration) {
defaultWindowConfiguration = windowConfiguration;
updateWindowConfiguration(windowConfiguration);
}
-
+
final void resetWindowConfiguration() {
if (defaultWindowConfiguration != null) {
setDefaultWindowConfiguration(defaultWindowConfiguration);
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Commands.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Commands.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Commands.java Mon Nov 10 11:20:53 2014
@@ -1,8 +1,8 @@
package org.hps.monitoring.gui;
/**
- * These strings are used to identify ActionEvents in the MonitoringApplication.
- * A few commands handled only by sub-components are not listed here.
+ * These strings are used to identify ActionEvents in the MonitoringApplication. A few commands
+ * handled only by sub-components are not listed here.
*/
final class Commands {
@@ -25,7 +25,7 @@
static final String LOG_TO_FILE_CHANGED = "logToFileChanged";
static final String LOG_TO_TERMINAL = "logToTerminal";
static final String NEXT = "next";
- static final String PAUSE = "pause";
+ static final String PAUSE = "pause";
static final String PROCESSING_STAGE_CHANGED = "processingStageChanged";
static final String RESTORE_DEFAULT_GUI_LAYOUT = "restoreDefaultGuiLayout";
static final String RESUME = "resume";
@@ -34,14 +34,14 @@
static final String SAVE_LOG_TABLE = "saveLogTable";
static final String SAVE_PLOTS = "savePlots";
static final String SCREENSHOT = "screenshot";
- static final String SELECT_CONFIG_FILE = "selectConfigFile";
+ static final String SELECT_CONFIG_FILE = "selectConfigFile";
static final String SELECT_LOG_FILE = "logToFile";
static final String SET_EVENT_BUILDER = "setEventBuilder";
static final String SET_STEERING_RESOURCE = "setSteeringResource";
static final String SHOW_SETTINGS = "showSettings";
static final String STEERING_TYPE_CHANGED = "steeringTypeChanged";
- static final String STEERING_RESOURCE_CHANGED = "steeringResourceChanged";
+ static final String STEERING_RESOURCE_CHANGED = "steeringResourceChanged";
static final String VERBOSE_CHANGED = "verboseChanged";
static final String VALIDATE_DATA_FILE = "validateDataFile";
- static final String WAIT_MODE_CHANGED = "waitModeChanged";
+ static final String WAIT_MODE_CHANGED = "waitModeChanged";
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionSettingsPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionSettingsPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionSettingsPanel.java Mon Nov 10 11:20:53 2014
@@ -33,13 +33,9 @@
private JComboBox<?> waitModeComboBox;
private JTextField waitTimeField;
private JTextField prescaleField;
-
- static final String[] waitModes = {
- Mode.SLEEP.name(),
- Mode.TIMED.name(),
- Mode.ASYNC.name()
- };
-
+
+ static final String[] waitModes = { Mode.SLEEP.name(), Mode.TIMED.name(), Mode.ASYNC.name() };
+
ConfigurationModel configurationModel;
/**
@@ -51,46 +47,46 @@
setLayout(new GridBagLayout());
- etNameField = addField("ET Name", "", 20);
+ etNameField = addField("ET Name", "", 20);
etNameField.addPropertyChangeListener("value", this);
-
+
hostField = addField("Host", 20);
hostField.addPropertyChangeListener("value", this);
-
+
portField = addField("Port", 5);
portField.addPropertyChangeListener("value", this);
-
+
blockingCheckBox = addCheckBox("Blocking", false, true);
blockingCheckBox.setActionCommand(BLOCKING_CHANGED);
blockingCheckBox.addActionListener(this);
-
- verboseCheckBox = addCheckBox("Verbose", false, true);
+
+ verboseCheckBox = addCheckBox("Verbose", false, true);
verboseCheckBox.setActionCommand(VERBOSE_CHANGED);
verboseCheckBox.addActionListener(this);
-
+
stationNameField = addField("Station Name", 10);
- stationNameField.addPropertyChangeListener("value", this);
-
+ stationNameField.addPropertyChangeListener("value", this);
+
chunkSizeField = addField("Chunk Size", 3);
chunkSizeField.addPropertyChangeListener("value", this);
-
+
queueSizeField = addField("Queue Size", 3);
queueSizeField.addPropertyChangeListener("value", this);
-
+
stationPositionField = addField("Station Position", 3);
stationPositionField.addPropertyChangeListener("value", this);
-
- waitModeComboBox = addComboBox("Wait Mode", waitModes);
+
+ waitModeComboBox = addComboBox("Wait Mode", waitModes);
waitModeComboBox.setActionCommand(WAIT_MODE_CHANGED);
waitModeComboBox.addActionListener(this);
-
+
waitTimeField = addField("Wait Time [microseconds]", 8);
waitTimeField.addPropertyChangeListener(this);
-
+
prescaleField = addField("Prescale", 8);
- prescaleField.addPropertyChangeListener(this);
- }
-
+ prescaleField.addPropertyChangeListener(this);
+ }
+
/**
* Enable or disable the connection panel GUI elements.
* @param e Set to true for enabled; false to disable.
@@ -109,16 +105,16 @@
waitTimeField.setEnabled(e);
prescaleField.setEnabled(e);
}
-
+
/**
* Updates the GUI from changes in the ConfigurationModel.
*/
public class ConfigurationSettingsChangeListener implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
-
+
Object value = evt.getNewValue();
-
+
if (evt.getPropertyName().equals(ET_NAME_PROPERTY)) {
etNameField.setText((String) value);
} else if (evt.getPropertyName().equals(HOST_PROPERTY)) {
@@ -138,12 +134,12 @@
} else if (evt.getPropertyName().equals(STATION_POSITION_PROPERTY)) {
stationPositionField.setText(value.toString());
} else if (evt.getPropertyName().equals(WAIT_MODE_PROPERTY)) {
- waitModeComboBox.setSelectedItem(((Mode)value).name());
+ waitModeComboBox.setSelectedItem(((Mode) value).name());
} else if (evt.getPropertyName().equals(WAIT_TIME_PROPERTY)) {
waitTimeField.setText(value.toString());
} else if (evt.getPropertyName().equals(PRESCALE_PROPERTY)) {
prescaleField.setText(value.toString());
- }
+ }
}
}
@@ -152,12 +148,12 @@
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
-
+
if (evt.getPropertyName().equals("ancestor"))
return;
-
+
Object source = evt.getSource();
-
+
if (source.equals(etNameField)) {
configurationModel.setEtName(etNameField.getText());
} else if (source.equals(hostField)) {
@@ -176,9 +172,9 @@
configurationModel.setWaitTime(Integer.parseInt(waitTimeField.getText()));
} else if (source.equals(prescaleField)) {
configurationModel.setPrescale(Integer.parseInt(prescaleField.getText()));
- }
- }
-
+ }
+ }
+
/**
* Used to update the ConfigurationModel from GUI components.
*/
@@ -191,16 +187,16 @@
} else if (VERBOSE_CHANGED.equals(e.getActionCommand())) {
configurationModel.setVerbose(verboseCheckBox.isSelected());
}
- }
+ }
@Override
public void setConfigurationModel(ConfigurationModel configurationModel) {
// Set the ConfigurationModel reference.
this.configurationModel = configurationModel;
-
+
// This listener pushes GUI values into the configuration.
this.configurationModel.addPropertyChangeListener(this);
-
+
// This listener updates the GUI from changes in the configuration.
this.configurationModel.addPropertyChangeListener(new ConfigurationSettingsChangeListener());
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ConnectionStatusPanel.java Mon Nov 10 11:20:53 2014
@@ -25,10 +25,10 @@
JTextField statusField;
JTextField dateField;
-
+
// Format for date field.
private final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss");
-
+
private static final int PANEL_HEIGHT = 50;
private static final int PANEL_WIDTH = 400;
@@ -36,23 +36,23 @@
* Class constructor.
*/
ConnectionStatusPanel() {
-
+
setMinimumSize(new Dimension(PANEL_WIDTH, PANEL_HEIGHT));
-
+
setLayout(new GridBagLayout());
- //setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
+ // setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
Font font = new Font("Arial", Font.PLAIN, 14);
GridBagConstraints c = new GridBagConstraints();
c.weightx = c.weighty = 1.0;
-
+
// Bottom separator.
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
add(new JSeparator(SwingConstants.HORIZONTAL), c);
-
+
// Connection status label.
c = new GridBagConstraints();
c.gridx = 0;
@@ -76,7 +76,7 @@
statusField.setFont(font);
statusField.setMinimumSize(new Dimension(300, 50));
add(statusField, c);
-
+
// The "@" label.
c.gridx = 2;
c.gridy = 1;
@@ -85,7 +85,7 @@
c.insets = new Insets(0, 0, 0, 10);
JLabel atLabel = new JLabel("@");
add(atLabel, c);
-
+
// The date field.
c = new GridBagConstraints();
c.gridx = 3;
@@ -98,7 +98,7 @@
dateField.setFont(font);
dateField.setMinimumSize(new Dimension(200, 50));
add(dateField, c);
-
+
// Bottom separator.
c = new GridBagConstraints();
c.gridx = 0;
@@ -106,9 +106,9 @@
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
c.insets = new Insets(10, 0, 0, 0);
- add(new JSeparator(SwingConstants.HORIZONTAL), c);
- }
-
+ add(new JSeparator(SwingConstants.HORIZONTAL), c);
+ }
+
void setConnectionStatus(final ConnectionStatus status) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DataSourcePanel.java Mon Nov 10 11:20:53 2014
@@ -26,64 +26,56 @@
import org.hps.record.enums.ProcessingStage;
/**
- * A sub-panel of the settings window for selecting a data source,
- * e.g. an ET server, an LCIO file, or an EVIO file.
+ * A sub-panel of the settings window for selecting a data source, e.g. an ET server, an LCIO file,
+ * or an EVIO file.
*/
class DataSourcePanel extends AbstractFieldsPanel {
-
- static final String[] dataSourceTypes = {
- DataSourceType.ET_SERVER.description(),
- DataSourceType.EVIO_FILE.description(),
- DataSourceType.LCIO_FILE.description()
- };
-
- static final String[] processingStages = {
- ProcessingStage.ET.name(),
- ProcessingStage.EVIO.name(),
- ProcessingStage.LCIO.name()
- };
-
+
+ static final String[] dataSourceTypes = { DataSourceType.ET_SERVER.description(), DataSourceType.EVIO_FILE.description(), DataSourceType.LCIO_FILE.description() };
+
+ static final String[] processingStages = { ProcessingStage.ET.name(), ProcessingStage.EVIO.name(), ProcessingStage.LCIO.name() };
+
JComboBox<?> dataSourceTypeComboBox;
JTextField dataSourcePathField;
JButton fileSourceButton;
JButton validateDataFileButton;
JComboBox<?> processingStageComboBox;
-
+
ConfigurationModel configurationModel;
-
+
DataSourcePanel() {
- setLayout(new GridBagLayout());
-
+ setLayout(new GridBagLayout());
+
dataSourceTypeComboBox = addComboBox("Data Source", dataSourceTypes);
dataSourceTypeComboBox.setSelectedIndex(0);
dataSourceTypeComboBox.setActionCommand(DATA_SOURCE_TYPE_CHANGED);
dataSourceTypeComboBox.addActionListener(this);
-
+
dataSourcePathField = addField("Data Source Path", 40);
dataSourcePathField.addPropertyChangeListener(this);
-
+
fileSourceButton = addButton("Select data file");
fileSourceButton.setActionCommand(CHOOSE_FILE_SOURCE);
fileSourceButton.addActionListener(this);
-
+
validateDataFileButton = addButton("Validate data file");
validateDataFileButton.setActionCommand(VALIDATE_DATA_FILE);
-
+
processingStageComboBox = addComboBox("Processing Stage", processingStages);
processingStageComboBox.setSelectedIndex(2);
processingStageComboBox.setActionCommand(PROCESSING_STAGE_CHANGED);
- processingStageComboBox.addActionListener(this);
+ processingStageComboBox.addActionListener(this);
}
-
+
private String getFileExtension(String path) {
return path.substring(path.lastIndexOf(".") + 1);
}
-
+
private void chooseDataFile() {
JFileChooser fc = new JFileChooser(System.getProperty("user.dir"));
fc.setAcceptAllFileFilterUsed(false);
fc.addChoosableFileFilter(new FileNameExtensionFilter("LCIO files", "slcio"));
- fc.addChoosableFileFilter(new FileNameExtensionFilter("EVIO files", "evio"));
+ fc.addChoosableFileFilter(new FileNameExtensionFilter("EVIO files", "evio"));
fc.setDialogTitle("Select Data File");
int r = fc.showDialog(this, "Select ...");
File file = null;
@@ -91,27 +83,27 @@
file = fc.getSelectedFile();
final String filePath = file.getPath();
final String extension = getFileExtension(filePath);
-
+
// This will cause the GUI to be updated via a PropertyChangeListener.
configurationModel.setDataSourcePath(filePath);
-
+
// This will set the combo box in the GUI to the correct state, which will then
// update the model.
- if (extension.equals("slcio")) {
+ if (extension.equals("slcio")) {
dataSourceTypeComboBox.setSelectedIndex(DataSourceType.LCIO_FILE.ordinal());
} else if (extension.equals("evio")) {
dataSourceTypeComboBox.setSelectedIndex(DataSourceType.EVIO_FILE.ordinal());
- }
+ }
}
}
-
+
@Override
public void setConfigurationModel(ConfigurationModel configurationModel) {
this.configurationModel = configurationModel;
-
+
// This listener pushes GUI values into the configuration.
this.configurationModel.addPropertyChangeListener(this);
-
+
// This listener updates the GUI from changes in the configuration.
this.configurationModel.addPropertyChangeListener(new DataSourceChangeListener());
}
@@ -125,40 +117,39 @@
public void actionPerformed(ActionEvent e) {
if (DATA_SOURCE_TYPE_CHANGED.equals(e.getActionCommand())) {
DataSourceType dataSourceType = DataSourceType.values()[dataSourceTypeComboBox.getSelectedIndex()];
- configurationModel.setDataSourceType(dataSourceType);
+ configurationModel.setDataSourceType(dataSourceType);
validateDataFileButton.setEnabled(dataSourceType.isFile());
} else if (PROCESSING_STAGE_CHANGED.equals(e.getActionCommand())) {
ProcessingStage processingStage = ProcessingStage.values()[processingStageComboBox.getSelectedIndex()];
configurationModel.setProcessingStage(processingStage);
- } else if (CHOOSE_FILE_SOURCE.equals(e.getActionCommand())) {
+ } else if (CHOOSE_FILE_SOURCE.equals(e.getActionCommand())) {
chooseDataFile();
- }
+ }
}
-
+
public void propertyChange(PropertyChangeEvent evt) {
- }
-
+ }
+
/**
- * Update the GUI from changes in the underlying configuration.
- * The changes from the configuration are distinguishable by their
- * property name.
+ * Update the GUI from changes in the underlying configuration. The changes from the
+ * configuration are distinguishable by their property name.
*/
public class DataSourceChangeListener implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("ancestor"))
- return;
+ return;
Object value = evt.getNewValue();
if (DATA_SOURCE_TYPE_PROPERTY.equals(evt.getPropertyName())) {
- dataSourceTypeComboBox.setSelectedIndex(((DataSourceType)evt.getNewValue()).ordinal());
+ dataSourceTypeComboBox.setSelectedIndex(((DataSourceType) evt.getNewValue()).ordinal());
} else if (DATA_SOURCE_PATH_PROPERTY.equals(evt.getPropertyName())) {
- dataSourcePathField.setText((String) value);
+ dataSourcePathField.setText((String) value);
} else if (PROCESSING_STAGE_PROPERTY.equals(evt.getPropertyName())) {
processingStageComboBox.setSelectedItem(value.toString());
}
}
}
-
+
public void addActionListener(ActionListener listener) {
// Hook the validate button to the main app where that task actually executes.
validateDataFileButton.addActionListener(listener);
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DatePanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DatePanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DatePanel.java Mon Nov 10 11:20:53 2014
@@ -8,25 +8,25 @@
* A small JPanel with a date field and a label on its border.
*/
class DatePanel extends FieldPanel {
-
+
private SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss");
-
+
DatePanel(String fieldName, String defaultValue, int size, boolean editable) {
super(fieldName, defaultValue, size, editable);
}
-
+
DatePanel(String fieldName, Date defaultValue, SimpleDateFormat format, int size, boolean editable) {
super(fieldName, format.format(defaultValue), size, editable);
}
-
+
void setDateFormat(SimpleDateFormat dateFormat) {
this.dateFormat = dateFormat;
}
-
+
void setValue(Date date) {
setValue(dateFormat.format(date));
}
-
+
Date getDateValue() {
try {
return dateFormat.parse(getValue());
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DialogUtil.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DialogUtil.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/DialogUtil.java Mon Nov 10 11:20:53 2014
@@ -10,29 +10,20 @@
import javax.swing.SwingUtilities;
class DialogUtil {
-
- static JDialog showStatusDialog(
- final Component parentComponent,
- String title,
- String message) {
- final JOptionPane optionPane = new JOptionPane(
- message,
- JOptionPane.INFORMATION_MESSAGE,
- JOptionPane.DEFAULT_OPTION,
- null,
- new Object[]{},
- null);
- final JDialog dialog = new JDialog();
+
+ static JDialog showStatusDialog(final Component parentComponent, String title, String message) {
+ final JOptionPane optionPane = new JOptionPane(message, JOptionPane.INFORMATION_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}, null);
+ final JDialog dialog = new JDialog();
dialog.setContentPane(optionPane);
dialog.setTitle(title);
dialog.setAlwaysOnTop(true);
dialog.setLocationRelativeTo(null);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
- dialog.pack();
+ dialog.pack();
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialog.setVisible(false);
- dialog.dispose();
+ dialog.dispose();
parentComponent.setEnabled(true);
}
});
@@ -40,29 +31,21 @@
optionPane.setVisible(true);
dialog.setVisible(true);
return dialog;
- }
-
+ }
+
static void showErrorDialog(final Component component, final Throwable error, final String title) {
final Runnable runnable = new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(
- component,
- error.getMessage(),
- title,
- JOptionPane.ERROR_MESSAGE);
+ public void run() {
+ JOptionPane.showMessageDialog(component, error.getMessage(), title, JOptionPane.ERROR_MESSAGE);
}
};
SwingUtilities.invokeLater(runnable);
}
-
+
static void showInfoDialog(final Component component, final String title, final String message) {
final Runnable runnable = new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(
- component,
- message,
- title,
- JOptionPane.INFORMATION_MESSAGE);
+ public void run() {
+ JOptionPane.showMessageDialog(component, message, title, JOptionPane.INFORMATION_MESSAGE);
}
};
SwingUtilities.invokeLater(runnable);
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ErrorHandler.java Mon Nov 10 11:20:53 2014
@@ -9,8 +9,8 @@
/**
* <p>
- * An error handling class which is able to do any of the following,
- * depending on how the users wants to handle the error.
+ * An error handling class which is able to do any of the following, depending on how the users
+ * wants to handle the error.
* </p>
* <ul>
* <li>Print a message</li>
@@ -20,11 +20,9 @@
* <li>Raise an exception</li>
* <li>Exit the application</li>
* </ul>
- * </p>
- * It mostly uses the "builder" pattern so that the various handling methods
- * can be easily chained, where appropriate. Some methods are not available
- * for chaining when it doesn't make sense.
- * </p>
+ * </p> It mostly uses the "builder" pattern so that the various handling methods can be easily
+ * chained, where appropriate. Some methods are not available for chaining when it doesn't make
+ * sense. </p>
*/
class ErrorHandler {
@@ -32,7 +30,7 @@
Component component;
Throwable error;
String message;
-
+
/**
* Constructor.
* @param component The GUI component to which this object is assigned.
@@ -42,10 +40,9 @@
this.logger = logger;
this.component = component;
}
-
+
/**
- * Set the error that occurred. This should always be called
- * first in a method chain.
+ * Set the error that occurred. This should always be called first in a method chain.
* @param error The error which is a <code>Throwable</code>.
* @return This object.
*/
@@ -54,7 +51,7 @@
this.message = error.getMessage();
return this;
}
-
+
/**
* Set the error message if it differs from the exception's message.
* @param message The erro message.
@@ -64,7 +61,7 @@
this.message = message;
return this;
}
-
+
/**
* Print the full stack trace of the error to System.err.
* @return This object.
@@ -73,16 +70,16 @@
error.printStackTrace();
return this;
}
-
+
/**
* Print the error message to System.err.
* @return This object.
*/
- ErrorHandler printMessage() {
+ ErrorHandler printMessage() {
System.err.println(message);
return this;
}
-
+
/**
* Log the error message to the <code>Logger</code>.
* @return This object.
@@ -91,39 +88,34 @@
logger.log(Level.SEVERE, message);
return this;
}
-
+
/**
* Show an error dialog with the message.
- * @return This object.
+ * @return This object.
*/
ErrorHandler showErrorDialog() {
final Runnable runnable = new Runnable() {
- public void run() {
- JOptionPane.showMessageDialog(
- component,
- error.getMessage(),
- "Application Error",
- JOptionPane.ERROR_MESSAGE);
+ public void run() {
+ JOptionPane.showMessageDialog(component, error.getMessage(), "Application Error", JOptionPane.ERROR_MESSAGE);
}
};
SwingUtilities.invokeLater(runnable);
return this;
}
-
+
/**
- * Rethrow the error as a <code>RuntimeException</code>.
- * Additional methods cannot be chained to this
- * as they would not be executed.
+ * Rethrow the error as a <code>RuntimeException</code>. Additional methods cannot be chained to
+ * this as they would not be executed.
*/
- void raiseException() {
+ void raiseException() {
throw new RuntimeException(message, error);
}
-
+
/**
- * Exit the application. This is not chainable for obvious reasons.
+ * Exit the application. This is not chainable for obvious reasons.
*/
void exit() {
System.err.println("Fatal error. Application will exit.");
System.exit(1);
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/EventButtonsPanel.java Mon Nov 10 11:20:53 2014
@@ -9,8 +9,8 @@
import javax.swing.JPanel;
/**
- * This is the panel with buttons for connecting or disconnecting
- * and controlling the app from pause mode.
+ * This is the panel with buttons for connecting or disconnecting and controlling the app from pause
+ * mode.
*/
class EventButtonsPanel extends JPanel {
@@ -86,7 +86,7 @@
}
/**
- * Enable the "next events" button.
+ * Enable the "next events" button.
* @param e Set to true to enable; false to disable.
*/
void enableNextEventsButton(boolean e) {
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/FieldPanel.java Mon Nov 10 11:20:53 2014
@@ -11,28 +11,28 @@
* A panel with a label and a text field.
*/
class FieldPanel extends JPanel {
-
+
String fieldName;
String defaultValue;
JTextField field;
-
+
static Border border = BorderFactory.createLoweredBevelBorder();
-
+
FieldPanel(String fieldName, String defaultValue, int size, boolean editable) {
this.fieldName = fieldName;
this.defaultValue = defaultValue;
-
+
TitledBorder title = BorderFactory.createTitledBorder(border, fieldName);
title.setTitleJustification(TitledBorder.LEFT);
-
+
field = new JTextField(defaultValue, size);
field.setHorizontalAlignment(JTextField.RIGHT);
field.setEditable(editable);
field.setBorder(title);
add(field);
}
-
+
void setValue(final String value) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -40,7 +40,7 @@
}
});
}
-
+
void setValue(final int value) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -48,7 +48,7 @@
}
});
}
-
+
void setValue(final double value) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -56,7 +56,7 @@
}
});
}
-
+
void setValue(final long value) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
@@ -64,19 +64,19 @@
}
});
}
-
+
String getValue() {
return field.getText();
}
-
+
Integer getIntegerValue() {
return Integer.parseInt(getValue());
}
-
+
Double getDoubleValue() {
return Double.parseDouble(getValue());
}
-
+
Long getLongValue() {
return Long.parseLong(getValue());
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettingsPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettingsPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/JobSettingsPanel.java Mon Nov 10 11:20:53 2014
@@ -34,12 +34,12 @@
import org.jdom.input.SAXBuilder;
/**
- * This is the GUI panel for setting job parameters. It is connected to the global configuration via
+ * This is the GUI panel for setting job parameters. It is connected to the global configuration via
* a {@link org.hps.monitoring.model.ConfigurationModel} object.
*/
-// TODO: Add validity checks for event builder, lcsim steering files, etc.
-// and revert to old values if new values are invalid.
-// http://docs.oracle.com/javase/7/docs/api/javax/swing/JFormattedTextField.html
+// TODO: Add validity checks for event builder, lcsim steering files, etc.
+// and revert to old values if new values are invalid.
+// http://docs.oracle.com/javase/7/docs/api/javax/swing/JFormattedTextField.html
class JobSettingsPanel extends AbstractFieldsPanel {
private JTextField aidaSaveFileNameField;
@@ -50,135 +50,119 @@
private JTextField eventBuilderField;
private JTextField logFileNameField;
private JComboBox<?> logLevelComboBox;
- private JCheckBox logToFileCheckbox;
+ private JCheckBox logToFileCheckbox;
private JTextField steeringFileField;
private JComboBox<?> steeringResourcesComboBox;
private JComboBox<?> steeringTypeComboBox;
-
+
// The package where steering resources must be located.
static final String STEERING_PACKAGE = "org/hps/steering/monitoring/";
-
+
// FIXME: This should be in the default global config file rather than hard-coded here.
static final String DEFAULT_EVENT_BUILDER_CLASS_NAME = "org.hps.evio.LCSimTestRunEventBuilder";
-
+
// This will connect the GUI component to the underlying global configuration model.
ConfigurationModel configurationModel;
-
- // The available LogLevel settings as an array of strings.
- static final String[] LOG_LEVELS = new String[] {
- Level.ALL.toString(),
- Level.FINEST.toString(),
- Level.FINER.toString(),
- Level.FINE.toString(),
- Level.CONFIG.toString(),
- Level.INFO.toString(),
- Level.WARNING.toString(),
- Level.SEVERE.toString(),
- Level.OFF.toString()
- };
+
+ // The available LogLevel settings as an array of strings.
+ static final String[] LOG_LEVELS = new String[] { Level.ALL.toString(), Level.FINEST.toString(), Level.FINER.toString(), Level.FINE.toString(), Level.CONFIG.toString(), Level.INFO.toString(), Level.WARNING.toString(), Level.SEVERE.toString(), Level.OFF.toString() };
/**
* Class constructor.
*/
JobSettingsPanel() {
-
+
super(new Insets(4, 2, 2, 4), true);
setLayout(new GridBagLayout());
-
+
disconnectOnErrorCheckBox = addCheckBox("Disconnect on error", false, true);
disconnectOnErrorCheckBox.setActionCommand(DISCONNECT_ON_ERROR_CHANGED);
disconnectOnErrorCheckBox.addActionListener(this);
-
+
disconnectOnEndRunCheckBox = addCheckBox("Disconnect on end run", false, true);
disconnectOnEndRunCheckBox.setActionCommand(DISCONNECT_ON_END_RUN_CHANGED);
disconnectOnEndRunCheckBox.addActionListener(this);
-
- logLevelComboBox = addComboBox("Log Level", LOG_LEVELS);
+
+ logLevelComboBox = addComboBox("Log Level", LOG_LEVELS);
logLevelComboBox.setActionCommand(Commands.LOG_LEVEL_CHANGED);
logLevelComboBox.addActionListener(this);
-
- steeringTypeComboBox = addComboBox("Steering Type",
- new String[] {SteeringType.RESOURCE.name(), SteeringType.FILE.name()});
+
+ steeringTypeComboBox = addComboBox("Steering Type", new String[] { SteeringType.RESOURCE.name(), SteeringType.FILE.name() });
steeringTypeComboBox.setActionCommand(STEERING_TYPE_CHANGED);
steeringTypeComboBox.addActionListener(this);
-
+
steeringFileField = addField("Steering File", 35);
- steeringFileField.addPropertyChangeListener("value", this);
-
+ steeringFileField.addPropertyChangeListener("value", this);
+
JButton steeringFileButton = addButton("Select Steering File");
steeringFileButton.setActionCommand(Commands.CHOOSE_STEERING_FILE);
steeringFileButton.addActionListener(this);
-
- steeringResourcesComboBox = addComboBoxMultiline("Steering File Resource",
- getAvailableSteeringFileResources(STEERING_PACKAGE));
+
+ steeringResourcesComboBox = addComboBoxMultiline("Steering File Resource", getAvailableSteeringFileResources(STEERING_PACKAGE));
steeringResourcesComboBox.setActionCommand(STEERING_RESOURCE_CHANGED);
steeringResourcesComboBox.addActionListener(this);
-
+
detectorNameField = addField("Detector Name", 20);
detectorNameField.addPropertyChangeListener("value", this);
-
+
eventBuilderField = addField("Event Builder Class", 30);
eventBuilderField.setActionCommand(Commands.SET_EVENT_BUILDER);
eventBuilderField.addPropertyChangeListener("value", this);
-
+
logToFileCheckbox = addCheckBox("Log to File", false, false);
logToFileCheckbox.setEnabled(false);
logToFileCheckbox.setActionCommand(LOG_TO_FILE_CHANGED);
logToFileCheckbox.addActionListener(this);
-
+
logFileNameField = addField("Log File", "", "Full path to log file.", 30, false);
logFileNameField.addPropertyChangeListener("value", this);
-
+
aidaAutoSaveCheckbox = addCheckBox("Save AIDA at End of Job", false, false);
aidaAutoSaveCheckbox.addActionListener(this);
aidaAutoSaveCheckbox.setActionCommand(AIDA_AUTO_SAVE_CHANGED);
-
+
aidaSaveFileNameField = addField("AIDA Auto Save File Name", "", 30, false);
aidaSaveFileNameField.addPropertyChangeListener("value", this);
}
-
+
@Override
public void setConfigurationModel(ConfigurationModel configModel) {
-
+
// Set the ConfigurationModel reference.
this.configurationModel = configModel;
-
+
// This listener pushes GUI values into the configuration.
this.configurationModel.addPropertyChangeListener(this);
-
+
// This listener updates the GUI from changes in the configuration.
this.configurationModel.addPropertyChangeListener(new JobSettingsChangeListener());
}
-
+
@Override
public ConfigurationModel getConfigurationModel() {
return configurationModel;
- }
-
+ }
+
/**
* Enable this component.
* @param enable Whether to enable or not.
*/
/*
- void enableJobPanel(boolean enable) {
- detectorNameField.setEnabled(enable);
- eventBuilderField.setEnabled(enable);
- steeringTypeComboBox.setEnabled(enable);
- steeringFileField.setEnabled(enable);
- steeringResourcesComboBox.setEnabled(enable);
- }
- */
-
+ * void enableJobPanel(boolean enable) { detectorNameField.setEnabled(enable);
+ * eventBuilderField.setEnabled(enable); steeringTypeComboBox.setEnabled(enable);
+ * steeringFileField.setEnabled(enable); steeringResourcesComboBox.setEnabled(enable); }
+ */
+
/**
* Attaches the ActionListener from the main app to specific GUI components in this class.
*/
void addActionListener(ActionListener listener) {
- eventBuilderField.addActionListener(listener);
+ eventBuilderField.addActionListener(listener);
logFileNameField.addActionListener(listener);
logToFileCheckbox.addActionListener(listener);
steeringResourcesComboBox.addActionListener(listener);
}
-
+
/**
* Choose a file name for the automatic AIDA save file.
*/
@@ -195,7 +179,7 @@
}
final String finalFileName = fileName;
configurationModel.setAidaAutoSave(true);
- configurationModel.setAidaFileName(finalFileName);
+ configurationModel.setAidaFileName(finalFileName);
}
}
@@ -215,9 +199,9 @@
} catch (IOException | JDOMException e) {
throw new RuntimeException("Error parsing the selected steering file.", e);
}
- }
- }
-
+ }
+ }
+
/**
* Parse the lcsim steering file to see if it appears to be valid.
* @param file The input steering file.
@@ -232,7 +216,7 @@
throw new IOException("Not an LCSim XML file.");
}
}
-
+
/**
* Get the files with extension "lcsim" from all loaded jar files.
* @return A list of embedded steering file resources.
@@ -255,28 +239,27 @@
}
}
archive.close();
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new RuntimeException(e);
- }
+ }
java.util.Collections.sort(resources);
String[] arr = new String[resources.size()];
- for (int i=0; i<arr.length; i++) {
+ for (int i = 0; i < arr.length; i++) {
arr[i] = resources.get(i);
}
return arr;
}
@Override
- public void actionPerformed(ActionEvent e) {
+ public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(Commands.CHOOSE_STEERING_FILE)) {
this.chooseSteeringFile();
} else if (DISCONNECT_ON_ERROR_CHANGED.equals(e.getActionCommand())) {
configurationModel.setDisconnectOnError(disconnectOnErrorCheckBox.isSelected());
- } else if (DISCONNECT_ON_END_RUN_CHANGED.equals(e.getActionCommand())) {
+ } else if (DISCONNECT_ON_END_RUN_CHANGED.equals(e.getActionCommand())) {
configurationModel.setDisconnectOnEndRun(disconnectOnEndRunCheckBox.isSelected());
} else if (STEERING_TYPE_CHANGED.equals(e.getActionCommand())) {
- configurationModel.setSteeringType(SteeringType.valueOf((String) steeringTypeComboBox.getSelectedItem()));
+ configurationModel.setSteeringType(SteeringType.valueOf((String) steeringTypeComboBox.getSelectedItem()));
} else if (STEERING_RESOURCE_CHANGED.equals(e.getActionCommand())) {
configurationModel.setSteeringResource((String) steeringResourcesComboBox.getSelectedItem());
} else if (LOG_TO_FILE_CHANGED.equals(e.getActionCommand())) {
@@ -289,8 +272,8 @@
}
/**
- * Updates the configuration with changes from the GUI component values.
- * The changes from the GUI are distinguishable by their component object.
+ * Updates the configuration with changes from the GUI component values. The changes from the
+ * GUI are distinguishable by their component object.
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
@@ -315,47 +298,57 @@
configurationModel.setAidaAutoSave(aidaAutoSaveCheckbox.isSelected());
}
}
-
- /**
- * Update the GUI from changes in the underlying configuration.
- * The changes from the configuration are distinguishable by their
- * property name.
+
+ /**
+ * Update the GUI from changes in the underlying configuration. The changes from the
+ * configuration are distinguishable by their property name.
*/
public class JobSettingsChangeListener implements PropertyChangeListener {
@Override
public void propertyChange(PropertyChangeEvent evt) {
-
+
// FIXME: Anyway to make sure this is not needed?
if (evt.getPropertyName().equals("ancestor"))
return;
-
+
Object value = evt.getNewValue();
-
+
if (evt.getPropertyName().equals(DETECTOR_NAME_PROPERTY)) {
- detectorNameField.setText((String) value);
- } if (evt.getPropertyName().equals(AIDA_AUTO_SAVE_PROPERTY)) {
+ detectorNameField.setText((String) value);
+ }
+ if (evt.getPropertyName().equals(AIDA_AUTO_SAVE_PROPERTY)) {
aidaAutoSaveCheckbox.setSelected((Boolean) value);
- } if (evt.getPropertyName().equals(AIDA_FILE_NAME_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(AIDA_FILE_NAME_PROPERTY)) {
aidaSaveFileNameField.setText((String) value);
- } if (evt.getPropertyName().equals(DISCONNECT_ON_ERROR_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(DISCONNECT_ON_ERROR_PROPERTY)) {
disconnectOnErrorCheckBox.setSelected((Boolean) value);
- } if (evt.getPropertyName().equals(DISCONNECT_ON_END_RUN_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(DISCONNECT_ON_END_RUN_PROPERTY)) {
disconnectOnEndRunCheckBox.setSelected((Boolean) value);
- } if (evt.getPropertyName().equals(EVENT_BUILDER_PROPERTY)) {
- eventBuilderField.setText((String) value);
- } if (evt.getPropertyName().equals(LOG_FILE_NAME_PROPERTY)) {
- logFileNameField.setText((String) value);
- } if (evt.getPropertyName().equals(LOG_LEVEL_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(EVENT_BUILDER_PROPERTY)) {
+ eventBuilderField.setText((String) value);
+ }
+ if (evt.getPropertyName().equals(LOG_FILE_NAME_PROPERTY)) {
+ logFileNameField.setText((String) value);
+ }
+ if (evt.getPropertyName().equals(LOG_LEVEL_PROPERTY)) {
logLevelComboBox.setSelectedItem(value.toString());
- } if (evt.getPropertyName().equals(LOG_TO_FILE_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(LOG_TO_FILE_PROPERTY)) {
logToFileCheckbox.setSelected((Boolean) value);
- } if (evt.getPropertyName().equals(STEERING_TYPE_PROPERTY)) {
- steeringTypeComboBox.setSelectedIndex(((SteeringType)value).ordinal());
- } if (evt.getPropertyName().equals(STEERING_FILE_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(STEERING_TYPE_PROPERTY)) {
+ steeringTypeComboBox.setSelectedIndex(((SteeringType) value).ordinal());
+ }
+ if (evt.getPropertyName().equals(STEERING_FILE_PROPERTY)) {
steeringFileField.setText(((File) value).getPath());
- } if (evt.getPropertyName().equals(STEERING_RESOURCE_PROPERTY)) {
+ }
+ if (evt.getPropertyName().equals(STEERING_RESOURCE_PROPERTY)) {
steeringResourcesComboBox.setSelectedItem(value);
- }
- }
- }
+ }
+ }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Main.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Main.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/Main.java Mon Nov 10 11:20:53 2014
@@ -14,8 +14,7 @@
import org.hps.monitoring.gui.model.Configuration;
/**
- * This is the front-end for running the monitoring app via a
- * {@link #main(String[])} method.
+ * This is the front-end for running the monitoring app via a {@link #main(String[])} method.
*/
// FIXME: Move to org.hps.monitoring instead of gui package.
public class Main {
@@ -50,7 +49,7 @@
// Run the application on the Swing EDT.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
-
+
// Create the application class.
MonitoringApplication app = new MonitoringApplication();
@@ -58,12 +57,12 @@
if (cl.hasOption("c")) {
app.setConfiguration(new Configuration(new File(cl.getOptionValue("c"))));
}
-
+
app.initialize();
-
+
// Set the app to be visible.
app.setVisible(true);
}
});
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/MonitoringApplication.java Mon Nov 10 11:20:53 2014
@@ -104,7 +104,7 @@
/**
* This class is the implementation of the GUI for the Monitoring Application.
*/
-// TODO: Move GUI/window functionality to a new class. (This one is too big!)
+// TODO: Move GUI/window functionality to a new class. (This one is too big!)
public final class MonitoringApplication extends ApplicationWindow implements ActionListener, SystemStatusListener, PropertyChangeListener {
// Top-level Swing components.
@@ -127,7 +127,7 @@
// Saved references to System.out and System.err in case need to reset.
private final PrintStream sysOut = System.out;
private final PrintStream sysErr = System.err;
-
+
// Error handling class for the application.
private ErrorHandler errorHandler;
@@ -149,7 +149,7 @@
private JTable logTable;
private static Level DEFAULT_LOG_LEVEL = Level.INFO;
- // Graogucs format for screenshots.
+ // Graogucs format for screenshots.
private static final String SCREENSHOT_FORMAT = "png";
// Format of date field for log.
@@ -162,44 +162,45 @@
private final static int LOG_TABLE_HEIGHT = 270;
private static final int MAIN_FRAME_HEIGHT = ScreenUtil.getScreenHeight() / 2;
private static final int MAIN_FRAME_WIDTH = 650;
-
+
// Default config which can be overridden by command line argument.
private static final String DEFAULT_CONFIG_RESOURCE = "/org/hps/monitoring/config/default_config.prop";
-
- // The application global Configuration object which is the default configuration unless overridden.
+
+ // The application global Configuration object which is the default configuration unless
+ // overridden.
private Configuration configuration = new Configuration(DEFAULT_CONFIG_RESOURCE);
-
+
// The ConfigurationModel for updating GUI components from the global configuration.
private ConfigurationModel configurationModel = new ConfigurationModel();
-
+
// The RunModel for updating the RunPanel.
private RunModel runModel = new RunModel();
-
+
private FileValidationThread fileValidationThread;
-
+
/**
* Constructor for the monitoring application.
*/
public MonitoringApplication() {
-
+
super(getApplicationTitle());
-
+
// Add the application as a property change listener on the configuration model.
configurationModel.addPropertyChangeListener(this);
}
-
- /**
- * Initialize GUI components and all other necessary objects
- * to put the application in a usable state.
+
+ /**
+ * Initialize GUI components and all other necessary objects to put the application in a usable
+ * state.
*/
public void initialize() {
-
+
// Create and configure the logger.
setupLogger();
-
+
// Setup the error handling class.
setupErrorHandler();
-
+
// Setup an uncaught exception handler.
setupUncaughtExceptionHandler();
@@ -208,47 +209,47 @@
// Create the log table GUI component.
createLogTable();
-
+
// Create settings dialog window.
createSettingsDialog();
-
+
// Setup the application menus.
createMenuBar();
-
+
// Create the system status window.
createSystemStatusWindow();
-
+
// Configuration of window for showing plots.
createPlotWindow();
-
+
// Setup AIDA.
setupAida();
-
+
// Configure the application's primary JFrame.
configApplicationFrame();
-
+
// Load the current configuration, which will push values into the GUI.
loadConfiguration();
-
+
// Log that the application started successfully.
log(Level.CONFIG, "Application initialized successfully.");
}
-
+
/**
* The action handler method for the application.
* @param e The event to handle.
*/
public void actionPerformed(ActionEvent e) {
-
- //System.out.println("MonitoringApplication. actionPerformed: " + e.getActionCommand());
-
+
+ // System.out.println("MonitoringApplication. actionPerformed: " + e.getActionCommand());
+
String cmd = e.getActionCommand();
if (CONNECT.equals(cmd)) {
// Run the start session method on a seperate thread.
new Thread() {
public void run() {
startSession();
- }
+ }
}.start();
} else if (DISCONNECT.equals(cmd)) {
// Run the stop session method on a seperate thread.
@@ -256,7 +257,7 @@
public void run() {
stopSession();
}
- }.start();
+ }.start();
} else if (SAVE_PLOTS.equals(cmd)) {
savePlots();
} else if (CHOOSE_LOG_FILE.equals(cmd)) {
@@ -300,41 +301,41 @@
}
}
}
-
+
/**
* Set the GUI to visible.
*/
public void setVisible(boolean visible) {
-
+
super.setVisible(true);
-
+
this.systemStatusWindow.setVisible(true);
-
+
// FIXME: If this is done earlier before app is visible, then the GUI will fail to show!
this.connectionStatusPanel.setConnectionStatus(ConnectionStatus.DISCONNECTED);
}
-
+
/**
* Set the Configuration but don't update the ConfigurationModel.
* @param configuration
*/
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
- }
-
+ }
+
/**
* Handle a property change event.
* @param evt The property change event.
*/
@Override
public void propertyChange(PropertyChangeEvent evt) {
-
+
if (evt.getPropertyName().equals("ancestor"))
- return;
+ return;
Object value = evt.getNewValue();
if (evt.getPropertyName().equals(SAVE_LAYOUT_PROPERTY)) {
saveLayoutItem.setSelected((Boolean) value);
- } else if (evt.getPropertyName().equals(MONITORING_APPLICATION_LAYOUT_PROPERTY)){
+ } else if (evt.getPropertyName().equals(MONITORING_APPLICATION_LAYOUT_PROPERTY)) {
updateWindowConfiguration(new WindowConfiguration((String) value));
} else if (evt.getPropertyName().equals(ConfigurationModel.SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY)) {
if (systemStatusWindow != null) {
@@ -349,26 +350,26 @@
System.err.println("ERROR: The plotWindow is null!");
}
} else if (evt.getPropertyName().equals(ConfigurationModel.LOG_TO_FILE_PROPERTY)) {
-
- //System.out.println("propertyChange - " + evt.getPropertyName());
- //System.out.println(" value: " + value);
-
- if ((Boolean)value == true) {
- //System.out.println("setting logToFile - " + configurationModel.getLogFileName());
+
+ // System.out.println("propertyChange - " + evt.getPropertyName());
+ // System.out.println(" value: " + value);
+
+ if ((Boolean) value == true) {
+ // System.out.println("setting logToFile - " + configurationModel.getLogFileName());
logToFile(new File(configurationModel.getLogFileName()));
} else {
- //System.out.println("setting logToTerminal");
+ // System.out.println("setting logToTerminal");
logToTerminal();
}
}
}
-
+
/**
* Hook for logging all status changes from the system status monitor.
*/
@Override
public void statusChanged(SystemStatus status) {
-
+
// Choose the appropriate log level.
Level level = Level.INFO;
if (status.getStatusCode().equals(Level.WARNING)) {
@@ -376,97 +377,82 @@
} else if (status.getStatusCode().ordinal() >= StatusCode.ERROR.ordinal()) {
level = Level.SEVERE;
}
-
+
// Log all status changes.
- log(level, "STATUS, "
- + "subsys: " + status.getSubsystem() + ", "
- + "code: " + status.getStatusCode().name() + ", "
- + "descr: " + status.getDescription() + ", "
- + "mesg: " + status.getMessage());
- }
-
+ log(level, "STATUS, " + "subsys: " + status.getSubsystem() + ", " + "code: " + status.getStatusCode().name() + ", " + "descr: " + status.getDescription() + ", " + "mesg: " + status.getMessage());
+ }
+
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
plotWindow.setEnabled(enabled);
systemStatusWindow.setEnabled(enabled);
- //settingsDialog.setEnabled(false);
-
- //this.setFocusable(enabled);
- //plotWindow.setFocusable(enabled);
- //systemStatusWindow.setFocusable(enabled);
- //settingsDialog.setFocusable(false);
- }
-
+ // settingsDialog.setEnabled(false);
+
+ // this.setFocusable(enabled);
+ // plotWindow.setFocusable(enabled);
+ // systemStatusWindow.setFocusable(enabled);
+ // settingsDialog.setFocusable(false);
+ }
+
/* -------------------------- private methods ----------------------------- */
-
+
/**
* Setup the error handler.
*/
private void setupErrorHandler() {
errorHandler = new ErrorHandler(this, logger);
}
-
+
/**
* Setup the uncaught exception handler which will trap unhandled errors.
*/
private void setupUncaughtExceptionHandler() {
- Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
- public void uncaughtException(Thread thread, Throwable exception) {
- MonitoringApplication.this.errorHandler.setError(exception)
- .log()
- .printStackTrace()
- .showErrorDialog();
+ Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
+ public void uncaughtException(Thread thread, Throwable exception) {
+ MonitoringApplication.this.errorHandler.setError(exception).log().printStackTrace().showErrorDialog();
// FIXME: This should probably cause a system.exit after the dialog box is closed!
}
});
}
-
+
/**
* Create the settings dialog GUI component.
*/
private void createSettingsDialog() {
-
- // Create and configure the settings dialog which has sub-panels for application configuration.
+
+ // Create and configure the settings dialog which has sub-panels for application
+ // configuration.
settingsDialog = new SettingsDialog();
settingsDialog.getSettingsPanel().addActionListener(this);
getJobSettingsPanel().addActionListener(this);
settingsDialog.getSettingsPanel().getDataSourcePanel().addActionListener(this);
-
+
// Push the ConfigurationModel to the job settings dialog.
getJobSettingsPanel().setConfigurationModel(configurationModel);
getConnectionSettingsPanel().setConfigurationModel(configurationModel);
- settingsDialog.getSettingsPanel().getDataSourcePanel().setConfigurationModel(configurationModel);
+ settingsDialog.getSettingsPanel().getDataSourcePanel().setConfigurationModel(configurationModel);
}
/**
* Create the plot window.
*/
private void createPlotWindow() {
-
+
// Create the JFrame.
plotWindow = new PlotWindow();
-
+
// Set initial size and position which might be overridden later.
- plotWindow.setDefaultWindowConfiguration(
- new WindowConfiguration(
- SCREEN_WIDTH - MAIN_FRAME_WIDTH,
- SCREEN_HEIGHT,
- (int)(ScreenUtil.getBoundsX(0)) + MAIN_FRAME_WIDTH,
- plotWindow.getY()
- ));
- }
-
+ plotWindow.setDefaultWindowConfiguration(new WindowConfiguration(SCREEN_WIDTH - MAIN_FRAME_WIDTH, SCREEN_HEIGHT, (int) (ScreenUtil.getBoundsX(0)) + MAIN_FRAME_WIDTH, plotWindow.getY()));
+ }
+
private void createSystemStatusWindow() {
systemStatusWindow = new SystemStatusWindow();
- WindowConfiguration wc = new WindowConfiguration(
- 650, /* FIXME: Hard-coded width setting. */
- ScreenUtil.getScreenHeight() / 2,
- (int)ScreenUtil.getBoundsX(0),
- MAIN_FRAME_HEIGHT);
+ WindowConfiguration wc = new WindowConfiguration(650, /* FIXME: Hard-coded width setting. */
+ ScreenUtil.getScreenHeight() / 2, (int) ScreenUtil.getBoundsX(0), MAIN_FRAME_HEIGHT);
systemStatusWindow.setMinimumSize(new Dimension(wc.width, wc.height));
systemStatusWindow.setDefaultWindowConfiguration(wc);
}
-
+
/**
* Configure the AIDA plotting backend.
*/
@@ -475,10 +461,10 @@
MonitoringPlotFactory.setRootPane(this.plotWindow.getPlotPane());
MonitoringPlotFactory.setPlotterRegionListener(new PlotterRegionListener() {
@Override
- public void regionSelected(PlotterRegion region) {
+ public void regionSelected(PlotterRegion region) {
if (region == null)
throw new RuntimeException("The region arg is null!!!");
- //System.out.println("MonitoringApplication - regionSelected - " + region.title());
+ // System.out.println("MonitoringApplication - regionSelected - " + region.title());
plotInfoWindow.setCurrentRegion(region);
}
});
@@ -489,7 +475,7 @@
* Create the main panel.
*/
private void createMainPanel() {
-
+
// Main panel setup.
mainPanel = new JPanel();
mainPanel.setLayout(new GridBagLayout());
@@ -526,7 +512,7 @@
c.gridy = 2;
mainPanel.add(runPanel, c);
}
-
+
/**
* Create the application menu bar and menu items.
*/
@@ -536,73 +522,79 @@
JMenu applicationMenu = new JMenu("Application");
applicationMenu.setMnemonic(KeyEvent.VK_A);
- menuBar.add(applicationMenu);
-
+ menuBar.add(applicationMenu);
+
JMenuItem loadConfigItem = new JMenuItem("Load Settings ...");
loadConfigItem.addActionListener(this);
loadConfigItem.setMnemonic(KeyEvent.VK_C);
loadConfigItem.setActionCommand(SELECT_CONFIG_FILE);
loadConfigItem.setToolTipText("Load application settings from a properties file");
applicationMenu.add(loadConfigItem);
-
+
JMenuItem saveConfigItem = new JMenuItem("Save Settings ...");
saveConfigItem.addActionListener(this);
saveConfigItem.setMnemonic(KeyEvent.VK_S);
- saveConfigItem.setActionCommand(SAVE_CONFIG_FILE);
+ saveConfigItem.setActionCommand(SAVE_CONFIG_FILE);
saveConfigItem.setToolTipText("Save settings to a properties file");
applicationMenu.add(saveConfigItem);
-
+
JMenuItem settingsItem = new JMenuItem("Show Settings ...");
settingsItem.setMnemonic(KeyEvent.VK_P);
settingsItem.setActionCommand(SHOW_SETTINGS);
settingsItem.addActionListener(this);
settingsItem.setToolTipText("Show application settings menu");
applicationMenu.add(settingsItem);
-
+
applicationMenu.addSeparator();
-
+
saveLayoutItem = new JCheckBoxMenuItem("Save GUI Layout");
saveLayoutItem.setActionCommand(SAVE_LAYOUT);
saveLayoutItem.addActionListener(this);
saveLayoutItem.setToolTipText("Include current GUI layout when saving settings.");
- saveLayoutItem.setSelected(configurationModel.getSaveLayout()); /* Initial setting from config. */
- saveLayoutItem.addPropertyChangeListener(this); /* Any subsequent changes to model will activate this. */
+ saveLayoutItem.setSelected(configurationModel.getSaveLayout()); /*
+ * Initial setting from
+ * config.
+ */
+ saveLayoutItem.addPropertyChangeListener(this); /*
+ * Any subsequent changes to model will
+ * activate this.
+ */
applicationMenu.add(saveLayoutItem);
-
+
JMenuItem restoreLayoutItem = new JMenuItem("Restore Default GUI Layout");
restoreLayoutItem.setActionCommand(RESTORE_DEFAULT_GUI_LAYOUT);
restoreLayoutItem.addActionListener(this);
restoreLayoutItem.setToolTipText("Restore the GUI windows to their default positions and sizes");
applicationMenu.add(restoreLayoutItem);
-
+
applicationMenu.addSeparator();
-
+
JMenuItem exitItem = new JMenuItem("Exit");
exitItem.setMnemonic(KeyEvent.VK_X);
exitItem.setActionCommand(EXIT);
exitItem.addActionListener(this);
exitItem.setToolTipText("Exit from the application");
applicationMenu.add(exitItem);
-
+
JMenu plotsMenu = new JMenu("Plots");
plotsMenu.setMnemonic(KeyEvent.VK_O);
menuBar.add(plotsMenu);
-
+
JMenuItem aidaAutoSaveItem = new JMenuItem("Set AIDA Auto Save File ...");
aidaAutoSaveItem.setMnemonic(KeyEvent.VK_A);
aidaAutoSaveItem.setActionCommand(AIDA_AUTO_SAVE);
aidaAutoSaveItem.addActionListener(this);
aidaAutoSaveItem.setToolTipText("Select name of file to auto save AIDA plots at end of job.");
plotsMenu.add(aidaAutoSaveItem);
-
+
savePlotsItem = new JMenuItem("Save Plots to AIDA File...");
savePlotsItem.setMnemonic(KeyEvent.VK_P);
savePlotsItem.setActionCommand(SAVE_PLOTS);
savePlotsItem.addActionListener(this);
savePlotsItem.setEnabled(false);
savePlotsItem.setToolTipText("Save plots from default AIDA tree to an output file.");
- plotsMenu.add(savePlotsItem);
-
+ plotsMenu.add(savePlotsItem);
+
JMenu logMenu = new JMenu("Log");
logMenu.setMnemonic(KeyEvent.VK_L);
menuBar.add(logMenu);
@@ -622,21 +614,21 @@
terminalItem.setEnabled(false);
terminalItem.setToolTipText("Redirect std out and err back to the terminal.");
logMenu.add(terminalItem);
-
+
JMenuItem saveLogItem = new JMenuItem("Save Log Table to File ...");
saveLogItem.setMnemonic(KeyEvent.VK_S);
saveLogItem.setActionCommand(SAVE_LOG_TABLE);
saveLogItem.addActionListener(this);
saveLogItem.setToolTipText("Save the log records to a tab delimited text file.");
logMenu.add(saveLogItem);
-
+
JMenuItem clearLogItem = new JMenuItem("Clear Log Table");
clearLogItem.addActionListener(this);
clearLogItem.setMnemonic(KeyEvent.VK_C);
clearLogItem.setActionCommand(CLEAR_LOG_TABLE);
clearLogItem.setToolTipText("Clear the log table of all messages.");
logMenu.add(clearLogItem);
-
+
JMenu utilMenu = new JMenu("Util");
plotsMenu.setMnemonic(KeyEvent.VK_U);
menuBar.add(utilMenu);
@@ -648,7 +640,7 @@
screenshotItem.setToolTipText("Save a full screenshot to a " + SCREENSHOT_FORMAT + " file.");
utilMenu.add(screenshotItem);
}
-
+
/**
* Log handler for inserting messages into the log table.
*/
@@ -657,14 +649,11 @@
/**
* Puts log messages into the log table.
*/
- public void publish(LogRecord record) {
+ public void publish(LogRecord record) {
// Add the row to the log table.
- Object[] row = new Object[] {
- dateFormat.format(new Date(record.getMillis())),
- record.getLevel(),
- record.getMessage() };
+ Object[] row = new Object[] { dateFormat.format(new Date(record.getMillis())), record.getLevel(), record.getMessage() };
logTableModel.insertRow(logTable.getRowCount(), row);
-
+
// Print all messages to System.out so they show up in the terminal or log file output.
System.out.println(row[0] + " :: " + row[1] + " :: " + row[2]);
}
@@ -677,8 +666,7 @@
}
/**
- * Creates the log table component, which is a JTable containing messages
- * from the logger.
+ * Creates the log table component, which is a JTable containing messages from the logger.
*/
private void createLogTable() {
@@ -710,17 +698,17 @@
logger.addHandler(logHandler);
logger.setLevel(Level.ALL);
}
-
+
/**
* Show the settings window.
*/
private void showSettingsDialog() {
settingsDialog.setVisible(true);
}
-
- /**
- * Set a new log level for the application. If the new log level is the same as the old one,
- * a new log level will NOT be set.
+
+ /**
+ * Set a new log level for the application. If the new log level is the same as the old one, a
+ * new log level will NOT be set.
*/
private void setLogLevel() {
Level newLevel = configurationModel.getLogLevel();
@@ -744,27 +732,23 @@
* Setup the primary <code>JFrame</code> for the application.
*/
private void configApplicationFrame() {
-
- mainPanel.setOpaque(true);
+
+ mainPanel.setOpaque(true);
// Configure window size and position.
- WindowConfiguration wc = new WindowConfiguration(
- MAIN_FRAME_WIDTH,
- MAIN_FRAME_HEIGHT,
- (int)ScreenUtil.getBoundsX(0),
- getY());
+ WindowConfiguration wc = new WindowConfiguration(MAIN_FRAME_WIDTH, MAIN_FRAME_HEIGHT, (int) ScreenUtil.getBoundsX(0), getY());
setMinimumSize(new Dimension(wc.width, wc.height));
setPreferredSize(new Dimension(wc.width, wc.height));
setDefaultWindowConfiguration(wc);
-
+
setResizable(true);
setContentPane(mainPanel);
setJMenuBar(menuBar);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
-
- pack();
- }
-
+
+ pack();
+ }
+
/**
* Save all the plots to a file using a <code>JFileChooser</code>.
*/
@@ -777,15 +761,11 @@
AIDA.defaultInstance().saveAs(fileName);
logger.log(Level.INFO, "Plots saved to file <" + fileName + ">");
} catch (IOException e) {
- errorHandler.setError(e)
- .setMessage("Error saving plots to file.")
- .printStackTrace()
- .log()
- .showErrorDialog();
- }
- }
- }
-
+ errorHandler.setError(e).setMessage("Error saving plots to file.").printStackTrace().log().showErrorDialog();
+ }
+ }
+ }
+
/**
* Get the full title of the application.
* @return The application title.
@@ -843,15 +823,16 @@
SwingUtilities.invokeLater(new Runnable() {
public void run() {
configurationModel.setLogToFile(false);
-
- // FIXME: These should be toggled via a PropertyChangeListener on the ConfigurationModel.
+
+ // FIXME: These should be toggled via a PropertyChangeListener on the
+ // ConfigurationModel.
terminalItem.setEnabled(false);
logItem.setEnabled(true);
}
});
log(Level.INFO, "Redirected std out and err back to terminal.");
}
-
+
/**
* Redirect <code>System.out</code> and <code>System.err</code> to a file.
*/
@@ -859,7 +840,8 @@
redirectStdOutAndErrToFile(file);
SwingUtilities.invokeLater(new Runnable() {
public void run() {
- // FIXME: These should be toggled via PropertyChangeListener on the ConfigurationModel.
+ // FIXME: These should be toggled via PropertyChangeListener on the
+ // ConfigurationModel.
terminalItem.setEnabled(true);
logItem.setEnabled(false);
}
@@ -884,7 +866,7 @@
getConnectionSettingsPanel().enableConnectionPanel(true);
// Re-enable the getJobPanel().
- //getJobSettingsPanel().enableJobPanel(true);
+ // getJobSettingsPanel().enableJobPanel(true);
// Set relevant event panel buttons to disabled.
buttonsPanel.enablePauseButton(false);
@@ -897,7 +879,8 @@
}
/**
- * Set the GUI to connected state, which will enable/disable appropriate components and menu items.
+ * Set the GUI to connected state, which will enable/disable appropriate components and menu
+ * items.
*/
private void setConnectedGuiState() {
SwingUtilities.invokeLater(new Runnable() {
@@ -907,7 +890,7 @@
getConnectionSettingsPanel().enableConnectionPanel(false);
// Disable getJobPanel().
- //getJobSettingsPanel().enableJobPanel(false);
+ // getJobSettingsPanel().enableJobPanel(false);
// Enable or disable appropriate menu items.
savePlotsItem.setEnabled(true);
@@ -965,28 +948,24 @@
BufferedImage image = robot.createScreenCapture(screenRectangle);
ImageIO.write(image, SCREENSHOT_FORMAT, new File(fileName));
} catch (Exception e) {
- errorHandler.setError(e)
- .setMessage("Failed to take screenshot.")
- .printStackTrace()
- .log()
- .showErrorDialog();
- }
- }
-
- /**
- * Start a new monitoring session. This method is executed in a separate thread from the EDT
- * within {@link #actionPerformed(ActionEvent)} so GUI updates are not blocked while the session
+ errorHandler.setError(e).setMessage("Failed to take screenshot.").printStackTrace().log().showErrorDialog();
+ }
+ }
+
+ /**
+ * Start a new monitoring session. This method is executed in a separate thread from the EDT
+ * within {@link #actionPerformed(ActionEvent)} so GUI updates are not blocked while the session
* is being setup.
*/
private void startSession() {
log(Level.FINE, "Starting a new monitoring session.");
-
+
// Show a modal window that will block the GUI until connected or an error occurs.
JDialog dialog = DialogUtil.showStatusDialog(this, "Info", "Starting new session ...");
-
+
try {
-
+
// Reset the plot panel and global AIDA state.
resetPlots();
@@ -997,13 +976,13 @@
// Setup the LCSim JobControlManager and event builder.
setupLCSim();
-
+
// Connect to the ET system.
- connect();
-
+ connect();
+
// Setup the EventProcessingChain object using the EtConnection.
setupCompositeLoop();
-
+
// Setup the system status monitor table.
setupSystemStatusMonitor();
@@ -1013,27 +992,25 @@
log(Level.INFO, "Successfully started the monitoring session.");
} catch (Exception e) {
-
+
log(Level.SEVERE, "An error occurred while setting up the session.");
-
+
// Log the error that occurred.
- errorHandler.setError(e)
- .log()
- .printStackTrace();
-
+ errorHandler.setError(e).log().printStackTrace();
+
// Disconnect from the session.
disconnect(ConnectionStatus.ERROR);
-
+
} finally {
// Close modal window.
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
}
}
-
+
/**
* Start the session watchdog thread, which will kill the session if event processing finishes.
*/
- private void startSessionWatchdogThread() {
+ private void startSessionWatchdogThread() {
sessionWatchdogThread = new SessionWatchdogThread();
sessionWatchdogThread.start();
}
@@ -1046,24 +1023,24 @@
// Make sure applicable menu items are enabled or disabled.
// This applies whether or not using an ET server or file source.
setConnectedGuiState();
-
+
// Setup the network connection if using an ET server.
if (usingEtServer()) {
-
+
setConnectionStatus(ConnectionStatus.CONNECTION_REQUESTED);
// Create a connection to the ET server.
try {
createEtConnection();
log(Level.INFO, "Successfully connected to ET system.");
- } catch (Exception e) {
+ } catch (Exception e) {
throw new IOException(e);
}
} else {
this.setConnectionStatus(ConnectionStatus.CONNECTED);
}
}
-
+
private ConnectionSettingsPanel getConnectionSettingsPanel() {
return settingsDialog.getSettingsPanel().getConnectionPanel();
}
@@ -1071,7 +1048,7 @@
private JobSettingsPanel getJobSettingsPanel() {
return settingsDialog.getSettingsPanel().getJobSettingsPanel();
}
-
+
private void disconnect() {
disconnect(ConnectionStatus.DISCONNECTING);
}
@@ -1086,7 +1063,7 @@
// Cleanup the ET connection.
cleanupEtConnection();
-
+
// Update state of GUI to disconnected.
setDisconnectedGuiState();
@@ -1104,7 +1081,7 @@
* Cleanup the ET connection.
*/
private void cleanupEtConnection() {
- if (connection != null) {
+ if (connection != null) {
if (connection.getEtSystem().alive()) {
log(Level.FINEST, "Cleaning up the ET connection.");
connection.cleanup();
@@ -1123,14 +1100,14 @@
// Get steering resource or file as a String parameter.
String steering = null;
- SteeringType steeringType = configurationModel.getSteeringType();
+ SteeringType steeringType = configurationModel.getSteeringType();
if (steeringType.equals(SteeringType.FILE))
try {
steering = configurationModel.getSteeringFile().getCanonicalPath();
} catch (IOException e) {
throw new RuntimeException(e);
}
- else
+ else
steering = configurationModel.getSteeringResource();
log(Level.CONFIG, "Set steering to <" + steering + "> with type <" + (steeringType == SteeringType.RESOURCE ? "RESOURCE" : "FILE") + ">");
@@ -1147,15 +1124,12 @@
// Setup the event builder to translate from EVIO to LCIO.
createEventBuilder();
-
+
log(Level.INFO, "LCSim setup was successful.");
} catch (Throwable t) {
// Catch all errors and rethrow them as RuntimeExceptions.
- errorHandler.setError(t)
- .setMessage("Error setting up LCSim.")
- .printStackTrace()
- .raiseException();
+ errorHandler.setError(t).setMessage("Error setting up LCSim.").printStackTrace().raiseException();
}
}
@@ -1192,18 +1166,18 @@
// Set the detector name on the event builder so it can find conditions data.
eventBuilder.setDetectorName(configurationModel.getDetectorName());
-
+
ConditionsManager.defaultInstance().addConditionsListener(eventBuilder);
log(Level.CONFIG, "Successfully initialized event builder <" + eventBuilderClassName + ">");
}
/**
- * Create a connection to an ET system using current parameters from the GUI. If successful,
- * the application's ConnectionStatus is changed to CONNECTED.
+ * Create a connection to an ET system using current parameters from the GUI. If successful, the
+ * application's ConnectionStatus is changed to CONNECTED.
*/
private void createEtConnection() {
-
+
// Setup connection to ET system.
connection = fromConfigurationModel(configurationModel);
@@ -1211,17 +1185,14 @@
// Set status to connected as there is now a live ET connection.
setConnectionStatus(ConnectionStatus.CONNECTED);
-
+
log(Level.INFO, "Successfully connected to ET system.");
} else {
// Some error occurred and the connection was not created.
setConnectionStatus(ConnectionStatus.ERROR);
-
- errorHandler.setError(new RuntimeException("Failed to create ET connection."))
- .log()
- .printStackTrace()
- .raiseException();
+
+ errorHandler.setError(new RuntimeException("Failed to create ET connection.")).log().printStackTrace().raiseException();
}
}
@@ -1248,12 +1219,8 @@
out.write(buf.toString());
out.close();
log("Saved log to file <" + logFile.getPath() + ">");
- } catch (IOException e) {
- errorHandler.setError(e)
- .setMessage("Error saving log to file.")
- .log()
- .printStackTrace()
- .showErrorDialog();
+ } catch (IOException e) {
+ errorHandler.setError(e).setMessage("Error saving log to file.").log().printStackTrace().showErrorDialog();
}
}
}
@@ -1266,7 +1233,7 @@
logTableModel.setRowCount(0);
log(Level.INFO, "Log table was cleared.");
}
-
+
/**
* Notify event processor to get next set of events, if in pause mode.
*/
@@ -1288,7 +1255,7 @@
buttonsPanel.setPauseModeState(false);
log(Level.FINEST, "Resuming event processing after pause.");
-
+
this.setConnectionStatus(ConnectionStatus.CONNECTED);
}
@@ -1296,17 +1263,17 @@
* Notify the event processor to start pause mode, which will pause between events.
*/
private void pauseEventProcessing() {
-
+
loop.pause();
// Set GUI state.
buttonsPanel.setPauseModeState(true);
-
+
log(Level.FINEST, "Event processing was paused.");
-
+
this.setConnectionStatus(ConnectionStatus.PAUSED);
}
-
+
/**
* Reset the contents of the default AIDA tree.
*/
@@ -1332,54 +1299,45 @@
private void log(String m) {
log(DEFAULT_LOG_LEVEL, m);
}
-
+
/**
* Configure the event processing chain.
*/
private void setupCompositeLoop() {
-
- CompositeLoopConfiguration loopConfig = new CompositeLoopConfiguration()
- .setStopOnEndRun(configurationModel.getDisconnectOnEndRun())
- .setStopOnErrors(configurationModel.getDisconnectOnError())
- .setDataSourceType(configurationModel.getDataSourceType())
- .setProcessingStage(configurationModel.getProcessingStage())
- .setEtConnection(connection)
- .setFilePath(configurationModel.getDataSourcePath())
- .setLCSimEventBuilder(eventBuilder)
- .setDetectorName(configurationModel.getDetectorName());
-
+
+ CompositeLoopConfiguration loopConfig = new CompositeLoopConfiguration().setStopOnEndRun(configurationModel.getDisconnectOnEndRun()).setStopOnErrors(configurationModel.getDisconnectOnError()).setDataSourceType(configurationModel.getDataSourceType()).setProcessingStage(configurationModel.getProcessingStage()).setEtConnection(connection).setFilePath(configurationModel.getDataSourcePath()).setLCSimEventBuilder(eventBuilder).setDetectorName(configurationModel.getDetectorName());
+
// Add all Drivers from the pre-configured JobManager.
for (Driver driver : jobManager.getDriverExecList()) {
loopConfig.add(driver);
- }
-
-
- // DEBUG: Turn these off while doing other stuff!!!!
+ }
+
+ // DEBUG: Turn these off while doing other stuff!!!!
// Using ET server?
if (usingEtServer()) {
// ET system monitor.
// FIXME: Make whether this is run or not configurable through the JobPanel.
loopConfig.add(new EtSystemMonitor());
-
+
// ET system strip charts.
// FIXME: Make whether this is run or not configurable through the JobPanel.
loopConfig.add(new EtSystemStripCharts());
}
-
+
// RunPanel updater.
loopConfig.add(runPanel.new RunModelUpdater());
-
- // Create the CompositeLoop with the configuration.
+
+ // Create the CompositeLoop with the configuration.
loop = new CompositeLoop(loopConfig);
-
+
// Create the processing thread.
processingThread = new EventProcessingThread(loop);
-
+
// Start the processing thread.
processingThread.start();
}
-
+
/**
* True if ET server is being used.
* @return True if using ET server.
@@ -1387,22 +1345,22 @@
private boolean usingEtServer() {
return configurationModel.getDataSourceType().equals(DataSourceType.ET_SERVER);
}
-
+
/**
* Configure the system status monitor panel for a new job.
*/
private void setupSystemStatusMonitor() {
- // Clear the system status monitor table.
+ // Clear the system status monitor table.
systemStatusWindow.getTableModel().clear();
-
+
// Get the global registry of SystemStatus objects.
SystemStatusRegistry registry = SystemStatusRegistry.getSystemStatusRegistery();
-
+
// Process the SystemStatus objects.
for (SystemStatus systemStatus : registry.getSystemStatuses()) {
// Add a row to the table for every SystemStatus.
systemStatusWindow.getTableModel().addSystemStatus(systemStatus);
-
+
// Add this class as a listener so all status changes can be logged.
systemStatus.addListener(this);
}
@@ -1420,11 +1378,11 @@
if (!plotWindow.isVisible()) {
// Turn on plot frame if it is off.
plotWindow.setVisible(true);
- //plotInfoWindow.setVisible(true);
- }
-
+ // plotInfoWindow.setVisible(true);
+ }
+
// Reset plots.
- plotWindow.reset();
+ plotWindow.reset();
}
/**
@@ -1437,11 +1395,7 @@
try {
AIDA.defaultInstance().saveAs(configurationModel.getAidaFileName());
} catch (IOException e) {
- errorHandler.setError(e)
- .setMessage("Error saving AIDA file.")
- .log()
- .printStackTrace()
- .showErrorDialog();
+ errorHandler.setError(e).setMessage("Error saving AIDA file.").log().printStackTrace().showErrorDialog();
}
}
}
@@ -1453,54 +1407,56 @@
private void stopSession() {
// Show a modal message window while this method executes.
JDialog dialog = DialogUtil.showStatusDialog(this, "Info", "Disconnecting from session ...");
-
+
try {
// Log message.
logger.log(Level.FINER, "Stopping the session.");
-
+
// Kill the watchdog thread which looks for disconnects, if it is active.
killSessionWatchdogThread();
-
+
// Automatically write AIDA file from job settings.
saveAidaFile();
-
- // Disconnect from ET system, if using the ET server, and set the proper disconnected GUI state.
+
+ // Disconnect from ET system, if using the ET server, and set the proper disconnected
+ // GUI state.
disconnect();
-
- // Stop the event processing, which is called after the ET system goes down to avoid hanging in calls to ET system.
+
+ // Stop the event processing, which is called after the ET system goes down to avoid
+ // hanging in calls to ET system.
stopEventProcessing();
-
+
logger.log(Level.INFO, "Session was stopped.");
-
- } finally {
+
+ } finally {
// Close modal message window.
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
}
}
-
- /**
- * Stop the event processing by executing a <code>STOP</code> command on the
- * record loop and killing the event processing thread. This is executed
- * after the ET system is disconnected so that the event processing does
- * not potentially hang in a call to <code>EtSystem.getEvents()</code> forever.
+
+ /**
+ * Stop the event processing by executing a <code>STOP</code> command on the record loop and
+ * killing the event processing thread. This is executed after the ET system is disconnected so
+ * that the event processing does not potentially hang in a call to
+ * <code>EtSystem.getEvents()</code> forever.
*/
private void stopEventProcessing() {
// Is the event processing thread not null?
if (processingThread != null) {
-
+
// Is the event processing thread actually still alive?
if (processingThread.isAlive()) {
-
+
// Request the event processing loop to execute stop.
loop.execute(Command.STOP);
-
+
try {
// This should always work, because the ET system is disconnected before this.
processingThread.join();
} catch (InterruptedException e) {
// Don't know when this would ever happen.
- e.printStackTrace();
+ e.printStackTrace();
}
}
@@ -1542,7 +1498,7 @@
/**
* Thread to automatically trigger a disconnect when the event processing chain finishes or
- * throws a fatal error. This thread joins to the event processing thread and automatically
+ * throws a fatal error. This thread joins to the event processing thread and automatically
* requests a disconnect using an ActionEvent when the event processing thread stops.
*/
private class SessionWatchdogThread extends Thread {
@@ -1553,18 +1509,21 @@
// disconnect should occur.
processingThread.join();
- // Activate a disconnect using the ActionEvent which is used by the disconnect button.
- // FIXME: When this happens the event processing object and its thread don't get set to null!
+ // Activate a disconnect using the ActionEvent which is used by the disconnect
+ // button.
+ // FIXME: When this happens the event processing object and its thread don't get set
+ // to null!
actionPerformed(new ActionEvent(Thread.currentThread(), 0, DISCONNECT));
} catch (InterruptedException e) {
- // This probably just means that the disconnect button was pushed, and this thread should
+ // This probably just means that the disconnect button was pushed, and this thread
+ // should
// no longer monitor the event processing.
e.printStackTrace();
}
}
}
-
+
/**
* Choose an output log file using a <code>JFileChooser</code>.
*/
@@ -1577,7 +1536,7 @@
File file = fc.getSelectedFile();
if (file.exists()) {
throw new RuntimeException("Log file already exists.");
- } else {
+ } else {
try {
configurationModel.setLogFileName(file.getCanonicalPath());
configurationModel.setLogToFile(true);
@@ -1585,15 +1544,15 @@
errorHandler.setError(e).log().printStackTrace().showErrorDialog();
}
logToFile(file);
- }
- }
-
- }
-
+ }
+ }
+
+ }
+
/**
* Choose an input configuration file using a <code>JFileChooser</code>.
*/
- private void chooseConfigurationFile() {
+ private void chooseConfigurationFile() {
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Load Settings");
fc.setCurrentDirectory(new File("."));
@@ -1604,9 +1563,9 @@
Configuration newConfig = new Configuration(f);
setConfiguration(newConfig);
loadConfiguration();
- }
- }
-
+ }
+ }
+
/**
* Save a configuration file using a <code>JFileChooser</code>.
*/
@@ -1617,11 +1576,11 @@
int r = fc.showSaveDialog(mainPanel);
if (r == JFileChooser.APPROVE_OPTION) {
File f = fc.getSelectedFile();
- log(Level.CONFIG, "Saving configuration to file <" + f.getPath() + ">");
+ log(Level.CONFIG, "Saving configuration to file <" + f.getPath() + ">");
configuration.writeToFile(f);
}
}
-
+
private void updateLayoutConfiguration() {
// Should the GUI config be saved?
if (configurationModel.getSaveLayout()) {
@@ -1632,45 +1591,46 @@
clearLayoutConfiguration();
}
}
-
+
private void saveLayoutConfiguration() {
configurationModel.setMonitoringApplicationLayout(new WindowConfiguration(this).toString());
configurationModel.setSystemStatusFrameLayout(new WindowConfiguration(systemStatusWindow).toString());
configurationModel.setPlotFrameLayout(new WindowConfiguration(plotWindow).toString());
}
-
+
private void clearLayoutConfiguration() {
configurationModel.remove(ConfigurationModel.MONITORING_APPLICATION_LAYOUT_PROPERTY);
configurationModel.remove(ConfigurationModel.SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY);
configurationModel.remove(ConfigurationModel.PLOT_FRAME_LAYOUT_PROPERTY);
}
-
+
private void setSaveLayout() {
configurationModel.setSaveLayout(saveLayoutItem.isSelected());
- }
-
+ }
+
private void restoreDefaultLayout() {
resetWindowConfiguration();
plotWindow.resetWindowConfiguration();
systemStatusWindow.resetWindowConfiguration();
}
-
+
/**
* Load the current Configuration by updating the ConfigurationModel.
*/
private void loadConfiguration() {
-
- // Set the Configuration on the ConfigurationModel which will trigger all the PropertyChangelListeners.
+
+ // Set the Configuration on the ConfigurationModel which will trigger all the
+ // PropertyChangelListeners.
configurationModel.setConfiguration(configuration);
-
+
// Log that a new configuration was loaded.
if (configuration.getFile() != null)
log(Level.CONFIG, "Loaded configuration from file <" + configuration.getFile().getPath() + ">");
- else
+ else
log(Level.CONFIG, "Loaded configuration from resource <" + configuration.getResourcePath() + ">");
-
- }
-
+
+ }
+
/**
* Load the default configuration file.
*/
@@ -1678,15 +1638,15 @@
setConfiguration(new Configuration(DEFAULT_CONFIG_RESOURCE));
loadConfiguration();
}
-
- /**
- * Validate the current file source by throwing an IOException if
- * there appears to be a problem with it.
+
+ /**
+ * Validate the current file source by throwing an IOException if there appears to be a problem
+ * with it.
* @throws IOException if there a problem with the current file source.
*/
private void validateDataFile() throws IOException {
- DataSourceType dataSourceType = configurationModel.getDataSourceType();
- if (dataSourceType.isFile()) {
+ DataSourceType dataSourceType = configurationModel.getDataSourceType();
+ if (dataSourceType.isFile()) {
try {
if (configurationModel.getDataSourcePath() == null)
throw new IOException("No data file set.");
@@ -1707,65 +1667,45 @@
}
} catch (IOException e) {
throw e;
- }
+ }
} else {
// This shouldn't really ever happen!
throw new IOException("No file source was selected.");
}
}
-
- /**
- * This is a thread to validate the current input file. This must
- * be done on a seperate thread, because EVIO files may take a long time
- * to be completely read in using the EvioReader. Also, since
- * the request for file validation comes on the EDT thread, the task
- * must be put onto a seperate thread so that actionPerformed() may exit
- * and not block the EDT from updating the GUI.
- */
- class FileValidationThread extends Thread {
+
+ /**
+ * This is a thread to validate the current input file. This must be done on a seperate thread,
+ * because EVIO files may take a long time to be completely read in using the EvioReader. Also,
+ * since the request for file validation comes on the EDT thread, the task must be put onto a
+ * seperate thread so that actionPerformed() may exit and not block the EDT from updating the
+ * GUI.
+ */
+ class FileValidationThread extends Thread {
boolean isFileValid;
+
public void run() {
settingsDialog.setEnabled(false);
- JDialog dialog = DialogUtil.showStatusDialog(
- MonitoringApplication.this,
- "Validating data file",
- configurationModel.getDataSourcePath());
- try {
+ JDialog dialog = DialogUtil.showStatusDialog(MonitoringApplication.this, "Validating data file", configurationModel.getDataSourcePath());
+ try {
validateDataFile();
- DialogUtil.showInfoDialog(
- MonitoringApplication.this,
- "File is valid",
- configurationModel.getDataSourcePath());
+ DialogUtil.showInfoDialog(MonitoringApplication.this, "File is valid", configurationModel.getDataSourcePath());
} catch (IOException error) {
- DialogUtil.showErrorDialog(
- MonitoringApplication.this,
- error,
- "Error validating file");
+ DialogUtil.showErrorDialog(MonitoringApplication.this, error, "Error validating file");
} finally {
dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING));
settingsDialog.setEnabled(true);
fileValidationThread = null;
- }
- }
- }
-
+ }
+ }
+ }
+
/**
* Create an ET server connection from a <code>ConfigurationModel</code>.
* @param config The ConfigurationModel with the connection parameters.
* @return The EtConnection object.
*/
private static EtConnection fromConfigurationModel(ConfigurationModel config) {
- return EtConnection.createConnection(
- config.getEtName(),
- config.getHost(),
- config.getPort(),
- config.getBlocking(),
- config.getQueueSize(),
- config.getPrescale(),
- config.getStationName(),
- config.getStationPosition(),
- config.getWaitMode(),
- config.getWaitTime(),
- config.getChunkSize());
- }
+ return EtConnection.createConnection(config.getEtName(), config.getHost(), config.getPort(), config.getBlocking(), config.getQueueSize(), config.getPrescale(), config.getStationName(), config.getStationPosition(), config.getWaitMode(), config.getWaitTime(), config.getChunkSize());
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotInfoWindow.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotInfoWindow.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotInfoWindow.java Mon Nov 10 11:20:53 2014
@@ -40,16 +40,17 @@
* This is a GUI component for showing the statistics and other information about an AIDA plot.
* <p>
* This information is updated dynamically via the <code>AIDAObserver</code> API on the AIDA object.
- */
-// FIXME: Add addRows for all types of AIDA objects (only Histogram1D implemented so far).
+ */
+// FIXME: Add addRows for all types of AIDA objects (only Histogram1D implemented so far).
// FIXME: Columns disappear when rebuilding table.
// TODO: Add sorting of info table.
-// TODO: Probably this should be moved out of monitoring application as it is generically applicable to AIDA objects.
+// TODO: Probably this should be moved out of monitoring application as it is generically applicable
+// to AIDA objects.
public class PlotInfoWindow extends JFrame implements AIDAListener, ActionListener {
JComboBox<Object> plotComboBox;
JTable infoTable = new JTable();
- DefaultTableModel model;
+ DefaultTableModel model;
JPanel contentPane = new JPanel();
PlotterRegion currentRegion;
Object currentObject;
@@ -59,26 +60,25 @@
static final String[] COLUMN_NAMES = { "Field", "Value" };
static final String PLOT_SELECTED = "PLOT_SELECTED";
-
+
Timer timer = new Timer();
-
+
/**
* Class constructor, which will setup the GUI components.
*/
@SuppressWarnings("unchecked")
PlotInfoWindow() {
-
+
contentPane.setLayout(new GridBagLayout());
contentPane.setBorder(BorderFactory.createEmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
-
+
GridBagConstraints c;
-
+
plotComboBox = new JComboBox<Object>();
- plotComboBox.setActionCommand(PLOT_SELECTED);
+ plotComboBox.setActionCommand(PLOT_SELECTED);
plotComboBox.setRenderer(new BasicComboBoxRenderer() {
@SuppressWarnings("rawtypes")
- public Component getListCellRendererComponent(JList list, Object value, int index,
- boolean isSelected, boolean cellHasFocus) {
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value != null) {
String title = getObjectTitle(value);
@@ -88,7 +88,7 @@
}
return this;
}
- });
+ });
plotComboBox.addActionListener(this);
c = new GridBagConstraints();
c.gridx = 0;
@@ -100,32 +100,32 @@
String data[][] = new String[0][0];
model = new DefaultTableModel(data, COLUMN_NAMES);
infoTable.setModel(model);
-
- // FIXME: Are these adequate column size settings? Could prob be bigger...
+
+ // FIXME: Are these adequate column size settings? Could prob be bigger...
infoTable.getColumn("Field").setMinWidth(25);
infoTable.getColumn("Value").setMinWidth(20);
-
+
c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 1;
c.fill = GridBagConstraints.BOTH;
contentPane.add(infoTable, c);
-
- setContentPane(contentPane);
+
+ setContentPane(contentPane);
setAlwaysOnTop(true);
setResizable(false);
this.pack();
}
-
- /**
- * This method will be called when the backing AIDA object is updated and a
- * state change is fired via the <code>AIDAObservable</code> API. The table
- * is updated to reflect the new state of the object.
+
+ /**
+ * This method will be called when the backing AIDA object is updated and a state change is
+ * fired via the <code>AIDAObservable</code> API. The table is updated to reflect the new state
+ * of the object.
* @param evt The EventObject pointing to the backing AIDA object.
*/
@Override
public void stateChanged(final EventObject evt) {
-
+
// Make a timer task for running the update.
TimerTask task = new TimerTask() {
public void run() {
@@ -134,26 +134,26 @@
// Assume this means that a different AIDAObservable was selected in the GUI.
return;
}
-
+
// Update the table values on the Swing EDT.
runUpdateTable();
-
+
// Set the observable to valid so subsequent state changes are received.
((AIDAObservable) currentObject).setValid((AIDAListener) PlotInfoWindow.this);
}
- };
-
- /*
- * Schedule the task to run in ~0.5 seconds. If the Runnable runs immediately, somehow the
- * observable state gets permanently set to invalid and additional state changes will not
- * be received!
+ };
+
+ /*
+ * Schedule the task to run in ~0.5 seconds. If the Runnable runs immediately, somehow the
+ * observable state gets permanently set to invalid and additional state changes will not be
+ * received!
*/
timer.schedule(task, 500);
}
/**
- * Implementation of <code>actionPerformed</code> to handle the selection of
- * a new object from the combo box.
+ * Implementation of <code>actionPerformed</code> to handle the selection of a new object from
+ * the combo box.
*/
@Override
public void actionPerformed(ActionEvent e) {
@@ -164,22 +164,21 @@
setCurrentObject(plotComboBox.getSelectedItem());
}
}
- }
-
- /**
- * Get the title of an AIDA object. Unfortunately there is
- * not base type with this information.
+ }
+
+ /**
+ * Get the title of an AIDA object. Unfortunately there is not base type with this information.
* @param object The AIDA object.
- * @return The title of the object from its title method
- * or value of its toString method, if none exists.
+ * @return The title of the object from its title method or value of its toString method, if
+ * none exists.
*/
String getObjectTitle(Object object) {
if (object instanceof IBaseHistogram) {
- return ((IBaseHistogram)object).title();
+ return ((IBaseHistogram) object).title();
} else if (object instanceof IDataPointSet) {
- return ((IDataPointSet)object).title();
+ return ((IDataPointSet) object).title();
} else if (object instanceof IFunction) {
- return ((IFunction)object).title();
+ return ((IFunction) object).title();
} else {
return object.toString();
}
@@ -189,79 +188,75 @@
* Set the current plotter region, which will rebuild the GUI accordingly.
* @param region The current plotter region.
*/
- synchronized void setCurrentRegion(PlotterRegion region) {
- if (region != currentRegion) {
+ synchronized void setCurrentRegion(PlotterRegion region) {
+ if (region != currentRegion) {
currentRegion = region;
if (currentRegion.title() != null)
setTitle(currentRegion.title());
- updateComboBox();
+ updateComboBox();
setCurrentObject(plotComboBox.getSelectedItem());
- setupContentPane();
+ setupContentPane();
}
}
/**
* Configure the frame's content panel from current component settings.
*/
- void setupContentPane() {
+ void setupContentPane() {
plotComboBox.setSize(plotComboBox.getPreferredSize());
infoTable.setSize(infoTable.getPreferredSize());
int width = plotComboBox.getPreferredSize().width;
int height = plotComboBox.getPreferredSize().height + INSET_SIZE + infoTable.getPreferredSize().height;
- contentPane.setPreferredSize(
- new Dimension(
- width,
- height
- ));
+ contentPane.setPreferredSize(new Dimension(width, height));
contentPane.setSize(contentPane.getPreferredSize());
contentPane.setMinimumSize(contentPane.getPreferredSize());
this.pack();
- setVisible(true);
- }
-
+ setVisible(true);
+ }
+
/**
* Update the info table from the state of the current AIDA object.
*/
void updateTable() {
model.setRowCount(0);
- model.setColumnIdentifiers(COLUMN_NAMES);
- if (currentObject instanceof IHistogram1D) {
- addRows((IHistogram1D)currentObject);
+ model.setColumnIdentifiers(COLUMN_NAMES);
+ if (currentObject instanceof IHistogram1D) {
+ addRows((IHistogram1D) currentObject);
} else if (currentObject instanceof IHistogram2D) {
- addRows((IHistogram2D)currentObject);
+ addRows((IHistogram2D) currentObject);
} else if (currentObject instanceof ICloud2D) {
- addRows((ICloud2D)currentObject);
+ addRows((ICloud2D) currentObject);
} else if (currentObject instanceof ICloud1D) {
- if (((ICloud1D)currentObject).isConverted()) {
- addRows(((ICloud1D)currentObject).histogram());
- }
- }
- }
-
+ if (((ICloud1D) currentObject).isConverted()) {
+ addRows(((ICloud1D) currentObject).histogram());
+ }
+ }
+ }
+
/**
* Run the {@link #updateTable()} method on the Swing EDT.
*/
void runUpdateTable() {
- SwingUtilities.invokeLater(new Runnable() {
+ SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateTable();
}
});
}
-
+
/**
* Update the combo box contents with the plots from the current region.
*/
void updateComboBox() {
plotComboBox.removeAllItems();
- List<Object> objects = currentRegion.getPlottedObjects();
+ List<Object> objects = currentRegion.getPlottedObjects();
for (Object object : objects) {
if (isValidObject(object)) {
this.plotComboBox.addItem(object);
}
- }
- }
-
+ }
+ }
+
boolean isValidObject(Object object) {
if (object == null)
return false;
@@ -287,7 +282,7 @@
addRow("overflow entries", histogram.binEntries(IAxis.OVERFLOW_BIN));
addRow("underflow entries", histogram.binEntries(IAxis.UNDERFLOW_BIN));
}
-
+
/**
* Add rows to the info table from the state of a 2D histogram.
* @param histogram The AIDA object.
@@ -308,18 +303,18 @@
addRow("x underflow entries", histogram.binEntriesX(IAxis.UNDERFLOW_BIN));
addRow("y underflow entries", histogram.binEntriesY(IAxis.UNDERFLOW_BIN));
}
-
+
/**
* Add rows to the info table from the state of a 2D cloud.
* @param cloud The AIDA object.
*/
- void addRows(ICloud2D cloud) {
+ void addRows(ICloud2D cloud) {
addRow("title", cloud.title());
addRow("entries", cloud.entries());
addRow("max entries", cloud.maxEntries());
addRow("x lower edge", cloud.lowerEdgeX());
addRow("x upper edge", cloud.upperEdgeX());
- addRow("y lower edge", cloud.lowerEdgeY());
+ addRow("y lower edge", cloud.lowerEdgeY());
addRow("y upper edge", cloud.upperEdgeY());
addRow("x mean", String.format("%.10f%n", cloud.meanX()));
addRow("y mean", String.format("%.10f%n", cloud.meanY()));
@@ -335,54 +330,55 @@
void addRow(String field, Object value) {
model.insertRow(infoTable.getRowCount(), new Object[] { field, value });
}
-
+
/**
* Set the current AIDA object that backs this GUI, i.e. an IHistogram1D etc.
* @param object The backing AIDA object.
*/
synchronized void setCurrentObject(Object object) {
-
+
if (object == null)
- throw new IllegalArgumentException("The object arg is null!");
+ throw new IllegalArgumentException("The object arg is null!");
if (object == currentObject)
return;
-
+
// Remove the AIDAListener from the previous object.
removeListener();
-
+
// Set the current object reference.
- currentObject = object;
-
+ currentObject = object;
+
// Update the table immediately with information from the current object.
- // We need to wait for this the first time, so we know the preferred size
+ // We need to wait for this the first time, so we know the preferred size
// of the table GUI component when resizing the content pane.
updateTable();
-
+
// Add an AIDAListener to the AIDA object via the AIDAObservable API.
addListener();
}
-
- /**
- * Remove this object as an <code>AIDAListener</code> on the current <code>AIDAObservable</code>.
+
+ /**
+ * Remove this object as an <code>AIDAListener</code> on the current <code>AIDAObservable</code>
+ * .
*/
void removeListener() {
if (currentObject != null) {
// Remove this object as a listener on the current observable.
- ((AIDAObservable)currentObject).removeListener(this);
- }
- }
-
+ ((AIDAObservable) currentObject).removeListener(this);
+ }
+ }
+
/**
* Add this object as an <code>AIDAListener</code> on the current <code>AIDAObservable</code>.
*/
- void addListener() {
+ void addListener() {
if (currentObject instanceof AIDAObservable) {
// Setup a listener on the current AIDA object.
- AIDAObservable observable = (AIDAObservable)currentObject;
+ AIDAObservable observable = (AIDAObservable) currentObject;
observable.addListener(this);
observable.setValid(this);
- observable.setConnected(true);
- }
- }
+ observable.setConnected(true);
+ }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotWindow.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotWindow.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/PlotWindow.java Mon Nov 10 11:20:53 2014
@@ -7,22 +7,22 @@
* A <code>JFrame</code> where monitoring plots will show in tabs.
*/
class PlotWindow extends ApplicationWindow {
-
+
private JTabbedPane plotPane;
-
+
PlotWindow() {
super("Monitoring Plots");
plotPane = new JTabbedPane();
setContentPane(plotPane);
setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
setResizable(true);
- pack();
+ pack();
}
-
+
void reset() {
plotPane.removeAll();
- }
-
+ }
+
JTabbedPane getPlotPane() {
return plotPane;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/RunPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/RunPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/RunPanel.java Mon Nov 10 11:20:53 2014
@@ -41,7 +41,7 @@
class RunPanel extends JPanel implements PropertyChangeListener {
FieldPanel runNumberField = new FieldPanel("Run Number", "", 10, false);
- DatePanel startDateField = new DatePanel("Run Start", "", 16, false);
+ DatePanel startDateField = new DatePanel("Run Start", "", 16, false);
DatePanel endDateField = new DatePanel("Run End", "", 16, false);
FieldPanel lengthField = new FieldPanel("Run Length [sec]", "", 12, false);
FieldPanel totalEventsField = new FieldPanel("Total Events in Run", "", 14, false);
@@ -49,22 +49,21 @@
FieldPanel eventsReceivedField = new FieldPanel("Events Received", "", 14, false);
FieldPanel dataReceivedField = new FieldPanel("Data Received [bytes]", "", 14, false);
FieldPanel eventNumberField = new FieldPanel("Event Number", "", 14, false);
-
+
Timer timer;
long jobStartMillis;
-
+
RunModel model;
-
+
RunPanel(RunModel model) {
this.model = model;
this.model.addPropertyChangeListener(this);
-
+
setLayout(new FlowLayout(FlowLayout.LEFT));
-
- TitledBorder titledBorder = BorderFactory.createTitledBorder(
- BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Run Summary");
- setBorder(titledBorder);
-
+
+ TitledBorder titledBorder = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Run Summary");
+ setBorder(titledBorder);
+
add(runNumberField);
add(startDateField);
add(endDateField);
@@ -74,93 +73,93 @@
add(eventsReceivedField);
add(dataReceivedField);
add(eventNumberField);
-
+
this.setMinimumSize(new Dimension(0, 190));
}
-
+
void startJobTimer() {
timer = new Timer("JobTimer");
jobStartMillis = System.currentTimeMillis();
- TimerTask updateTimeTask = new TimerTask() {
+ TimerTask updateTimeTask = new TimerTask() {
public void run() {
- final int elapsedTime = (int)((System.currentTimeMillis() - jobStartMillis) / 1000);
+ final int elapsedTime = (int) ((System.currentTimeMillis() - jobStartMillis) / 1000);
model.setElapsedTime(elapsedTime);
- }
+ }
};
timer.scheduleAtFixedRate(updateTimeTask, 0, 1000);
}
-
+
void stopRunTimer() {
timer.cancel();
timer.purge();
}
-
+
class RunModelUpdater extends CompositeRecordProcessor {
-
+
@Override
public void startJob() {
model.reset();
RunPanel.this.startJobTimer();
}
-
+
@Override
public void process(CompositeRecord event) {
- model.incrementEventsReceived();
+ model.incrementEventsReceived();
EvioEvent evioEvent = event.getEvioEvent();
if (event.getEtEvent() != null && event.getEvioEvent() == null) {
model.addDataReceived(event.getEtEvent().getData().length);
} else if (evioEvent != null) {
- model.addDataReceived((long)evioEvent.getTotalBytes());
+ model.addDataReceived((long) evioEvent.getTotalBytes());
model.setEventNumber(evioEvent.getEventNumber());
- if (EventConstants.isPreStartEvent(evioEvent)) {
+ if (EventConstants.isPreStartEvent(evioEvent)) {
startRun(evioEvent);
- } else if (EventConstants.isEndEvent(evioEvent)) {
+ } else if (EventConstants.isEndEvent(evioEvent)) {
endRun(evioEvent);
- }
+ }
} else if (event.getLcioEvent() != null) {
model.setEventNumber(event.getLcioEvent().getEventNumber());
}
}
- private void endRun(EvioEvent evioEvent) {
+ private void endRun(EvioEvent evioEvent) {
// Get end run data.
int[] data = evioEvent.getIntData();
int seconds = data[0];
int eventCount = data[2];
long endMillis = ((long) seconds) * 1000;
-
+
// Update the GUI.
model.setEndDate(new Date(endMillis));
- model.computeRunLength();
+ model.computeRunLength();
model.setTotalEvents(eventCount);
}
- private void startRun(EvioEvent evioEvent) {
+ private void startRun(EvioEvent evioEvent) {
// Get start of run data.
int[] data = evioEvent.getIntData();
int seconds = data[0];
- int runNumber = data[1];
+ int runNumber = data[1];
long startMillis = ((long) seconds) * 1000;
-
+
// Update the GUI.
model.setRunNumber(runNumber);
model.setStartDate(new Date(startMillis));
}
-
+
@Override
public void endJob() {
RunPanel.this.stopRunTimer();
- }
+ }
}
/**
* Update the GUI from changes in the underlying RunModel object.
*/
@Override
- public void propertyChange(PropertyChangeEvent evt) {
+ public void propertyChange(PropertyChangeEvent evt) {
Object value = evt.getNewValue();
- if (RUN_NUMBER_PROPERTY.equals(evt.getPropertyName())) {
- this.runNumberField.setValue((Integer) value);
+ if (RUN_NUMBER_PROPERTY.equals(evt.getPropertyName())) {
+ this.runNumberField.setValue((Integer) value);
} else if (START_DATE_PROPERTY.equals(evt.getPropertyName())) {
if (value != null)
this.startDateField.setValue((Date) value);
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ScreenUtil.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ScreenUtil.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/ScreenUtil.java Mon Nov 10 11:20:53 2014
@@ -33,10 +33,10 @@
System.out.println(graphicsDevice.getDisplayMode().getWidth() + " x " + graphicsDevice.getDisplayMode().getHeight());
}
}
-
+
static void printComponentInfo(Component component) {
if (component instanceof JFrame) {
- System.out.println(((JFrame)component).getTitle());
+ System.out.println(((JFrame) component).getTitle());
} else {
System.out.println(component);
}
@@ -44,19 +44,19 @@
System.out.println("size: " + component.getSize().getWidth() + " x " + component.getSize().getHeight());
System.out.println();
}
-
+
static GraphicsDevice getGraphicsDevice(int index) {
return GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[index];
}
-
+
static Rectangle getScreenBounds(int index) {
return ScreenUtil.getGraphicsDevice(index).getDefaultConfiguration().getBounds();
}
-
+
static double getBoundsX(int index) {
return ScreenUtil.getGraphicsDevice(index).getDefaultConfiguration().getBounds().getX();
}
-
+
static double getBoundsY(int index) {
return ScreenUtil.getGraphicsDevice(index).getDefaultConfiguration().getBounds().getY();
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsDialog.java Mon Nov 10 11:20:53 2014
@@ -6,11 +6,11 @@
import javax.swing.JDialog;
/**
- * The modal dialog for entering settings. It contains a <code>JPanel</code>
- * with the different settings sub-tabs.
+ * The modal dialog for entering settings. It contains a <code>JPanel</code> with the different
+ * settings sub-tabs.
*/
class SettingsDialog extends JDialog {
-
+
final SettingsPanel settingsPanel = new SettingsPanel(this);
SettingsDialog() {
@@ -21,14 +21,14 @@
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setModalityType(ModalityType.APPLICATION_MODAL);
pack();
-
+
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible(false);
}
});
}
-
+
SettingsPanel getSettingsPanel() {
return settingsPanel;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SettingsPanel.java Mon Nov 10 11:20:53 2014
@@ -22,63 +22,62 @@
ConnectionSettingsPanel connectionPanel = new ConnectionSettingsPanel();
DataSourcePanel dataSourcePanel = new DataSourcePanel();
static final String OKAY_COMMAND = "settingsOkay";
-
+
JButton defaultsButton;
-
+
JDialog parent;
-
+
SettingsPanel(JDialog parent) {
this.parent = parent;
this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
-
+
tabs = new JTabbedPane();
tabs.addTab("Connection Settings", connectionPanel);
tabs.addTab("Job Settings", jobPanel);
tabs.addTab("Data Source", dataSourcePanel);
add(tabs);
-
+
JButton okayButton = new JButton("Okay");
okayButton.setActionCommand(OKAY_COMMAND);
okayButton.addActionListener(this);
-
+
defaultsButton = new JButton("Defaults");
defaultsButton.setActionCommand(Commands.LOAD_DEFAULT_CONFIG_FILE);
defaultsButton.addActionListener(this);
-
- add(Box.createRigidArea(new Dimension(1,5)));
+
+ add(Box.createRigidArea(new Dimension(1, 5)));
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(okayButton);
buttonsPanel.add(defaultsButton);
- buttonsPanel.setLayout(new FlowLayout());
+ buttonsPanel.setLayout(new FlowLayout());
add(buttonsPanel);
- add(Box.createRigidArea(new Dimension(1,5)));
+ add(Box.createRigidArea(new Dimension(1, 5)));
}
-
+
ConnectionSettingsPanel getConnectionPanel() {
return connectionPanel;
}
-
+
JobSettingsPanel getJobSettingsPanel() {
return jobPanel;
}
-
+
DataSourcePanel getDataSourcePanel() {
return dataSourcePanel;
}
-
+
@Override
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals(OKAY_COMMAND)) {
- parent.setVisible(false);
+ parent.setVisible(false);
}
- }
-
+ }
+
/**
- * This method is used to register a listener so that the Monitoring Application
- * can reset to the default configuration when the "Defaults" button is pushed from
- * the settings panel.
+ * This method is used to register a listener so that the Monitoring Application can reset to
+ * the default configuration when the "Defaults" button is pushed from the settings panel.
* @param listener
*/
void addActionListener(ActionListener listener) {
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusWindow.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusWindow.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/SystemStatusWindow.java Mon Nov 10 11:20:53 2014
@@ -25,20 +25,21 @@
import org.hps.monitoring.subsys.StatusCode;
/**
- * A GUI window for showing changes to {@link org.hps.monitoring.subsys.SystemStatus} objects
- * using a <code>JTable</code>.
+ * A GUI window for showing changes to {@link org.hps.monitoring.subsys.SystemStatus} objects using
+ * a <code>JTable</code>.
*/
-// TODO: It might be a good idea if there was a second table which logged all status changes as separate
-// rows so they could be seen in order.
+// TODO: It might be a good idea if there was a second table which logged all status changes as
+// separate
+// rows so they could be seen in order.
class SystemStatusWindow extends ApplicationWindow {
JTable table;
-
+
SystemStatusWindow() {
super("System Status Monitor");
-
+
table = new JTable(new SystemStatusTableModel());
-
+
// Rendering of system status cells using different background colors.
table.getColumnModel().getColumn(SystemStatusTableModel.STATUS_COL).setCellRenderer(new DefaultTableCellRenderer() {
@@ -75,7 +76,7 @@
return label;
}
});
-
+
// Date formatting for last changed.
table.getColumnModel().getColumn(LAST_CHANGED_COL).setCellRenderer(new DefaultTableCellRenderer() {
@@ -89,22 +90,22 @@
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
}
});
-
+
// Button for clearing system statuses.
table.getColumnModel().getColumn(RESET_COL).setCellRenderer(new ButtonRenderer("Clear"));
table.addMouseListener(new JTableButtonMouseListener(table));
table.getColumn("Clearable").setWidth(0);
table.getColumn("Clearable").setMinWidth(0);
table.getColumn("Clearable").setMaxWidth(0);
-
+
// Column widths.
table.getColumnModel().getColumn(ACTIVE_COL).setPreferredWidth(8);
table.getColumnModel().getColumn(STATUS_COL).setPreferredWidth(10);
table.getColumnModel().getColumn(SYSTEM_COL).setPreferredWidth(10);
// TODO: Add default width setting for every column.
-
+
table.setAutoCreateRowSorter(true);
-
+
// Scroll pane.
JScrollPane scrollPane = new JScrollPane(table);
scrollPane.setOpaque(true);
@@ -119,47 +120,46 @@
public SystemStatusTableModel getTableModel() {
return (SystemStatusTableModel) table.getModel();
}
-
+
/**
* Renders a button if the status is clearable.
*/
private class ButtonRenderer extends JButton implements TableCellRenderer {
-
+
public ButtonRenderer(String label) {
this.setText(label);
}
- public Component getTableCellRendererComponent(
- JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- boolean clearable = (Boolean)table.getModel().getValueAt(row, CLEARABLE_COL);
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ boolean clearable = (Boolean) table.getModel().getValueAt(row, CLEARABLE_COL);
if (clearable)
return this;
- else
+ else
return null;
}
}
-
+
/**
- * Fires a mouse click event when the clear button is pressed, which in turn
- * will activate the action event for the button. The <code>ActionListener</code>
- * then sets the <code>StatusCode</code> to <code>CLEARED</code>.
+ * Fires a mouse click event when the clear button is pressed, which in turn will activate the
+ * action event for the button. The <code>ActionListener</code> then sets the
+ * <code>StatusCode</code> to <code>CLEARED</code>.
*/
private static class JTableButtonMouseListener extends MouseAdapter {
private final JTable table;
-
+
public JTableButtonMouseListener(JTable table) {
this.table = table;
}
public void mouseClicked(MouseEvent e) {
int column = table.getColumnModel().getColumnIndexAtX(e.getX());
- int row = e.getY() / table.getRowHeight();
+ int row = e.getY() / table.getRowHeight();
if (row < table.getRowCount() && row >= 0 && column < table.getColumnCount() && column >= 0) {
Object value = table.getValueAt(row, column);
if (value instanceof JButton) {
- ((JButton)value).doClick();
+ ((JButton) value).doClick();
}
}
}
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/WindowConfiguration.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/WindowConfiguration.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/WindowConfiguration.java Mon Nov 10 11:20:53 2014
@@ -2,26 +2,25 @@
import javax.swing.JFrame;
-
/**
- * Simple class for encapsulating the width, height, x position, and
- * y position of a GUI component in the app.
+ * Simple class for encapsulating the width, height, x position, and y position of a GUI component
+ * in the app.
* @author Jeremy McCormick <[log in to unmask]>
*/
class WindowConfiguration {
-
+
int width;
int height;
int x;
int y;
-
+
WindowConfiguration(int width, int height, int x, int y) {
this.width = width;
this.height = height;
this.x = x;
this.y = y;
}
-
+
WindowConfiguration(String configuration) {
String[] splited = configuration.split(" ");
if (splited.length != 4)
@@ -31,14 +30,14 @@
x = Integer.parseInt(splited[2]);
y = Integer.parseInt(splited[3]);
}
-
+
WindowConfiguration(JFrame frame) {
width = frame.getWidth();
height = frame.getHeight();
x = frame.getLocation().x;
y = frame.getLocation().y;
}
-
+
public String toString() {
return width + " " + height + " " + x + " " + y;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/AbstractModel.java Mon Nov 10 11:20:53 2014
@@ -18,11 +18,11 @@
public AbstractModel() {
propertyChangeSupport = new PropertyChangeSupport(this);
}
-
+
public void setListenersEnabled(boolean listenersEnabled) {
this.listenersEnabled = listenersEnabled;
}
-
+
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
@@ -34,20 +34,20 @@
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
if (listenersEnabled)
propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
- //System.out.println("firePropertyChange");
- //System.out.println(" name: " + propertyName);
- //System.out.println(" old value: " + oldValue);
- //System.out.println(" new value: " + newValue);
+ // System.out.println("firePropertyChange");
+ // System.out.println(" name: " + propertyName);
+ // System.out.println(" old value: " + oldValue);
+ // System.out.println(" new value: " + newValue);
}
-
+
protected void firePropertyChange(PropertyChangeEvent evt) {
if (listenersEnabled)
propertyChangeSupport.firePropertyChange(evt);
}
-
+
abstract public String[] getPropertyNames();
-
- // FIXME: This method is kind of a hack. Any other good way to do this?
+
+ // FIXME: This method is kind of a hack. Any other good way to do this?
public void fireAllChanged() {
if (!listenersEnabled)
return;
@@ -62,22 +62,23 @@
try {
Object value = null;
try {
- value = getMethod.invoke(this, (Object[])null);
+ value = getMethod.invoke(this, (Object[]) null);
} catch (NullPointerException e) {
throw new RuntimeException("No get method exists for property: " + property, e);
}
- // Is the value non-null?
- // (Null values are actually okay. It just means the property is not set.)
+ // Is the value non-null?
+ // (Null values are actually okay. It just means the property is not set.)
if (value != null) {
- firePropertyChange(property, value, value);
+ firePropertyChange(property, value, value);
for (PropertyChangeListener listener : propertyChangeSupport.getPropertyChangeListeners()) {
- // FIXME: For some reason calling the propertyChangeSupport methods directly here doesn't work!!!
+ // FIXME: For some reason calling the propertyChangeSupport methods directly
+ // here doesn't work!!!
listener.propertyChange(new PropertyChangeEvent(this, property, value, value));
}
}
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new RuntimeException(e);
- }
+ }
}
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/Configuration.java Mon Nov 10 11:20:53 2014
@@ -8,20 +8,20 @@
import java.util.Properties;
/**
- * This class provides a list of key, value pairs backed by a <code>Properties</code> object.
- * The accessor methods to get these values are not public, because the {@link ConfigurationModel}
+ * This class provides a list of key, value pairs backed by a <code>Properties</code> object. The
+ * accessor methods to get these values are not public, because the {@link ConfigurationModel}
* should be used instead.
*/
public final class Configuration {
-
+
Properties properties;
File file;
String resourcePath;
-
- Configuration() {
+
+ Configuration() {
properties = new Properties();
}
-
+
/**
* Load a configuration from a properties file.
* @param file The properties file.
@@ -33,9 +33,9 @@
properties.load(new FileInputStream(this.file));
} catch (IOException e) {
throw new RuntimeException("Error parsing properties file.", e);
- }
+ }
}
-
+
/**
* Load a configuration from a resource path pointing to a properties file.
* @param resourcePath The resource path to the properties file.
@@ -50,25 +50,24 @@
throw new RuntimeException("Error parsing properties resource.", e);
}
}
-
+
/**
- * Get the file associated with this configuration or <code>null</code>
- * if not set.
+ * Get the file associated with this configuration or <code>null</code> if not set.
* @return The file associated with the configuration.
*/
public File getFile() {
return file;
}
-
+
/**
- * Get the resource path associated with this configuration or <code>null</code>
- * if not applicable.
+ * Get the resource path associated with this configuration or <code>null</code> if not
+ * applicable.
* @return The resource path of this configuration.
*/
public String getResourcePath() {
return resourcePath;
}
-
+
/**
* True if configuration has value for the key.
* @param key The key.
@@ -77,7 +76,7 @@
boolean hasKey(String key) {
return properties.getProperty(key) != null;
}
-
+
/**
* Get a key value as a string.
* @param key The key to lookup.
@@ -86,7 +85,7 @@
String get(String key) {
return properties.getProperty(key);
}
-
+
/**
* Get a key value as a boolean.
* @param key The key to lookup.
@@ -95,7 +94,7 @@
Boolean getBoolean(String key) {
return Boolean.parseBoolean(properties.getProperty(key));
}
-
+
/**
* Get a key value as a double.
* @param key The key to lookup.
@@ -104,7 +103,7 @@
Double getDouble(String key) {
return Double.parseDouble(properties.getProperty(key));
}
-
+
/**
* Get a key value as an integer.
* @param key The key to lookup.
@@ -113,10 +112,9 @@
Integer getInteger(String key) {
return Integer.parseInt(properties.getProperty(key));
}
-
+
/**
- * Write this configuration to a file and set that file
- * as the current one.
+ * Write this configuration to a file and set that file as the current one.
* @param file The output file.
*/
public void writeToFile(File file) {
@@ -124,10 +122,10 @@
try {
properties.store(new FileOutputStream(this.file), null);
} catch (IOException e) {
- throw new RuntimeException("Error saving properties file.", e);
- }
+ throw new RuntimeException("Error saving properties file.", e);
+ }
}
-
+
/**
* Set a configuration value.
* @param key The key for lookup.
@@ -136,7 +134,7 @@
void set(String key, Object value) {
properties.put(key, String.valueOf(value));
}
-
+
/**
* Remove a configuration value.
* @param key The key of the value.
@@ -144,7 +142,7 @@
void remove(String key) {
properties.remove(key);
}
-
+
/**
* Convert this object to a string by printing out its properties list.
*/
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/ConfigurationModel.java Mon Nov 10 11:20:53 2014
@@ -10,27 +10,26 @@
import org.jlab.coda.et.enums.Mode;
/**
- * A model of the global configuration parameters that can be
- * used to automatically update the GUI from a configuration
- * or push changes from GUI components into the current configuration.
+ * A model of the global configuration parameters that can be used to automatically update the GUI
+ * from a configuration or push changes from GUI components into the current configuration.
*/
// TODO: Should set methods check if new value is equal to old and then ignore if so?
// FIXME: When the set methods are called, e.g. from GUI updates, this triggers
-// a property change event that pushes the values back to the GUI again.
+// a property change event that pushes the values back to the GUI again.
public final class ConfigurationModel extends AbstractModel {
-
+
Configuration config;
-
+
// Job settings
public static final String AIDA_AUTO_SAVE_PROPERTY = "AidaAutoSave";
public static final String AIDA_FILE_NAME_PROPERTY = "AidaFileName";
public static final String DETECTOR_NAME_PROPERTY = "DetectorName";
public static final String DISCONNECT_ON_ERROR_PROPERTY = "DisconnectOnError";
- public static final String DISCONNECT_ON_END_RUN_PROPERTY = "DisconnectOnEndRun";
+ public static final String DISCONNECT_ON_END_RUN_PROPERTY = "DisconnectOnEndRun";
public static final String EVENT_BUILDER_PROPERTY = "EventBuilderClassName";
public static final String LOG_FILE_NAME_PROPERTY = "LogFileName";
public static final String LOG_LEVEL_PROPERTY = "LogLevel";
- public static final String LOG_TO_FILE_PROPERTY = "LogToFile";
+ public static final String LOG_TO_FILE_PROPERTY = "LogToFile";
public static final String MONITORING_APPLICATION_LAYOUT_PROPERTY = "MonitoringApplicationLayout";
public static final String PLOT_FRAME_LAYOUT_PROPERTY = "PlotFrameLayout";
public static final String SAVE_LAYOUT_PROPERTY = "SaveLayout";
@@ -38,12 +37,12 @@
public static final String STEERING_TYPE_PROPERTY = "SteeringType";
public static final String STEERING_FILE_PROPERTY = "SteeringFile";
public static final String STEERING_RESOURCE_PROPERTY = "SteeringResource";
-
+
// Data source
public static final String DATA_SOURCE_TYPE_PROPERTY = "DataSourceType";
public static final String DATA_SOURCE_PATH_PROPERTY = "DataSourcePath";
public static final String PROCESSING_STAGE_PROPERTY = "ProcessingStage";
-
+
// ET connection parameters
public static final String ET_NAME_PROPERTY = "EtName";
public static final String HOST_PROPERTY = "Host";
@@ -57,383 +56,355 @@
public static final String WAIT_MODE_PROPERTY = "WaitMode";
public static final String WAIT_TIME_PROPERTY = "WaitTime";
public static final String PRESCALE_PROPERTY = "Prescale";
-
+
static final String[] CONFIG_PROPERTIES = new String[] {
-
+
// Job settings
- AIDA_AUTO_SAVE_PROPERTY,
- AIDA_FILE_NAME_PROPERTY,
- DETECTOR_NAME_PROPERTY,
- DISCONNECT_ON_ERROR_PROPERTY,
- DISCONNECT_ON_END_RUN_PROPERTY,
- EVENT_BUILDER_PROPERTY,
- LOG_FILE_NAME_PROPERTY,
- LOG_LEVEL_PROPERTY,
- LOG_TO_FILE_PROPERTY,
- STEERING_FILE_PROPERTY,
- STEERING_RESOURCE_PROPERTY,
- STEERING_TYPE_PROPERTY,
-
+ AIDA_AUTO_SAVE_PROPERTY, AIDA_FILE_NAME_PROPERTY, DETECTOR_NAME_PROPERTY, DISCONNECT_ON_ERROR_PROPERTY, DISCONNECT_ON_END_RUN_PROPERTY, EVENT_BUILDER_PROPERTY, LOG_FILE_NAME_PROPERTY, LOG_LEVEL_PROPERTY, LOG_TO_FILE_PROPERTY, STEERING_FILE_PROPERTY, STEERING_RESOURCE_PROPERTY, STEERING_TYPE_PROPERTY,
+
// Data source
- DATA_SOURCE_TYPE_PROPERTY,
- DATA_SOURCE_PATH_PROPERTY,
- PROCESSING_STAGE_PROPERTY,
-
+ DATA_SOURCE_TYPE_PROPERTY, DATA_SOURCE_PATH_PROPERTY, PROCESSING_STAGE_PROPERTY,
+
// ET parameters
- ET_NAME_PROPERTY,
- HOST_PROPERTY,
- PORT_PROPERTY,
- BLOCKING_PROPERTY,
- VERBOSE_PROPERTY,
- STATION_NAME_PROPERTY,
- CHUNK_SIZE_PROPERTY,
- QUEUE_SIZE_PROPERTY,
- STATION_POSITION_PROPERTY,
- WAIT_MODE_PROPERTY,
- WAIT_TIME_PROPERTY,
- PRESCALE_PROPERTY,
-
+ ET_NAME_PROPERTY, HOST_PROPERTY, PORT_PROPERTY, BLOCKING_PROPERTY, VERBOSE_PROPERTY, STATION_NAME_PROPERTY, CHUNK_SIZE_PROPERTY, QUEUE_SIZE_PROPERTY, STATION_POSITION_PROPERTY, WAIT_MODE_PROPERTY, WAIT_TIME_PROPERTY, PRESCALE_PROPERTY,
+
// GUI layout
- SAVE_LAYOUT_PROPERTY,
- MONITORING_APPLICATION_LAYOUT_PROPERTY,
- PLOT_FRAME_LAYOUT_PROPERTY,
- SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY
- };
-
+ SAVE_LAYOUT_PROPERTY, MONITORING_APPLICATION_LAYOUT_PROPERTY, PLOT_FRAME_LAYOUT_PROPERTY, SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY };
+
String detectorName;
-
+
public ConfigurationModel() {
this.config = new Configuration();
}
-
+
public ConfigurationModel(Configuration config) {
this.config = config;
}
-
+
public void setConfiguration(Configuration config) {
this.config = config;
fireAllChanged();
}
-
+
public Configuration getConfiguration() {
return this.config;
}
-
+
public Level getLogLevel() {
- return Level.parse(config.get(LOG_LEVEL_PROPERTY));
- }
-
+ return Level.parse(config.get(LOG_LEVEL_PROPERTY));
+ }
+
public void setLogLevel(Level level) {
Level oldValue = getLogLevel();
config.set(LOG_LEVEL_PROPERTY, level.getName());
firePropertyChange(LOG_LEVEL_PROPERTY, oldValue, getLogLevel());
}
-
- public SteeringType getSteeringType() {
+
+ public SteeringType getSteeringType() {
return SteeringType.valueOf(config.get(STEERING_TYPE_PROPERTY));
}
-
+
public void setSteeringType(SteeringType steeringType) {
SteeringType oldValue = getSteeringType();
config.set(STEERING_TYPE_PROPERTY, steeringType.name());
firePropertyChange(STEERING_TYPE_PROPERTY, oldValue, getSteeringType());
}
-
+
public File getSteeringFile() {
if (config.hasKey(STEERING_FILE_PROPERTY))
return new File(config.get(STEERING_FILE_PROPERTY));
else
return null;
}
-
+
public void setSteeringFile(String steeringFile) {
File oldValue = getSteeringFile();
config.set(STEERING_FILE_PROPERTY, steeringFile);
firePropertyChange(STEERING_FILE_PROPERTY, oldValue, getSteeringFile().getPath());
}
-
+
public String getSteeringResource() {
return config.get(STEERING_RESOURCE_PROPERTY);
- }
-
+ }
+
public void setSteeringResource(String steeringResource) {
String oldValue = getSteeringResource();
config.set(STEERING_RESOURCE_PROPERTY, steeringResource);
firePropertyChange(STEERING_RESOURCE_PROPERTY, oldValue, steeringResource);
}
-
+
public String getDetectorName() {
return config.get(DETECTOR_NAME_PROPERTY);
}
-
+
public void setDetectorName(String detectorName) {
String oldValue = getDetectorName();
config.set(DETECTOR_NAME_PROPERTY, detectorName);
firePropertyChange(DETECTOR_NAME_PROPERTY, oldValue, getDetectorName());
}
-
+
public String getEventBuilderClassName() {
- return config.get(EVENT_BUILDER_PROPERTY);
- }
-
+ return config.get(EVENT_BUILDER_PROPERTY);
+ }
+
public void setEventBuilderClassName(String eventBuilderClassName) {
String oldValue = getEventBuilderClassName();
config.set(EVENT_BUILDER_PROPERTY, eventBuilderClassName);
firePropertyChange(EVENT_BUILDER_PROPERTY, oldValue, getEventBuilderClassName());
}
-
+
public boolean getLogToFile() {
return config.getBoolean(LOG_TO_FILE_PROPERTY);
}
-
+
public void setLogToFile(boolean logToFile) {
boolean oldValue = getLogToFile();
config.set(LOG_TO_FILE_PROPERTY, logToFile);
firePropertyChange(LOG_TO_FILE_PROPERTY, oldValue, getLogToFile());
}
-
+
public String getLogFileName() {
return config.get(LOG_FILE_NAME_PROPERTY);
}
-
+
public void setLogFileName(String logFileName) {
String oldValue = getLogFileName();
config.set(LOG_FILE_NAME_PROPERTY, logFileName);
firePropertyChange(LOG_FILE_NAME_PROPERTY, oldValue, getLogFileName());
}
-
+
public boolean getAidaAutoSave() {
return config.equals(AIDA_AUTO_SAVE_PROPERTY);
}
-
+
public void setAidaAutoSave(boolean aidaAutoSave) {
boolean oldValue = getAidaAutoSave();
config.set(AIDA_AUTO_SAVE_PROPERTY, aidaAutoSave);
firePropertyChange(AIDA_AUTO_SAVE_PROPERTY, oldValue, aidaAutoSave);
}
-
+
public String getAidaFileName() {
return config.get(AIDA_FILE_NAME_PROPERTY);
}
-
+
public void setAidaFileName(String aidaFileName) {
String oldValue = getAidaFileName();
config.set(AIDA_FILE_NAME_PROPERTY, aidaFileName);
firePropertyChange(AIDA_FILE_NAME_PROPERTY, oldValue, aidaFileName);
}
-
+
public boolean getDisconnectOnError() {
return config.getBoolean(DISCONNECT_ON_ERROR_PROPERTY);
- }
-
+ }
+
public void setDisconnectOnError(boolean disconnectOnError) {
boolean oldValue = getDisconnectOnError();
config.set(DISCONNECT_ON_ERROR_PROPERTY, disconnectOnError);
firePropertyChange(DISCONNECT_ON_ERROR_PROPERTY, oldValue, getDisconnectOnError());
- }
-
+ }
+
public boolean getDisconnectOnEndRun() {
return config.getBoolean(DISCONNECT_ON_END_RUN_PROPERTY);
}
-
+
public void setDisconnectOnEndRun(boolean disconnectOnEndRun) {
boolean oldValue = getDisconnectOnEndRun();
config.set(DISCONNECT_ON_END_RUN_PROPERTY, disconnectOnEndRun);
firePropertyChange(DISCONNECT_ON_END_RUN_PROPERTY, oldValue, getDisconnectOnEndRun());
}
-
+
public DataSourceType getDataSourceType() {
return DataSourceType.valueOf(config.get(DATA_SOURCE_TYPE_PROPERTY));
}
-
+
public void setDataSourceType(DataSourceType dataSourceType) {
DataSourceType oldValue = getDataSourceType();
config.set(DATA_SOURCE_TYPE_PROPERTY, dataSourceType);
firePropertyChange(DATA_SOURCE_TYPE_PROPERTY, oldValue, getDataSourceType());
}
-
+
public String getDataSourcePath() {
return config.get(DATA_SOURCE_PATH_PROPERTY);
}
-
+
public void setDataSourcePath(String dataSourcePath) {
String oldValue = getDataSourcePath();
config.set(DATA_SOURCE_PATH_PROPERTY, dataSourcePath);
firePropertyChange(DATA_SOURCE_PATH_PROPERTY, oldValue, getDataSourcePath());
}
-
+
public ProcessingStage getProcessingStage() {
if (config.get(PROCESSING_STAGE_PROPERTY) == null)
throw new RuntimeException(PROCESSING_STAGE_PROPERTY + " is null!!!");
return ProcessingStage.valueOf(config.get(PROCESSING_STAGE_PROPERTY));
}
-
+
public void setProcessingStage(ProcessingStage processingStage) {
ProcessingStage oldValue = getProcessingStage();
config.set(PROCESSING_STAGE_PROPERTY, processingStage);
firePropertyChange(PROCESSING_STAGE_PROPERTY, oldValue, getProcessingStage());
}
-
+
public String getEtName() {
return config.get(ET_NAME_PROPERTY);
}
-
+
public void setEtName(String etName) {
String oldValue = getEtName();
config.set(ET_NAME_PROPERTY, etName);
firePropertyChange(ET_NAME_PROPERTY, oldValue, getEtName());
}
-
+
public String getHost() {
return config.get(HOST_PROPERTY);
}
-
+
public void setHost(String host) {
String oldValue = getHost();
config.set(HOST_PROPERTY, host);
firePropertyChange(HOST_PROPERTY, oldValue, getHost());
}
-
+
public int getPort() {
return config.getInteger(PORT_PROPERTY);
}
-
+
public void setPort(int port) {
int oldValue = getPort();
config.set(PORT_PROPERTY, port);
firePropertyChange(PORT_PROPERTY, oldValue, getPort());
}
-
+
public boolean getBlocking() {
return config.getBoolean(BLOCKING_PROPERTY);
}
-
+
public void setBlocking(boolean blocking) {
boolean oldValue = getBlocking();
config.set(BLOCKING_PROPERTY, blocking);
firePropertyChange(BLOCKING_PROPERTY, oldValue, getBlocking());
}
-
+
public boolean getVerbose() {
return config.getBoolean(VERBOSE_PROPERTY);
}
-
+
public void setVerbose(boolean verbose) {
boolean oldValue = getVerbose();
config.set(VERBOSE_PROPERTY, verbose);
firePropertyChange(VERBOSE_PROPERTY, oldValue, getVerbose());
}
-
+
public String getStationName() {
- return config.get(STATION_NAME_PROPERTY);
- }
-
+ return config.get(STATION_NAME_PROPERTY);
+ }
+
public void setStationName(String stationName) {
String oldValue = getStationName();
config.set(STATION_NAME_PROPERTY, stationName);
firePropertyChange(STATION_NAME_PROPERTY, oldValue, getStationName());
}
-
+
public int getChunkSize() {
return config.getInteger(CHUNK_SIZE_PROPERTY);
}
-
+
public void setChunkSize(int chunkSize) {
int oldValue = getChunkSize();
config.set(CHUNK_SIZE_PROPERTY, chunkSize);
firePropertyChange(CHUNK_SIZE_PROPERTY, oldValue, getChunkSize());
- }
-
+ }
+
public int getQueueSize() {
return config.getInteger(QUEUE_SIZE_PROPERTY);
}
-
+
public void setQueueSize(int queueSize) {
int oldValue = getQueueSize();
config.set(QUEUE_SIZE_PROPERTY, queueSize);
firePropertyChange(QUEUE_SIZE_PROPERTY, oldValue, getQueueSize());
}
-
+
public int getStationPosition() {
return config.getInteger(STATION_POSITION_PROPERTY);
}
-
+
public void setStationPosition(int stationPosition) {
int oldValue = getStationPosition();
config.set(STATION_POSITION_PROPERTY, stationPosition);
firePropertyChange(STATION_POSITION_PROPERTY, oldValue, getStationPosition());
}
-
+
public Mode getWaitMode() {
return Mode.valueOf(config.get(WAIT_MODE_PROPERTY));
}
-
+
public void setWaitMode(Mode waitMode) {
Mode oldValue = getWaitMode();
- config.set(WAIT_MODE_PROPERTY, waitMode.name());
+ config.set(WAIT_MODE_PROPERTY, waitMode.name());
firePropertyChange(WAIT_MODE_PROPERTY, oldValue, getWaitMode());
}
-
+
public int getWaitTime() {
return config.getInteger(WAIT_TIME_PROPERTY);
}
-
+
public void setWaitTime(int waitTime) {
int oldValue = getWaitTime();
config.set(WAIT_TIME_PROPERTY, waitTime);
firePropertyChange(WAIT_TIME_PROPERTY, oldValue, getWaitTime());
}
-
+
public int getPrescale() {
return config.getInteger(PRESCALE_PROPERTY);
}
-
+
public void setPrescale(int prescale) {
int oldValue = getPrescale();
config.set(PRESCALE_PROPERTY, prescale);
firePropertyChange(PRESCALE_PROPERTY, oldValue, getPrescale());
}
-
+
public boolean getSaveLayout() {
return config.getBoolean(SAVE_LAYOUT_PROPERTY);
}
-
+
public void setSaveLayout(boolean saveLayout) {
boolean oldValue = getSaveLayout();
config.set(SAVE_LAYOUT_PROPERTY, saveLayout);
firePropertyChange(SAVE_LAYOUT_PROPERTY, oldValue, getSaveLayout());
}
-
+
public String getMonitoringApplicationLayout() {
return config.get(MONITORING_APPLICATION_LAYOUT_PROPERTY);
}
-
+
public void setMonitoringApplicationLayout(String layout) {
String oldValue = getMonitoringApplicationLayout();
config.set(MONITORING_APPLICATION_LAYOUT_PROPERTY, layout);
firePropertyChange(MONITORING_APPLICATION_LAYOUT_PROPERTY, oldValue, getMonitoringApplicationLayout());
}
-
+
public String getSystemStatusFrameLayout() {
return config.get(SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY);
}
-
+
public void setSystemStatusFrameLayout(String layout) {
String oldValue = getSystemStatusFrameLayout();
config.set(SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY, layout);
firePropertyChange(SYSTEM_STATUS_FRAME_LAYOUT_PROPERTY, oldValue, getSystemStatusFrameLayout());
}
-
+
public String getPlotFrameLayout() {
return config.get(PLOT_FRAME_LAYOUT_PROPERTY);
}
-
+
public void setPlotFrameLayout(String layout) {
String oldValue = getPlotFrameLayout();
config.set(PLOT_FRAME_LAYOUT_PROPERTY, layout);
- firePropertyChange(PLOT_FRAME_LAYOUT_PROPERTY, oldValue, getPlotFrameLayout());
- }
-
+ firePropertyChange(PLOT_FRAME_LAYOUT_PROPERTY, oldValue, getPlotFrameLayout());
+ }
+
public void remove(String property) {
Object oldValue = config.get(property);
if (oldValue != null) {
@@ -441,9 +412,9 @@
firePropertyChange(property, oldValue, null);
}
}
-
+
@Override
public String[] getPropertyNames() {
return CONFIG_PROPERTIES;
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/HasConfigurationModel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/HasConfigurationModel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/HasConfigurationModel.java Mon Nov 10 11:20:53 2014
@@ -3,14 +3,14 @@
/**
* Mixin interface for classes that have an associated {@link ConfigurationModel}.
*/
-public interface HasConfigurationModel {
-
+public interface HasConfigurationModel {
+
/**
* Set the ConfigurationModel of the object.
* @param configurationModel The ConfigurationModel.
*/
void setConfigurationModel(ConfigurationModel configurationModel);
-
+
/**
* Get the current ConfigurationModel of the object.
* @return The ConfigurationModel.
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/RunModel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/RunModel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/RunModel.java Mon Nov 10 11:20:53 2014
@@ -6,28 +6,22 @@
* Backing model for run information that shows in the {@link org.hps.monitoring.gui.RunPanel}.
*/
public final class RunModel extends AbstractModel {
-
- public final static String RUN_NUMBER_PROPERTY = "RunNumber";
+
+ public final static String RUN_NUMBER_PROPERTY = "RunNumber";
public final static String START_DATE_PROPERTY = "StartDate";
public final static String END_DATE_PROPERTY = "EndDate";
public final static String RUN_LENGTH_PROPERTY = "RunLength"; // set at end, in seconds
public final static String TOTAL_EVENTS_PROPERTY = "TotalEvents"; // only set at end
- public final static String EVENTS_RECEIVED_PROPERTY = "EventsReceived"; // events received so far
- public final static String ELAPSED_TIME_PROPERTY = "ElapsedTime"; // updated on the fly, in seconds
- public final static String DATA_RECEIVED_PROPERTY = "DataReceived"; // updated on the fly, in bytes
+ public final static String EVENTS_RECEIVED_PROPERTY = "EventsReceived"; // events received so
+ // far
+ public final static String ELAPSED_TIME_PROPERTY = "ElapsedTime"; // updated on the fly, in
+ // seconds
+ public final static String DATA_RECEIVED_PROPERTY = "DataReceived"; // updated on the fly, in
+ // bytes
public final static String EVENT_NUMBER_PROPERTY = "EventNumber"; // current event number
- static final String[] properties = new String[] {
- RUN_NUMBER_PROPERTY,
- START_DATE_PROPERTY,
- END_DATE_PROPERTY,
- RUN_LENGTH_PROPERTY,
- TOTAL_EVENTS_PROPERTY,
- ELAPSED_TIME_PROPERTY,
- DATA_RECEIVED_PROPERTY,
- EVENT_NUMBER_PROPERTY
- };
-
+ static final String[] properties = new String[] { RUN_NUMBER_PROPERTY, START_DATE_PROPERTY, END_DATE_PROPERTY, RUN_LENGTH_PROPERTY, TOTAL_EVENTS_PROPERTY, ELAPSED_TIME_PROPERTY, DATA_RECEIVED_PROPERTY, EVENT_NUMBER_PROPERTY };
+
int runNumber;
Date startDate;
Date endDate;
@@ -37,113 +31,113 @@
int elapsedTime;
long dataReceived;
int eventNumber;
-
+
public String[] getPropertyNames() {
return properties;
}
-
+
public int getRunNumber() {
return runNumber;
}
-
+
public void setRunNumber(int runNumber) {
int oldValue = this.runNumber;
this.runNumber = runNumber;
this.firePropertyChange(RUN_NUMBER_PROPERTY, oldValue, this.runNumber);
}
-
+
public Date getStartDate() {
return startDate;
}
-
+
public void setStartDate(Date startDate) {
Date oldValue = this.startDate;
this.startDate = startDate;
this.firePropertyChange(START_DATE_PROPERTY, oldValue, this.startDate);
}
-
+
public Date getEndDate() {
return endDate;
}
-
+
public void setEndDate(Date endDate) {
Date oldValue = this.endDate;
this.endDate = endDate;
this.firePropertyChange(END_DATE_PROPERTY, oldValue, this.endDate);
}
-
+
public int getRunLength() {
return runLength;
}
-
+
public void setRunLength(int runLength) {
int oldValue = this.runLength;
this.runLength = runLength;
this.firePropertyChange(RUN_LENGTH_PROPERTY, oldValue, this.runLength);
}
-
+
public void computeRunLength() {
if (startDate != null && endDate != null) {
long elapsedMillis = endDate.getTime() - startDate.getTime();
- int elapsedSeconds = (int)((double)elapsedMillis / 1000.);
+ int elapsedSeconds = (int) ((double) elapsedMillis / 1000.);
this.setRunLength(elapsedSeconds);
}
}
-
+
public int getTotalEvents() {
return totalEvents;
}
-
+
public void setTotalEvents(int totalEvents) {
int oldValue = this.totalEvents;
this.totalEvents = totalEvents;
this.firePropertyChange(TOTAL_EVENTS_PROPERTY, oldValue, this.totalEvents);
}
-
+
public int getEventsReceived() {
return eventsReceived;
}
-
+
public void setEventsReceived(int eventsReceived) {
int oldValue = this.eventsReceived;
this.eventsReceived = eventsReceived;
this.firePropertyChange(EVENTS_RECEIVED_PROPERTY, oldValue, this.eventsReceived);
}
-
+
public void incrementEventsReceived() {
this.setEventsReceived(eventsReceived + 1);
}
-
+
public int getElapsedTime() {
return elapsedTime;
}
-
+
public void setElapsedTime(int elapsedTime) {
int oldValue = this.elapsedTime;
this.elapsedTime = elapsedTime;
this.firePropertyChange(ELAPSED_TIME_PROPERTY, oldValue, this.elapsedTime);
}
-
+
public long getDataReceived() {
return dataReceived;
}
-
+
public void setDataReceived(long dataReceived) {
long oldValue = this.dataReceived;
this.dataReceived = dataReceived;
this.firePropertyChange(DATA_RECEIVED_PROPERTY, oldValue, this.dataReceived);
}
-
+
public void addDataReceived(long addDataReceived) {
this.setDataReceived(dataReceived + addDataReceived);
}
-
+
public void setEventNumber(int eventNumber) {
int oldValue = this.eventNumber;
this.eventNumber = eventNumber;
this.firePropertyChange(EVENT_NUMBER_PROPERTY, oldValue, this.eventNumber);
}
-
+
public void reset() {
setDataReceived(0);
setElapsedTime(0);
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/SystemStatusTableModel.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/SystemStatusTableModel.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/gui/model/SystemStatusTableModel.java Mon Nov 10 11:20:53 2014
@@ -15,7 +15,8 @@
import org.hps.monitoring.subsys.SystemStatusListener;
/**
- * A <code>JTableModel</code> that has a list of {@link org.hps.monitoring.subsys.SystemStatus} objects.
+ * A <code>JTableModel</code> that has a list of {@link org.hps.monitoring.subsys.SystemStatus}
+ * objects.
*/
public final class SystemStatusTableModel extends AbstractTableModel implements SystemStatusListener {
@@ -27,27 +28,18 @@
public static final int MESSAGE_COL = 5;
public static final int LAST_CHANGED_COL = 6;
public static final int CLEARABLE_COL = 7;
-
- static final String[] columnNames = {
- "Reset",
- "Active",
- "Status",
- "System",
- "Description",
- "Message",
- "Last Changed",
- "Clearable"
- };
-
+
+ static final String[] columnNames = { "Reset", "Active", "Status", "System", "Description", "Message", "Last Changed", "Clearable" };
+
List<SystemStatus> statuses = new ArrayList<SystemStatus>();
final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss.SSS");
-
+
public void addSystemStatus(SystemStatus status) {
statuses.add(status);
status.addListener(this);
fireTableDataChanged();
}
-
+
@Override
public int getRowCount() {
return statuses.size();
@@ -57,9 +49,9 @@
public int getColumnCount() {
return columnNames.length;
}
-
+
@Override
- public String getColumnName(int col) {
+ public String getColumnName(int col) {
return columnNames[col];
}
@@ -67,82 +59,82 @@
public Object getValueAt(final int rowIndex, final int columnIndex) {
SystemStatus status = statuses.get(rowIndex);
switch (columnIndex) {
- case ACTIVE_COL:
- return status.isActive();
- case STATUS_COL:
- return status.getStatusCode().name();
- case SYSTEM_COL:
- return status.getSubsystem().name();
- case DESCRIPTION_COL:
- return status.getDescription();
- case MESSAGE_COL:
- return status.getMessage();
- case LAST_CHANGED_COL:
- return new Date(status.getLastChangedMillis());
- case RESET_COL:
- // If the status is clearable, then it has a button that can be used to
- // manually set the state to CLEARED. If the status is not clearable,
- // then nothing is rendered in this cell.
- if (status.isClearable()) {
- final JButton button = new JButton();
- button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- SystemStatus status = statuses.get(rowIndex);
- // Only clearable statuses can have this state set. Check for this
- // just to be safe, even though no button is available for non-clearable
- // statuses.
- if (status.isClearable()) {
- StatusCode oldStatusCode = status.getStatusCode();
- status.setStatus(StatusCode.CLEARED, "Cleared from " + oldStatusCode.name() + " state.");
- }
+ case ACTIVE_COL:
+ return status.isActive();
+ case STATUS_COL:
+ return status.getStatusCode().name();
+ case SYSTEM_COL:
+ return status.getSubsystem().name();
+ case DESCRIPTION_COL:
+ return status.getDescription();
+ case MESSAGE_COL:
+ return status.getMessage();
+ case LAST_CHANGED_COL:
+ return new Date(status.getLastChangedMillis());
+ case RESET_COL:
+ // If the status is clearable, then it has a button that can be used to
+ // manually set the state to CLEARED. If the status is not clearable,
+ // then nothing is rendered in this cell.
+ if (status.isClearable()) {
+ final JButton button = new JButton();
+ button.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ SystemStatus status = statuses.get(rowIndex);
+ // Only clearable statuses can have this state set. Check for this
+ // just to be safe, even though no button is available for non-clearable
+ // statuses.
+ if (status.isClearable()) {
+ StatusCode oldStatusCode = status.getStatusCode();
+ status.setStatus(StatusCode.CLEARED, "Cleared from " + oldStatusCode.name() + " state.");
}
- });
- return button;
- } else {
- return null;
- }
- case CLEARABLE_COL:
- return status.isClearable();
- default:
+ }
+ });
+ return button;
+ } else {
return null;
+ }
+ case CLEARABLE_COL:
+ return status.isClearable();
+ default:
+ return null;
}
}
-
+
@Override
public Class getColumnClass(int column) {
switch (column) {
- case ACTIVE_COL:
- return Boolean.class;
- case LAST_CHANGED_COL:
- return Date.class;
- default:
- return String.class;
- }
+ case ACTIVE_COL:
+ return Boolean.class;
+ case LAST_CHANGED_COL:
+ return Date.class;
+ default:
+ return String.class;
+ }
}
-
+
@Override
public boolean isCellEditable(int row, int col) {
if (col == ACTIVE_COL)
- return true;
- else
+ return true;
+ else
return false;
}
-
+
@Override
public void statusChanged(SystemStatus status) {
int rowNumber = statuses.indexOf(status);
this.fireTableRowsUpdated(rowNumber, rowNumber);
}
-
+
public void clear() {
statuses.clear();
fireTableDataChanged();
}
-
+
@Override
public void setValueAt(Object value, int row, int col) {
if (col == ACTIVE_COL) {
statuses.get(row).setActive((Boolean) value);
}
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringAnalysisFactory.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringAnalysisFactory.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringAnalysisFactory.java Mon Nov 10 11:20:53 2014
@@ -5,24 +5,24 @@
/**
* This class implements the AIDA <code>IAnalysisFactory</code> for the monitoring application,
- * which puts plots into a series of tabs. Each <code>IPlotter</code> has its own tab where
- * its regions are shown. This class overrides {@link #createPlotterFactory()} and
- * {@link #createPlotterFactory(String)} to return a custom <code>IPlotterFactory</code> object
- * that implements this behavior.
+ * which puts plots into a series of tabs. Each <code>IPlotter</code> has its own tab where its
+ * regions are shown. This class overrides {@link #createPlotterFactory()} and
+ * {@link #createPlotterFactory(String)} to return a custom <code>IPlotterFactory</code> object that
+ * implements this behavior.
*/
public class MonitoringAnalysisFactory extends AnalysisFactory {
-
+
public MonitoringAnalysisFactory() {
}
-
+
/**
- * Register this class as the default AnalysisFactory for AIDA by setting
- * the magic property string.
+ * Register this class as the default AnalysisFactory for AIDA by setting the magic property
+ * string.
*/
public final static void register() {
System.setProperty("hep.aida.IAnalysisFactory", MonitoringAnalysisFactory.class.getName());
}
-
+
/**
* Create a named plotter factory for the monitoring application.
*/
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/MonitoringPlotFactory.java Mon Nov 10 11:20:53 2014
@@ -15,12 +15,11 @@
import org.jfree.chart.JFreeChart;
/**
- * This class implements an AIDA <code>IPlotterFactory</code> for the monitoring application.
- * It extends the JFree plotter by putting plots into tabs. Each plotter factory
- * is given its own top-level tab in a root tabbed pane, under which are separate tabs
- * for each plotter. The root pane is static and shared across all plotter factories.
- * The top level component is set externally by the MonitoringApplication before any calls
- * to AIDA are made from Drivers.
+ * This class implements an AIDA <code>IPlotterFactory</code> for the monitoring application. It
+ * extends the JFree plotter by putting plots into tabs. Each plotter factory is given its own
+ * top-level tab in a root tabbed pane, under which are separate tabs for each plotter. The root
+ * pane is static and shared across all plotter factories. The top level component is set externally
+ * by the MonitoringApplication before any calls to AIDA are made from Drivers.
*/
public class MonitoringPlotFactory extends PlotterFactory {
@@ -32,9 +31,9 @@
// Root pane where this factory's top-level tab will be inserted.
private static JTabbedPane rootPane = null;
-
+
private static PlotterRegionListener regionListener;
-
+
public static void setPlotterRegionListener(PlotterRegionListener regionListener) {
MonitoringPlotFactory.regionListener = regionListener;
}
@@ -43,7 +42,7 @@
* Class constructor.
*/
MonitoringPlotFactory() {
- super();
+ super();
setIsEmbedded(true);
setupRootPane(" ");
if (regionListener != null)
@@ -65,8 +64,7 @@
private void setupRootPane(String name) {
// FIXME: Hack to disregard call from an AIDA related class.
- if (!(new RuntimeException()).getStackTrace()[2].getClassName()
- .equals("hep.aida.ref.plotter.style.registry.StyleStoreXMLReader")) {
+ if (!(new RuntimeException()).getStackTrace()[2].getClassName().equals("hep.aida.ref.plotter.style.registry.StyleStoreXMLReader")) {
rootPane.addTab(name, tabs);
rootPane.setTabComponentAt(rootPane.getTabCount() - 1, new JLabel(name));
}
@@ -98,25 +96,24 @@
public static void setRootPane(JTabbedPane rootPane) {
MonitoringPlotFactory.rootPane = rootPane;
}
-
+
private void setupPlotterTab(String plotterName, IPlotter plotter) {
JPanel plotterPanel = new JPanel(new BorderLayout());
plotterPanel.add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER);
tabs.addTab(plotterName, plotterPanel);
tabs.setTabComponentAt(tabs.getTabCount() - 1, new JLabel(plotterName));
- }
-
+ }
+
private void addChart(JFreeChart chart) {
ChartPanel panel = new ChartPanel(chart);
tabs.addTab(chart.getTitle().getText(), panel);
tabs.setTabComponentAt(tabs.getTabCount() - 1, new JLabel(chart.getTitle().getText()));
}
-
+
/**
- * Create a strip chart using a JFreeChart implementation.
- * It will be automatically updated from a {@link StripChartUpdater}.
- * Similar to AIDA plots, the chart will be given a sub-tab in the tab
- * of this factory.
+ * Create a strip chart using a JFreeChart implementation. It will be automatically updated from
+ * a {@link StripChartUpdater}. Similar to AIDA plots, the chart will be given a sub-tab in the
+ * tab of this factory.
*
* @param title The title of the chart.
* @param yAxisLabel The y axis label.
@@ -131,7 +128,7 @@
updater.setChart(stripChart);
return updater;
}
-
+
/**
* Create a strip chart which must be updated manually.
* @param title The title of the chart.
@@ -146,5 +143,5 @@
stripChart.getLegend().setVisible(false); /* Legend turned off for now. */
addChart(stripChart);
return stripChart;
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartBuilder.java Mon Nov 10 11:20:53 2014
@@ -16,9 +16,9 @@
*/
public final class StripChartBuilder {
- private StripChartBuilder() {
+ private StripChartBuilder() {
}
-
+
/**
* This creates a strip chart that will be updated at fixed intervals from a timer.
* @param title
@@ -29,22 +29,22 @@
public static JFreeChart createDynamicTimeSeriesChart(String title, String yAxisLabel, int size) {
final DynamicTimeSeriesCollection dataset = new DynamicTimeSeriesCollection(1, size, new Second());
dataset.setTimeBase(new Second(new Date()));
- dataset.addSeries(new float[] {}, 0, "Default Dataset");
+ dataset.addSeries(new float[] {}, 0, "Default Dataset");
final JFreeChart result = ChartFactory.createTimeSeriesChart(title, "hh:mm:ss", yAxisLabel, dataset, true, true, false);
- final XYPlot plot = result.getXYPlot();
- plot.getDomainAxis().setAutoRange(true);
- NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
+ final XYPlot plot = result.getXYPlot();
+ plot.getDomainAxis().setAutoRange(true);
+ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRange(true);
rangeAxis.setAutoRangeIncludesZero(true);
return result;
}
-
+
/**
- * This should be used when the time period for updating is variable.
+ * This should be used when the time period for updating is variable.
*
- * To update a chart of this type:
- *
+ * To update a chart of this type:
+ *
* <code>sensorSeries.add(new Minute(new Date()), newData);</code>
*
* @param title
@@ -52,24 +52,23 @@
* @param maxAge
* @param maxCount
* @return
- */
+ */
public static JFreeChart createTimeSeriesChart(String title, String yAxisLabel, int maxAge, int maxCount, int rangeSize) {
-
+
TimeSeriesCollection dataset = new TimeSeriesCollection();
TimeSeries timeSeries = new TimeSeries("Default Dataset");
timeSeries.setMaximumItemAge(maxAge);
timeSeries.setMaximumItemCount(maxCount);
dataset.addSeries(timeSeries);
-
+
final JFreeChart result = ChartFactory.createTimeSeriesChart(title, "hh:mm:ss", yAxisLabel, dataset, true, true, false);
final XYPlot plot = result.getXYPlot();
- plot.getDomainAxis().setAutoRange(true);
+ plot.getDomainAxis().setAutoRange(true);
plot.getDomainAxis().setAutoRangeMinimumSize(rangeSize);
- NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
- rangeAxis.setAutoRange(true);
+ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
+ rangeAxis.setAutoRange(true);
rangeAxis.setAutoRangeIncludesZero(true);
return result;
}
-
-
+
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUpdater.java Mon Nov 10 11:20:53 2014
@@ -13,14 +13,14 @@
DynamicTimeSeriesCollection dataset;
long updateIntervalMillis = 1000;
-
- public StripChartUpdater() {
+
+ public StripChartUpdater() {
}
-
+
public void setChart(JFreeChart chart) {
- this.dataset = (DynamicTimeSeriesCollection)chart.getXYPlot().getDataset();
+ this.dataset = (DynamicTimeSeriesCollection) chart.getXYPlot().getDataset();
}
-
+
public void setUpdateIntervalMillis(long updateIntervalMillis) {
this.updateIntervalMillis = updateIntervalMillis;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUtil.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUtil.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/plotting/StripChartUtil.java Mon Nov 10 11:20:53 2014
@@ -4,14 +4,13 @@
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
-
public final class StripChartUtil {
private StripChartUtil() {
}
-
+
public static TimeSeries getTimeSeries(JFreeChart chart) {
- return (TimeSeries)((TimeSeriesCollection)chart.getXYPlot().getDataset()).getSeries().get(0);
+ return (TimeSeries) ((TimeSeriesCollection) chart.getXYPlot().getDataset()).getSeries().get(0);
}
-
+
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/StatusCode.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/StatusCode.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/StatusCode.java Mon Nov 10 11:20:53 2014
@@ -1,16 +1,8 @@
package org.hps.monitoring.subsys;
/**
- * Code that represents a sub-system status.
+ * Code that represents a sub-system status.
*/
public enum StatusCode {
- OKAY,
- UNKNOWN,
- CLEARED,
- OFFLINE,
- INFO,
- WARNING,
- ERROR,
- ALARM,
- HALT;
+ OKAY, UNKNOWN, CLEARED, OFFLINE, INFO, WARNING, ERROR, ALARM, HALT;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/Subsystem.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/Subsystem.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/Subsystem.java Mon Nov 10 11:20:53 2014
@@ -1,11 +1,8 @@
package org.hps.monitoring.subsys;
-/**
- * Names of valid subsystems that can be monitored.
+/**
+ * Names of valid subsystems that can be monitored.
*/
-public enum Subsystem {
- ET,
- ECAL,
- SVT,
- TRIGGER;
+public enum Subsystem {
+ ET, ECAL, SVT, TRIGGER;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatistics.java Mon Nov 10 11:20:53 2014
@@ -4,8 +4,7 @@
import java.util.TimerTask;
/**
- * This is an interface for a set of basic statistics
- * about an online event processing system.
+ * This is an interface for a set of basic statistics about an online event processing system.
*/
public interface SystemStatistics {
@@ -14,120 +13,118 @@
* @param tickLengthMillis The desired tick length in millis.
*/
void setTickLengthMillis(long tickLengthMillis);
-
+
/**
- * Get the nominal length of one tick in millis.
- * Actual ticks lengths may vary slightly.
+ * Get the nominal length of one tick in millis. Actual ticks lengths may vary slightly.
* @return The nominal tick length in millis.
*/
long getTickLengthMillis();
-
+
/**
- * Start the timer thread for accumulating statistics.
+ * Start the timer thread for accumulating statistics.
*/
void start();
-
+
/**
* Stop the timer thread for accumulating statistics.
*/
void stop();
-
+
/**
- * Update the statistics by incrementing the event count
- * by one and then adding <tt>size</tt> to the number of bytes
- * received.
+ * Update the statistics by incrementing the event count by one and then adding <tt>size</tt> to
+ * the number of bytes received.
* @param size The number of bytes received.
*/
void update(int size);
-
+
/**
* Get the number of millis since the session started.
* @return The number of millis since session start.
*/
long getTimeElapsedMillis();
-
+
/**
- * Get the Unix start time of the session.
+ * Get the Unix start time of the session.
* @return The start time in millis.
*/
long getStartTimeMillis();
-
+
/**
* Get the Unix stop time of the session.
* @return The stop time in millis.
*/
long getStopTimeMillis();
-
+
/**
* Get the number of events in the current tick.
* @return The number of events in the current tick.
*/
long getEventsInTick();
-
+
/**
* Get the total number of events processed thusfar.
* @return The total number of events processed so far.
*/
long getCumulativeEvents();
-
+
/**
- * Get the average number of events per second in the session.
- * It simply divides the number of events by the session time.
+ * Get the average number of events per second in the session. It simply divides the number of
+ * events by the session time.
* @return The average events per second.
*/
- double getAverageEventsPerSecond();
-
+ double getAverageEventsPerSecond();
+
/**
* Get the number of bytes received in the current tick.
* @return The number of bytes received in the tick.
*/
long getBytesInTick();
-
+
/**
* Get the total number of megabytes of data received thusfar.
* @return The amount of data in megabytes received in the session.
*/
double getCumulativeMb();
-
+
/**
- * Get the average Mb per second of the session, which is the
- * total amount of data divided by the total time.
+ * Get the average Mb per second of the session, which is the total amount of data divided by
+ * the total time.
* @return The average megabytes per second.
*/
double getAverageMbPerSecond();
-
+
/**
- * Get the immediate event rate which is the number of events received
- * in the current tick over the time elapsed in the tick.
+ * Get the immediate event rate which is the number of events received in the current tick over
+ * the time elapsed in the tick.
* @return The event rate in [events/second].
*/
double getEventRate();
-
+
/**
- * Get the immediate data rate which is the amount of data in bytes received
- * in the current tick over the tim elapsed in the tick.
+ * Get the immediate data rate which is the amount of data in bytes received in the current tick
+ * over the tim elapsed in the tick.
* @return The data rate in [bytes/second].
*/
public double getDataRateBytes();
-
+
/**
* Get the number of milliseconds since the last tick.
* @return The number of millis elapsed in the current tick.
*/
- long getTickElapsedMillis();
-
+ long getTickElapsedMillis();
+
/**
- * Print session statistics.
+ * Print session statistics.
* @param ps The PrintStream for display.
*/
void printSession(PrintStream ps);
-
- /**
+
+ /**
* Print tick statistics.
* @param ps The PrintStream for display.
*/
- void printTick(PrintStream ps);
-
+ void printTick(PrintStream ps);
+
/**
* Add subtask which will execute right before a new tick.
* @param subtask The subtask to execute.
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatisticsImpl.java Mon Nov 10 11:20:53 2014
@@ -15,43 +15,43 @@
// FIXME: Rolling averages need to happen over a greater time period like 30 seconds
// instead of 1 second, because otherwise the statistics don't look right.
public class SystemStatisticsImpl implements SystemStatistics {
-
+
long tickLengthMillis = 1000; // default is one second tick
long sessionElapsedMillis;
long startTimeMillis;
- long stopTimeMillis;
+ long stopTimeMillis;
long eventsSinceTick;
- long bytesSinceTick;
+ long bytesSinceTick;
long totalEvents;
- long totalBytes;
+ long totalBytes;
long tickStartMillis;
- long tickElapsedMillis;
- static final long Kb = 1 * 1024;
- static final long Mb = Kb * 1024;
- static final double milliToSecond = 0.001;
+ long tickElapsedMillis;
+ static final long Kb = 1 * 1024;
+ static final long Mb = Kb * 1024;
+ static final double milliToSecond = 0.001;
static final DecimalFormat decimalFormat = new DecimalFormat("#.##");
Timer timer;
List<TimerTask> subtasks = new ArrayList<TimerTask>();
-
+
@Override
public void update(int size) {
addEvent();
addData(size);
updateElapsedTime();
}
-
+
@Override
public void setTickLengthMillis(long tickLengthMillis) {
this.tickLengthMillis = tickLengthMillis;
}
-
+
@Override
public long getTickLengthMillis() {
return tickLengthMillis;
}
@Override
- public long getTimeElapsedMillis() {
+ public long getTimeElapsedMillis() {
return sessionElapsedMillis;
}
@@ -59,7 +59,7 @@
public long getStartTimeMillis() {
return this.startTimeMillis;
}
-
+
@Override
public long getStopTimeMillis() {
return this.stopTimeMillis;
@@ -86,7 +86,7 @@
@Override
public double getAverageMbPerSecond() {
- try {
+ try {
return Double.parseDouble(decimalFormat.format(bytesToMb(totalBytes) / millisToSeconds(getTimeElapsedMillis())));
} catch (NumberFormatException e) {
return Double.NaN;
@@ -102,64 +102,64 @@
public long getBytesInTick() {
return bytesSinceTick;
}
-
+
@Override
public long getTickElapsedMillis() {
return tickElapsedMillis;
}
-
+
@Override
public double getEventRate() {
if (eventsSinceTick > 0 && tickElapsedMillis > 0)
- return (double)eventsSinceTick / millisToSeconds(tickElapsedMillis);
+ return (double) eventsSinceTick / millisToSeconds(tickElapsedMillis);
else
return 0.;
}
-
+
@Override
public double getDataRateBytes() {
if (bytesSinceTick > 0 && tickElapsedMillis > 0)
- return (double)bytesSinceTick / millisToSeconds(tickElapsedMillis);
+ return (double) bytesSinceTick / millisToSeconds(tickElapsedMillis);
else
return 0.;
}
-
+
@Override
public void start() {
-
+
// Set time variables.
- long currentTimeMillis = System.currentTimeMillis();
+ long currentTimeMillis = System.currentTimeMillis();
startTimeMillis = currentTimeMillis;
tickStartMillis = currentTimeMillis;
-
+
// Start Timer task which executes at tick length.
- TimerTask task = new TimerTask() {
+ TimerTask task = new TimerTask() {
public void run() {
-
+
// Run sub-tasks.
for (TimerTask subtask : subtasks) {
subtask.run();
}
-
+
nextTick();
}
- };
+ };
timer = new Timer();
timer.schedule(task, 0, tickLengthMillis);
}
@Override
- public void stop() {
+ public void stop() {
// Kill the Timer.
if (timer != null) {
timer.cancel();
timer.purge();
}
-
+
// Set stop time.
stopTimeMillis = System.currentTimeMillis();
- }
-
+ }
+
@Override
public void printSession(PrintStream ps) {
ps.println("session statistics ...");
@@ -167,9 +167,9 @@
ps.println(" cumulativeEvents = " + this.getCumulativeEvents());
ps.println(" averageEventsPerSecond = " + this.getAverageEventsPerSecond());
ps.println(" averageMegaBytesPerSecond = " + this.getAverageMbPerSecond());
-
- }
-
+
+ }
+
@Override
public void printTick(PrintStream ps) {
ps.println("tick statistics ...");
@@ -177,106 +177,106 @@
ps.println(" eventsSinceTick = " + this.getEventsInTick());
ps.println(" bytesSinceTick = " + this.getBytesInTick());
}
-
+
@Override
public void addSubTask(TimerTask subtask) {
this.subtasks.add(subtask);
}
-
+
void addEvent() {
eventsSinceTick += 1;
totalEvents += 1;
}
-
+
void addData(int size) {
bytesSinceTick += size;
totalBytes += size;
}
-
+
void updateElapsedTime() {
tickElapsedMillis = System.currentTimeMillis() - tickStartMillis;
sessionElapsedMillis = System.currentTimeMillis() - startTimeMillis;
}
-
+
// Bytes to megabytes to 2 decimal places.
static final double bytesToMb(long size) {
- return Double.parseDouble(decimalFormat.format((double)size / Mb));
- }
-
+ return Double.parseDouble(decimalFormat.format((double) size / Mb));
+ }
+
static final double millisToSeconds(long millis) {
- return ((double)millis) / 1000.;
- }
-
+ return ((double) millis) / 1000.;
+ }
+
synchronized void nextTick() {
eventsSinceTick = 0;
bytesSinceTick = 0;
tickElapsedMillis = 0;
tickStartMillis = System.currentTimeMillis();
- }
-
+ }
+
public abstract class SystemStatisticsUpdater extends StripChartUpdater {
SystemStatisticsUpdater() {
addSubTask(this);
}
}
-
+
public class AverageEventRateUpdater extends SystemStatisticsUpdater {
@Override
public float nextValue() {
- return (float)getAverageEventsPerSecond();
- }
- }
-
+ return (float) getAverageEventsPerSecond();
+ }
+ }
+
public class EventsInTickUpdater extends SystemStatisticsUpdater {
-
- @Override
- public float nextValue() {
- return getEventsInTick();
- }
- }
-
+
+ @Override
+ public float nextValue() {
+ return getEventsInTick();
+ }
+ }
+
public class CumulativeEventsUpdater extends SystemStatisticsUpdater {
@Override
public float nextValue() {
return getCumulativeEvents();
}
}
-
+
public class BytesInTickUpdater extends SystemStatisticsUpdater {
@Override
public float nextValue() {
return getBytesInTick();
}
}
-
+
public class AverageMbUpdater extends SystemStatisticsUpdater {
@Override
public float nextValue() {
- return (float)getAverageMbPerSecond();
- }
- }
-
+ return (float) getAverageMbPerSecond();
+ }
+ }
+
public class CumulativeMbUpdater extends SystemStatisticsUpdater {
@Override
public float nextValue() {
- return (float)getCumulativeMb();
- }
- }
-
+ return (float) getCumulativeMb();
+ }
+ }
+
public class EventRateUpdater extends SystemStatisticsUpdater {
-
- @Override
- public float nextValue() {
- return (float)getEventRate();
- }
- }
-
+
+ @Override
+ public float nextValue() {
+ return (float) getEventRate();
+ }
+ }
+
public class DataRateUpdater extends SystemStatisticsUpdater {
-
- @Override
- public float nextValue() {
- return (float)getDataRateBytes();
- }
+
+ @Override
+ public float nextValue() {
+ return (float) getDataRateBytes();
+ }
}
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatus.java Mon Nov 10 11:20:53 2014
@@ -1,78 +1,74 @@
package org.hps.monitoring.subsys;
-
/**
- * The <tt>SystemStatus</tt> describes the state of a system, e.g. whether it is okay
- * or some level of error has occurred. Listeners can be registered on these objects,
- * which will be notified whenever the status changes, in order to update a GUI component,
- * trip an alarm, etc.
+ * The <tt>SystemStatus</tt> describes the state of a system, e.g. whether it is okay or some level
+ * of error has occurred. Listeners can be registered on these objects, which will be notified
+ * whenever the status changes, in order to update a GUI component, trip an alarm, etc.
*
- * There is one <tt>SystemStatus</tt> object for each quantity to be monitored
- * on a sub-system. New objects are not created when the status changes. Instead,
- * the <tt>StatusCode</tt> is changed with a custom message describing the new state.
- * Listeners are updated whenever the status is changed. It is up to the notified
- * object to determine what to do when the state changes.
+ * There is one <tt>SystemStatus</tt> object for each quantity to be monitored on a sub-system. New
+ * objects are not created when the status changes. Instead, the <tt>StatusCode</tt> is changed with
+ * a custom message describing the new state. Listeners are updated whenever the status is changed.
+ * It is up to the notified object to determine what to do when the state changes.
*/
public interface SystemStatus {
-
+
/**
* Get the sub-system e.g. "SVT".
* @return The assigned sub-system.
*/
Subsystem getSubsystem();
-
+
/**
* Get the current status code.
* @return The current status code.
*/
StatusCode getStatusCode();
-
+
/**
- * Get the description of the system status.
- * This is used to differentiate multiple monitoring points
- * on the same sub-system so it could be something like "SVT occupancy rates".
+ * Get the description of the system status. This is used to differentiate multiple monitoring
+ * points on the same sub-system so it could be something like "SVT occupancy rates".
* @return The description of the system status.
*/
String getDescription();
-
+
/**
* Get the current message.
* @return The current message
*/
String getMessage();
-
+
/**
- * Set the current status code and message, which will cause the last changed
- * time to be set and the listeners to be notified of the status change.
+ * Set the current status code and message, which will cause the last changed time to be set and
+ * the listeners to be notified of the status change.
* @param code The new status code.
*/
void setStatus(StatusCode code, String message);
-
+
/**
* Get the time when the system status last changed.
* @return The time when the system status changed.
*/
long getLastChangedMillis();
-
+
/**
* Add a listener to receive notification when the status changes.
* @param listener The listener object.
*/
void addListener(SystemStatusListener listener);
-
+
/**
- * Set whether this status is active. Inactive statuses will not be
- * updated in the GUI. This can be changed "on the fly" in the system status panel.
- * Listeners will NOT be notified of state changes when active is <code>False</code>.
+ * Set whether this status is active. Inactive statuses will not be updated in the GUI. This can
+ * be changed "on the fly" in the system status panel. Listeners will NOT be notified of state
+ * changes when active is <code>False</code>.
*/
void setActive(boolean active);
-
+
/**
* True if the status is active.
* @return True if status is active.
*/
boolean isActive();
-
+
/**
* True if the status can be cleared.
* @return True if status can be cleared.
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusImpl.java Mon Nov 10 11:20:53 2014
@@ -16,7 +16,7 @@
final String description;
boolean active = true;
final boolean clearable;
-
+
/**
* Fully qualified constructor.
* @param systemName The enum specifiying the system being monitored.
@@ -30,17 +30,17 @@
setLastChangedTime();
SystemStatusRegistry.getSystemStatusRegistery().register(this);
}
-
+
@Override
public Subsystem getSubsystem() {
return systemName;
}
-
+
@Override
public String getDescription() {
return description;
}
-
+
@Override
public String getMessage() {
return message;
@@ -65,7 +65,7 @@
public void addListener(SystemStatusListener listener) {
this.listeners.add(listener);
}
-
+
@Override
public long getLastChangedMillis() {
return lastChangedMillis;
@@ -79,22 +79,22 @@
listener.statusChanged(this);
}
}
-
+
private void setLastChangedTime() {
this.lastChangedMillis = System.currentTimeMillis();
}
-
+
@Override
public void setActive(boolean masked) {
this.active = masked;
}
-
+
@Override
public boolean isActive() {
return active;
}
-
- @Override
+
+ @Override
public boolean isClearable() {
return clearable;
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusListener.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusListener.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusListener.java Mon Nov 10 11:20:53 2014
@@ -1,15 +1,13 @@
package org.hps.monitoring.subsys;
/**
- * Interface for receiving changes to {@link SystemStatus} objects,
- * e.g. when a new status is set.
+ * Interface for receiving changes to {@link SystemStatus} objects, e.g. when a new status is set.
*/
public interface SystemStatusListener {
-
+
/**
- * Receive a change to the system status.
- * The implementation of this method should absolutely not
- * attempt to change the status!
+ * Receive a change to the system status. The implementation of this method should absolutely
+ * not attempt to change the status!
* @param status The system status.
*/
void statusChanged(SystemStatus status);
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/SystemStatusRegistry.java Mon Nov 10 11:20:53 2014
@@ -8,28 +8,28 @@
* Global registry of all {@link SystemStatus} objects.
*/
public final class SystemStatusRegistry {
-
+
static SystemStatusRegistry instance = new SystemStatusRegistry();
List<SystemStatus> systemStatuses = new ArrayList<SystemStatus>();
-
+
private SystemStatusRegistry() {
}
-
+
public static SystemStatusRegistry getSystemStatusRegistery() {
return instance;
}
-
+
void register(SystemStatus systemStatus) {
if (!systemStatuses.contains(systemStatus))
systemStatuses.add(systemStatus);
else
throw new IllegalArgumentException("The system status is already registered.");
- }
-
+ }
+
public List<SystemStatus> getSystemStatuses() {
return Collections.unmodifiableList(systemStatuses);
}
-
+
public void clear() {
systemStatuses.clear();
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal/EcalStripChartTestDriver.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal/EcalStripChartTestDriver.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/ecal/EcalStripChartTestDriver.java Mon Nov 10 11:20:53 2014
@@ -17,38 +17,37 @@
* Example Driver for plotting a sub-system's data using a strip chart.
*/
public class EcalStripChartTestDriver extends Driver {
-
+
int eventInterval = 1000;
static String collectionName = "EcalReadoutHits";
-
- MonitoringPlotFactory plotFactory = (MonitoringPlotFactory)
- AIDA.defaultInstance().analysisFactory().createPlotterFactory("ECAL System Monitoring");
+
+ MonitoringPlotFactory plotFactory = (MonitoringPlotFactory) AIDA.defaultInstance().analysisFactory().createPlotterFactory("ECAL System Monitoring");
TimeSeries series;
JFreeChart stripChart;
TimerTask updateTask;
EventHeader currentEvent;
int hits;
int events;
-
- public void startOfData() {
- stripChart = plotFactory.createStripChart(
- "Average ECAL Hits per " + eventInterval + " Events",
- "Hits",
- 99999999, /* max age */
+
+ public void startOfData() {
+ stripChart = plotFactory.createStripChart("Average ECAL Hits per " + eventInterval + " Events", "Hits", 99999999, /*
+ * max
+ * age
+ */
1000, /* max count */
100000 /* range size */);
- series = StripChartUtil.getTimeSeries(stripChart);
+ series = StripChartUtil.getTimeSeries(stripChart);
}
-
+
public void process(EventHeader event) {
int size = event.get(RawCalorimeterHit.class, collectionName).size();
++events;
hits += size;
if (event.getEventNumber() % eventInterval == 0) {
- double averageHits = (double)hits / (double)events;
+ double averageHits = (double) hits / (double) events;
series.add(new Millisecond(new Date()), averageHits);
hits = 0;
events = 0;
- }
+ }
}
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java Mon Nov 10 11:20:53 2014
@@ -16,24 +16,25 @@
public final class EtSystemMonitor extends EtEventProcessor {
SystemStatus systemStatus;
- int events = 0;
+ int events = 0;
long eventReceivedMillis = 0;
long warningIntervalMillis = 1000; /* default of 1 second */
Timer timer = new Timer("ET Event Monitor");
-
+
public EtSystemMonitor() {
systemStatus = new SystemStatusImpl(Subsystem.ET, "ET System Monitor", false);
systemStatus.setStatus(StatusCode.UNKNOWN, "System is not active yet.");
}
-
+
public void setWarningIntervalMillis(long warningIntervalMillis) {
this.warningIntervalMillis = warningIntervalMillis;
}
-
+
public void startJob() {
systemStatus.setStatus(StatusCode.OKAY, "ET job started.");
- TimerTask task = new TimerTask() {
+ TimerTask task = new TimerTask() {
long startedMillis = 0;
+
public void run() {
if (startedMillis == 0)
startedMillis = System.currentTimeMillis();
@@ -41,24 +42,24 @@
if (eventReceivedMillis == 0)
elapsedMillis = System.currentTimeMillis() - startedMillis;
else
- elapsedMillis = System.currentTimeMillis() - eventReceivedMillis;
- if (elapsedMillis > warningIntervalMillis)
+ elapsedMillis = System.currentTimeMillis() - eventReceivedMillis;
+ if (elapsedMillis > warningIntervalMillis)
systemStatus.setStatus(StatusCode.WARNING, "No ET events received for " + elapsedMillis + " millis.");
else
systemStatus.setStatus(StatusCode.OKAY, "ET events received.");
- }
+ }
};
-
+
timer.schedule(task, 0, 1000);
}
-
+
public void process(EtEvent event) {
eventReceivedMillis = System.currentTimeMillis();
}
-
+
public void endJob() {
timer.cancel();
timer.purge();
systemStatus.setStatus(StatusCode.OFFLINE, "ET job ended.");
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/et/EtSystemStripCharts.java Mon Nov 10 11:20:53 2014
@@ -9,76 +9,43 @@
/**
* A basic set of strip charts for monitoring the ET system.
*/
-public final class EtSystemStripCharts extends EtEventProcessor {
-
- SystemStatisticsImpl stats = new SystemStatisticsImpl();
- MonitoringPlotFactory plotFactory = (MonitoringPlotFactory)
- AIDA.defaultInstance().analysisFactory().createPlotterFactory("ET System Monitoring");
-
+public final class EtSystemStripCharts extends EtEventProcessor {
+
+ SystemStatisticsImpl stats = new SystemStatisticsImpl();
+ MonitoringPlotFactory plotFactory = (MonitoringPlotFactory) AIDA.defaultInstance().analysisFactory().createPlotterFactory("ET System Monitoring");
+
/**
* Setup the strip charts for ET system monitoring and start accumulating statistics.
*/
@Override
public void startJob() {
- plotFactory.createStripChart(
- "Event Rate",
- "Event Count",
- 100,
- stats.new EventRateUpdater());
-
- plotFactory.createStripChart(
- "Average Event Rate",
- "Event Count",
- 100,
- stats.new AverageEventRateUpdater());
-
- plotFactory.createStripChart(
- "Events in Tick",
- "Event Count",
- 100,
- stats.new EventsInTickUpdater());
+ plotFactory.createStripChart("Event Rate", "Event Count", 100, stats.new EventRateUpdater());
- plotFactory.createStripChart(
- "Cumulative Events",
- "Event Count",
- 100,
- stats.new CumulativeEventsUpdater());
-
- plotFactory.createStripChart(
- "Data Rate",
- "Bytes",
- 100,
- stats.new DataRateUpdater());
-
- plotFactory.createStripChart(
- "Bytes in Tick",
- "Bytes",
- 100,
- stats.new BytesInTickUpdater());
-
- plotFactory.createStripChart(
- "Average Megabytes",
- "Megabytes",
- 100,
- stats.new AverageMbUpdater());
-
- plotFactory.createStripChart(
- "Cumulative Megabytes",
- "Megabytes",
- 100,
- stats.new CumulativeMbUpdater());
-
- stats.start();
+ plotFactory.createStripChart("Average Event Rate", "Event Count", 100, stats.new AverageEventRateUpdater());
+
+ plotFactory.createStripChart("Events in Tick", "Event Count", 100, stats.new EventsInTickUpdater());
+
+ plotFactory.createStripChart("Cumulative Events", "Event Count", 100, stats.new CumulativeEventsUpdater());
+
+ plotFactory.createStripChart("Data Rate", "Bytes", 100, stats.new DataRateUpdater());
+
+ plotFactory.createStripChart("Bytes in Tick", "Bytes", 100, stats.new BytesInTickUpdater());
+
+ plotFactory.createStripChart("Average Megabytes", "Megabytes", 100, stats.new AverageMbUpdater());
+
+ plotFactory.createStripChart("Cumulative Megabytes", "Megabytes", 100, stats.new CumulativeMbUpdater());
+
+ stats.start();
}
-
+
@Override
public void process(EtEvent event) {
stats.update(event.getLength());
- }
-
+ }
+
@Override
public void endJob() {
stats.stop();
- }
+ }
}
Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java
=============================================================================
--- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java (original)
+++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/subsys/svt/BasicHitMonitoringDriver.java Mon Nov 10 11:20:53 2014
@@ -12,9 +12,9 @@
import org.lcsim.util.Driver;
/**
- * This is a basic example of monitoring hits using an updateable <code>SystemStatus</code>.
- * It checks from a <code>TimerTask</code> once per second whether <code>RawTrackerHit</code>
- * objects are being received by the {@link #process(EventHeader)} method.
+ * This is a basic example of monitoring hits using an updateable <code>SystemStatus</code>. It
+ * checks from a <code>TimerTask</code> once per second whether <code>RawTrackerHit</code> objects
+ * are being received by the {@link #process(EventHeader)} method.
*/
public class BasicHitMonitoringDriver extends Driver {
@@ -23,16 +23,16 @@
long warningIntervalMillis = 1000;
Timer timer;
static final String hitsCollectionName = "SVTRawTrackerHits";
-
+
public BasicHitMonitoringDriver() {
status = new SystemStatusImpl(Subsystem.SVT, "Checks that SVT hits are received.", true);
status.setStatus(StatusCode.UNKNOWN, "Status is unknown.");
}
-
+
public void setWarningIntervalMillis(long warningIntervalMillis) {
this.warningIntervalMillis = warningIntervalMillis;
}
-
+
public void startOfData() {
if (hitsCollectionName == null)
throw new RuntimeException("The hitsCollectionName was never set.");
@@ -40,6 +40,7 @@
timer = new Timer("SVT Hit Monitor");
TimerTask task = new TimerTask() {
long startedMillis = 0;
+
public void run() {
if (startedMillis == 0)
startedMillis = System.currentTimeMillis();
@@ -57,17 +58,17 @@
// Task will run once per second.
timer.schedule(task, 0, 1000);
}
-
+
public void process(EventHeader event) {
if (event.hasCollection(RawTrackerHit.class, hitsCollectionName))
if (event.get(RawTrackerHit.class, hitsCollectionName).size() > 0)
hitsReceivedMillis = System.currentTimeMillis();
- }
-
+ }
+
public void endOfData() {
timer.cancel();
timer.purge();
status.setStatus(StatusCode.OFFLINE, "SVT hit monitor went offline.");
status.setActive(false);
- }
+ }
}
|