View Javadoc

    1   /*
    2    * @(#) DeleteRowAction.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   * DeleteRowAction <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 DeleteRowAction extends AbstractAction
    34  {
    35  	/*** target of the chartpanel */
    36  	private ChartPanel target = null;
    37
    38  	/***
    39  	 * constructs a new DeleteRowAction
    40  	 *
    41  	 * @param target the target
    42  	 */
    43  	public DeleteRowAction(final ChartPanel target)
    44  	{
    45  		super("DeleteRow");
    46  		this.target = target;
    47  		this.putValue(Action.SMALL_ICON, new ImageIcon(URLResource
    48  				.getResource("/toolbarButtonGraphics/table/RowDelete24.gif")));
    49  		this.setEnabled(true);
    50  	}
    51
    52  	/***
    53  	 * @see java.awt.event.ActionListener
    54  	 *      #actionPerformed(java.awt.event.ActionEvent)
    55  	 */
    56  	public void actionPerformed(final ActionEvent actionEvent)
    57  	{
    58  		new Worker(this.target).start();
    59  	}
    60
    61  	/*** SimulatorRunThread extends Thread */
    62  	private class Worker extends Thread
    63  	{
    64  		/*** the source */
    65  		private ChartPanel target = null;
    66
    67  		/***
    68  		 * constructs a new
    69  		 *
    70  		 * @param target the target
    71  		 */
    72  		public Worker(final ChartPanel target)
    73  		{
    74  			this.target = target;
    75  		}
    76
    77  		/***
    78  		 * @see java.lang.Runnable#run()
    79  		 */
    80  		public void run()
    81  		{
    82  			synchronized (this.target)
    83  			{
    84  				this.target.deleteRow();
    85  			}
    86  		}
    87  	}
    88  }