source: tmcsimulator/trunk/src/tmcsim/cadsimulator/viewer/CADSimulatorViewer.java @ 8

Revision 8, 5.1 KB checked in by bokumura, 10 years ago (diff)

Added about item to help menu. About item contains current revision information.

Line 
1package tmcsim.cadsimulator.viewer;
2
3import java.awt.AWTEvent;
4import java.awt.Dimension;
5import java.awt.event.WindowEvent;
6
7import javax.swing.JFrame;
8import javax.swing.JMenu;
9import javax.swing.JMenuBar;
10import javax.swing.JMenuItem;
11import javax.swing.JOptionPane;
12import javax.swing.JTabbedPane;
13
14import tmcsim.cadsimulator.videocontrol.DVDStatusUpdate;
15import tmcsim.cadsimulator.videocontrol.DVDTitleUpdate;
16import tmcsim.cadsimulator.viewer.actions.ExitAction;
17import tmcsim.common.CADEnums.PARAMICS_STATUS;
18import tmcsim.common.CADEnums.SCRIPT_STATUS;
19import tmcsim.common.RevisionNumber;
20
21/**
22 * This class provides a GUI to view current status information for the
23 * CAD Simulator.
24 *
25 * @see SimulationStatusPanel
26 * @see MediaStatusPanel
27 * @author Matthew Cechini
28 * @version $Revision: 1.3 $ $Date: 2006/06/06 20:46:41 $
29 */
30@SuppressWarnings("serial")
31public class CADSimulatorViewer extends JFrame {
32
33    /** Panel to display simulation information. */
34    private SimulationStatusPanel simulationPanel;
35   
36    /** Panel to display media control information. */
37    private MediaStatusPanel mediaPanel;
38   
39    /** Constructor. */
40    public CADSimulatorViewer() {
41        super("CAD Simulator");
42       
43        initComponents();
44    }   
45   
46    /**
47     * @see SimulationStatusPanel
48     */
49    public void connectClient() {
50        simulationPanel.connectClient();
51    }
52   
53    /**
54     * @see SimulationStatusPanel
55     */
56    public void disconnectClient() {
57        simulationPanel.disconnectClient();
58    }
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) {
71        simulationPanel.setTime(seconds);
72    }
73
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    /**
96     * @see MediaStatusPanel
97     */
98    public void updateDVDStatus(DVDStatusUpdate update) {
99        mediaPanel.updateDVDStatus(update);
100    }
101
102    /**
103     * @see MediaStatusPanel
104     */
105    public void updateDVDTitle(DVDTitleUpdate update) {
106        mediaPanel.updateDVDTitle(update);
107    }
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() {
114        processEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
115    }
116
117    /**
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) {
125            int option = JOptionPane.showConfirmDialog(null,
126                    "Closing the CAD Simulator will stop the current " +
127                    "simulation.  Do you wish to continue exiting?",
128                    "Confirm Exit",
129                    JOptionPane.YES_NO_OPTION);
130           
131            if(option != JOptionPane.NO_OPTION) {
132                System.exit(0);
133            }       
134        }
135     }
136   
137    /** Initialize GUI Components */
138    private void initComponents() {
139
140       
141        simulationPanel = new SimulationStatusPanel();
142        mediaPanel      = new MediaStatusPanel();
143       
144        cadSimTabbedPane = new JTabbedPane();
145        cadSimTabbedPane.addTab("Status", simulationPanel);
146        cadSimTabbedPane.addTab("Media", mediaPanel);
147       
148        add(cadSimTabbedPane);     
149
150        menubar = new JMenuBar();
151       
152        fileMenu = new JMenu("File");
153        menubar.add(fileMenu);
154       
155        exitMenuItem = new JMenuItem(new ExitAction(this));
156        fileMenu.add(exitMenuItem);
157       
158        javax.swing.JMenu helpMenu = new javax.swing.JMenu("Help");
159        javax.swing.JMenuItem aboutItem = new javax.swing.JMenuItem("About");
160
161        aboutItem.addActionListener(new java.awt.event.ActionListener()
162        {
163            public void actionPerformed(java.awt.event.ActionEvent evt)
164            {
165                String ver = RevisionNumber.getString();
166                JOptionPane.showMessageDialog(rootPane, "Version: " + ver, "About", JOptionPane.INFORMATION_MESSAGE);
167            }
168        });
169        helpMenu.add(aboutItem);
170        menubar.add(helpMenu);
171       
172        setJMenuBar(menubar);
173       
174        setPreferredSize(new Dimension(500, 575)); 
175        pack();
176        setResizable(false);
177    }
178   
179   
180    private JTabbedPane cadSimTabbedPane;
181   
182    private JMenuBar menubar;
183   
184    private JMenu fileMenu;
185   
186    private JMenuItem exitMenuItem;
187   
188}
Note: See TracBrowser for help on using the repository browser.