Class BufferedHeaderDetailTableModel<H>

    • Constructor Detail

      • BufferedHeaderDetailTableModel

        protected BufferedHeaderDetailTableModel​(DetailAdapter<H> detailAdapter,
                                                 java.util.function.Function<? super H,​?> idFunction)
      • BufferedHeaderDetailTableModel

        public BufferedHeaderDetailTableModel​(DetailAdapter<H> detailAdapter,
                                              java.util.List<? extends ColumnAdapter<H,​?>> columnAdapters,
                                              java.util.List<? extends java.util.List<? extends ColumnAdapter<?,​?>>> detailColumnAdapters)
      • BufferedHeaderDetailTableModel

        public BufferedHeaderDetailTableModel​(DetailAdapter<H> detailAdapter,
                                              java.util.function.Function<? super H,​?> idFunction,
                                              java.util.List<? extends ColumnAdapter<H,​?>> columnAdapters,
                                              java.util.List<? extends java.util.List<? extends ColumnAdapter<?,​?>>> detailColumnAdapters)
    • Method Detail

      • queueDelete

        public boolean queueDelete​(H bean)
        Specified by:
        queueDelete in interface ChangeBufferTableModel<H>
        Returns:
        true if the delete was queued, false if the row was an unsaved addition and was deleted immediately.
      • queueDelete

        public boolean queueDelete​(int rowIndex)
        Mark a row as a pending delete or remove the row if it is a pending addition. If the specified row is the header of a group then the operation is applied to the entire group.
        Returns:
        true if the delete was queued or false if the row was an unsaved addition and was deleted immediately.
      • queueAppendSubRow

        public int queueAppendSubRow​(int currentRow)
        Append a detail row to a group.
        Parameters:
        currentRow - the index of a row in the group.
        Returns:
        the index of the new row.
      • addBean

        public void addBean​(H bean)
        Append a saved group.
      • addBean

        public void addBean​(int index,
                            H bean)
        Insert a saved group.
        Overrides:
        addBean in class HeaderDetailTableModel<H>
        Parameters:
        index - the insertion point in the list of groups
        bean - the group to add
      • setBean

        public void setBean​(int index,
                            H bean)
        Overridden to reset pending changes and validation for the group.
        Overrides:
        setBean in class HeaderDetailTableModel<H>
        Parameters:
        index - the index in the list of groups.
        bean - the replacement group
      • removeSubRow

        protected void removeSubRow​(H bean,
                                    java.lang.Object subRow)
      • fireSubRowInserted

        protected void fireSubRowInserted​(H bean,
                                          int subRowIndex)
        Mark the sub-row as an unsaved addition unless the header bean is already an unsaved addition.
      • updateGroupValidation

        protected void updateGroupValidation​(int groupNumber)
        Update the errors for all rows in a group without firing change events.
      • updateRowValidation

        protected void updateRowValidation​(int rowIndex)
        Update the errors for a row without firing change events.
      • validateCell

        protected boolean validateCell​(int rowIndex,
                                       int columnIndex)
        Returns:
        true if the cell validation changed
      • validateAt

        public java.lang.String validateAt​(int rowIndex,
                                           int columnIndex)
        Specified by:
        validateAt in interface ValidatedTableModel
        Returns:
        error messages or null if current value valid.
      • validateAt

        public <V> java.lang.String validateAt​(int rowIndex,
                                               int columnIndex,
                                               V value)
        Specified by:
        validateAt in interface ValidatedTableModel
        Returns:
        error message or null if specified value is valid.
      • isNoErrors

        public boolean isNoErrors()
        Specified by:
        isNoErrors in interface ValidatedTableModel
        Returns:
        true if there are no validation errors.
      • setValueAt

        public void setValueAt​(java.lang.Object value,
                               int rowIndex,
                               int columnIndex)
        Overridden to update change tracking and validation.
        Specified by:
        setValueAt in interface javax.swing.table.TableModel
        Overrides:
        setValueAt in class javax.swing.table.AbstractTableModel
      • fireTableCellUpdated

        public void fireTableCellUpdated​(int row,
                                         int column)
        Overridden to update validation.
        Overrides:
        fireTableCellUpdated in class javax.swing.table.AbstractTableModel
      • setCellValue

        protected void setCellValue​(java.lang.Object value,
                                    int rowIndex,
                                    int columnIndex)
        Description copied from class: HeaderDetailTableModel
        Set a value on a header or detail.
        Overrides:
        setCellValue in class HeaderDetailTableModel<H>
        Parameters:
        value - the cell value
        rowIndex - the table row index
        columnIndex - the table column index
      • isChanged

        public boolean isChanged()
        Specified by:
        isChanged in interface ChangeBuffer
        Returns:
        true if there are pending changes
      • isChanged

        public boolean isChanged​(H bean)
        Returns:
        true if there are pending changes for the group.
      • isPendingAdd

        public boolean isPendingAdd​(int rowIndex)
      • isPendingDelete

        public boolean isPendingDelete​(H bean)
      • revert

        public void revert()
        Description copied from interface: ChangeBuffer
        Undo any pending changes.
        Specified by:
        revert in interface ChangeBuffer
      • commit

        public void commit()
        Description copied from interface: ChangeBuffer
        Save any pending changes.
        Specified by:
        commit in interface ChangeBuffer