1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.dsol.gui.actions;
11
12 import java.awt.event.ActionEvent;
13
14 import javax.swing.Action;
15 import javax.swing.ImageIcon;
16
17 import nl.tudelft.simulation.dsol.gui.DSOLApplicationInterface;
18 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
19 import nl.tudelft.simulation.event.EventInterface;
20 import nl.tudelft.simulation.event.EventListenerInterface;
21 import nl.tudelft.simulation.logger.Logger;
22
23 /***
24 * The StopAction <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 StopAction extends SimulatorAction implements
36 EventListenerInterface
37 {
38 /***
39 * constructs a new ShowGridAction
40 *
41 * @param application the application
42 */
43 public StopAction(final DSOLApplicationInterface application)
44 {
45 super("stop", application);
46 this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass()
47 .getResource("/toolbarButtonGraphics/media/Stop16.gif")));
48 }
49
50 /***
51 * @see java.awt.event.ActionListener
52 * #actionPerformed(java.awt.event.ActionEvent)
53 */
54 public void actionPerformed(final ActionEvent event)
55 {
56 try
57 {
58 super.simulator.stop();
59 } catch (Exception exception)
60 {
61 Logger.warning(this, "actionPerformed", exception);
62 }
63 }
64
65 /***
66 * @see nl.tudelft.simulation.event.EventListenerInterface
67 * #notify(nl.tudelft.simulation.event.EventInterface)
68 */
69 public void notify(final EventInterface event)
70 {
71 super.notify(event);
72 if (event.getType().equals(SimulatorInterface.START_EVENT))
73 {
74 this.setEnabled(true);
75 return;
76 }
77 if (event.getType().equals(SimulatorInterface.STOP_EVENT))
78 {
79 this.setEnabled(false);
80 return;
81 }
82 }
83 }