- Timestamp:
- 07/18/2019 08:20:12 AM (7 years ago)
- Location:
- trunk/src/tmcsim
- Files:
-
- 6 edited
-
application.properties (modified) (1 diff)
-
cadsimulator/CADServer.java (modified) (2 diffs)
-
cadsimulator/viewer/CADConsoleViewer.java (modified) (1 diff)
-
cadsimulator/viewer/CADServerViewer.java (modified) (2 diffs)
-
cadsimulator/viewer/ConfigStatusTab.form (modified) (1 diff)
-
cadsimulator/viewer/ConfigStatusTab.java (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/application.properties
r448 r455 1 #T ue, 16 Jul 2019 08:06:49-07001 #Thu, 18 Jul 2019 09:49:25 -0700 2 2 3 Application.revision=4 473 Application.revision=453 4 4 5 Application.buildnumber=16 05 Application.buildnumber=165 -
trunk/src/tmcsim/cadsimulator/CADServer.java
r448 r455 3 3 import java.io.File; 4 4 import java.io.FileInputStream; 5 import java.lang.reflect.Constructor; 5 6 import java.rmi.Naming; 6 7 import java.rmi.RemoteException; … … 239 240 { 240 241 Class uiClass = Class.forName(userInterfaceName); 241 theViewer = (CADViewer) uiClass.newInstance(); 242 Constructor<?> cons = uiClass.getConstructor(String.class); 243 theViewer = (CADViewer) cons.newInstance(propertiesFile); 242 244 } catch (Exception exc) 243 245 { -
trunk/src/tmcsim/cadsimulator/viewer/CADConsoleViewer.java
r123 r455 36 36 * Constructor. 37 37 */ 38 public CADConsoleViewer( )38 public CADConsoleViewer(String propertiesFile) 39 39 { 40 40 display = new PrintWriter(System.out, true); -
trunk/src/tmcsim/cadsimulator/viewer/CADServerViewer.java
r365 r455 58 58 */ 59 59 private TrafficModelViewPanel trafficPanel; 60 /* 61 * Name of propertes file for this run of CAD Server. 62 */ 63 private String propertiesFile; 60 64 61 65 /** 62 66 * Constructor. 63 67 */ 64 public CADServerViewer( )68 public CADServerViewer(String propertiesFile) 65 69 { 66 70 super(); 71 this.propertiesFile = propertiesFile; 67 72 setTitle("CAD Server " + RevisionNumber.getAppVersion()); 68 73 … … 111 116 simulationPanel = new SimulationStatusPanel(); 112 117 mediaPanel = new MediaStatusPanel(); 113 configPanel = new ConfigStatusTab( );118 configPanel = new ConfigStatusTab(propertiesFile); 114 119 trafficPanel = new TrafficModelViewPanel(); 115 120 -
trunk/src/tmcsim/cadsimulator/viewer/ConfigStatusTab.form
r231 r455 18 18 <SubComponents> 19 19 <Component class="javax.swing.JComboBox" name="selectMenu"> 20 <Properties>21 <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">22 <StringArray count="5">23 <StringItem index="0" value="cad_simulator_config.properties"/>24 <StringItem index="1" value="cad_simulator_media_config.properties"/>25 <StringItem index="2" value="cad_simulator_paramics_config.properties"/>26 <StringItem index="3" value="cad_simulator_smoketest_config.properties"/>27 <StringItem index="4" value="traffic_model_config.properties"/>28 </StringArray>29 </Property>30 </Properties>31 20 <AuxValues> 32 21 <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/> -
trunk/src/tmcsim/cadsimulator/viewer/ConfigStatusTab.java
r231 r455 7 7 import java.io.FileInputStream; 8 8 import java.io.FileNotFoundException; 9 import java.io.IOException; 9 10 import java.nio.file.FileSystems; 10 11 import java.nio.file.Path; 12 import java.util.Properties; 11 13 import java.util.Scanner; 14 import java.util.logging.Level; 15 import java.util.logging.Logger; 12 16 import javax.swing.JComboBox; 13 17 import javax.swing.JFrame; … … 16 20 /** 17 21 * ConfigStatusPanel displays the content of configuration files. 22 * A ComboBox allows the user to select from a list of current properties files. 18 23 * 19 24 * @author Drew Miller … … 22 27 public class ConfigStatusTab extends javax.swing.JPanel 23 28 { 24 /** Root config directory name */ 25 private String configDir; 26 29 /** 30 * Properties file for the CAD Server. 31 */ 32 private Properties cadServerProperties; 33 27 34 /** 28 35 * Creates new form 29 36 */ 30 public ConfigStatusTab( )37 public ConfigStatusTab(String propertiesFile) 31 38 { 32 39 initComponents(); 33 if (System.getProperty("CONFIG_DIR") == null) 34 { 35 System.setProperty("CONFIG_DIR", "config"); 36 } 37 configDir = System.getProperty("CONFIG_DIR"); 38 setupComboBox(); 40 createMenu(propertiesFile); 41 addMenuListener(); 39 42 setupTextView(); 40 43 } 44 /** Add the properties filenames to the combobox menu */ 45 private void createMenu(String propertiesFile) 46 { 47 selectMenu.addItem(propertiesFile); 48 try { 49 cadServerProperties = new Properties(); 50 cadServerProperties.load(new FileInputStream(propertiesFile)); 51 // Add each item that's a properties file to the menu 52 for (String propname: cadServerProperties.stringPropertyNames()) 53 { 54 String currVal = (String) cadServerProperties.get(propname); 55 if (currVal.endsWith(".properties")) 56 { 57 selectMenu.addItem(currVal); 58 } 59 } 60 } catch (FileNotFoundException ex) { 61 Logger.getLogger(ConfigStatusTab.class.getName()).log(Level.SEVERE, null, ex); 62 } catch (IOException ex) { 63 Logger.getLogger(ConfigStatusTab.class.getName()).log(Level.SEVERE, null, ex); 64 } 65 } 41 66 67 /** Determine complete path to file, given the filename */ 68 private Path getPathToFile(String fileName) 69 { 70 return FileSystems.getDefault().getPath(fileName); 71 } 72 /** Return the text from the given file */ 42 73 private String getFileContent(Path pathToFile) 43 74 { … … 54 85 return "Error: config file not found."; 55 86 } 56 57 87 } 58 59 private Path getPathToFile(String fileName) 60 { 61 Path p = FileSystems.getDefault().getPath(configDir, fileName); 62 return p; 63 } 64 /** Refresh the display using the given config file */ 88 /** Refresh the display using the given properties file path */ 65 89 private void updateDisplay(Path pathToFileName) 66 90 { … … 69 93 } 70 94 71 /** Combo Box with names of config files for user to select*/72 private void setupComboBox()95 /** Add menu listener to the Combo Box */ 96 private void addMenuListener() 73 97 { 74 98 selectMenu.addActionListener(new ActionListener() … … 76 100 public void actionPerformed(ActionEvent e) 77 101 { 102 // Find which menu item was clicked 78 103 JComboBox src = (JComboBox) e.getSource(); 79 Path p = getPathToFile(src.getSelectedItem().toString()); 104 // Get the menu item string 105 String menuItem = src.getSelectedItem().toString(); 106 // Get the path to that file 107 Path p = getPathToFile(menuItem); 108 // Display the contents of that file 80 109 updateDisplay(p); 81 110 } 82 83 111 }); 84 112 } … … 89 117 view.setLineWrap(true); 90 118 view.setWrapStyleWord(true); 91 // Initial ize withfirst config file in list119 // Initially display the first config file in list 92 120 Path path = getPathToFile(selectMenu.getItemAt(0)); 93 121 view.setText(getFileContent(path)); … … 104 132 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 105 133 frame.setSize(1050, 450); 106 ConfigStatusTab pnl = new ConfigStatusTab( );134 ConfigStatusTab pnl = new ConfigStatusTab("config/cad_simulator_config.properties"); 107 135 frame.add(pnl); 108 136 frame.setVisible(true); … … 115 143 @SuppressWarnings("unchecked") 116 144 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 117 private void initComponents() 118 { 145 private void initComponents() { 119 146 120 147 selectMenu = new javax.swing.JComboBox<>(); … … 123 150 124 151 setLayout(new java.awt.BorderLayout()); 125 126 selectMenu.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "cad_simulator_config.properties", "cad_simulator_media_config.properties", "cad_simulator_paramics_config.properties", "cad_simulator_smoketest_config.properties", "traffic_model_config.properties" }));127 152 add(selectMenu, java.awt.BorderLayout.PAGE_START); 128 153
Note: See TracChangeset
for help on using the changeset viewer.
