View Javadoc

1   /*
2    * @(#) AddRowAction.java Oct 29, 2003
3    * 
4    * Copyright (c) 2002-2005 Delft University of Technology Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the Lesser General Public License
9    */
10  package nl.tudelft.simulation.dsol.gui.statistics.actions;
11  
12  import java.awt.event.ActionEvent;
13  
14  import javax.swing.AbstractAction;
15  import javax.swing.Action;
16  import javax.swing.ImageIcon;
17  
18  import nl.tudelft.simulation.dsol.gui.statistics.ChartPanel;
19  import nl.tudelft.simulation.language.io.URLResource;
20  
21  /***
22   * AddRowAction <br>
23   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
24   * University of Technology </a>, the Netherlands. <br>
25   * See for project information <a href="http://www.simulation.tudelft.nl">
26   * www.simulation.tudelft.nl </a> <br>
27   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
28   * General Public License (LGPL) </a>, no warranty.
29   * 
30   * @version 1.1 05.11.2003 <br>
31   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja">Peter Jacobs </a>
32   */
33  public class AddRowAction extends AbstractAction
34  {
35  	/*** target of the chartpanel */
36  	private ChartPanel target = null;
37  
38  	/***
39  	 * constructs a new AddRowAction
40  	 * 
41  	 * @param target the target
42  	 */
43  	public AddRowAction(final ChartPanel target)
44  	{
45  		super("AddRow");
46  		this.target = target;
47  		this
48  				.putValue(
49  						Action.SMALL_ICON,
50  						new ImageIcon(
51  								URLResource
52  										.getResource("/toolbarButtonGraphics/table/RowInsertAfter24.gif")));
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  		new Worker(this.target).start();
63  	}
64  
65  	/*** SimulatorRunThread extends Thread */
66  	private class Worker extends Thread
67  	{
68  		/*** the source */
69  		private ChartPanel target = null;
70  
71  		/***
72  		 * constructs a new
73  		 * 
74  		 * @param target the target
75  		 */
76  		public Worker(final ChartPanel target)
77  		{
78  			this.target = target;
79  		}
80  
81  		/***
82  		 * @see java.lang.Runnable#run()
83  		 */
84  		public void run()
85  		{
86  			synchronized (this.target)
87  			{
88  				this.target.addRow();
89  			}
90  		}
91  	}
92  }