Class BeanListMultimapTableModel<G,​T>

    • Field Summary

      • Fields inherited from class javax.swing.table.AbstractTableModel

        listenerList
    • Constructor Summary

      Constructors 
      Constructor Description
      BeanListMultimapTableModel​(java.util.List<? extends ColumnAdapter<? super T,​?>> columnAdapters, java.lang.Iterable<? extends TableDataProvider<T>> tableDataProviders, java.util.function.Function<T,​G> groupingFunction, java.util.function.Function<G,​java.lang.String> groupNameFunction)
      Create a new model.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addBean​(T bean)  
      T getBean​(int rowIndex)
      Get the bean at the specified index.
      int getBeanCount()
      Get the number of beans in the model.
      java.util.List<T> getBeans()  
      java.util.List<T> getBeans​(G group)  
      java.lang.Class<?> getColumnClass​(int columnIndex)  
      int getColumnCount()  
      ColumnAdapter<? super T,​?> getColumnIdentifier​(int modelIndex)  
      java.lang.String getColumnName​(int modelIndex)  
      java.awt.Cursor getCursor​(java.awt.event.MouseEvent event, javax.swing.JTable table, int rowIndex, int columnIndex)
      Get the mouse cursor to display for a cell.
      java.util.List<T> getGroup​(int groupNumber)  
      int getGroupNumber​(int rowIndex)  
      int getRowCount()  
      java.lang.String getSectionName​(int rowIndex)  
      int getSectionRow​(int rowIndex)  
      java.util.List<G> getSections()  
      java.lang.Object getValue​(T bean, int columnIndex)
      Get a column cell value for a bean.
      java.lang.Object getValueAt​(int rowIndex, int columnIndex)  
      void handleClick​(java.awt.event.MouseEvent event, javax.swing.JTable table, int rowIndex, int columnIndex)
      Handle a mouse click on a cell.
      int indexOf​(java.util.function.Predicate<T> predicate)
      Find the index of a bean matching a predicate.
      boolean isCellEditable​(int rowIndex, int columnIndex)  
      boolean isSectionRow​(int rowIndex)  
      protected void notifyDataProviders​(T row, java.lang.String columnId, java.lang.Object oldValue)  
      void put​(G group, T bean)
      Add a bean to a group.
      void putAll​(G group, java.util.Collection<? extends T> beans)
      Add beans to a group.
      void remove​(int rowIndex)
      Remove a bean from a group.
      java.util.List<T> removeAll​(G group)
      Remove an entire group.
      protected void setBean​(int rowIndex, T bean)  
      void setBeans​(com.google.common.collect.Multimap<G,​T> beans)  
      void setBeans​(java.util.Collection<T> beans)
      Replace all rows of the table model.
      void setValueAt​(java.lang.Object aValue, int rowIndex, int columnIndex)  
      void updateBeans​(java.util.Collection<T> beans, java.util.function.BiPredicate<T,​T> isEqual)
      Update existing rows and add missing rows to the table model.
      • 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
    • Constructor Detail

      • BeanListMultimapTableModel

        public BeanListMultimapTableModel​(java.util.List<? extends ColumnAdapter<? super T,​?>> columnAdapters,
                                          java.lang.Iterable<? extends TableDataProvider<T>> tableDataProviders,
                                          java.util.function.Function<T,​G> groupingFunction,
                                          java.util.function.Function<G,​java.lang.String> groupNameFunction)
        Create a new model.
        Parameters:
        columnAdapters - provides access to column values on the row beans
        tableDataProviders - supplemental data providers
        groupingFunction - provides the group key for a row
        groupNameFunction - provides the display name for a group
    • Method Detail

      • isSectionRow

        public boolean isSectionRow​(int rowIndex)
        Specified by:
        isSectionRow in interface SectionTableModel<G>
        Returns:
        true of the row is a group header.
      • getSectionRow

        public int getSectionRow​(int rowIndex)
        Specified by:
        getSectionRow in interface SectionTableModel<G>
        Returns:
        the index of the group header row for the specified row.
      • getSectionName

        public java.lang.String getSectionName​(int rowIndex)
        Specified by:
        getSectionName in interface SectionTableModel<G>
        Returns:
        the display text for the header row of the group containing the specified row.
      • getGroupNumber

        public int getGroupNumber​(int rowIndex)
        Specified by:
        getGroupNumber in interface SectionTableModel<G>
        Returns:
        the group number of the specified row.
      • getGroup

        public java.util.List<T> getGroup​(int groupNumber)
        Specified by:
        getGroup in interface SectionTableModel<G>
        Returns:
        the beans in the specified group.
      • setBeans

        public void setBeans​(java.util.Collection<T> beans)
        Description copied from interface: BeanTableModel
        Replace all rows of the table model.
        Specified by:
        setBeans in interface BeanTableModel<G>
        Parameters:
        beans - the new rows
      • setBeans

        public void setBeans​(com.google.common.collect.Multimap<G,​T> beans)
      • updateBeans

        public void updateBeans​(java.util.Collection<T> beans,
                                java.util.function.BiPredicate<T,​T> isEqual)
        Description copied from interface: BeanTableModel
        Update existing rows and add missing rows to the table model.
        Specified by:
        updateBeans in interface BeanTableModel<G>
        Parameters:
        beans - beans to update/append
        isEqual - used to determine if a row is already in the model
      • getBeans

        public java.util.List<T> getBeans()
      • getSections

        public java.util.List<G> getSections()
      • getBeans

        public java.util.List<T> getBeans​(G group)
      • getBeanCount

        public int getBeanCount()
        Description copied from interface: BeanTableModel
        Get the number of beans in the model. Need not be the same as the number of the rows in the table.
        Specified by:
        getBeanCount in interface BeanTableModel<G>
      • getBean

        public T getBean​(int rowIndex)
        Description copied from interface: BeanTableModel
        Get the bean at the specified index.
        Specified by:
        getBean in interface BeanTableModel<G>
        Parameters:
        rowIndex - the index of the bean.
      • setBean

        protected void setBean​(int rowIndex,
                               T bean)
      • getValue

        public java.lang.Object getValue​(T bean,
                                         int columnIndex)
        Description copied from interface: BeanTableModel
        Get a column cell value for a bean.
        Specified by:
        getValue in interface BeanTableModel<G>
      • addBean

        public void addBean​(T bean)
      • put

        public void put​(G group,
                        T bean)
        Add a bean to a group.
      • remove

        public void remove​(int rowIndex)
        Remove a bean from a group. If the group is empty then the group is also removed.
      • removeAll

        public java.util.List<T> removeAll​(G group)
        Remove an entire group.
        Returns:
        the removed beans.
      • putAll

        public void putAll​(G group,
                           java.util.Collection<? extends T> beans)
        Add beans to a group.
      • getColumnName

        public java.lang.String getColumnName​(int modelIndex)
        Specified by:
        getColumnName in interface javax.swing.table.TableModel
        Overrides:
        getColumnName in class javax.swing.table.AbstractTableModel
      • getColumnClass

        public java.lang.Class<?> getColumnClass​(int columnIndex)
        Specified by:
        getColumnClass in interface javax.swing.table.TableModel
        Overrides:
        getColumnClass in class javax.swing.table.AbstractTableModel
      • getRowCount

        public int getRowCount()
        Specified by:
        getRowCount in interface javax.swing.table.TableModel
      • getColumnCount

        public int getColumnCount()
        Specified by:
        getColumnCount in interface javax.swing.table.TableModel
      • notifyDataProviders

        protected void notifyDataProviders​(T row,
                                           java.lang.String columnId,
                                           java.lang.Object oldValue)
      • indexOf

        public int indexOf​(java.util.function.Predicate<T> predicate)
        Find the index of a bean matching a predicate.
        Returns:
        the index of the first matching bean or -1 if none match.
      • getValueAt

        public java.lang.Object getValueAt​(int rowIndex,
                                           int columnIndex)
        Specified by:
        getValueAt in interface javax.swing.table.TableModel
      • isCellEditable

        public boolean isCellEditable​(int rowIndex,
                                      int columnIndex)
        Specified by:
        isCellEditable in interface javax.swing.table.TableModel
        Overrides:
        isCellEditable in class javax.swing.table.AbstractTableModel
      • getCursor

        public java.awt.Cursor getCursor​(java.awt.event.MouseEvent event,
                                         javax.swing.JTable table,
                                         int rowIndex,
                                         int columnIndex)
        Description copied from interface: BeanTableModel
        Get the mouse cursor to display for a cell.
        Specified by:
        getCursor in interface BeanTableModel<G>
        rowIndex - the row index of the cell
        columnIndex - the column index of the cell
        Returns:
        the mouse cursor to use for the cell or null to use the default cursor.
      • handleClick

        public void handleClick​(java.awt.event.MouseEvent event,
                                javax.swing.JTable table,
                                int rowIndex,
                                int columnIndex)
        Description copied from interface: BeanTableModel
        Handle a mouse click on a cell.
        Specified by:
        handleClick in interface BeanTableModel<G>
        Parameters:
        event - the click event
        rowIndex - the row containing the cell
        columnIndex - the column index of the cell
      • setValueAt

        public void setValueAt​(java.lang.Object aValue,
                               int rowIndex,
                               int columnIndex)
        Specified by:
        setValueAt in interface javax.swing.table.TableModel
        Overrides:
        setValueAt in class javax.swing.table.AbstractTableModel