Changeset 44 in tmcsimulator for trunk/src/tmcsim/cadsimulator/viewer/CADSimulatorViewer.java
- Timestamp:
- 06/23/2016 06:30:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/viewer/CADSimulatorViewer.java
r36 r44 6 6 import java.awt.event.KeyEvent; 7 7 import java.awt.event.WindowEvent; 8 import java.io.IOException; 9 import java.util.Observable; 10 import java.util.Properties; 11 import java.util.logging.Level; 12 import java.util.logging.Logger; 8 13 import javax.swing.JFrame; 9 14 import javax.swing.JMenu; … … 13 18 import javax.swing.JTabbedPane; 14 19 import javax.swing.KeyStroke; 15 import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate;16 import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate;17 20 import tmcsim.cadsimulator.viewer.actions.ExitAction; 18 import tmcsim.c ommon.CADEnums.PARAMICS_STATUS;19 import tmcsim.c ommon.CADEnums.SCRIPT_STATUS;20 import tmcsim. common.RevisionNumber;21 import tmcsim.cadsimulator.viewer.model.CADMediaStatus; 22 import tmcsim.cadsimulator.viewer.model.CADSimulatorStatus; 23 import tmcsim.interfaces.CADViewer; 21 24 22 25 /** … … 30 33 */ 31 34 @SuppressWarnings("serial") 32 public class CADSimulatorViewer extends JFrame 35 public class CADSimulatorViewer extends JFrame implements CADViewer 33 36 { 34 37 … … 45 48 */ 46 49 private ConfigStatusPanel configPanel; 50 47 51 /** 48 52 * Constructor. 49 53 */ 50 51 54 public CADSimulatorViewer() 52 55 { 53 super("CAD Simulator"); 56 super(); 57 setTitle("CAD Simulator " + getAppVersion()); 54 58 55 59 initComponents(); … … 57 61 58 62 /** 59 * @see SimulationStatusPanel 63 * Read the version number from the application properties. The file 64 * 'application.properties' is generated by build.xml. 65 * 66 * @return a version string obtained from application.properties file, or 67 * "Version: unknown" if an IOerror prevents us from reading the file. 60 68 */ 61 p ublic void connectClient()69 private String getAppVersion() 62 70 { 63 simulationPanel.connectClient(); 64 } 65 66 /** 67 * @see SimulationStatusPanel 68 */ 69 public void disconnectClient() 70 { 71 simulationPanel.disconnectClient(); 72 } 73 74 /** 75 * @see SimulationStatusPanel 76 */ 77 public void setSimManagerStatus(boolean connection) 78 { 79 simulationPanel.setSimManagerStatus(connection); 80 } 81 82 /** 83 * @see SimulationStatusPanel 84 */ 85 public void setTime(long seconds) 86 { 87 simulationPanel.setTime(seconds); 88 } 89 90 /** 91 * @see SimulationStatusPanel 92 */ 93 public void setScriptStatus(SCRIPT_STATUS newStatus) 94 { 95 simulationPanel.setScriptStatus(newStatus); 96 } 97 98 /** 99 * @see SimulationStatusPanel 100 */ 101 public void setParamicsStatus(PARAMICS_STATUS newStatus) 102 { 103 simulationPanel.setParamicsStatus(newStatus); 104 } 105 106 /** 107 * @see SimulationStatusPanel 108 */ 109 public void setParamicsNetworkLoaded(String networkID) 110 { 111 simulationPanel.setParamicsNetworkLoaded(networkID); 112 } 113 114 /** 115 * @see MediaStatusPanel 116 */ 117 public void updateDVDStatus(DVDStatusUpdate update) 118 { 119 mediaPanel.updateDVDStatus(update); 120 } 121 122 /** 123 * @see MediaStatusPanel 124 */ 125 public void updateDVDTitle(DVDTitleUpdate update) 126 { 127 mediaPanel.updateDVDTitle(update); 71 String propfilename = "/tmcsim/application.properties"; 72 String propKey = "Application.revision"; 73 String version = "unknown"; 74 try 75 { 76 Properties props = new Properties(); 77 props.load(this.getClass().getResourceAsStream(propfilename)); 78 version = (String) props.get(propKey); 79 } catch (IOException ex) 80 { 81 Logger.getLogger("tmcsim/cadsimulator").log(Level.SEVERE, 82 "CADSimulatorView.getAppVersion()", 83 "IOError reading " + propfilename); 84 } 85 return "revision: " + version; 128 86 } 129 87 … … 147 105 if (evt.getID() == WindowEvent.WINDOW_CLOSING) 148 106 { 149 int option = JOptionPane.showConfirmDialog(null,150 "Closing the CAD Simulator will stop the current "151 + "simulation. Do you wish to continue exiting?",152 "Confirm Exit",153 JOptionPane.YES_NO_OPTION);154 155 if (option != JOptionPane.NO_OPTION)156 {157 System.exit(0);158 }107 // int option = JOptionPane.showConfirmDialog(null, 108 // "Closing the CAD Simulator will stop the current " 109 // + "simulation. Do you wish to continue exiting?", 110 // "Confirm Exit", 111 // JOptionPane.YES_NO_OPTION); 112 // 113 // if (option != JOptionPane.NO_OPTION) 114 // { 115 System.exit(0); 116 // } 159 117 } 160 118 } … … 196 154 public void actionPerformed(java.awt.event.ActionEvent evt) 197 155 { 198 String ver = RevisionNumber.getString();156 String ver = "";//RevisionNumber.getString(); 199 157 JOptionPane.showMessageDialog(rootPane, "Version: " + ver, "About", JOptionPane.INFORMATION_MESSAGE); 200 158 } … … 208 166 pack(); 209 167 setResizable(true); 168 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 210 169 } 211 170 private JTabbedPane cadSimTabbedPane; … … 213 172 private JMenu fileMenu; 214 173 private JMenuItem exitMenuItem; 174 175 @Override 176 public void update(Observable obs, Object obj) 177 { 178 if (obs instanceof CADSimulatorStatus) 179 { 180 simulationPanel.refresh(obs); 181 } 182 if (obs instanceof CADMediaStatus) 183 { 184 mediaPanel.refresh(obs); 185 } 186 } 215 187 }
Note: See TracChangeset
for help on using the changeset viewer.
