View Javadoc
1   package nl.tudelft.simulation.dsol.swing.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 org.djutils.logger.CategoryLogger;
11  
12  import nl.tudelft.simulation.dsol.swing.introspection.gui.ExpandButton;
13  
14  /**
15   * Implements the pop-up behaviour of the {see nl.tudelft.simulation.introspection.gui.ExpandButton}.
16   * <p>
17   * Copyright (c) 2002-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
18   * for project information <a href="https://simulation.tudelft.nl/" target="_blank"> https://simulation.tudelft.nl</a>. The DSOL
19   * project is distributed under a three-clause BSD-style license, which can be found at
20   * <a href="https://https://simulation.tudelft.nl/dsol/docs/latest/license.html" target="_blank">
21   * https://https://simulation.tudelft.nl/dsol/docs/latest/license.html</a>.
22   * </p>
23   * @author <a href="https://www.linkedin.com/in/peterhmjacobs">Peter Jacobs</a>.
24   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>.
25   * @author Niels Lang.
26   * @since 1.5
27   */
28  public class ExpandButtonEditor extends AbstractCellEditor implements TableCellEditor
29  {
30      /** */
31      private static final long serialVersionUID = 20140831L;
32  
33      /** the value. */
34      private JComponent component;
35  
36      /** {@inheritDoc} */
37      @Override
38      public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected,
39              final int row, final int column)
40      {
41          if (value instanceof ExpandButton)
42          {
43              ((ExpandButton) value).setMyJTable(table);
44          }
45          else
46          {
47              CategoryLogger.always().warn("getTableCellEditorComponent: Expected value to be an ExpandButton, but found: {}",
48                      value);
49          }
50          return (Component) value;
51      }
52  
53      /** {@inheritDoc} */
54      @Override
55      public Object getCellEditorValue()
56      {
57          return this.component;
58      }
59  }