Author: [log in to unmask] Date: Mon Apr 13 10:40:21 2015 New Revision: 2678 Log: Cleanup in monitoring-app module. Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/Commands.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotInfoPanel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsDialog.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsPanel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusEventsTable.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusTable.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/ToolbarPanel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/TriggerDiagnosticsPanel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/AbstractModel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/Configuration.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConfigurationModel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConnectionStatusModel.java java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/HasConfigurationModel.java Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/Commands.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/Commands.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/Commands.java Mon Apr 13 10:40:21 2015 @@ -154,6 +154,11 @@ static final String PAUSE = "pause"; /** + * Action when plot is selected from a tab. + */ + static final String PLOT_SELECTED = "PlotSelected"; + + /** * Processing stage changed. */ static final String PROCESSING_STAGE_CHANGED = "processingStageChanged"; @@ -197,6 +202,11 @@ * Set the steering resource. */ static final String SET_STEERING_RESOURCE = "setSteeringResource"; + + /** + * Okay button in settings panel. + */ + static final String SETTINGS_OKAY_COMMAND = "settingsOkay"; /** * Show the settings dialog. Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java Mon Apr 13 10:40:21 2015 @@ -107,11 +107,11 @@ public MonitoringApplicationFrame(final MonitoringApplication application) { // Disable interaction until specifically enabled externally after initialization. - setEnabled(false); + this.setEnabled(false); // Create the content panel. final JPanel contentPanel = new JPanel(); - setContentPane(contentPanel); + this.setContentPane(contentPanel); contentPanel.setLayout(new BorderLayout()); contentPanel.setOpaque(true); contentPanel.setPreferredSize(new Dimension(PIXEL_WIDTH_MAX, PIXEL_HEIGHT_MAX)); @@ -167,7 +167,7 @@ // Create the plot panel. this.plotPanel = new PlotPanel(); - this.plotInfoPanel.saveButton.addActionListener(this.plotPanel); + this.plotInfoPanel.addActionListener(this.plotPanel); // Create the right panel vertical split pane for displaying plots and their information and statistics. this.rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.plotPanel, this.plotInfoPanel); @@ -181,16 +181,16 @@ // Create the menu bar. this.menu = new MenuBar(application.getConfigurationModel(), application.getConnectionModel(), application); - setJMenuBar(this.menu); + this.setJMenuBar(this.menu); this.toolbarPanel.getDataSourceComboBox().addActionListener(this.menu); // Setup the settings dialog box (invisible until activated). this.settingsDialog = new SettingsDialog(application.getConfigurationModel(), application); // Setup the frame now that all components have been added. - pack(); - setExtendedState(Frame.MAXIMIZED_BOTH); - setVisible(true); + this.pack(); + this.setExtendedState(Frame.MAXIMIZED_BOTH); + this.setVisible(true); } /** @@ -287,7 +287,7 @@ * Restore default window settings. */ void restoreDefaults() { - setExtendedState(Frame.MAXIMIZED_BOTH); + this.setExtendedState(Frame.MAXIMIZED_BOTH); this.mainSplitPane.resetToPreferredSizes(); this.leftSplitPane.resetToPreferredSizes(); this.rightSplitPane.resetToPreferredSizes(); Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotInfoPanel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotInfoPanel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotInfoPanel.java Mon Apr 13 10:40:21 2015 @@ -45,31 +45,71 @@ * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -final class PlotInfoPanel extends JPanel implements AIDAListener, ActionListener, FunctionListener { - - static final String[] COLUMN_NAMES = { "Field", "Value" }; - static final int MAX_ROWS = 13; - static final int MIN_HEIGHT = 300; - static final int MIN_WIDTH = 400; - - static final String PLOT_SELECTED = "PlotSelected"; - Object currentObject; - - PlotterRegion currentRegion; - JTable infoTable = new JTable(); - DefaultTableModel model; - JComboBox<Object> plotComboBox; - JButton saveButton; - - Timer timer = new Timer(); +@SuppressWarnings("serial") +final class PlotInfoPanel extends JPanel implements AIDAListener, ActionListener, FunctionListener, AddActionListener { + + /** + * The names of the two columns. + */ + private static final String[] COLUMN_NAMES = {"Field", "Value"}; + + /** + * The maximum number of rows in the table. + */ + private static final int MAX_ROWS = 13; + + /** + * Minimum height of panel in pixels. + */ + private static final int MIN_HEIGHT = 300; + + /** + * Minimum width of panel in pixels. + */ + private static final int MIN_WIDTH = 400; + + /** + * The currently selected AIDA object. + */ + private Object currentObject; + + /** + * The currently selected plotter region. + */ + private PlotterRegion currentRegion; + + /** + * The table showing plot statistics. + */ + private final JTable infoTable = new JTable(); + + /** + * The default table model. + */ + private DefaultTableModel model; + + /** + * The combo box for selecting the object from the region. + */ + private JComboBox<Object> plotComboBox; + + /** + * The button for saving plot graphics.. + */ + private JButton saveButton; + + /** + * The timer for updating the table. + */ + private final Timer timer = new Timer(); /** * Class constructor, which will setup the GUI components. */ - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked"}) PlotInfoPanel() { - setLayout(new FlowLayout(FlowLayout.CENTER)); + this.setLayout(new FlowLayout(FlowLayout.CENTER)); final JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); @@ -90,11 +130,11 @@ @Override public Dimension getMaximumSize() { final Dimension max = super.getMaximumSize(); - max.height = getPreferredSize().height; + max.height = this.getPreferredSize().height; return max; } }; - this.plotComboBox.setActionCommand(PLOT_SELECTED); + this.plotComboBox.setActionCommand(Commands.PLOT_SELECTED); this.plotComboBox.setAlignmentX(CENTER_ALIGNMENT); this.plotComboBox.setRenderer(new BasicComboBoxRenderer() { @Override @@ -103,10 +143,10 @@ final boolean isSelected, final boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { - final String title = getObjectTitle(value); - setText(value.getClass().getSimpleName() + " - " + title); + final String title = PlotInfoPanel.this.getObjectTitle(value); + this.setText(value.getClass().getSimpleName() + " - " + title); } else { - setText("Click on a plot region ..."); + this.setText("Click on a plot region ..."); } return this; } @@ -117,7 +157,7 @@ leftPanel.add(new Box.Filler(filler, filler, filler)); // Table with plot info. - final String data[][] = new String[0][0]; + final String[][] data = new String[0][0]; this.model = new DefaultTableModel(data, COLUMN_NAMES); this.model.setColumnIdentifiers(COLUMN_NAMES); this.infoTable.setModel(this.model); @@ -125,27 +165,39 @@ this.infoTable.setAlignmentX(CENTER_ALIGNMENT); leftPanel.add(this.infoTable); - add(leftPanel); + this.add(leftPanel); } /** * Implementation of <code>actionPerformed</code> to handle the selection of a new object from the combo box. + * + * @param e the {@link java.awt.event.ActionEvent} to handle */ @Override public void actionPerformed(final ActionEvent e) { // Is there a new item selected in the combo box? - if (PLOT_SELECTED.equals(e.getActionCommand())) { + if (Commands.PLOT_SELECTED.equals(e.getActionCommand())) { if (this.plotComboBox.getSelectedItem() != null) { // Set the current object from the combo box value, to update the GUI state. - setCurrentObject(this.plotComboBox.getSelectedItem()); - } - } + this.setCurrentObject(this.plotComboBox.getSelectedItem()); + } + } + } + + /** + * Assign an action listener to certain components. + * + * @param listener the action listener to add + */ + @Override + public void addActionListener(final ActionListener listener) { + this.saveButton.addActionListener(listener); } /** * Add this object as an <code>AIDAListener</code> on the current <code>AIDAObservable</code>. */ - void addListener() { + private void addListener() { if (this.currentObject instanceof AIDAObservable && !(this.currentObject instanceof FunctionDispatcher)) { // Setup a listener on the current AIDA object. final AIDAObservable observable = (AIDAObservable) this.currentObject; @@ -162,94 +214,94 @@ /** * Add a row to the info table. * - * @param field The field name. - * @param value The field value. - */ - void addRow(final String field, final Object value) { - this.model.insertRow(this.infoTable.getRowCount(), new Object[] { field, value }); + * @param field the field name + * @param value the field value + */ + private void addRow(final String field, final Object value) { + this.model.insertRow(this.infoTable.getRowCount(), new Object[] {field, value}); } /** * Add rows to the info table from the state of a 2D cloud. * - * @param cloud The AIDA object. - */ - void addRows(final 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 upper edge", cloud.upperEdgeY()); - addRow("x mean", String.format("%.10f%n", cloud.meanX())); - addRow("y mean", String.format("%.10f%n", cloud.meanY())); - addRow("x rms", String.format("%.10f%n", cloud.rmsX())); - addRow("y rms", String.format("%.10f%n", cloud.rmsY())); - } - - /** - * Add rows to the info table from the state of a 2D cloud. - * - * @param cloud The AIDA object. - */ - void addRows(final IFunction function) { - addRow("title", function.title()); + * @param cloud the AIDA object + */ + private void addRows(final ICloud2D cloud) { + this.addRow("title", cloud.title()); + this.addRow("entries", cloud.entries()); + this.addRow("max entries", cloud.maxEntries()); + this.addRow("x lower edge", cloud.lowerEdgeX()); + this.addRow("x upper edge", cloud.upperEdgeX()); + this.addRow("y lower edge", cloud.lowerEdgeY()); + this.addRow("y upper edge", cloud.upperEdgeY()); + this.addRow("x mean", String.format("%.10f%n", cloud.meanX())); + this.addRow("y mean", String.format("%.10f%n", cloud.meanY())); + this.addRow("x rms", String.format("%.10f%n", cloud.rmsX())); + this.addRow("y rms", String.format("%.10f%n", cloud.rmsY())); + } + + /** + * Add rows to the info table from the state of a function. + * + * @param function the AIDA function object + */ + private void addRows(final IFunction function) { + this.addRow("title", function.title()); // Add generically the values of all function parameters. for (final String parameter : function.parameterNames()) { - addRow(parameter, function.parameter(parameter)); + this.addRow(parameter, function.parameter(parameter)); } } /** * Add rows to the info table from the state of a 1D histogram. * - * @param histogram The AIDA object. - */ - void addRows(final IHistogram1D histogram) { - addRow("title", histogram.title()); - addRow("bins", histogram.axis().bins()); - addRow("entries", histogram.entries()); - addRow("mean", String.format("%.10f%n", histogram.mean())); - addRow("rms", String.format("%.10f%n", histogram.rms())); - addRow("sum bin heights", histogram.sumBinHeights()); - addRow("max bin height", histogram.maxBinHeight()); - addRow("overflow entries", histogram.binEntries(IAxis.OVERFLOW_BIN)); - addRow("underflow entries", histogram.binEntries(IAxis.UNDERFLOW_BIN)); + * @param histogram the AIDA object + */ + private void addRows(final IHistogram1D histogram) { + this.addRow("title", histogram.title()); + this.addRow("bins", histogram.axis().bins()); + this.addRow("entries", histogram.entries()); + this.addRow("mean", String.format("%.10f%n", histogram.mean())); + this.addRow("rms", String.format("%.10f%n", histogram.rms())); + this.addRow("sum bin heights", histogram.sumBinHeights()); + this.addRow("max bin height", histogram.maxBinHeight()); + this.addRow("overflow entries", histogram.binEntries(IAxis.OVERFLOW_BIN)); + this.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. - */ - void addRows(final IHistogram2D histogram) { - addRow("title", histogram.title()); - addRow("x bins", histogram.xAxis().bins()); - addRow("y bins", histogram.yAxis().bins()); - addRow("entries", histogram.entries()); - addRow("x mean", String.format("%.10f%n", histogram.meanX())); - addRow("y mean", String.format("%.10f%n", histogram.meanY())); - addRow("x rms", String.format("%.10f%n", histogram.rmsX())); - addRow("y rms", String.format("%.10f%n", histogram.rmsY())); - addRow("sum bin heights", histogram.sumBinHeights()); - addRow("max bin height", histogram.maxBinHeight()); - addRow("x overflow entries", histogram.binEntriesX(IAxis.OVERFLOW_BIN)); - addRow("y overflow entries", histogram.binEntriesY(IAxis.OVERFLOW_BIN)); - addRow("x underflow entries", histogram.binEntriesX(IAxis.UNDERFLOW_BIN)); - addRow("y underflow entries", histogram.binEntriesY(IAxis.UNDERFLOW_BIN)); + * @param histogram the AIDA object + */ + private void addRows(final IHistogram2D histogram) { + this.addRow("title", histogram.title()); + this.addRow("x bins", histogram.xAxis().bins()); + this.addRow("y bins", histogram.yAxis().bins()); + this.addRow("entries", histogram.entries()); + this.addRow("x mean", String.format("%.10f%n", histogram.meanX())); + this.addRow("y mean", String.format("%.10f%n", histogram.meanY())); + this.addRow("x rms", String.format("%.10f%n", histogram.rmsX())); + this.addRow("y rms", String.format("%.10f%n", histogram.rmsY())); + this.addRow("sum bin heights", histogram.sumBinHeights()); + this.addRow("max bin height", histogram.maxBinHeight()); + this.addRow("x overflow entries", histogram.binEntriesX(IAxis.OVERFLOW_BIN)); + this.addRow("y overflow entries", histogram.binEntriesY(IAxis.OVERFLOW_BIN)); + this.addRow("x underflow entries", histogram.binEntriesX(IAxis.UNDERFLOW_BIN)); + this.addRow("y underflow entries", histogram.binEntriesY(IAxis.UNDERFLOW_BIN)); } /** * Callback for updating from changed to <code>IFunction</code> object. * - * @param event The change event (unused in this method). + * @param event the change event (unused in this method) */ @Override public void functionChanged(final FunctionChangedEvent event) { try { - runUpdateTable(); + this.runUpdateTable(); } catch (final Exception e) { e.printStackTrace(); } @@ -259,10 +311,11 @@ * Get the title of an AIDA object. Unfortunately there is no base type with this information, so it is read * manually from each possible type. * - * @param object The AIDA object. - * @return The title of the object from its title method or value of its toString method, if none exists. - */ - String getObjectTitle(final Object object) { + * @param object the AIDA object + * @return the title of the object from its title method or value of its <code>toString</code> method, if none + * exists + */ + private String getObjectTitle(final Object object) { if (object instanceof IBaseHistogram) { return ((IBaseHistogram) object).title(); } else if (object instanceof IDataPointSet) { @@ -274,7 +327,13 @@ } } - boolean isValidObject(final Object object) { + /** + * Return <code>true</code> if the object is a valid AIDA object. + * + * @param object the object + * @return <code>true</code> if object is a valid AIDA object + */ + private boolean isValidObject(final Object object) { if (object == null) { return false; } @@ -287,7 +346,7 @@ /** * Remove this as a listener on the current AIDA object. */ - void removeListener() { + private void removeListener() { if (this.currentObject != null) { if (this.currentObject instanceof AIDAObservable && !(this.currentObject instanceof IFunction)) { // Remove this object as an listener on the AIDA observable. @@ -302,21 +361,21 @@ /** * Run the {@link #updateTable()} method on the Swing EDT. */ - void runUpdateTable() { + private void runUpdateTable() { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - updateTable(); + PlotInfoPanel.this.updateTable(); } }); } /** - * Set the current AIDA object that backs this GUI, i.e. an IHistogram1D etc. - * - * @param object The backing AIDA object. - */ - synchronized void setCurrentObject(final Object object) { + * Set the current AIDA object that backs this GUI, i.e. an IHistogram1D or other plot object etc. + * + * @param object the backing AIDA object + */ + private synchronized void setCurrentObject(final Object object) { if (object == null) { throw new IllegalArgumentException("The object arg is null!"); @@ -327,7 +386,7 @@ } // Remove the AIDAListener from the previous object. - removeListener(); + this.removeListener(); // Set the current object reference. this.currentObject = object; @@ -335,10 +394,10 @@ // 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 // of the table GUI component when resizing the content pane. - updateTable(); + this.updateTable(); // Add an AIDAListener to the AIDA object via the AIDAObservable API. - addListener(); + this.addListener(); } /** @@ -349,26 +408,26 @@ synchronized void setCurrentRegion(final PlotterRegion region) { if (region != this.currentRegion) { this.currentRegion = region; - updateComboBox(); - setCurrentObject(this.plotComboBox.getSelectedItem()); - setupContentPane(); + this.updateComboBox(); + this.setCurrentObject(this.plotComboBox.getSelectedItem()); + this.setupContentPane(); } } /** * Configure the frame's content panel from current component settings. */ - void setupContentPane() { + private void setupContentPane() { this.plotComboBox.setSize(this.plotComboBox.getPreferredSize()); this.infoTable.setSize(this.infoTable.getPreferredSize()); - setVisible(true); + this.setVisible(true); } /** * 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. + * @param evt the EventObject pointing to the backing AIDA object */ @Override public void stateChanged(final EventObject evt) { @@ -385,7 +444,7 @@ } // Update the table values on the Swing EDT. - runUpdateTable(); + PlotInfoPanel.this.runUpdateTable(); // Set the observable to valid so subsequent state changes are received. ((AIDAObservable) PlotInfoPanel.this.currentObject).setValid(PlotInfoPanel.this); @@ -402,11 +461,11 @@ /** * Update the combo box contents with the plots from the current region. */ - void updateComboBox() { + private void updateComboBox() { this.plotComboBox.removeAllItems(); final List<Object> objects = this.currentRegion.getPlottedObjects(); for (final Object object : objects) { - if (isValidObject(object)) { + if (this.isValidObject(object)) { this.plotComboBox.addItem(object); } } @@ -415,20 +474,20 @@ /** * Update the info table from the state of the current AIDA object. */ - void updateTable() { + private void updateTable() { this.model.setRowCount(0); if (this.currentObject instanceof IHistogram1D) { - addRows((IHistogram1D) this.currentObject); + this.addRows((IHistogram1D) this.currentObject); } else if (this.currentObject instanceof IHistogram2D) { - addRows((IHistogram2D) this.currentObject); + this.addRows((IHistogram2D) this.currentObject); } else if (this.currentObject instanceof ICloud2D) { - addRows((ICloud2D) this.currentObject); + this.addRows((ICloud2D) this.currentObject); } else if (this.currentObject instanceof ICloud1D) { if (((ICloud1D) this.currentObject).isConverted()) { - addRows(((ICloud1D) this.currentObject).histogram()); + this.addRows(((ICloud1D) this.currentObject).histogram()); } } else if (this.currentObject instanceof IFunction) { - addRows((IFunction) this.currentObject); - } - } -} + this.addRows((IFunction) this.currentObject); + } + } +} Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java Mon Apr 13 10:40:21 2015 @@ -25,34 +25,56 @@ * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ +@SuppressWarnings("serial") final class PlotPanel extends JPanel implements ActionListener { + /** + * The tabs containing the plots. + */ private final JTabbedPane plotPane; + /** + * Class constructor. + */ public PlotPanel() { - setLayout(new BorderLayout()); + this.setLayout(new BorderLayout()); this.plotPane = new JTabbedPane(); - this.plotPane.setPreferredSize(getPreferredSize()); - add(this.plotPane, BorderLayout.CENTER); + this.plotPane.setPreferredSize(this.getPreferredSize()); + this.add(this.plotPane, BorderLayout.CENTER); } + /** + * Handle an {@link java.awt.event.ActionEvent}. + * + * @param event the {@link java.awt.event.ActionEvent} to handle + */ @Override public void actionPerformed(final ActionEvent event) { if (event.getActionCommand().equals(Commands.SAVE_SELECTED_PLOTS)) { - final int[] indices = getSelectedTabIndices(); + final int[] indices = this.getSelectedTabIndices(); final IPlotter plotter = MonitoringPlotFactory.getPlotterRegistry().find(indices[0], indices[1]); if (plotter != null) { - savePlotter(plotter); + this.savePlotter(plotter); } else { DialogUtil.showErrorDialog(this, "Error Finding Plots", "No plots found in selected tab."); } } } + /** + * Get the tabbed pane with the plots. + * + * @return the tabbed pane with the plots + */ JTabbedPane getPlotPane() { return this.plotPane; } + /** + * Get the currently selected plot tab. + * + * @return the currently selected plot tab + */ Component getSelectedTab() { return ((JTabbedPane) this.plotPane.getSelectedComponent()).getSelectedComponent(); } @@ -62,7 +84,7 @@ * * @return The indices of the current tabs. */ - int[] getSelectedTabIndices() { + private int[] getSelectedTabIndices() { final int[] indices = new int[2]; indices[0] = this.plotPane.getSelectedIndex(); final Component component = this.plotPane.getSelectedComponent(); @@ -72,11 +94,19 @@ return indices; } + /** + * Remove all tabs from the plot pane. + */ void reset() { this.plotPane.removeAll(); } - void savePlotter(final IPlotter plotter) { + /** + * Save the plotter from a tab to a graphics file. + * + * @param plotter the plotter to save + */ + private void savePlotter(final IPlotter plotter) { final JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); fc.setDialogTitle("Save Plots - " + plotter.title()); @@ -92,7 +122,7 @@ if (!path.endsWith("." + filter.getExtensions()[0])) { path += "." + filter.getExtensions()[0]; } - final BufferedImage image = ExportPdf.getImage(getSelectedTab()); + final BufferedImage image = ExportPdf.getImage(this.getSelectedTab()); try { ImageIO.write(image, filter.getExtensions()[0], new File(path)); DialogUtil.showInfoDialog(this, "Plots Saved", "Plots from panel were saved to" + '\n' + path); @@ -102,4 +132,4 @@ } } } -} +} Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsDialog.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsDialog.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsDialog.java Mon Apr 13 10:40:21 2015 @@ -13,28 +13,38 @@ * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ +@SuppressWarnings("serial") final class SettingsDialog extends JDialog { - final SettingsPanel settingsPanel; + /** + * The panel with the settings. + */ + private final SettingsPanel settingsPanel; + /** + * Class constructor. + * + * @param configurationModel the configuration model with global settings + * @param listener the action listener assigned to certain components + */ public SettingsDialog(final ConfigurationModel configurationModel, final ActionListener listener) { // Initialize the GUI panel. this.settingsPanel = new SettingsPanel(this, configurationModel, listener); // Configure the frame. - setTitle("Settings"); - setContentPane(this.settingsPanel); - setResizable(false); - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - setModalityType(ModalityType.APPLICATION_MODAL); - pack(); + this.setTitle("Settings"); + this.setContentPane(this.settingsPanel); + this.setResizable(false); + this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + this.setModalityType(ModalityType.APPLICATION_MODAL); + this.pack(); // Add window listener for turning invisible when closing. - addWindowListener(new WindowAdapter() { + this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent e) { - setVisible(false); + SettingsDialog.this.setVisible(false); } @Override Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsPanel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsPanel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SettingsPanel.java Mon Apr 13 10:40:21 2015 @@ -19,15 +19,36 @@ * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ +@SuppressWarnings("serial") final class SettingsPanel extends JPanel implements ActionListener { - static final String OKAY_COMMAND = "settingsOkay"; - ConnectionSettingsPanel connectionPanel; - JobSettingsPanel jobPanel; - JDialog parent; + /** + * The panel with connection settings. + */ + private final ConnectionSettingsPanel connectionPanel; - JTabbedPane tabs; + /** + * The panel with general job settings. + */ + private final JobSettingsPanel jobPanel; + /** + * The parent dialog window. + */ + private final JDialog parent; + + /** + * The tabs with the sub-panels. + */ + private final JTabbedPane tabs; + + /** + * Class constructor. + * + * @param parent the parent dialog window + * @param configurationModel the global configuration model + * @param listener the action listener assigned to certain components + */ SettingsPanel(final JDialog parent, final ConfigurationModel configurationModel, final ActionListener listener) { this.parent = parent; @@ -48,23 +69,28 @@ this.tabs = new JTabbedPane(); this.tabs.addTab("Connection Settings", this.connectionPanel); this.tabs.addTab("Job Settings", this.jobPanel); - add(this.tabs); + this.add(this.tabs); final JButton okayButton = new JButton("Okay"); - okayButton.setActionCommand(OKAY_COMMAND); + okayButton.setActionCommand(Commands.SETTINGS_OKAY_COMMAND); okayButton.addActionListener(this); - add(Box.createRigidArea(new Dimension(1, 5))); + this.add(Box.createRigidArea(new Dimension(1, 5))); final JPanel buttonsPanel = new JPanel(); buttonsPanel.add(okayButton); buttonsPanel.setLayout(new FlowLayout()); - add(buttonsPanel); - add(Box.createRigidArea(new Dimension(1, 5))); + this.add(buttonsPanel); + this.add(Box.createRigidArea(new Dimension(1, 5))); } + /** + * Handle action events. + * + * @param e the action event to handle + */ @Override public void actionPerformed(final ActionEvent e) { - if (e.getActionCommand().equals(OKAY_COMMAND)) { + if (e.getActionCommand().equals(Commands.SETTINGS_OKAY_COMMAND)) { this.parent.setVisible(false); } } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusEventsTable.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusEventsTable.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusEventsTable.java Mon Apr 13 10:40:21 2015 @@ -25,47 +25,88 @@ * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ +@SuppressWarnings("serial") final class SystemStatusEventsTable extends JTable { + /** + * The model for the system status events table. + */ static class SystemStatusEventsTableModel extends DefaultTableModel implements SystemStatusListener { - Class<?>[] columnClasses = { Date.class, Subsystem.class, SystemStatus.class, String.class, String.class }; - - String[] columnNames = { "Date", "Subsystem", "Status Code", "Description", "Message" }; - List<SystemStatus> statuses = new ArrayList<SystemStatus>(); - + /** + * The classes of the table columns. + */ + private final Class<?>[] columnClasses = {Date.class, Subsystem.class, SystemStatus.class, String.class, + String.class}; + + /** + * The names of the columns. + */ + private final String[] columnNames = {"Date", "Subsystem", "Status Code", "Description", "Message"}; + + /** + * The list of statuses shown in the table. + */ + private final List<SystemStatus> statuses = new ArrayList<SystemStatus>(); + + /** + * Class constructor. + */ SystemStatusEventsTableModel() { } /** * Register the listener on this status. * - * @param status The system status. + * @param status the system status */ void addSystemStatus(final SystemStatus status) { status.addListener(this); } - public void clear() { + /** + * Clear all the records from the table. + */ + void clear() { this.statuses.clear(); this.setRowCount(0); } - @Override - public Class<?> getColumnClass(final int column) { - return this.columnClasses[column]; - } - + /** + * Get the column class. + * + * @param columnIndex the column index + */ + @Override + public Class<?> getColumnClass(final int columnIndex) { + return this.columnClasses[columnIndex]; + } + + /** + * Get the column count. + * + * @return the column count + */ @Override public int getColumnCount() { return this.columnNames.length; } - @Override - public String getColumnName(final int column) { - return this.columnNames[column]; - } - + /** + * Get the column name. + * + * @param columnIndex the column index + */ + @Override + public String getColumnName(final int columnIndex) { + return this.columnNames[columnIndex]; + } + + /** + * Get the row count. + * + * @return the row count + */ @Override public int getRowCount() { if (this.statuses != null) { @@ -75,45 +116,58 @@ } } - @Override - public Object getValueAt(final int row, final int column) { - final SystemStatus status = this.statuses.get(row); - switch (column) { - case 0: - return new Date(status.getLastChangedMillis()); - case 1: - return status.getSubsystem(); - case 2: - return status.getStatusCode(); - case 3: - return status.getDescription(); - case 4: - return status.getMessage(); - default: - return null; + /** + * Get a cell value from the table. + * + * @param rowIndex the row index + * @param columnIndex the column index + * @return the cell value at the rowIndex and columnIndex + */ + @Override + public Object getValueAt(final int rowIndex, final int columnIndex) { + final SystemStatus status = this.statuses.get(rowIndex); + switch (columnIndex) { + case 0: + return new Date(status.getLastChangedMillis()); + case 1: + return status.getSubsystem(); + case 2: + return status.getStatusCode(); + case 3: + return status.getDescription(); + case 4: + return status.getMessage(); + default: + return null; } } /** * Update the table with status changes. * - * @param status The system status. + * @param status the system status */ @Override public void statusChanged(final SystemStatus status) { final SystemStatus newStatus = new SystemStatusImpl(status); this.statuses.add(newStatus); - fireTableDataChanged(); + this.fireTableDataChanged(); } } - SystemStatusEventsTableModel tableModel = new SystemStatusEventsTableModel(); - + /** + * The table model. + */ + private final SystemStatusEventsTableModel tableModel = new SystemStatusEventsTableModel(); + + /** + * Class constructor. + */ SystemStatusEventsTable() { - setModel(this.tableModel); + this.setModel(this.tableModel); // Date formatting. - getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { + this.getColumnModel().getColumn(0).setCellRenderer(new DefaultTableCellRenderer() { final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss.SSS"); @@ -128,7 +182,7 @@ }); // Rendering of system status cells using different background colors. - getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { + this.getColumnModel().getColumn(2).setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(final JTable table, final Object value, @@ -146,6 +200,12 @@ }); } - void registerListener() { + /** + * Get the system status events table model. + * + * @return the system status events table model + */ + SystemStatusEventsTableModel getSystemStatusEventsTableModel() { + return this.tableModel; } } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java Mon Apr 13 10:40:21 2015 @@ -20,23 +20,41 @@ */ final class SystemStatusPanel extends JPanel { - SystemStatusEventsTable eventsTable = new SystemStatusEventsTable(); - SystemStatusTable statusTable = new SystemStatusTable(); + /** + * The system status events table. + */ + private final SystemStatusEventsTable eventsTable = new SystemStatusEventsTable(); + /** + * The system status table. + */ + private final SystemStatusTable statusTable = new SystemStatusTable(); + + /** + * Class constructor. + */ SystemStatusPanel() { super(new BorderLayout()); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(this.statusTable), new JScrollPane(this.eventsTable)); splitPane.setDividerLocation(50); - add(splitPane, BorderLayout.CENTER); + this.add(splitPane, BorderLayout.CENTER); } + /** + * Add a system status. + * + * @param status the system status to add + */ void addSystemStatus(final SystemStatus status) { // Register listeners of table models on this status. this.statusTable.getTableModel().addSystemStatus(status); - this.eventsTable.tableModel.addSystemStatus(status); + this.eventsTable.getSystemStatusEventsTableModel().addSystemStatus(status); } + /** + * Clear all the table records. + */ void clear() { // Clear the system status monitor table. this.statusTable.getTableModel().clear(); Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusTable.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusTable.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusTable.java Mon Apr 13 10:40:21 2015 @@ -20,6 +20,7 @@ * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ +@SuppressWarnings("serial") final class SystemStatusTable extends JTable { /** @@ -27,14 +28,30 @@ */ private class ButtonRenderer extends JButton implements TableCellRenderer { + /** + * Class constructor. + * + * @param label the label of the button + */ public ButtonRenderer(final String label) { this.setText(label); } + /** + * Get the renderer for the table cell. + * + * @param table the table + * @param value the object from the table cell + * @param isSelected <code>true</code> if cell is selected + * @param hasFocus <code>true</code> if cell has focus + * @param rowIndex the row index + * @param columnIndex the column index + */ @Override public Component getTableCellRendererComponent(final JTable table, final Object value, - final boolean isSelected, final boolean hasFocus, final int row, final int column) { - final boolean clearable = (Boolean) table.getModel().getValueAt(row, SystemStatusTableModel.CLEARABLE_COL); + final boolean isSelected, final boolean hasFocus, final int rowIndex, final int columnIndex) { + final boolean clearable = (Boolean) table.getModel().getValueAt(rowIndex, + SystemStatusTableModel.CLEARABLE_COL); if (clearable) { return this; } else { @@ -48,12 +65,26 @@ * button. The <code>ActionListener</code> then sets the <code>StatusCode</code> to <code>CLEARED</code>. */ private static class JTableButtonMouseListener extends MouseAdapter { + + /** + * The table. + */ private final JTable table; + /** + * Class constructor. + * + * @param table the table for the listener + */ public JTableButtonMouseListener(final JTable table) { this.table = table; } + /** + * Implement mouse clicked action. + * + * @param e the mouse event + */ @Override public void mouseClicked(final MouseEvent e) { final int column = this.table.getColumnModel().getColumnIndexAtX(e.getX()); @@ -67,20 +98,24 @@ } } + /** + * Class constructor. + */ SystemStatusTable() { - setModel(new SystemStatusTableModel()); + this.setModel(new SystemStatusTableModel()); // Rendering of system status cells using different background colors. - getColumnModel().getColumn(SystemStatusTableModel.STATUS_COL).setCellRenderer(new DefaultTableCellRenderer() { + this.getColumnModel().getColumn(SystemStatusTableModel.STATUS_COL) + .setCellRenderer(new DefaultTableCellRenderer() { @Override public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int col) { // Cells are by default rendered as a JLabel. - final JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, - row, col); + final JLabel label = (JLabel) super.getTableCellRendererComponent(table, value, isSelected, + hasFocus, row, col); // Color code the cell by its status. final StatusCode statusCode = StatusCode.valueOf((String) value); @@ -90,38 +125,43 @@ }); // Date formatting for last changed. - getColumnModel().getColumn(SystemStatusTableModel.LAST_CHANGED_COL).setCellRenderer( - new DefaultTableCellRenderer() { + this.getColumnModel().getColumn(SystemStatusTableModel.LAST_CHANGED_COL) + .setCellRenderer(new DefaultTableCellRenderer() { - final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss.SSS"); + final SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM-dd-yyyy HH:mm:ss.SSS"); - @Override - public Component getTableCellRendererComponent(final JTable table, Object value, - final boolean isSelected, final boolean hasFocus, final int row, final int column) { - if (value instanceof Date) { - value = this.dateFormat.format(value); - } - return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - } - }); + @Override + public Component getTableCellRendererComponent(final JTable table, Object value, + final boolean isSelected, final boolean hasFocus, final int row, final int column) { + if (value instanceof Date) { + value = this.dateFormat.format(value); + } + return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + } + }); // Button for clearing system statuses. - getColumnModel().getColumn(SystemStatusTableModel.RESET_COL).setCellRenderer(new ButtonRenderer("Clear")); - addMouseListener(new JTableButtonMouseListener(this)); - getColumn("Clearable").setWidth(0); - getColumn("Clearable").setMinWidth(0); - getColumn("Clearable").setMaxWidth(0); + this.getColumnModel().getColumn(SystemStatusTableModel.RESET_COL).setCellRenderer(new ButtonRenderer("Clear")); + this.addMouseListener(new JTableButtonMouseListener(this)); + this.getColumn("Clearable").setWidth(0); + this.getColumn("Clearable").setMinWidth(0); + this.getColumn("Clearable").setMaxWidth(0); // Column widths. - getColumnModel().getColumn(SystemStatusTableModel.ACTIVE_COL).setPreferredWidth(8); - getColumnModel().getColumn(SystemStatusTableModel.STATUS_COL).setPreferredWidth(10); - getColumnModel().getColumn(SystemStatusTableModel.SYSTEM_COL).setPreferredWidth(10); + this.getColumnModel().getColumn(SystemStatusTableModel.ACTIVE_COL).setPreferredWidth(8); + this.getColumnModel().getColumn(SystemStatusTableModel.STATUS_COL).setPreferredWidth(10); + this.getColumnModel().getColumn(SystemStatusTableModel.SYSTEM_COL).setPreferredWidth(10); // TODO: Add default width setting for every column. - setAutoCreateRowSorter(true); + this.setAutoCreateRowSorter(true); } + /** + * Get the tqble model. + * + * @return the table model + */ public SystemStatusTableModel getTableModel() { - return (SystemStatusTableModel) getModel(); + return (SystemStatusTableModel) this.getModel(); } } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/ToolbarPanel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/ToolbarPanel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/ToolbarPanel.java Mon Apr 13 10:40:21 2015 @@ -18,13 +18,27 @@ */ final class ToolbarPanel extends JPanel { + /** + * The panel with the buttons. + */ private final JPanel buttonsPanel; + + /** + * The combo box with the list of data sources. + */ private final DataSourceComboBox dataSourceComboBox; + /** + * Class constructor. + * + * @param configurationModel the configuration model for the application + * @param connectionModel the connection status model + * @param listener the action listener to assign to certain components + */ ToolbarPanel(final ConfigurationModel configurationModel, final ConnectionStatusModel connectionModel, final ActionListener listener) { - setLayout(new FlowLayout(FlowLayout.LEFT)); + this.setLayout(new FlowLayout(FlowLayout.LEFT)); final JPanel containerPanel = new JPanel(); containerPanel.setLayout(new GridBagLayout()); @@ -60,11 +74,15 @@ gbs.fill = GridBagConstraints.HORIZONTAL; containerPanel.add(this.dataSourceComboBox, gbs); - add(containerPanel); + this.add(containerPanel); } + /** + * Get the combo box with the data sources + * + * @return the combo box with the data sources + */ DataSourceComboBox getDataSourceComboBox() { return this.dataSourceComboBox; } - } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/TriggerDiagnosticsPanel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/TriggerDiagnosticsPanel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/TriggerDiagnosticsPanel.java Mon Apr 13 10:40:21 2015 @@ -29,7 +29,9 @@ */ class TriggerDiagnosticGUIDriver extends Driver { - // FIXME: Hard-coded collection name. + /** + * Default name of trigger diagnostics collection. + */ private String diagnosticCollectionName = "DiagnosticSnapshot"; @Override @@ -48,22 +50,51 @@ } } + /** + * Set the name of the trigger diagnostics collection. + * + * @param name the name of the trigger diagnostics collection + */ void setDiagnosticCollectionName(final String name) { this.diagnosticCollectionName = name; } } - ClusterTablePanel clusterPanel = new ClusterTablePanel(); - EfficiencyTablePanel efficiencyPanel = new EfficiencyTablePanel(); - PairTablePanel pairsPanel = new PairTablePanel(); - SinglesTablePanel singlesPanel = new SinglesTablePanel(); + /** + * The panel with cluster statistics. + */ + private final ClusterTablePanel clusterPanel = new ClusterTablePanel(); - JTabbedPane tabs = new JTabbedPane(); + /** + * The panel with efficiency statistics. + */ + private final EfficiencyTablePanel efficiencyPanel = new EfficiencyTablePanel(); - List<DiagnosticUpdatable> updateList = new ArrayList<DiagnosticUpdatable>(); + /** + * The panel with pairs statistics. + */ + private final PairTablePanel pairsPanel = new PairTablePanel(); + /** + * The panel for singles statistics. + */ + private final SinglesTablePanel singlesPanel = new SinglesTablePanel(); + + /** + * The tabs containing the statistics panels. + */ + private final JTabbedPane tabs = new JTabbedPane(); + + /** + * The list of objects that can be updated with trigger diagnostics. + */ + private final List<DiagnosticUpdatable> updateList = new ArrayList<DiagnosticUpdatable>(); + + /** + * Class constructor. + */ TriggerDiagnosticsPanel() { - setLayout(new BorderLayout()); + this.setLayout(new BorderLayout()); this.tabs.addTab("Clusters", this.clusterPanel); this.tabs.addTab("Singles", this.singlesPanel); @@ -75,6 +106,6 @@ this.updateList.add(this.pairsPanel); this.updateList.add(this.efficiencyPanel); - add(this.tabs, BorderLayout.CENTER); + this.add(this.tabs, BorderLayout.CENTER); } } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/AbstractModel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/AbstractModel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/AbstractModel.java Mon Apr 13 10:40:21 2015 @@ -24,8 +24,8 @@ * This method will statically extract property names from a class, which in this package's conventions are * statically declared, public strings that end with "_PROPERTY". * - * @param type The class with the properties. - * @return The list of property names. + * @param type the class with the properties + * @return the list of property names */ protected static String[] getPropertyNames(final Class<? extends AbstractModel> type) { final List<String> fields = new ArrayList<String>(); @@ -42,24 +42,43 @@ return fields.toArray(new String[] {}); } - protected PropertyChangeSupport propertyChangeSupport; + /** + * The property change support object. + */ + private final PropertyChangeSupport propertyChangeSupport; + /** + * Class constructor. + */ public AbstractModel() { this.propertyChangeSupport = new PropertyChangeSupport(this); } + /** + * Add a property change listener. + * + * @param listener the property change listener + */ public void addPropertyChangeListener(final PropertyChangeListener listener) { this.propertyChangeSupport.addPropertyChangeListener(listener); } + /** + * Fire property change events. + */ public void fireModelChanged() { - firePropertiesChanged(Arrays.asList(getPropertyNames())); + this.firePropertiesChanged(Arrays.asList(this.getPropertyNames())); } + /** + * Fire property change for a list of named properties. + * + * @param properties the list of property names + */ void firePropertiesChanged(final Collection<String> properties) { propertyLoop: for (final String property : properties) { Method getMethod = null; - for (final Method method : getClass().getMethods()) { + for (final Method method : this.getClass().getMethods()) { if (method.getName().equals("get" + property)) { getMethod = method; break; @@ -87,7 +106,7 @@ } } if (value != null) { - firePropertyChange(property, value, value); + this.firePropertyChange(property, value, value); for (final PropertyChangeListener listener : this.propertyChangeSupport .getPropertyChangeListeners()) { // FIXME: For some reason calling the propertyChangeSupport methods directly here doesn't work! @@ -101,17 +120,48 @@ } } + /** + * Fire a property change event. + * + * @param evt the property change event + */ protected void firePropertyChange(final PropertyChangeEvent evt) { this.propertyChangeSupport.firePropertyChange(evt); } + /** + * Fire a property change. + * + * @param propertyName the name of the property + * @param oldValue the old property value + * @param newValue the new property value + */ protected void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) { this.propertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue); } + /** + * Get the property change support object. + * + * @return the property change support object + */ + PropertyChangeSupport getPropertyChangeSupport() { + return this.propertyChangeSupport; + } + + /** + * Get the list of the property names for this model. + * + * @return the list of the property names for this model + */ abstract public String[] getPropertyNames(); + /** + * Remove a property change listener from the model. + * + * @param listener the property change listener to remove + */ public void removePropertyChangeListener(final PropertyChangeListener listener) { this.propertyChangeSupport.removePropertyChangeListener(listener); } -} +} Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/Configuration.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/Configuration.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/Configuration.java Mon Apr 13 10:40:21 2015 @@ -17,18 +17,34 @@ */ public final class Configuration { - File file; - Properties properties; - String resourcePath; - + /** + * The file containing the keys and values. + */ + private File file; + + /** + * The Java properties file. + */ + private Properties properties; + + /** + * The path to an embedded properties resource from a jar. + */ + private String resourcePath; + + /** + * Class constructor. + */ Configuration() { this.properties = new Properties(); } /** - * Load a configuration from a properties file. - * - * @param file The properties file. + * Class constructor. + * <p> + * Loads a configuration from a properties file. + * + * @param file the properties file */ public Configuration(final File file) { this.file = file; @@ -41,9 +57,11 @@ } /** + * Class constructor. + * <p> * Load a configuration from a resource path pointing to a properties file. - * - * @param resourcePath The resource path to the properties file. + * + * @param resourcePath the resource path to the properties file */ public Configuration(final String resourcePath) { this.resourcePath = resourcePath; @@ -58,22 +76,22 @@ /** * Check if the properties contains the key and if it has a non-null value. - * - * @param key The properties key. - * @return True if properties key is valid. + * + * @param key the properties key + * @return <code>true</code> if properties key is valid */ boolean checkKey(final String key) { - return hasKey(key) && this.properties.getProperty(key) != null; + return this.hasKey(key) && this.properties.getProperty(key) != null; } /** * Get a key value as a string. - * - * @param key The key to lookup. - * @return The value or null if does not exist. + * + * @param key the key to lookup + * @return the value or null if does not exist */ String get(final String key) { - if (checkKey(key)) { + if (this.checkKey(key)) { // Return the key value for properties that are set. return this.properties.getProperty(key); } else { @@ -84,12 +102,12 @@ /** * Get a key value as a boolean. - * - * @param key The key to lookup. - * @return The value or null if does not exist. + * + * @param key the key to lookup + * @return the value or null if does not exist */ Boolean getBoolean(final String key) { - if (checkKey(key)) { + if (this.checkKey(key)) { return Boolean.parseBoolean(this.properties.getProperty(key)); } else { return null; @@ -98,12 +116,12 @@ /** * Get a key value as a double. - * - * @param key The key to lookup. - * @return The value or null if does not exist. + * + * @param key the key to lookup + * @return the value as a <code>Double</code> or <code>null</code> if does not exist */ Double getDouble(final String key) { - if (checkKey(key)) { + if (this.checkKey(key)) { return Double.parseDouble(this.properties.getProperty(key)); } else { return null; @@ -112,8 +130,8 @@ /** * Get the file associated with this configuration or <code>null</code> if not set. - * - * @return The file associated with the configuration. + * + * @return the file associated with the configuration */ public File getFile() { return this.file; @@ -121,12 +139,12 @@ /** * Get a key value as an integer. - * - * @param key The key to lookup. - * @return The value or null if does not exist. + * + * @param key the key to lookup + * @return the value as an <code>Integer</code> or <code>null</code> if does not exist */ Integer getInteger(final String key) { - if (checkKey(key)) { + if (this.checkKey(key)) { return Integer.parseInt(this.properties.getProperty(key)); } else { return null; @@ -135,8 +153,8 @@ /** * Get the property keys. - * - * @return The collection of property keys. + * + * @return the collection of property keys */ public Set<String> getKeys() { return this.properties.stringPropertyNames(); @@ -144,13 +162,12 @@ /** * Get a key value as a Long. - * - * @param key The key to lookup. - * @param key The value or null if does not exist. - * @return + * + * @param key the key to lookup + * @return the key value as a <code>Long</code> */ Long getLong(final String key) { - if (checkKey(key)) { + if (this.checkKey(key)) { return Long.parseLong(this.properties.getProperty(key)); } else { return null; @@ -159,18 +176,18 @@ /** * Get the resource path associated with this configuration or <code>null</code> if not applicable. - * - * @return The resource path of this configuration. + * + * @return the resource path of this configuration */ public String getResourcePath() { return this.resourcePath; } /** - * True if configuration has value for the key. - * - * @param key The key. - * @return True if configuration has value for the key. + * Return <code>true</code> if configuration has value for the key. + * + * @param key the key + * @return <code>true</code> if configuration has value for the key */ boolean hasKey(final String key) { try { @@ -183,8 +200,8 @@ /** * Merge in values from another configuration into this one which will override properties that already exist with * new values. - * - * @param configuration The configuration with the properties to merge. + * + * @param configuration the configuration with the properties to merge */ void merge(final Configuration configuration) { for (final String property : configuration.getKeys()) { @@ -194,8 +211,8 @@ /** * Remove a configuration value. - * - * @param key The key of the value. + * + * @param key the key of the value */ void remove(final String key) { this.properties.remove(key); @@ -203,9 +220,9 @@ /** * Set a configuration value. - * - * @param key The key for lookup. - * @param value The value to assign to that key. + * + * @param key the key for lookup + * @param value the value to assign to that key */ void set(final String key, final Object value) { this.properties.put(key, String.valueOf(value)); @@ -221,7 +238,7 @@ /** * Write this configuration to a file and set that file as the current one. - * + * * @param file The output file. */ public void writeToFile(final File file) { Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConfigurationModel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConfigurationModel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConfigurationModel.java Mon Apr 13 10:40:21 2015 @@ -16,107 +16,303 @@ */ public final class ConfigurationModel extends AbstractModel { - // Job setting properties. + /** + * Name of AIDA server. + */ public static final String AIDA_SERVER_NAME_PROPERTY = "AIDAServerName"; + /** + * ET blocking setting. + */ public static final String BLOCKING_PROPERTY = "Blocking"; + /** + * ET chunk size (number of events per ET <code>getEvents</code>). + */ public static final String CHUNK_SIZE_PROPERTY = "ChunkSize"; + + /** + * Conditions tag. + */ public static final String CONDITIONS_TAG_PROPERTY = "ConditionsTag"; + + /** + * The list of all property names. + */ static final String[] CONFIG_PROPERTIES = AbstractModel.getPropertyNames(ConfigurationModel.class); - public static final String CONFIGURATION_CHANGED = "configurationChanged"; + + /** + * The data source path which is a file path if using a file source (EVIO or LCIO file. + */ public static final String DATA_SOURCE_PATH_PROPERTY = "DataSourcePath"; + + /** + * The data source type (EVIO, LCIO or ET). + * + * @see org.hps.record.enums.DataSourceType + * @return the data source type + */ public static final String DATA_SOURCE_TYPE_PROPERTY = "DataSourceType"; + + /** + * The detector alias which is pointing to a local compact.xml detector file. + */ public static final String DETECTOR_ALIAS_PROPERTY = "DetectorAlias"; + + /** + * The name of a detector model to use from the jar file. + */ public static final String DETECTOR_NAME_PROPERTY = "DetectorName"; + + /** + * Flag to enable disconnecting when an EVIO END event is received. + */ public static final String DISCONNECT_ON_END_RUN_PROPERTY = "DisconnectOnEndRun"; + + /** + * Flag to enable disconnecting if an event processing error occurs. + */ public static final String DISCONNECT_ON_ERROR_PROPERTY = "DisconnectOnError"; + + /** + * The name of the ET system which is generally a file on disk. + */ public static final String ET_NAME_PROPERTY = "EtName"; + + /** + * The name of the event builder for converting from EVIO to LCIO events. + */ public static final String EVENT_BUILDER_PROPERTY = "EventBuilderClassName"; + + /** + * Flag to freeze conditions system after initialization. + */ public static final String FREEZE_CONDITIONS_PROPERTY = "FreezeConditions"; + + /** + * The ET host property (TCP/IP host name). + */ public static final String HOST_PROPERTY = "Host"; + + /** + * The name of the output log file. + */ public static final String LOG_FILE_NAME_PROPERTY = "LogFileName"; + + /** + * The filter level for displaying records in the log table. + */ public static final String LOG_LEVEL_FILTER_PROPERTY = "LogLevelFilter"; + + /** + * The global log level. + */ public static final String LOG_LEVEL_PROPERTY = "LogLevel"; + + /** + * Flag to log to a file. + */ public static final String LOG_TO_FILE_PROPERTY = "LogToFile"; + + /** + * Max events after which session will be automatically ended. + */ public static final String MAX_EVENTS_PROPERTY = "MaxEvents"; + + /** + * The maximum number of recent files (hard-coded to 10 to match 0-9 shortcut mnemonics). + */ private static final int MAX_RECENT_FILES = 10; + + /** + * The ET TCP/IP port. + */ public static final String PORT_PROPERTY = "Port"; + + /** + * The ET pre-scaling value which throttles event rate. + */ public static final String PRESCALE_PROPERTY = "Prescale"; + + /** + * The processing stage(s) to execute (ET, EVIO or LCIO). + */ public static final String PROCESSING_STAGE_PROPERTY = "ProcessingStage"; + + /** + * The ET queue size. + */ public static final String QUEUE_SIZE_PROPERTY = "QueueSize"; + + /** + * The list of recent files. + */ public static final String RECENT_FILES_PROPERTY = "RecentFiles"; + + /** + * The ET station name. + */ public static final String STATION_NAME_PROPERTY = "StationName"; + + /** + * The ET station position. + */ public static final String STATION_POSITION_PROPERTY = "StationPosition"; + + /** + * The steering file. + */ public static final String STEERING_FILE_PROPERTY = "SteeringFile"; + + /** + * The steering resource. + */ public static final String STEERING_RESOURCE_PROPERTY = "SteeringResource"; + + /** + * The steering type (file or resource). + */ public static final String STEERING_TYPE_PROPERTY = "SteeringType"; + + /** + * A user run number to use for initializing the conditions system. + */ public static final String USER_RUN_NUMBER_PROPERTY = "UserRunNumber"; + + /** + * The verbose setting for the ET system. + */ public static final String VERBOSE_PROPERTY = "Verbose"; + + /** + * The ET wait mode. + */ public static final String WAIT_MODE_PROPERTY = "WaitMode"; + + /** + * The ET wait time (if using timed wait mode). + */ public static final String WAIT_TIME_PROPERTY = "WaitTime"; - Configuration configuration; - + /** + * The underlying properties for the model. + */ + private Configuration configuration; + + /** + * Class constructor. + * <p> + * Create a new model without any initial property settings. + */ public ConfigurationModel() { this.configuration = new Configuration(); } + /** + * Class constructor. + * <p> + * Sets the properties from a configuration (file or resource). + * + * @param configuration the configuration containing property settings + */ public ConfigurationModel(final Configuration configuration) { this.configuration = configuration; - fireModelChanged(); - } - + this.fireModelChanged(); + } + + /** + * Add a single recent file. + * + * @param recentFile the recent file to add + */ public void addRecentFile(final String recentFile) { if (!this.configuration.checkKey(RECENT_FILES_PROPERTY)) { this.configuration.set(RECENT_FILES_PROPERTY, recentFile); - firePropertyChange(RECENT_FILES_PROPERTY, null, recentFile); + this.firePropertyChange(RECENT_FILES_PROPERTY, null, recentFile); } else { - final List<String> recentFilesList = getRecentFilesList(); + final List<String> recentFilesList = this.getRecentFilesList(); if (!recentFilesList.contains(recentFile)) { - if (getRecentFilesList().size() >= MAX_RECENT_FILES) { + if (this.getRecentFilesList().size() >= MAX_RECENT_FILES) { // Bump the first file from the list if max recent files is exceeded (10 files). recentFilesList.remove(0); - setRecentFilesList(recentFilesList); + this.setRecentFilesList(recentFilesList); } final String oldValue = this.configuration.get(RECENT_FILES_PROPERTY); final String recentFiles = oldValue + "\n" + recentFile; this.configuration.set(RECENT_FILES_PROPERTY, recentFiles); - firePropertyChange(RECENT_FILES_PROPERTY, oldValue, recentFile); + this.firePropertyChange(RECENT_FILES_PROPERTY, oldValue, recentFile); } } } + /** + * Fire property change for all property keys. + */ @Override public void fireModelChanged() { - firePropertiesChanged(this.configuration.getKeys()); - } - + this.firePropertiesChanged(this.configuration.getKeys()); + } + + /** + * Get the AIDA server name. + * + * @return the AIDA server name + */ public String getAIDAServerName() { return this.configuration.get(AIDA_SERVER_NAME_PROPERTY); } + /** + * Get the ET blocking setting. + * + * @return the ET blocking setting + */ public Boolean getBlocking() { return this.configuration.getBoolean(BLOCKING_PROPERTY); } + /** + * Get the ET chunk size + * + * @return the ET chunk size + */ public Integer getChunkSize() { return this.configuration.getInteger(CHUNK_SIZE_PROPERTY); } + /** + * Get the conditions system tag. + * + * @return the conditions system tag + */ public String getConditionsTag() { return this.configuration.get(CONDITIONS_TAG_PROPERTY); } + /** + * Get the underlying configuration containing properties. + * + * @return the underlying configuration with properties settings + */ public Configuration getConfiguration() { return this.configuration; } + /** + * Get the data source path. + * + * @return the data source path + */ public String getDataSourcePath() { return this.configuration.get(DATA_SOURCE_PATH_PROPERTY); } + /** + * Get the data source type (EVIO, LCIO or ET). + * + * @return the data source type + */ public DataSourceType getDataSourceType() { if (this.configuration.checkKey(DATA_SOURCE_TYPE_PROPERTY)) { return DataSourceType.valueOf(this.configuration.get(DATA_SOURCE_TYPE_PROPERTY)); @@ -125,70 +321,158 @@ } } + /** + * Get the detector alias which is a compact.xml file on disk. + * + * @return the detector alias + */ public String getDetectorAlias() { return this.configuration.get(DETECTOR_ALIAS_PROPERTY); } + /** + * Get the detector name. + * + * @return the detector name + */ public String getDetectorName() { return this.configuration.get(DETECTOR_NAME_PROPERTY); } + /** + * Get the disconnect on end run flag. + * + * @return the disconnect on end run flag + */ public Boolean getDisconnectOnEndRun() { return this.configuration.getBoolean(DISCONNECT_ON_END_RUN_PROPERTY); } + /** + * Get the disconnect on error flag. + * + * @return the disconnect on error flag + */ public Boolean getDisconnectOnError() { return this.configuration.getBoolean(DISCONNECT_ON_ERROR_PROPERTY); } + /** + * Get the ET system name. + * + * @return the ET system name + */ public String getEtName() { return this.configuration.get(ET_NAME_PROPERTY); } + /** + * Get the ET path from concatenating the ET system name, host and post (which is just used for the GUI). + * + * @return the ET path + */ public String getEtPath() { - return getEtName() + "@" + getHost() + ":" + getPort(); - } - + return this.getEtName() + "@" + this.getHost() + ":" + this.getPort(); + } + + /** + * Get the event builder class name. + * + * @return the event builder class name + */ public String getEventBuilderClassName() { return this.configuration.get(EVENT_BUILDER_PROPERTY); } + /** + * Get the freeze conditions setting which will cause conditions system to be frozen after initialization with the + * currently selected run number and detector name. + * + * @return the freeze conditions setting + */ public Boolean getFreezeConditions() { return this.configuration.getBoolean(FREEZE_CONDITIONS_PROPERTY); } + /** + * Get the ET host name. + * + * @return the ET host name + */ public String getHost() { return this.configuration.get(HOST_PROPERTY); } + /** + * Get the log file name. + * + * @return the log file name + */ public String getLogFileName() { return this.configuration.get(LOG_FILE_NAME_PROPERTY); } + /** + * Get the global log level. + * + * @return the global log level + */ public Level getLogLevel() { return Level.parse(this.configuration.get(LOG_LEVEL_PROPERTY)); } + /** + * Get the log level filter for displaying messages in the log table. + * + * @return the log level filter + */ public Level getLogLevelFilter() { return Level.parse(this.configuration.get(LOG_LEVEL_FILTER_PROPERTY)); } + /** + * Get the log to file setting which redirects monitoring application log messages from the console to a file. + * + * @return the log to file setting + */ public Boolean getLogToFile() { return this.configuration.getBoolean(LOG_TO_FILE_PROPERTY); } + /** + * Get the maximum number of events before disconnecting. + * + * @return the maximum number of events before disconnecting + */ public Long getMaxEvents() { return this.configuration.getLong(MAX_EVENTS_PROPERTY); } + /** + * Get the ET TCP/IP port value. + * + * @return the ET TCP/IP port value + */ public Integer getPort() { return this.configuration.getInteger(PORT_PROPERTY); } + /** + * Get the ET station prescale value. + * + * @return the ET station prescale value + */ public Integer getPrescale() { return this.configuration.getInteger(PRESCALE_PROPERTY); } + /** + * Get the processing stage. + * <p> + * Each level will execute the preceding ones, e.g. LCIO exectures EVIO, ET and LCIO event processing + * + * @return the processing stage to execute + */ public ProcessingStage getProcessingStage() { if (this.configuration.get(PROCESSING_STAGE_PROPERTY) == null) { throw new RuntimeException(PROCESSING_STAGE_PROPERTY + " is null!!!"); @@ -196,6 +480,11 @@ return ProcessingStage.valueOf(this.configuration.get(PROCESSING_STAGE_PROPERTY)); } + /** + * Get the property names in the configuration. + * + * @return the property names in the configuration + */ @Override public String[] getPropertyNames() { return CONFIG_PROPERTIES; @@ -205,6 +494,11 @@ return this.configuration.getInteger(QUEUE_SIZE_PROPERTY); } + /** + * Get recent files as a string with paths separated by the '\n' string. + * + * @return the recent files as a delimited string + */ public String getRecentFiles() { if (this.configuration.hasKey(RECENT_FILES_PROPERTY)) { return this.configuration.get(RECENT_FILES_PROPERTY); @@ -213,6 +507,14 @@ } } + /** + * Get the recent files list. + * <p> + * This is actually just a copy from the property, so to set the recent file list call + * {@link #setRecentFiles(String)}. + * + * @return the recent files list + */ public List<String> getRecentFilesList() { final List<String> recentFilesList = new ArrayList<String>(); if (this.configuration.hasKey(RECENT_FILES_PROPERTY)) { @@ -223,217 +525,392 @@ return recentFilesList; } - /* - * public void setDataSource(String dataSource) { setDataSourcePath(dataSource); DataSourceType dst = - * DataSourceType.getDataSourceType(dataSource); setDataSourceType(dst); } - */ - + /** + * Get the ET station name. + * + * @return the ET station name + */ public String getStationName() { return this.configuration.get(STATION_NAME_PROPERTY); } + /** + * Get the ET station position. + * + * @return the ET station position + */ public Integer getStationPosition() { return this.configuration.getInteger(STATION_POSITION_PROPERTY); } + /** + * Get the steering file location (if using a file on disk). + * + * @return the XML file steering path + */ public String getSteeringFile() { return this.configuration.get(STEERING_FILE_PROPERTY); } + /** + * Get the steering resource (if using a jar resource). + * + * @return the steering resource location + */ public String getSteeringResource() { return this.configuration.get(STEERING_RESOURCE_PROPERTY); } + /** + * Get whether the steering is a file or resource. + * + * @return whether the steering is a file or resource + */ public SteeringType getSteeringType() { return SteeringType.valueOf(this.configuration.get(STEERING_TYPE_PROPERTY)); } + /** + * Get the user run number for configuring the conditions system. + * + * @return the user run number for configuring the conditions system + */ public Integer getUserRunNumber() { return this.configuration.getInteger(USER_RUN_NUMBER_PROPERTY); } + /** + * Get the ET verbose flag. + * + * @return the ET verbose flag + */ public Boolean getVerbose() { return this.configuration.getBoolean(VERBOSE_PROPERTY); } + /** + * Get the ET wait mode. + * + * @return the ET wait mode + */ public Mode getWaitMode() { return Mode.valueOf(this.configuration.get(WAIT_MODE_PROPERTY)); } + /** + * Get the ET wait time. + * + * @return the ET wait time + */ public Integer getWaitTime() { return this.configuration.getInteger(WAIT_TIME_PROPERTY); } + /** + * Return <code>true</code> if the given property key exists. + * + * @param key the property key + * @return <code>true</code> if property key exists (still might be <code>null</code>) + */ public boolean hasPropertyKey(final String key) { return this.configuration.hasKey(key); } + /** + * Return <code>true</code> if the given property key exists and is non-null. + * + * @param key the property key + * @return <code>true</code> if the property key exists and is non-null + */ public boolean hasValidProperty(final String key) { return this.configuration.checkKey(key); } + /** + * Merge another properties configuration into this one. + * <p> + * Settings from the merged properties will override this one. + * + * @param configuration the properties configuration to merge in + */ public void merge(final Configuration configuration) { this.configuration.merge(configuration); this.firePropertiesChanged(configuration.getKeys()); } + /** + * Remove the given property which should remove its key and value. + * + * @param property the property to remove + */ public void remove(final String property) { - if (hasPropertyKey(property)) { + if (this.hasPropertyKey(property)) { final Object oldValue = this.configuration.get(property); if (oldValue != null) { this.configuration.remove(property); - firePropertyChange(property, oldValue, null); + this.firePropertyChange(property, oldValue, null); } } } + /** + * Set the name of the AIDA server. + * + * @param AIDAServerName the name of the AIDA server + */ public void setAIDAServerName(final String AIDAServerName) { - final String oldValue = getAIDAServerName(); + final String oldValue = this.getAIDAServerName(); this.configuration.set(AIDA_SERVER_NAME_PROPERTY, AIDAServerName); - firePropertyChange(AIDA_SERVER_NAME_PROPERTY, oldValue, getAIDAServerName()); - } - + this.firePropertyChange(AIDA_SERVER_NAME_PROPERTY, oldValue, this.getAIDAServerName()); + } + + /** + * Set whether the ET station is blocking (generally this should not be set to <code>true</code>!) + * + * @param blocking <code>true</code> if station should be blocking + */ public void setBlocking(final Boolean blocking) { - final Boolean oldValue = getBlocking(); + final Boolean oldValue = this.getBlocking(); this.configuration.set(BLOCKING_PROPERTY, blocking); - firePropertyChange(BLOCKING_PROPERTY, oldValue, getBlocking()); - } - + this.firePropertyChange(BLOCKING_PROPERTY, oldValue, this.getBlocking()); + } + + /** + * The ET chunk size which is how many events should be returned at once in the array. + * + * @param chunkSize the ET chunk size + */ public void setChunkSize(final Integer chunkSize) { - final Integer oldValue = getChunkSize(); + final Integer oldValue = this.getChunkSize(); this.configuration.set(CHUNK_SIZE_PROPERTY, chunkSize); - firePropertyChange(CHUNK_SIZE_PROPERTY, oldValue, getChunkSize()); - } - + this.firePropertyChange(CHUNK_SIZE_PROPERTY, oldValue, this.getChunkSize()); + } + + /** + * Set the conditions system tag. + * + * @param conditionsTag the conditions system tag + */ public void setConditionsTag(final String conditionsTag) { - final String oldValue = getConditionsTag(); + final String oldValue = this.getConditionsTag(); this.configuration.set(CONDITIONS_TAG_PROPERTY, conditionsTag); - firePropertyChange(CONDITIONS_TAG_PROPERTY, oldValue, getConditionsTag()); - } - + this.firePropertyChange(CONDITIONS_TAG_PROPERTY, oldValue, this.getConditionsTag()); + } + + /** + * Set a new configuration for the model which will fire property change events on all properties. + * + * @param configuration the configuration with properties for the model + */ public void setConfiguration(final Configuration configuration) { this.configuration = configuration; - fireModelChanged(); - } - + this.fireModelChanged(); + } + + /** + * Set the data source path which should be a valid EVIO or LCIO file on an accessible disk. + * + * @param dataSourcePath the data source path + */ public void setDataSourcePath(final String dataSourcePath) { - final String oldValue = getDataSourcePath(); + final String oldValue = this.getDataSourcePath(); this.configuration.set(DATA_SOURCE_PATH_PROPERTY, dataSourcePath); - firePropertyChange(DATA_SOURCE_PATH_PROPERTY, oldValue, getDataSourcePath()); - } - + this.firePropertyChange(DATA_SOURCE_PATH_PROPERTY, oldValue, this.getDataSourcePath()); + } + + /** + * Set the data source type + * + * @see + * @param dataSourceType + */ public void setDataSourceType(final DataSourceType dataSourceType) { - final DataSourceType oldValue = getDataSourceType(); + final DataSourceType oldValue = this.getDataSourceType(); this.configuration.set(DATA_SOURCE_TYPE_PROPERTY, dataSourceType); - firePropertyChange(DATA_SOURCE_TYPE_PROPERTY, oldValue, getDataSourceType()); - } - + this.firePropertyChange(DATA_SOURCE_TYPE_PROPERTY, oldValue, this.getDataSourceType()); + } + + /** + * Set the detector alias which is an alternate file path to use for the detector model instead of the one from jar. + * + * @param detectorAlias the detector alias + */ public void setDetectorAlias(final String detectorAlias) { String oldValue = null; - if (hasPropertyKey(DETECTOR_ALIAS_PROPERTY)) { - oldValue = getDetectorAlias(); + if (this.hasPropertyKey(DETECTOR_ALIAS_PROPERTY)) { + oldValue = this.getDetectorAlias(); } this.configuration.set(DETECTOR_ALIAS_PROPERTY, detectorAlias); - firePropertyChange(DETECTOR_ALIAS_PROPERTY, oldValue, getDetectorAlias()); - } - + this.firePropertyChange(DETECTOR_ALIAS_PROPERTY, oldValue, this.getDetectorAlias()); + } + + /** + * Set the detector to load from the detector model resources in the jar. + * <p> + * These are present in the jar accordin to the LCSim convension like: + * + * <pre> + * ${DETECTOR_NAME}/detector.properties + * </pre> + * + * @param detectorName the name of the detector name + */ public void setDetectorName(final String detectorName) { - final String oldValue = getDetectorName(); + final String oldValue = this.getDetectorName(); this.configuration.set(DETECTOR_NAME_PROPERTY, detectorName); - firePropertyChange(DETECTOR_NAME_PROPERTY, oldValue, getDetectorName()); - } - + this.firePropertyChange(DETECTOR_NAME_PROPERTY, oldValue, this.getDetectorName()); + } + + /** + * Set to <code>true</code> to disconnect when an EVIO END event is received. + * + * @param disconnectOnEndRun <code>true</code> to disconnect when an EVIO END event is received + */ public void setDisconnectOnEndRun(final Boolean disconnectOnEndRun) { - final Boolean oldValue = getDisconnectOnEndRun(); + final Boolean oldValue = this.getDisconnectOnEndRun(); this.configuration.set(DISCONNECT_ON_END_RUN_PROPERTY, disconnectOnEndRun); - firePropertyChange(DISCONNECT_ON_END_RUN_PROPERTY, oldValue, getDisconnectOnEndRun()); - } - + this.firePropertyChange(DISCONNECT_ON_END_RUN_PROPERTY, oldValue, this.getDisconnectOnEndRun()); + } + + /** + * Set to <code>true<code> to disconnect if event processing errors occur + * + * @param disconnectOnError set to <code>true</code> to disconnect if event processing errors occur + */ public void setDisconnectOnError(final Boolean disconnectOnError) { - final Boolean oldValue = getDisconnectOnError(); + final Boolean oldValue = this.getDisconnectOnError(); this.configuration.set(DISCONNECT_ON_ERROR_PROPERTY, disconnectOnError); - firePropertyChange(DISCONNECT_ON_ERROR_PROPERTY, oldValue, getDisconnectOnError()); - } - + this.firePropertyChange(DISCONNECT_ON_ERROR_PROPERTY, oldValue, this.getDisconnectOnError()); + } + + /** + * Set the name of the ET system which is usually a file. + * <p> + * Setting this to a valid file on disk being used by the ET server to buffer events will result in event processing + * speedup. + * + * @param etName the name of the ET system (usually a path on disk used as an event buffer by an ET server) + */ public void setEtName(final String etName) { - final String oldValue = getEtName(); + final String oldValue = this.getEtName(); this.configuration.set(ET_NAME_PROPERTY, etName); - firePropertyChange(ET_NAME_PROPERTY, oldValue, getEtName()); - } - + this.firePropertyChange(ET_NAME_PROPERTY, oldValue, this.getEtName()); + } + + /** + * Set the fully qualified class name of the {@link org.hps.record.LCSimEventBuilder} that should be used to build + * LCIO events from EVIO. + * + * @param eventBuilderClassName + */ public void setEventBuilderClassName(final String eventBuilderClassName) { - final String oldValue = getEventBuilderClassName(); + final String oldValue = this.getEventBuilderClassName(); this.configuration.set(EVENT_BUILDER_PROPERTY, eventBuilderClassName); - firePropertyChange(EVENT_BUILDER_PROPERTY, oldValue, getEventBuilderClassName()); - } - + this.firePropertyChange(EVENT_BUILDER_PROPERTY, oldValue, this.getEventBuilderClassName()); + } + + /** + * Set to <code>true</code> to freeze the conditions system after initialization if there is a valid detector name + * and run number setting + * + * @param freezeConditions <code>true</code> to freeze the conditions + */ public void setFreezeConditions(final Boolean freezeConditions) { Boolean oldValue = null; - if (hasPropertyKey(FREEZE_CONDITIONS_PROPERTY)) { - oldValue = getFreezeConditions(); + if (this.hasPropertyKey(FREEZE_CONDITIONS_PROPERTY)) { + oldValue = this.getFreezeConditions(); } this.configuration.set(FREEZE_CONDITIONS_PROPERTY, freezeConditions); - firePropertyChange(FREEZE_CONDITIONS_PROPERTY, oldValue, freezeConditions); - } - + this.firePropertyChange(FREEZE_CONDITIONS_PROPERTY, oldValue, freezeConditions); + } + + /** + * Set the ET TCP/IP host name of the server. + * + * @param host the host name + */ public void setHost(final String host) { - final String oldValue = getHost(); + final String oldValue = this.getHost(); this.configuration.set(HOST_PROPERTY, host); - firePropertyChange(HOST_PROPERTY, oldValue, getHost()); - } - + this.firePropertyChange(HOST_PROPERTY, oldValue, this.getHost()); + } + + /** + * Set the log file name if using file logging. + * + * @param logFileName the log file name + */ public void setLogFileName(final String logFileName) { - final String oldValue = getLogFileName(); + final String oldValue = this.getLogFileName(); this.configuration.set(LOG_FILE_NAME_PROPERTY, logFileName); - firePropertyChange(LOG_FILE_NAME_PROPERTY, oldValue, getLogFileName()); - } - + this.firePropertyChange(LOG_FILE_NAME_PROPERTY, oldValue, this.getLogFileName()); + } + + /** + * Set the global log level. + * + * @param level the global log level + */ public void setLogLevel(final Level level) { - final Level oldValue = getLogLevel(); + final Level oldValue = this.getLogLevel(); this.configuration.set(LOG_LEVEL_PROPERTY, level.getName()); - firePropertyChange(LOG_LEVEL_PROPERTY, oldValue, getLogLevel()); - } - + this.firePropertyChange(LOG_LEVEL_PROPERTY, oldValue, this.getLogLevel()); + } + + /** + * Set log filter level for the log table. + * + * @param level the log filter level + */ public void setLogLevelFilter(final Level level) { - final Level oldValue = getLogLevelFilter(); + final Level oldValue = this.getLogLevelFilter(); this.configuration.set(LOG_LEVEL_FILTER_PROPERTY, level.getName()); - firePropertyChange(LOG_LEVEL_FILTER_PROPERTY, oldValue, getLogLevelFilter()); - } - + this.firePropertyChange(LOG_LEVEL_FILTER_PROPERTY, oldValue, this.getLogLevelFilter()); + } + + /** + * Set to <code>true</code> to send global messages to a file instead of the console. + * + * @param logToFile <code>true</code> to log to file + */ public void setLogToFile(final Boolean logToFile) { - final Boolean oldValue = getLogToFile(); + final Boolean oldValue = this.getLogToFile(); this.configuration.set(LOG_TO_FILE_PROPERTY, logToFile); - firePropertyChange(LOG_TO_FILE_PROPERTY, oldValue, getLogToFile()); - } - + this.firePropertyChange(LOG_TO_FILE_PROPERTY, oldValue, this.getLogToFile()); + } + + /** + * + * @param maxEvents + */ public void setMaxEvents(final Long maxEvents) { - final Long oldValue = getMaxEvents(); + final Long oldValue = this.getMaxEvents(); this.configuration.set(MAX_EVENTS_PROPERTY, maxEvents); - firePropertyChange(MAX_EVENTS_PROPERTY, oldValue, getMaxEvents()); + this.firePropertyChange(MAX_EVENTS_PROPERTY, oldValue, this.getMaxEvents()); } public void setPort(final Integer port) { - final Integer oldValue = getPort(); + final Integer oldValue = this.getPort(); this.configuration.set(PORT_PROPERTY, port); - firePropertyChange(PORT_PROPERTY, oldValue, getPort()); + this.firePropertyChange(PORT_PROPERTY, oldValue, this.getPort()); } public void setPrescale(final Integer prescale) { - final Integer oldValue = getPrescale(); + final Integer oldValue = this.getPrescale(); this.configuration.set(PRESCALE_PROPERTY, prescale); - firePropertyChange(PRESCALE_PROPERTY, oldValue, getPrescale()); + this.firePropertyChange(PRESCALE_PROPERTY, oldValue, this.getPrescale()); } public void setProcessingStage(final ProcessingStage processingStage) { - final ProcessingStage oldValue = getProcessingStage(); + final ProcessingStage oldValue = this.getProcessingStage(); this.configuration.set(PROCESSING_STAGE_PROPERTY, processingStage); - firePropertyChange(PROCESSING_STAGE_PROPERTY, oldValue, getProcessingStage()); + this.firePropertyChange(PROCESSING_STAGE_PROPERTY, oldValue, this.getProcessingStage()); } public void setQueueSize(final Integer queueSize) { - final Integer oldValue = getQueueSize(); + final Integer oldValue = this.getQueueSize(); this.configuration.set(QUEUE_SIZE_PROPERTY, queueSize); - firePropertyChange(QUEUE_SIZE_PROPERTY, oldValue, getQueueSize()); + this.firePropertyChange(QUEUE_SIZE_PROPERTY, oldValue, this.getQueueSize()); } public void setRecentFiles(final String recentFiles) { @@ -442,7 +919,7 @@ oldValue = this.configuration.get(RECENT_FILES_PROPERTY); } this.configuration.set(RECENT_FILES_PROPERTY, recentFiles); - firePropertyChange(RECENT_FILES_PROPERTY, oldValue, this.configuration.get(RECENT_FILES_PROPERTY)); + this.firePropertyChange(RECENT_FILES_PROPERTY, oldValue, this.configuration.get(RECENT_FILES_PROPERTY)); } private void setRecentFilesList(final List<String> recentFilesList) { @@ -455,59 +932,59 @@ } public void setStationName(final String stationName) { - final String oldValue = getStationName(); + final String oldValue = this.getStationName(); this.configuration.set(STATION_NAME_PROPERTY, stationName); - firePropertyChange(STATION_NAME_PROPERTY, oldValue, getStationName()); + this.firePropertyChange(STATION_NAME_PROPERTY, oldValue, this.getStationName()); } public void setStationPosition(final Integer stationPosition) { - final Integer oldValue = getStationPosition(); + final Integer oldValue = this.getStationPosition(); this.configuration.set(STATION_POSITION_PROPERTY, stationPosition); - firePropertyChange(STATION_POSITION_PROPERTY, oldValue, getStationPosition()); + this.firePropertyChange(STATION_POSITION_PROPERTY, oldValue, this.getStationPosition()); } public void setSteeringFile(final String steeringFile) { - final String oldValue = getSteeringFile(); + final String oldValue = this.getSteeringFile(); this.configuration.set(STEERING_FILE_PROPERTY, steeringFile); - firePropertyChange(STEERING_FILE_PROPERTY, oldValue, getSteeringFile()); + this.firePropertyChange(STEERING_FILE_PROPERTY, oldValue, this.getSteeringFile()); } public void setSteeringResource(final String steeringResource) { - final String oldValue = getSteeringResource(); + final String oldValue = this.getSteeringResource(); this.configuration.set(STEERING_RESOURCE_PROPERTY, steeringResource); - firePropertyChange(STEERING_RESOURCE_PROPERTY, oldValue, steeringResource); + this.firePropertyChange(STEERING_RESOURCE_PROPERTY, oldValue, steeringResource); } public void setSteeringType(final SteeringType steeringType) { - final SteeringType oldValue = getSteeringType(); + final SteeringType oldValue = this.getSteeringType(); this.configuration.set(STEERING_TYPE_PROPERTY, steeringType.name()); - firePropertyChange(STEERING_TYPE_PROPERTY, oldValue, getSteeringType()); + this.firePropertyChange(STEERING_TYPE_PROPERTY, oldValue, this.getSteeringType()); } public void setUserRunNumber(final Integer userRunNumber) { Integer oldValue = null; - if (hasPropertyKey(USER_RUN_NUMBER_PROPERTY)) { - oldValue = getUserRunNumber(); + if (this.hasPropertyKey(USER_RUN_NUMBER_PROPERTY)) { + oldValue = this.getUserRunNumber(); } this.configuration.set(USER_RUN_NUMBER_PROPERTY, userRunNumber); - firePropertyChange(USER_RUN_NUMBER_PROPERTY, oldValue, getUserRunNumber()); + this.firePropertyChange(USER_RUN_NUMBER_PROPERTY, oldValue, this.getUserRunNumber()); } public void setVerbose(final Boolean verbose) { - final Boolean oldValue = getVerbose(); + final Boolean oldValue = this.getVerbose(); this.configuration.set(VERBOSE_PROPERTY, verbose); - firePropertyChange(VERBOSE_PROPERTY, oldValue, getVerbose()); + this.firePropertyChange(VERBOSE_PROPERTY, oldValue, this.getVerbose()); } public void setWaitMode(final Mode waitMode) { - final Mode oldValue = getWaitMode(); + final Mode oldValue = this.getWaitMode(); this.configuration.set(WAIT_MODE_PROPERTY, waitMode.name()); - firePropertyChange(WAIT_MODE_PROPERTY, oldValue, getWaitMode()); + this.firePropertyChange(WAIT_MODE_PROPERTY, oldValue, this.getWaitMode()); } public void setWaitTime(final Integer waitTime) { - final Integer oldValue = getWaitTime(); + final Integer oldValue = this.getWaitTime(); this.configuration.set(WAIT_TIME_PROPERTY, waitTime); - firePropertyChange(WAIT_TIME_PROPERTY, oldValue, getWaitTime()); + this.firePropertyChange(WAIT_TIME_PROPERTY, oldValue, this.getWaitTime()); } } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConnectionStatusModel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConnectionStatusModel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/ConnectionStatusModel.java Mon Apr 13 10:40:21 2015 @@ -14,7 +14,7 @@ public static final String CONNECTION_STATUS_PROPERTY = "ConnectionStatus"; public static final String PAUSED_PROPERTY = "Paused"; - static final String[] propertyNames = new String[] { CONNECTION_STATUS_PROPERTY, PAUSED_PROPERTY }; + static final String[] propertyNames = new String[] {CONNECTION_STATUS_PROPERTY, PAUSED_PROPERTY}; ConnectionStatus connectionStatus = ConnectionStatus.DISCONNECTED; boolean paused = false; @@ -47,7 +47,7 @@ public void setConnectionStatus(final ConnectionStatus connectionStatus) { final ConnectionStatus oldValue = connectionStatus; this.connectionStatus = connectionStatus; - for (final PropertyChangeListener listener : this.propertyChangeSupport.getPropertyChangeListeners()) { + for (final PropertyChangeListener listener : this.getPropertyChangeSupport().getPropertyChangeListeners()) { listener.propertyChange(new PropertyChangeEvent(this, CONNECTION_STATUS_PROPERTY, oldValue, this.connectionStatus)); } @@ -56,7 +56,7 @@ public void setPaused(final boolean paused) { final boolean oldValue = this.paused; this.paused = paused; - for (final PropertyChangeListener listener : this.propertyChangeSupport.getPropertyChangeListeners()) { + for (final PropertyChangeListener listener : this.getPropertyChangeSupport().getPropertyChangeListeners()) { listener.propertyChange(new PropertyChangeEvent(this, PAUSED_PROPERTY, oldValue, this.paused)); } } Modified: java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/HasConfigurationModel.java ============================================================================= --- java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/HasConfigurationModel.java (original) +++ java/trunk/monitoring-app/src/main/java/org/hps/monitoring/application/model/HasConfigurationModel.java Mon Apr 13 10:40:21 2015 @@ -9,14 +9,14 @@ /** * Get the current ConfigurationModel of the object. - * + * * @return The ConfigurationModel. */ ConfigurationModel getConfigurationModel(); /** * Set the ConfigurationModel of the object. - * + * * @param configurationModel The ConfigurationModel. */ void setConfigurationModel(ConfigurationModel configurationModel);