View Javadoc

1   package nl.tudelft.simulation.introspection.mapping;
2   
3   import java.awt.Component;
4   
5   import javax.swing.AbstractCellEditor;
6   import javax.swing.JComponent;
7   import javax.swing.JTable;
8   import javax.swing.table.TableCellEditor;
9   
10  import nl.tudelft.simulation.introspection.gui.ExpandButton;
11  import nl.tudelft.simulation.logger.Logger;
12  
13  /***
14   * Implements the pop-up behaviour of the {see
15   * nl.tudelft.simulation.introspection.gui.ExpandButton}.
16   * <p>
17   * (c) copyright 2002-2005 <a href="http://www.simulation.tudelft.nl">Delft
18   * University of Technology </a>, the Netherlands. <br>
19   * See for project information <a
20   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
21   * License of use: <a href="http://www.gnu.org/copyleft/lesser.html">Lesser
22   * General Public License (LGPL) </a>, no warranty.
23   * 
24   * @author <a href="http://www.peter-jacobs.com/index.htm">Peter Jacobs </a>
25   * @version 1.2 Apr 15, 2004
26   * @since 1.5
27   */
28  public class ExpandButtonEditor extends AbstractCellEditor implements
29          TableCellEditor
30  {
31      /*** the value */
32      private JComponent value;
33  
34      /***
35       * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(JTable,
36       *      Object, boolean, int, int)
37       */
38      public Component getTableCellEditorComponent(final JTable table,
39              final Object value, final boolean isSelected, final int row,
40              final int column)
41      {
42          if (value instanceof ExpandButton)
43          {
44              ((ExpandButton) value).setMyJTable(table);
45          } else
46          {
47              Logger
48                      .warning(this, "getTableCellEditorComponent",
49                              "Expected value to be an ExpandButton, but found: "
50                                      + value);
51          }
52          return (Component) value;
53      }
54  
55      /***
56       * @see javax.swing.CellEditor#getCellEditorValue()
57       */
58      public Object getCellEditorValue()
59      {
60          return this.value;
61      }
62  }