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.windows.EventlistFrame;
21 import nl.tudelft.simulation.logger.Logger;
22
23 /***
24 * The ViewEventlist action <br>
25 * (c) copyright 2002-2005 <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/lesser.html">Lesser
30 * General Public License (LGPL) </a>, no warranty.
31 *
32 * @version $Revision$ $Date$
33 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja">Peter Jacobs </a>
34 */
35 public class ViewEventlistAction extends AbstractAction
36 {
37 /*** application the application */
38 private DSOLApplicationInterface application = null;
39
40 /***
41 * constructs a new ViewContextAction
42 *
43 * @param application the application
44 */
45 public ViewEventlistAction(final DSOLApplicationInterface application)
46 {
47 super("Eventlist");
48 this.application = application;
49 this.putValue(Action.MNEMONIC_KEY, new Integer('E'));
50 this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
51 KeyEvent.VK_F4, 0));
52 this.setEnabled(true);
53 }
54
55 /***
56 * @see java.awt.event.ActionListener
57 * #actionPerformed(java.awt.event.ActionEvent)
58 */
59 public void actionPerformed(final ActionEvent actionEvent)
60 {
61 try
62 {
63 boolean running = false;
64 try
65 {
66 if (this.application.getExperiment().getSimulator().isRunning())
67 {
68 running = true;
69 this.application.getExperiment().getSimulator().stop();
70 }
71 } catch (NullPointerException nullPointerException)
72 {
73
74 nullPointerException = null;
75 }
76 new EventlistFrame(this.application);
77 if (running)
78 {
79 this.application.getExperiment().getSimulator().start();
80 }
81 } catch (Exception exception)
82 {
83 Logger.warning(this, "actionPerformed", exception);
84 }
85 }
86 }