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.experiment.Experiment;
18 import nl.tudelft.simulation.dsol.gui.DSOLApplicationInterface;
19 import nl.tudelft.simulation.dsol.simulators.SimulatorInterface;
20 import nl.tudelft.simulation.event.EventInterface;
21 import nl.tudelft.simulation.event.EventListenerInterface;
22
23 /***
24 * The ResetAction <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 ResetAction extends SimulatorAction implements
37 EventListenerInterface
38 {
39 /***
40 * constructs a new ShowGridAction
41 *
42 * @param application the application
43 */
44 public ResetAction(final DSOLApplicationInterface application)
45 {
46 super("reset", application);
47 this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass()
48 .getResource("/toolbarButtonGraphics/general/Undo16.gif")));
49 }
50
51 /***
52 * @see java.awt.event.ActionListener
53 * #actionPerformed(java.awt.event.ActionEvent)
54 */
55 public void actionPerformed(final ActionEvent event)
56 {
57 Experiment experiment = this.application.getExperiment();
58 experiment.reset();
59 }
60
61 /***
62 * @see nl.tudelft.simulation.event.EventListenerInterface
63 * #notify(nl.tudelft.simulation.event.EventInterface)
64 */
65 public void notify(final EventInterface event)
66 {
67 super.notify(event);
68 if (event.getType().equals(SimulatorInterface.START_EVENT))
69 {
70 this.setEnabled(false);
71 return;
72 }
73 if (event.getType().equals(SimulatorInterface.STOP_EVENT))
74 {
75 this.setEnabled(true);
76 return;
77 }
78 if (event.getSource() instanceof Experiment
79 && event.getType().equals(Experiment.END_OF_EXPERIMENT_EVENT))
80 {
81 this.setEnabled(true);
82 }
83 }
84 }