Fix most warnings from GCJ
[jpcrr.git] / org / jpc / plugins / PCStartStopTest.java
blob49c599a4a84249b4b187f1da5c95914762429dbf
1 /*
2 JPC-RR: A x86 PC Hardware Emulator
3 Release 1
5 Copyright (C) 2007-2009 Isis Innovation Limited
6 Copyright (C) 2009 H. Ilari Liusvaara
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 2 as published by
10 the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Based on JPC x86 PC Hardware emulator,
22 A project from the Physics Dept, The University of Oxford
24 Details about original JPC can be found at:
26 www-jpc.physics.ox.ac.uk
30 package org.jpc.plugins;
32 import java.awt.event.ActionEvent;
33 import java.awt.event.ActionListener;
34 import java.security.AccessControlException;
35 import javax.swing.*;
37 import org.jpc.pluginsbase.Plugins;
38 import org.jpc.pluginsbase.Plugin;
39 import org.jpc.emulator.PC;
40 import org.jpc.emulator.peripheral.Keyboard;
41 import static org.jpc.Misc.errorDialog;
42 import static org.jpc.Misc.moveWindow;
44 public class PCStartStopTest extends JFrame implements Plugin
46 private static final long serialVersionUID = 8;
47 private Plugins vPluginManager;
48 private Keyboard keyboard;
50 public boolean systemShutdown()
52 //Not interested (JVM kill ok)
53 return true;
56 public void reconnect(PC pc)
58 if(pc != null) {
59 keyboard = (Keyboard)pc.getComponent(Keyboard.class);
60 } else {
61 keyboard = null;
65 public void pcStarting()
67 //Not interested.
70 public void pcStopping()
72 //Not interested.
75 public void main()
77 //Not interested.
80 public void connectPC(PC pc)
82 //Not interested.
85 public void eci_pcstartstoptest_setwinpos(Integer x, Integer y)
87 moveWindow(this, x.intValue(), y.intValue(), 720, 50);
91 public PCStartStopTest(Plugins manager) throws Exception
93 super("Control test");
95 this.vPluginManager = manager;
97 JMenuBar bar = new JMenuBar();
98 JMenuItem tmp;
100 JMenu file = new JMenu("Action");
101 (tmp = file.add("Vretrace start trap on")).addActionListener(new ActionListener() {
102 public void actionPerformed(ActionEvent e)
104 vPluginManager.invokeExternalCommand("trap-vretrace-start-on", null);
107 tmp.setAccelerator(KeyStroke.getKeyStroke("3"));
109 (tmp = file.add("Vretrace start trap off")).addActionListener(new ActionListener() {
110 public void actionPerformed(ActionEvent e)
112 vPluginManager.invokeExternalCommand("trap-vretrace-start-off", null);
115 tmp.setAccelerator(KeyStroke.getKeyStroke("4"));
117 (tmp = file.add("Start")).addActionListener(new ActionListener() {
118 public void actionPerformed(ActionEvent e)
120 vPluginManager.invokeExternalCommand("pc-start", null);
123 tmp.setAccelerator(KeyStroke.getKeyStroke("5"));
125 (tmp = file.add("Stop")).addActionListener(new ActionListener() {
126 public void actionPerformed(ActionEvent e)
128 vPluginManager.invokeExternalCommand("pc-stop", null);
131 tmp.setAccelerator(KeyStroke.getKeyStroke("6"));
133 (tmp = file.add("Send <Left> Edge")).addActionListener(new ActionListener() {
134 public void actionPerformed(ActionEvent e)
136 try {
137 keyboard.sendEdge(128 + 75);
138 } catch(Exception f) {
139 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
143 tmp.setAccelerator(KeyStroke.getKeyStroke("J"));
145 (tmp = file.add("Send <Down> Edge")).addActionListener(new ActionListener() {
146 public void actionPerformed(ActionEvent e)
148 try {
149 keyboard.sendEdge(128 + 80);
150 } catch(Exception f) {
151 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
155 tmp.setAccelerator(KeyStroke.getKeyStroke("K"));
157 (tmp = file.add("Send <Right> Edge")).addActionListener(new ActionListener() {
158 public void actionPerformed(ActionEvent e)
160 try {
161 keyboard.sendEdge(128 + 77);
162 } catch(Exception f) {
163 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
167 tmp.setAccelerator(KeyStroke.getKeyStroke("L"));
169 (tmp = file.add("Send <Up> Edge")).addActionListener(new ActionListener() {
170 public void actionPerformed(ActionEvent e)
172 try {
173 keyboard.sendEdge(128 + 72);
174 } catch(Exception f) {
175 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
179 tmp.setAccelerator(KeyStroke.getKeyStroke("I"));
181 (tmp = file.add("Send <Enter> Edge")).addActionListener(new ActionListener() {
182 public void actionPerformed(ActionEvent e)
184 try {
185 keyboard.sendEdge(28);
186 } catch(Exception f) {
187 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
191 tmp.setAccelerator(KeyStroke.getKeyStroke("M"));
193 (tmp = file.add("Send <Escape> Edge")).addActionListener(new ActionListener() {
194 public void actionPerformed(ActionEvent e)
196 try {
197 keyboard.sendEdge(1);
198 } catch(Exception f) {
199 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
203 tmp.setAccelerator(KeyStroke.getKeyStroke("N"));
205 (tmp = file.add("Send <RShift> Edge")).addActionListener(new ActionListener() {
206 public void actionPerformed(ActionEvent e)
208 try {
209 keyboard.sendEdge(54);
210 } catch(Exception f) {
211 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
215 tmp.setAccelerator(KeyStroke.getKeyStroke("B"));
217 (tmp = file.add("Send <RCTRL> Edge")).addActionListener(new ActionListener() {
218 public void actionPerformed(ActionEvent e)
220 try {
221 keyboard.sendEdge(128 + 29);
222 } catch(Exception f) {
223 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
227 tmp.setAccelerator(KeyStroke.getKeyStroke("V"));
229 (tmp = file.add("Send <RALT> Edge")).addActionListener(new ActionListener() {
230 public void actionPerformed(ActionEvent e)
232 try {
233 keyboard.sendEdge(128 + 56);
234 } catch(Exception f) {
235 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
239 tmp.setAccelerator(KeyStroke.getKeyStroke("C"));
241 (tmp = file.add("Send <SPACE> Edge")).addActionListener(new ActionListener() {
242 public void actionPerformed(ActionEvent e)
244 try {
245 keyboard.sendEdge(57);
246 } catch(Exception f) {
247 errorDialog(f, "Failed to send keyboard event", null, "Dismiss");
251 tmp.setAccelerator(KeyStroke.getKeyStroke("X"));
253 bar.add(file);
255 JMenu save = new JMenu("Save");
256 for(int i = 1; i <= 12; i++) {
257 final int i2 = i;
258 (tmp = save.add("Save slot #" + i)).addActionListener(new ActionListener() {
259 public void actionPerformed(ActionEvent e)
261 try {
262 vPluginManager.invokeExternalCommand("state-save", new String[]{"saveslot-" + i2 + ".jrsr"});
263 } catch(Exception f) {
264 errorDialog(f, "Failed to save state", null, "Dismiss");
268 tmp.setAccelerator(KeyStroke.getKeyStroke("F" + i));
270 (tmp = save.add("Load slot #" + i)).addActionListener(new ActionListener() {
271 public void actionPerformed(ActionEvent e)
273 try {
274 vPluginManager.invokeExternalCommand("state-load", new String[]{"saveslot-" + i2 + ".jrsr"});
275 } catch(Exception f) {
276 errorDialog(f, "Failed to load state", null, "Dismiss");
280 tmp.setAccelerator(KeyStroke.getKeyStroke("shift F" + i));
283 bar.add(save);
284 setJMenuBar(bar);
288 setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
290 catch (AccessControlException e)
292 System.err.println("Error: Not able to add some components to frame: " + e.getMessage());
295 setBounds(150, 150, 720, 50);
296 validate();
297 setVisible(true);