Changeset 24 in tmcsimulator
- Timestamp:
- 04/26/2016 07:26:04 AM (10 years ago)
- Location:
- trunk/src/tmcsim/cadsimulator/viewer
- Files:
-
- 2 edited
-
CADSimulatorViewer.java (modified) (4 diffs)
-
actions/ExitAction.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/tmcsim/cadsimulator/viewer/CADSimulatorViewer.java
r8 r24 3 3 import java.awt.AWTEvent; 4 4 import java.awt.Dimension; 5 import java.awt.event.ActionEvent; 6 import java.awt.event.KeyEvent; 5 7 import java.awt.event.WindowEvent; 6 7 8 import javax.swing.JFrame; 8 9 import javax.swing.JMenu; … … 11 12 import javax.swing.JOptionPane; 12 13 import javax.swing.JTabbedPane; 13 14 import javax.swing.KeyStroke; 14 15 import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate; 15 16 import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate; … … 20 21 21 22 /** 22 * This class provides a GUI to view current status information for the 23 * CADSimulator.23 * This class provides a GUI to view current status information for the CAD 24 * Simulator. 24 25 * 25 26 * @see SimulationStatusPanel 26 27 * @see MediaStatusPanel 27 * @author Matthew Cechini 28 * @author Matthew Cechini 28 29 * @version $Revision: 1.3 $ $Date: 2006/06/06 20:46:41 $ 29 30 */ 30 31 @SuppressWarnings("serial") 31 public class CADSimulatorViewer extends JFrame { 32 33 /** Panel to display simulation information. */ 32 public class CADSimulatorViewer extends JFrame 33 { 34 35 /** 36 * Panel to display simulation information. 37 */ 34 38 private SimulationStatusPanel simulationPanel; 35 36 /** Panel to display media control information. */ 39 /** 40 * Panel to display media control information. 41 */ 37 42 private MediaStatusPanel mediaPanel; 38 39 /** Constructor. */ 40 public CADSimulatorViewer() { 43 44 /** 45 * Constructor. 46 */ 47 public CADSimulatorViewer() 48 { 41 49 super("CAD Simulator"); 42 50 43 51 initComponents(); 44 } 45 46 /** 47 * @see SimulationStatusPanel 48 */ 49 public void connectClient() { 52 } 53 54 /** 55 * @see SimulationStatusPanel 56 */ 57 public void connectClient() 58 { 50 59 simulationPanel.connectClient(); 51 60 } 52 53 /** 54 * @see SimulationStatusPanel 55 */ 56 public void disconnectClient() { 61 62 /** 63 * @see SimulationStatusPanel 64 */ 65 public void disconnectClient() 66 { 57 67 simulationPanel.disconnectClient(); 58 68 } 59 60 /** 61 * @see SimulationStatusPanel 62 */ 63 public void setSimManagerStatus(boolean connection) { 64 simulationPanel.setSimManagerStatus(connection); 65 } 66 67 /** 68 * @see SimulationStatusPanel 69 */ 70 public void setTime(long seconds) { 69 70 /** 71 * @see SimulationStatusPanel 72 */ 73 public void setSimManagerStatus(boolean connection) 74 { 75 simulationPanel.setSimManagerStatus(connection); 76 } 77 78 /** 79 * @see SimulationStatusPanel 80 */ 81 public void setTime(long seconds) 82 { 71 83 simulationPanel.setTime(seconds); 72 84 } 73 85 74 /** 75 * @see SimulationStatusPanel 76 */ 77 public void setScriptStatus(SCRIPT_STATUS newStatus) { 78 simulationPanel.setScriptStatus(newStatus); 79 } 80 81 /** 82 * @see SimulationStatusPanel 83 */ 84 public void setParamicsStatus(PARAMICS_STATUS newStatus) { 85 simulationPanel.setParamicsStatus(newStatus); 86 } 87 88 /** 89 * @see SimulationStatusPanel 90 */ 91 public void setParamicsNetworkLoaded(String networkID) { 92 simulationPanel.setParamicsNetworkLoaded(networkID); 93 } 94 95 /** 86 /** 87 * @see SimulationStatusPanel 88 */ 89 public void setScriptStatus(SCRIPT_STATUS newStatus) 90 { 91 simulationPanel.setScriptStatus(newStatus); 92 } 93 94 /** 95 * @see SimulationStatusPanel 96 */ 97 public void setParamicsStatus(PARAMICS_STATUS newStatus) 98 { 99 simulationPanel.setParamicsStatus(newStatus); 100 } 101 102 /** 103 * @see SimulationStatusPanel 104 */ 105 public void setParamicsNetworkLoaded(String networkID) 106 { 107 simulationPanel.setParamicsNetworkLoaded(networkID); 108 } 109 110 /** 96 111 * @see MediaStatusPanel 97 112 */ 98 public void updateDVDStatus(DVDStatusUpdate update) { 113 public void updateDVDStatus(DVDStatusUpdate update) 114 { 99 115 mediaPanel.updateDVDStatus(update); 100 116 } 101 117 102 /** 118 /** 103 119 * @see MediaStatusPanel 104 120 */ 105 public void updateDVDTitle(DVDTitleUpdate update) { 121 public void updateDVDTitle(DVDTitleUpdate update) 122 { 106 123 mediaPanel.updateDVDTitle(update); 107 124 } 108 109 /** 110 * Method calls the processEvent() method with a WINDOW_CLOSING 111 * WindowEvent to start the application closing process. 112 */ 113 public void closeViewer() { 125 126 /** 127 * Method calls the processEvent() method with a WINDOW_CLOSING WindowEvent 128 * to start the application closing process. 129 */ 130 public void closeViewer() 131 { 114 132 processEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); 115 133 } 116 134 117 135 /** 118 * Overloads the processEvent method. If the AWTEvent is a 119 * WINDOW_CLOSING event, prompt the user to confirm the action. 120 * If confirmed, close the application. 121 */ 122 protected void processEvent(AWTEvent evt) { 123 124 if(evt.getID() == WindowEvent.WINDOW_CLOSING) { 136 * Overloads the processEvent method. If the AWTEvent is a WINDOW_CLOSING 137 * event, prompt the user to confirm the action. If confirmed, close the 138 * application. 139 */ 140 protected void processEvent(AWTEvent evt) 141 { 142 143 if (evt.getID() == WindowEvent.WINDOW_CLOSING) 144 { 125 145 int option = JOptionPane.showConfirmDialog(null, 126 "Closing the CAD Simulator will stop the current " +127 "simulation. Do you wish to continue exiting?",146 "Closing the CAD Simulator will stop the current " 147 + "simulation. Do you wish to continue exiting?", 128 148 "Confirm Exit", 129 149 JOptionPane.YES_NO_OPTION); 130 131 if(option != JOptionPane.NO_OPTION) { 150 151 if (option != JOptionPane.NO_OPTION) 152 { 132 153 System.exit(0); 133 } 154 } 134 155 } 135 } 136 137 /** Initialize GUI Components */ 138 private void initComponents() { 139 140 156 } 157 158 /** 159 * Initialize GUI Components 160 */ 161 private void initComponents() 162 { 163 164 141 165 simulationPanel = new SimulationStatusPanel(); 142 mediaPanel = new MediaStatusPanel();143 166 mediaPanel = new MediaStatusPanel(); 167 144 168 cadSimTabbedPane = new JTabbedPane(); 145 169 cadSimTabbedPane.addTab("Status", simulationPanel); 146 170 cadSimTabbedPane.addTab("Media", mediaPanel); 147 148 add(cadSimTabbedPane); 171 172 add(cadSimTabbedPane); 149 173 150 174 menubar = new JMenuBar(); 151 175 152 176 fileMenu = new JMenu("File"); 177 fileMenu.setMnemonic(KeyEvent.VK_F); 153 178 menubar.add(fileMenu); 154 179 155 180 exitMenuItem = new JMenuItem(new ExitAction(this)); 181 exitMenuItem.setAccelerator(KeyStroke.getKeyStroke( 182 KeyEvent.VK_X, ActionEvent.ALT_MASK)); 156 183 fileMenu.add(exitMenuItem); 157 184 158 185 javax.swing.JMenu helpMenu = new javax.swing.JMenu("Help"); 159 186 javax.swing.JMenuItem aboutItem = new javax.swing.JMenuItem("About"); … … 169 196 helpMenu.add(aboutItem); 170 197 menubar.add(helpMenu); 171 198 172 199 setJMenuBar(menubar); 173 174 setPreferredSize(new Dimension(500, 575)); 200 201 setPreferredSize(new Dimension(500, 575)); 175 202 pack(); 176 203 setResizable(false); 177 204 } 178 179 180 205 private JTabbedPane cadSimTabbedPane; 181 182 206 private JMenuBar menubar; 183 184 207 private JMenu fileMenu; 185 186 208 private JMenuItem exitMenuItem; 187 188 209 } -
trunk/src/tmcsim/cadsimulator/viewer/actions/ExitAction.java
r2 r24 2 2 3 3 import java.awt.event.ActionEvent; 4 5 4 import javax.swing.AbstractAction; 6 7 5 import tmcsim.cadsimulator.viewer.CADSimulatorViewer; 8 6 9 7 /** 10 * Abstract action to exit the CADSimulator. When the action is performed 11 * theCADSimulatorView.closeViewer() method is called.12 * 8 * Abstract action to exit the CADSimulator. When the action is performed the 9 * CADSimulatorView.closeViewer() method is called. 10 * 13 11 * @author Matthew Cechini 14 * @version 12 * @version 15 13 */ 16 14 @SuppressWarnings("serial") 17 public class ExitAction extends AbstractAction { 15 public class ExitAction extends AbstractAction 16 { 18 17 19 /** Reference to the CADSimulatorViewer. */ 18 /** 19 * Reference to the CADSimulatorViewer. 20 */ 20 21 private CADSimulatorViewer theViewer; 21 22 22 public ExitAction(CADSimulatorViewer viewer) { 23 public ExitAction(CADSimulatorViewer viewer) 24 { 23 25 super("Exit"); 24 26 25 27 theViewer = viewer; 26 28 } 27 28 public void actionPerformed(ActionEvent arg0) { 29 theViewer.closeViewer(); 29 30 public void actionPerformed(ActionEvent arg0) 31 { 32 //theViewer.closeViewer(); 33 /* closeViewer() will prompt the user for confirmation. 34 * 26 Apr 2016 I'm tired of seeing the confirmation message, 35 * so if the user chooses File>Exit, assume they intend to exit 36 * and don't ask for confirmation. If they click window close 37 * button, they will still get the confirmation prompt. jdalbey 38 */ 39 System.exit(0); 30 40 } 31 32 41 }
Note: See TracChangeset
for help on using the changeset viewer.
