Class DefaultEventTableModel<E>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected EventList<E> source
      the source of data for this TableModel, which may or may not be #swingThreadSource
      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected DefaultEventTableModel​(EventList<E> source, boolean disposeSource, TableFormat<? super E> tableFormat)
      Creates a new table model that extracts column data from the given source using the the given tableFormat.
        DefaultEventTableModel​(EventList<E> source, TableFormat<? super E> tableFormat)
      Creates a new table model that extracts column data from the given source using the the given tableFormat.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispose()
      Releases the resources consumed by this AdvancedTableModel so that it may eventually be garbage collected.
      java.lang.Class getColumnClass​(int columnIndex)
      Gets the class of elements in the specified column.
      int getColumnCount()
      Get the column count as specified by the table format.
      java.lang.String getColumnName​(int column)
      Fetch the name for the specified column.
      E getElementAt​(int index)
      Retrieves the value at the specified location from the table.
      protected MutableTableModelEvent getMutableTableModelEvent()  
      int getRowCount()
      The number of rows equals the number of entries in the source event list.
      TableFormat<? super E> getTableFormat()
      Gets the TableFormat used by this table model.
      java.lang.Object getValueAt​(int row, int column)
      Retrieves the value at the specified location of the table.
      protected void handleListChange​(ListEvent<E> listChanges)
      Default implementation for converting a ListEvent to TableModelEvents.
      boolean isCellEditable​(int row, int column)
      Delegates the question of whether the cell is editable or not to the backing TableFormat if it is a WritableTableFormat.
      void listChanged​(ListEvent<E> listChanges)
      For implementing the ListEventListener interface.
      void setTableFormat​(TableFormat<? super E> tableFormat)
      Sets the TableFormat that will extract column data from each element.
      void setValueAt​(java.lang.Object editedValue, int row, int column)
      Attempts to update the object for the given row with the editedValue.
      • Methods inherited from class javax.swing.table.AbstractTableModel

        addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
      • Methods inherited from class java.lang.Object

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

        addTableModelListener, removeTableModelListener
    • Field Detail

      • source

        protected EventList<E> source
        the source of data for this TableModel, which may or may not be #swingThreadSource
    • Constructor Detail

      • DefaultEventTableModel

        public DefaultEventTableModel​(EventList<E> source,
                                      TableFormat<? super E> tableFormat)
        Creates a new table model that extracts column data from the given source using the the given tableFormat.
        Parameters:
        source - the EventList that provides the row objects
        tableFormat - the object responsible for extracting column data from the row objects
      • DefaultEventTableModel

        protected DefaultEventTableModel​(EventList<E> source,
                                         boolean disposeSource,
                                         TableFormat<? super E> tableFormat)
        Creates a new table model that extracts column data from the given source using the the given tableFormat.
        Parameters:
        source - the EventList that provides the row objects
        diposeSource - true if the source list should be disposed when disposing this model, false otherwise
        tableFormat - the object responsible for extracting column data from the row objects
    • Method Detail

      • setTableFormat

        public void setTableFormat​(TableFormat<? super E> tableFormat)
        Sets the TableFormat that will extract column data from each element. This has some very important consequences. Any cell selections will be lost - this is due to the fact that the TableFormats may have different numbers of columns, and JTable has no event to specify columns changing without rows.
        Specified by:
        setTableFormat in interface AdvancedTableModel<E>
      • getElementAt

        public E getElementAt​(int index)
        Retrieves the value at the specified location from the table.

        This may be used by renderers to paint the cells of a row differently based on the entire value for that row.

        Specified by:
        getElementAt in interface AdvancedTableModel<E>
        See Also:
        TableModel.getValueAt(int,int)
      • handleListChange

        protected void handleListChange​(ListEvent<E> listChanges)
        Default implementation for converting a ListEvent to TableModelEvents. There will be one TableModelEvent per ListEvent block. Subclasses may choose to implement a different conversion.
        Parameters:
        listChanges - ListEvent to translate
      • getMutableTableModelEvent

        protected final MutableTableModelEvent getMutableTableModelEvent()
        Returns:
        reusable TableModelEvent for broadcasting changes
      • getColumnName

        public java.lang.String getColumnName​(int column)
        Fetch the name for the specified column.
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
      • getRowCount

        public int getRowCount()
        The number of rows equals the number of entries in the source event list.
        Specified by:
        getRowCount in interface javax.swing.table.TableModel
      • getColumnCount

        public int getColumnCount()
        Get the column count as specified by the table format.
        Specified by:
        getColumnCount in interface javax.swing.table.TableModel
      • getColumnClass

        public java.lang.Class getColumnClass​(int columnIndex)
        Gets the class of elements in the specified column. This behaviour can be customized by implementing the AdvancedTableFormat interface.
        Specified by:
        getColumnClass in interface javax.swing.table.TableModel
        Overrides:
        getColumnClass in class javax.swing.table.AbstractTableModel
      • getValueAt

        public java.lang.Object getValueAt​(int row,
                                           int column)
        Retrieves the value at the specified location of the table.
        Specified by:
        getValueAt in interface javax.swing.table.TableModel
      • isCellEditable

        public boolean isCellEditable​(int row,
                                      int column)
        Delegates the question of whether the cell is editable or not to the backing TableFormat if it is a WritableTableFormat. Otherwise, the column is assumed to be uneditable.
        Specified by:
        isCellEditable in interface javax.swing.table.TableModel
        Overrides:
        isCellEditable in class javax.swing.table.AbstractTableModel
      • setValueAt

        public void setValueAt​(java.lang.Object editedValue,
                               int row,
                               int column)
        Attempts to update the object for the given row with the editedValue. This requires the backing TableFormat be a WritableTableFormat. WritableTableFormat.setColumnValue(E, java.lang.Object, int) is expected to contain the logic for updating the object at the given row with the editedValue which was in the given column.
        Specified by:
        setValueAt in interface javax.swing.table.TableModel
        Overrides:
        setValueAt in class javax.swing.table.AbstractTableModel