LISTSERV mailing list manager LISTSERV 16.5

Help for HPS-SVN Archives


HPS-SVN Archives

HPS-SVN Archives


HPS-SVN@LISTSERV.SLAC.STANFORD.EDU


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Proportional Font

LISTSERV Archives

LISTSERV Archives

HPS-SVN Home

HPS-SVN Home

HPS-SVN  March 2015

HPS-SVN March 2015

Subject:

r2263 - in /java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring: ./ application/

From:

[log in to unmask]

Reply-To:

Notification of commits to the hps svn repository <[log in to unmask]>

Date:

Thu, 5 Mar 2015 18:14:37 -0000

Content-Type:

text/plain

Parts/Attachments:

Parts/Attachments

text/plain (357 lines)

Author: [log in to unmask]
Date: Thu Mar  5 10:14:30 2015
New Revision: 2263

Log:
More updates to monitoring branch.

Removed:
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/DataSourcePanel.java
Modified:
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/Main.java
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/Commands.java
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/ConnectionStatusPanel.java
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/DataSourceComboBox.java
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationActionListener.java
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java
    java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/SettingsPanel.java

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/Main.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/Main.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/Main.java	Thu Mar  5 10:14:30 2015
@@ -16,7 +16,6 @@
 /**
  * This is the front-end for running the monitoring app via a {@link #main(String[])} method.
  */
-// FIXME: Move to org.hps.monitoring instead of gui package.
 public class Main {
 
     public static void main(String[] args) {
@@ -49,54 +48,5 @@
         }        
         
         MonitoringApplication.create(configuration);
-    }
-    
-    /**
-     * Run the monitoring application from the command line.
-     * @param args The command line arguments.
-     */
-    /*
-    public static void main(String[] args) {
-
-        // Set up command line parsing.
-        Options options = new Options();
-        options.addOption(new Option("h", false, "Print help."));
-        options.addOption(new Option("c", true, "Load a properties file with configuration parameters."));
-        CommandLineParser parser = new PosixParser();
-
-        // Parse command line arguments.
-        final CommandLine cl;
-        try {
-            cl = parser.parse(options, args);
-        } catch (ParseException e) {
-            throw new RuntimeException("Problem parsing command line options.", e);
-        }
-
-        // Print help and exit.
-        if (cl.hasOption("h")) {
-            HelpFormatter help = new HelpFormatter();
-            help.printHelp(" ", options);
-            System.exit(1);
-        }
-
-        // Run the application on the Swing EDT.
-        SwingUtilities.invokeLater(new Runnable() {
-            public void run() {
-
-                // Create the application class.
-                MonitoringApplication app = new MonitoringApplication();
-
-                // Load the connection settings.
-                if (cl.hasOption("c")) {
-                    app.setConfiguration(new Configuration(new File(cl.getOptionValue("c"))));
-                }
-
-                app.initialize();
-
-                // Set the app to be visible.
-                app.setVisible(true);
-            }
-        });
-    }
-    */
+    }    
 }

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/Commands.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/Commands.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/Commands.java	Thu Mar  5 10:14:30 2015
@@ -12,11 +12,10 @@
     static final String SETTINGS_SHOW = "settingsShow";
     static final String OPEN_FILE = "openFile";
     
+    static final String DATA_SOURCE_CHANGED = "dataSourceChanged";
 
     ////////////////////////////////////////////
     
-    static final String AIDA_AUTO_SAVE = "aidaAutoSave";
-    static final String AIDA_AUTO_SAVE_CHANGED = "aidaAutoSaveChanged";
     static final String BLOCKING_CHANGED = "blockingChanged";
     static final String CHOOSE_COMPACT_FILE = "chooseCompactFile";
     static final String CHOOSE_LOG_FILE = "chooseLogFile";

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/ConnectionStatusPanel.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/ConnectionStatusPanel.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/ConnectionStatusPanel.java	Thu Mar  5 10:14:30 2015
@@ -14,7 +14,6 @@
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
 
 import org.hps.monitoring.application.model.ConnectionStatusModel;
 

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/DataSourceComboBox.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/DataSourceComboBox.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/DataSourceComboBox.java	Thu Mar  5 10:14:30 2015
@@ -1,6 +1,7 @@
 package org.hps.monitoring.application;
 
 import java.awt.Dimension;
+import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -9,6 +10,7 @@
 import javax.swing.JComboBox;
 
 import org.hps.monitoring.application.DataSourceComboBox.DataSourceItem;
+import org.hps.monitoring.application.model.ConfigurationModel;
 import org.hps.monitoring.application.model.ConnectionStatusModel;
 import org.hps.record.enums.DataSourceType;
 
@@ -17,22 +19,33 @@
  * @author Jeremy McCormick <[log in to unmask]>
  *
  */
-public class DataSourceComboBox extends JComboBox<DataSourceItem> implements PropertyChangeListener {
+public class DataSourceComboBox extends JComboBox<DataSourceItem> implements PropertyChangeListener, ActionListener {
 
     ConnectionStatusModel connectionModel;
+    ConfigurationModel configurationModel;
     
-    DataSourceComboBox(ConnectionStatusModel connectionModel, ActionListener listener) {
+    DataSourceComboBox(
+            ConfigurationModel configurationModel, 
+            ConnectionStatusModel connectionModel, 
+            ActionListener listener) {
         addActionListener(listener);
-        setPreferredSize(new Dimension(400, this.getPreferredSize().height));        
-        this.connectionModel = connectionModel;
+        setActionCommand(Commands.DATA_SOURCE_CHANGED);
+        setPreferredSize(new Dimension(400, this.getPreferredSize().height));
+        setEditable(false);
         connectionModel.addPropertyChangeListener(this);
+        configurationModel.addPropertyChangeListener(this);
+        this.configurationModel = configurationModel;
     }
     
     public void addItem(DataSourceItem item) {
         // Do not add duplicates.
-        if (((DefaultComboBoxModel<DataSourceItem>)getModel()).getIndexOf(item) == -1) {
+        if (!contains(item)) {
             super.addItem(item);
         }
+    }
+    
+    boolean contains(DataSourceItem item) {
+        return ((DefaultComboBoxModel<DataSourceItem>)getModel()).getIndexOf(item) != -1;
     }
     
     static class DataSourceItem {
@@ -42,6 +55,7 @@
         
         DataSourceItem(String name, DataSourceType type) {
             this.type = type;
+            this.name = name;
         }
         
         public String toString() {
@@ -70,6 +84,71 @@
            } else {
                setEnabled(false);
            }
-       }
+       } else if (evt.getPropertyName().equals(ConfigurationModel.DATA_SOURCE_PATH_PROPERTY)) {     
+           System.out.println("data source path property changed");
+           addDataSourceItem();
+       } 
     }         
-}
+    
+    public void actionPerformed(ActionEvent evt) {
+        if (evt.getActionCommand().equals(Commands.DATA_SOURCE_CHANGED)) {
+            try {
+                configurationModel.removePropertyChangeListener(this);
+                DataSourceItem item = (DataSourceItem) getSelectedItem();
+                configurationModel.setDataSourceType(item.type);
+                if (item.type != DataSourceType.ET_SERVER) {
+                    configurationModel.setDataSourcePath(item.name);
+                }
+            } finally {
+                configurationModel.addPropertyChangeListener(this);
+            }
+        }
+    }
+    
+    void addDataSourceItem() {
+                        
+        DataSourceType type = configurationModel.getDataSourceType();
+        String path = configurationModel.getDataSourcePath();
+                
+        // Remove an existing ET item in case the settings have changed.
+        if (hasEtItem()) {            
+            removeEtItem();
+        }
+        
+        // Always make sure there is an ET server available as a data source.
+        addItem(new DataSourceItem(getEtName(), DataSourceType.ET_SERVER));
+        
+        // Add a data source for a file.
+        if (!type.equals(DataSourceType.ET_SERVER)) {
+            DataSourceItem newItem = new DataSourceItem(path, type);
+            if (!contains(newItem)) {
+                addItem(newItem);
+                setSelectedItem(newItem);
+            }
+        }       
+    }
+    
+    void removeEtItem() {
+        for (int i=0; i<this.getItemCount(); i++) {
+            DataSourceItem item = this.getItemAt(i);
+            if (item.type == DataSourceType.ET_SERVER) {
+                this.removeItem(item);
+                break;
+            }
+        }
+    }
+    
+    boolean hasEtItem() {
+        for (int i=0; i<this.getItemCount(); i++) {
+            DataSourceItem item = this.getItemAt(i);
+            if (item.type == DataSourceType.ET_SERVER) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    String getEtName() {
+        return configurationModel.getEtName() + "@" + configurationModel.getHost() + ":" + configurationModel.getPort();
+    }
+}

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationActionListener.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationActionListener.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationActionListener.java	Thu Mar  5 10:14:30 2015
@@ -59,6 +59,7 @@
 
         String cmd = e.getActionCommand();
         if (CONNECT.equals(cmd)) {
+            // FIXME: Can the application run this in a separate thread instead?
             // Run the start session method on a separate thread.
             new Thread() {
                 public void run() {

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java	Thu Mar  5 10:14:30 2015
@@ -81,7 +81,11 @@
         topPanel.add(sep);
         
         // Add the data source combo box.
-        JComboBox<DataSourceItem> dataSourceComboBox = new DataSourceComboBox(application.connectionModel, application.actionListener);
+        JComboBox<DataSourceItem> dataSourceComboBox = 
+                new DataSourceComboBox(
+                        application.configurationModel, 
+                        application.connectionModel, 
+                        application.actionListener);
         topPanel.add(dataSourceComboBox);
         
         // Create the bottom panel.

Modified: java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/SettingsPanel.java
 =============================================================================
--- java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/SettingsPanel.java	(original)
+++ java/branches/monitoring-app-HPSJAVA-442/src/main/java/org/hps/monitoring/application/SettingsPanel.java	Thu Mar  5 10:14:30 2015
@@ -22,7 +22,6 @@
     JTabbedPane tabs;
     JobSettingsPanel jobPanel;
     ConnectionSettingsPanel connectionPanel;
-    DataSourcePanel dataSourcePanel;
     static final String OKAY_COMMAND = "settingsOkay";
 
     JDialog parent;
@@ -33,33 +32,25 @@
         
         connectionPanel = new ConnectionSettingsPanel();        
         jobPanel = new JobSettingsPanel();
-        dataSourcePanel = new DataSourcePanel();
         
         // Push configuration to sub-components.
         connectionPanel.setConfigurationModel(configurationModel);
         jobPanel.setConfigurationModel(configurationModel);
-        dataSourcePanel.setConfigurationModel(configurationModel);
         
         // Add ActionListener to sub-components.
         connectionPanel.addActionListener(listener);
         jobPanel.addActionListener(listener);
-        dataSourcePanel.addActionListener(listener);
                
         this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
 
         tabs = new JTabbedPane();
         tabs.addTab("Connection Settings", connectionPanel);
         tabs.addTab("Job Settings", jobPanel);
-        tabs.addTab("Data Source", dataSourcePanel);
         add(tabs);
 
         JButton okayButton = new JButton("Okay");
         okayButton.setActionCommand(OKAY_COMMAND);
         okayButton.addActionListener(this);
-
-        //defaultsButton = new JButton("Defaults");
-        //defaultsButton.setActionCommand(Commands.LOAD_DEFAULT_SETTINGS);
-        //defaultsButton.addActionListener(this);
 
         add(Box.createRigidArea(new Dimension(1, 5)));
         JPanel buttonsPanel = new JPanel();
@@ -70,18 +61,6 @@
         add(Box.createRigidArea(new Dimension(1, 5)));
     }
 
-    ConnectionSettingsPanel getConnectionPanel() {
-        return connectionPanel;
-    }
-
-    JobSettingsPanel getJobSettingsPanel() {
-        return jobPanel;
-    }
-
-    DataSourcePanel getDataSourcePanel() {
-        return dataSourcePanel;
-    }
-
     @Override
     public void actionPerformed(ActionEvent e) {
         if (e.getActionCommand().equals(OKAY_COMMAND)) {

Top of Message | Previous Page | Permalink

Advanced Options


Options

Log In

Log In

Get Password

Get Password


Search Archives

Search Archives


Subscribe or Unsubscribe

Subscribe or Unsubscribe


Archives

November 2017
August 2017
July 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013

ATOM RSS1 RSS2



LISTSERV.SLAC.STANFORD.EDU

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager

Privacy Notice, Security Notice and Terms of Use