1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.gui.menu.actions;
11
12 import java.awt.event.ActionEvent;
13 import java.awt.event.KeyEvent;
14
15 import javax.swing.AbstractAction;
16 import javax.swing.Action;
17 import javax.swing.KeyStroke;
18
19 import nl.tudelft.simulation.dsol.gui.DSOLApplicationInterface;
20 import nl.tudelft.simulation.dsol.gui.editor2D.Editor2DFrame;
21 import nl.tudelft.simulation.logger.Logger;
22
23 /***
24 * The ViewAnimationAction action <br>
25 * (c) copyright 2003 <a href="http://www.simulation.tudelft.nl">Delft
26 * University of Technology </a>, the Netherlands. <br>
27 * See for project information <a
28 * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
29 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
30 * License (GPL) </a>, no warranty <br>
31 *
32 * @version 1.0 18.10.2003 <br>
33 * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
34 * Jacobs </a>
35 */
36 public class ViewEditor2DPanelAction extends AbstractAction
37 {
38 /*** application the application */
39 private DSOLApplicationInterface application = null;
40
41 /***
42 * constructs a new ViewContextAction
43 *
44 * @param application the application
45 */
46 public ViewEditor2DPanelAction(final DSOLApplicationInterface application)
47 {
48 super("Animation Editor 2D");
49 this.application = application;
50 this.putValue(Action.MNEMONIC_KEY, new Integer('E'));
51 this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
52 KeyEvent.VK_F6, 0));
53 this.setEnabled(true);
54 }
55
56 /***
57 * @see java.awt.event.ActionListener
58 * #actionPerformed(java.awt.event.ActionEvent)
59 */
60 public void actionPerformed(final ActionEvent actionEvent)
61 {
62 try
63 {
64 boolean running = false;
65 try
66 {
67 if (this.application.getExperiment().getSimulator().isRunning())
68 {
69 running = true;
70 this.application.getExperiment().getSimulator().stop();
71 }
72 } catch (NullPointerException nullPointerException)
73 {
74
75 nullPointerException = null;
76 }
77 new Editor2DFrame(ViewEditor2DPanelAction.this.application);
78 if (running)
79 {
80 this.application.getExperiment().getSimulator().start();
81 }
82 } catch (Exception exception)
83 {
84 Logger.warning(this, "actionPerformed", exception);
85 }
86 }
87 }