diff options
| author | Paul Buetow <paul@buetow.org> | 2008-06-01 22:45:59 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-06-01 22:45:59 +0000 |
| commit | 293c73f50f87b3d73d3947a9f79430b23ec4ddba (patch) | |
| tree | 129ece28dcda9d17bb6e0fc417d8b25bb82dac4c /sources/simulator/VSSimulatorFrame.java | |
| parent | 8086082daaed71ee9105c156e3a1e8e63caf1990 (diff) | |
better serialization
Diffstat (limited to 'sources/simulator/VSSimulatorFrame.java')
| -rw-r--r-- | sources/simulator/VSSimulatorFrame.java | 76 |
1 files changed, 40 insertions, 36 deletions
diff --git a/sources/simulator/VSSimulatorFrame.java b/sources/simulator/VSSimulatorFrame.java index f5ef5af..aff8787 100644 --- a/sources/simulator/VSSimulatorFrame.java +++ b/sources/simulator/VSSimulatorFrame.java @@ -33,6 +33,7 @@ import javax.swing.event.*; import core.*; import prefs.*; import prefs.editors.*; +import serialize.*; import utils.*; /** @@ -42,7 +43,7 @@ import utils.*; * * @author Paul C. Buetow */ -public class VSSimulatorFrame extends VSFrame implements Serializable { +public class VSSimulatorFrame extends VSFrame { /** The serial version uid */ private static final long serialVersionUID = 1L; @@ -143,6 +144,22 @@ public class VSSimulatorFrame extends VSFrame implements Serializable { dispose(); } else if (sourceText.equals( + finalPrefs.getString("lang.open"))) { + + VSSerialize serialize = new VSSerialize(); + VSSimulator simulator = serialize.openSimulator( + VSSerialize.STANDARD_FILENAME, + VSSimulatorFrame.this); + addSimulator(simulator); + + } else if (sourceText.equals( + finalPrefs.getString("lang.save"))) { + + VSSerialize serialize = new VSSerialize(); + serialize.saveSimulator(VSSerialize.STANDARD_FILENAME, + currentSimulator); + + } else if (sourceText.equals( finalPrefs.getString("lang.about"))) { new VSAbout(finalPrefs, VSSimulatorFrame.this); @@ -253,6 +270,28 @@ public class VSSimulatorFrame extends VSFrame implements Serializable { menuItem.addActionListener(actionListener); menuFile.add(menuItem); + menuFile.addSeparator(); + + menuItem = new JMenuItem(prefs.getString("lang.open")); + menuItem.setAccelerator(KeyStroke.getKeyStroke( + prefs.getInteger("keyevent.open"), + ActionEvent.ALT_MASK)); + menuItem.addActionListener(actionListener); + menuFile.add(menuItem); + + menuItem = new JMenuItem(prefs.getString("lang.save")); + menuItem.setAccelerator(KeyStroke.getKeyStroke( + prefs.getInteger("keyevent.save"), + ActionEvent.ALT_MASK)); + menuItem.addActionListener(actionListener); + menuFile.add(menuItem); + + menuItem = new JMenuItem(prefs.getString("lang.saveas")); + menuItem.setAccelerator(KeyStroke.getKeyStroke( + prefs.getInteger("keyevent.saveas"), + ActionEvent.ALT_MASK)); + menuItem.addActionListener(actionListener); + menuFile.add(menuItem); menuFile.addSeparator(); @@ -508,39 +547,4 @@ public class VSSimulatorFrame extends VSFrame implements Serializable { return new ImageIcon(imageURL, descr); } - - /** - * Write object. - * - * @param objectOutputStream the object output stream - * - * @throws IOException Signals that an I/O exception has occurred. - */ - public synchronized void writeObject(ObjectOutputStream objectOutputStream) - throws IOException { - objectOutputStream.writeObject(currentSimulator); - } - - /** - * Read object. - * - * @param objectInputStream the object input stream - * - * @throws IOException Signals that an I/O exception has occurred. - * @throws ClassNotFoundException the class not found exception - */ - @SuppressWarnings("unchecked") - public synchronized void readObject(ObjectInputStream objectInputStream) - throws IOException, ClassNotFoundException { - if (VSDeserializationHelper.DEBUG) - System.out.println("Deserializing: VSSimulatorFrame"); - - VSDeserializationHelper.init(); - VSDeserializationHelper.setObject("simulatorFrame", this); - - currentSimulator = (VSSimulator) objectInputStream.readObject(); - - VSDeserializationHelper.destroy(); - addSimulator(currentSimulator); - } } |
