View Javadoc

1   /*
2    * @(#) ShowGridAction.java Oct 24, 2003
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
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 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 StopAction extends SimulatorAction implements
37  		EventListenerInterface
38  {
39  	/***
40  	 * constructs a new ShowGridAction
41  	 * 
42  	 * @param application the application
43  	 */
44  	public StopAction(final DSOLApplicationInterface application)
45  	{
46  		super("stop", application);
47  		this.putValue(Action.SMALL_ICON, new ImageIcon(this.getClass()
48  				.getResource("/toolbarButtonGraphics/media/Stop16.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  		try
58  		{
59  			super.simulator.stop();
60  		} catch (Exception exception)
61  		{
62  			Logger.warning(this, "actionPerformed", exception);
63  		}
64  	}
65  
66  	/***
67  	 * @see nl.tudelft.simulation.event.EventListenerInterface
68  	 *      #notify(nl.tudelft.simulation.event.EventInterface)
69  	 */
70  	public void notify(final EventInterface event)
71  	{
72  		super.notify(event);
73  		if (event.getType().equals(SimulatorInterface.START_EVENT))
74  		{
75  			this.setEnabled(true);
76  			return;
77  		}
78  		if (event.getType().equals(SimulatorInterface.STOP_EVENT))
79  		{
80  			this.setEnabled(false);
81  			return;
82  		}
83  	}
84  }