Class CompositeCellEditor<T>

  • Type Parameters:
    T - class of the table cell value
    All Implemented Interfaces:
    java.io.Serializable, javax.swing.CellEditor, javax.swing.table.TableCellEditor

    public abstract class CompositeCellEditor<T>
    extends javax.swing.AbstractCellEditor
    implements javax.swing.table.TableCellEditor
    Base class for Cell editors with multiple input fields. This class handles the keyboard navigation between the fields. For compatibility with ChangeBufferTableModel, editing is performed on a copy of the table cell value.
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class javax.swing.AbstractCellEditor

        changeEvent, listenerList
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected CompositeCellEditor​(java.util.function.Function<T,​T> copyFunction)  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addFields​(javax.swing.JComponent... fields)
      Add nested input fields for the table cell editor.
      T getCellEditorValue()  
      protected abstract int getInitialFocus()  
      java.awt.Component getTableCellEditorComponent​(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int column)
      Creates a copy of the table cell value and initializes the input fields.
      protected abstract void prepareEditor​(javax.swing.JTable table, T value, boolean isSelected, int row, int column)
      Initializes the nested input fields based on the table cell value.
      protected abstract void updateCellEditorValue​(T bean)
      Updates the bean with the field values of the editor.
      • Methods inherited from class javax.swing.AbstractCellEditor

        addCellEditorListener, cancelCellEditing, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.CellEditor

        addCellEditorListener, cancelCellEditing, isCellEditable, removeCellEditorListener, shouldSelectCell, stopCellEditing
    • Constructor Detail

      • CompositeCellEditor

        protected CompositeCellEditor​(java.util.function.Function<T,​T> copyFunction)
        Parameters:
        copyFunction - a function used to create a copy of the table cell value for editing
    • Method Detail

      • addFields

        protected void addFields​(javax.swing.JComponent... fields)
        Add nested input fields for the table cell editor.
      • getTableCellEditorComponent

        public java.awt.Component getTableCellEditorComponent​(javax.swing.JTable table,
                                                              java.lang.Object value,
                                                              boolean isSelected,
                                                              int row,
                                                              int column)
        Creates a copy of the table cell value and initializes the input fields.
        Specified by:
        getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
      • getInitialFocus

        protected abstract int getInitialFocus()
        Returns:
        the index of the nested input field to receive focus when editing starts.
      • prepareEditor

        protected abstract void prepareEditor​(javax.swing.JTable table,
                                              T value,
                                              boolean isSelected,
                                              int row,
                                              int column)
        Initializes the nested input fields based on the table cell value.
      • getCellEditorValue

        public T getCellEditorValue()
        Specified by:
        getCellEditorValue in interface javax.swing.CellEditor