Class JKTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
com.jk.core.model.table.JKTableModel
All Implemented Interfaces:
Serializable, TableModel
Direct Known Subclasses:
JKMapTableModel

public class JKTableModel extends AbstractTableModel
The Class JKTableModel.
See Also:
  • Constructor Details

    • JKTableModel

      public JKTableModel()
      Instantiates a new JK table model.
  • Method Details

    • addJKTableColumn

      public void addJKTableColumn(JKTableColumn col)
      Adds the JK table column.
      Parameters:
      col - the col
    • addRecord

      public JKTableRecord addRecord()
      Adds the record.
      Returns:
      the JK table record
    • addRecord

      public void addRecord(JKTableRecord record)
      Adds the record.
      Parameters:
      record - the record
    • clearRecords

      public void clearRecords()
      Clear records.
    • createEmptyRecord

      protected JKTableRecord createEmptyRecord()
      Creates the empty record.
      Returns:
      the JK table record
    • deleteRow

      public JKTableRecord deleteRow(int selectedRow)
      Delete row.
      Parameters:
      selectedRow - the selected row
      Returns:
      the JK table record
    • deleteRows

      public void deleteRows(int[] rows)
      Delete rows.
      Parameters:
      rows - the rows
    • fireTableColumnDataChanged

      public void fireTableColumnDataChanged(int col)
      Fire table column data changed.
      Parameters:
      col - the col
    • getActualColumnCount

      public int getActualColumnCount()
      Gets the actual column count.
      Returns:
      the actual column count
    • getActualColumnIndexFromVisible

      public int getActualColumnIndexFromVisible(int visibleIndex)
      Gets the actual column index from visible.
      Parameters:
      visibleIndex - the visible index
      Returns:
      the actual column index from visible
    • getActualColumnName

      public String getActualColumnName(int index)
      Gets the actual column name.
      Parameters:
      index - the index
      Returns:
      the actual column name
    • getCellEditor

      public TableCellEditor getCellEditor(int column)
      Gets the cell editor.
      Parameters:
      column - the column
      Returns:
      the cell editor
    • getCellRenderer

      public TableCellRenderer getCellRenderer(int column)
      Gets the cell renderer.
      Parameters:
      column - the column
      Returns:
      the cell renderer
    • getColumnClass

      public Class getColumnClass(int columnIndex)
      Gets the column class.
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class AbstractTableModel
      Parameters:
      columnIndex - the column index
      Returns:
      the column class
    • getColumnCount

      public int getColumnCount()
      Gets the column count.
      Returns:
      the column count
    • getColumnName

      public String getColumnName(int visibleColumnIndex)
      Gets the column name.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class AbstractTableModel
      Parameters:
      visibleColumnIndex - the visible column index
      Returns:
      the column name
    • getColumnType

      public int getColumnType(int col)
      Gets the column type.
      Parameters:
      col - the col
      Returns:
      the column type
    • getColunmIndex

      public int getColunmIndex(String name)
      Gets the colunm index.
      Parameters:
      name - the name
      Returns:
      the colunm index
    • getColunmIndexByName

      public int getColunmIndexByName(String colName)
      Gets the colunm index by name.
      Parameters:
      colName - the col name
      Returns:
      the colunm index by name
    • getColunmSum

      public double getColunmSum(int col)
      Gets the colunm sum.
      Parameters:
      col - the col
      Returns:
      the colunm sum
    • getDeletedRecords

      public Vector<JKTableRecord> getDeletedRecords()
      Gets the deleted records.
      Returns:
      the deleted records
    • getDeletedRecordsAsDataVector

      public Vector<Vector> getDeletedRecordsAsDataVector()
      Gets the deleted records as data vector.
      Returns:
      the deleted records as data vector
    • getFormatter

      public Format getFormatter(int col)
      Gets the formatter.
      Parameters:
      col - the col
      Returns:
      the formatter
    • getIntegerColunmSum

      public int getIntegerColunmSum(int col)
      Gets the integer colunm sum.
      Parameters:
      col - the col
      Returns:
      the integer colunm sum
    • getPrefferedWidth

      public int getPrefferedWidth(int column)
      Gets the preffered width.
      Parameters:
      column - the column
      Returns:
      the preffered width
    • getRecord

      public JKTableRecord getRecord(int row)
      Gets the record.
      Parameters:
      row - the row
      Returns:
      the record
    • getRecords

      public Vector<JKTableRecord> getRecords()
      Gets the records.
      Returns:
      the records
    • getRecordsAsDataVector

      public Vector<Vector> getRecordsAsDataVector()
      Gets the records as data vector.
      Returns:
      the records as data vector
    • getRowCount

      public int getRowCount()
      Gets the row count.
      Returns:
      the row count
    • getTableColumn

      public JKTableColumn getTableColumn(int visibleColumnIndex)
      Gets the table column.
      Parameters:
      visibleColumnIndex - the visible column index
      Returns:
      the table column
    • getTableColumn

      public JKTableColumn getTableColumn(int col, boolean visibleIndex)
      Gets the table column.
      Parameters:
      col - the col
      visibleIndex - the visible index
      Returns:
      the table column
    • getValueAt

      public Object getValueAt(int row, int visibleColumnIndex)
      Gets the value at.
      Parameters:
      row - the row
      visibleColumnIndex - the visible column index
      Returns:
      the value at
    • getValueAtAsDouble

      public double getValueAtAsDouble(int row, int col)
      Gets the value at as double.
      Parameters:
      row - the row
      col - the col
      Returns:
      the value at as double
    • getValueAtAsFloat

      public float getValueAtAsFloat(int row, int col)
      Gets the value at as float.
      Parameters:
      row - the row
      col - the col
      Returns:
      the value at as float
    • getValueAtAsInteger

      public int getValueAtAsInteger(int row, int col)
      Gets the value at as integer.
      Parameters:
      row - the row
      col - the col
      Returns:
      the value at as integer
    • getVisibleColumnIndexFromActual

      public int getVisibleColumnIndexFromActual(int actualIndex)
      Gets the visible column index from actual.
      Parameters:
      actualIndex - the actual index
      Returns:
      the visible column index from actual
    • insertRecord

      public void insertRecord(int selectedRow)
      Insert record.
      Parameters:
      selectedRow - the selected row
    • insertRecord

      public void insertRecord(int row, JKTableRecord record)
      Insert record.
      Parameters:
      row - the row
      record - the record
    • isAllDataValid

      public boolean isAllDataValid()
      Checks if is all data valid.
      Returns:
      true, if is all data valid
    • isAllowDelete

      public boolean isAllowDelete()
      Checks if is allow delete.
      Returns:
      true, if is allow delete
    • isDataModified

      public boolean isDataModified()
      Checks if is data modified.
      Returns:
      true, if is data modified
    • isEditable

      public boolean isEditable()
      Checks if is editable.
      Returns:
      true, if is editable
    • isEditable

      public boolean isEditable(int column)
      Checks if is editable.
      Parameters:
      column - the column
      Returns:
      true, if is editable
    • isEditable

      public boolean isEditable(int row, int column)
      Checks if is editable.
      Parameters:
      row - the row
      column - the column
      Returns:
      true, if is editable
    • isNumericClumn

      public boolean isNumericClumn(int visibleColIndex)
      Checks if is numeric clumn.
      Parameters:
      visibleColIndex - the visible col index
      Returns:
      true, if is numeric clumn
    • isValidTableColumnIndex

      protected boolean isValidTableColumnIndex(int actualIndex)
      Checks if is valid table column index.
      Parameters:
      actualIndex - the actual index
      Returns:
      true, if is valid table column index
    • isVisible

      public boolean isVisible(int col)
      Checks if is visible.
      Parameters:
      col - the col
      Returns:
      true, if is visible
    • refreshVisibility

      public void refreshVisibility()
      Refresh visibility.
    • removeRecord

      public JKTableRecord removeRecord(int row)
      Removes the record.
      Parameters:
      row - the row
      Returns:
      the JK table record
    • resetRecords

      public void resetRecords()
      Reset records.
    • setAllowDelete

      public void setAllowDelete(boolean allowDelete)
      Sets the allow delete.
      Parameters:
      allowDelete - the new allow delete
    • setColumnValue

      public void setColumnValue(int row, int col, Object value, boolean visibleIndex)
      Sets the column value.
      Parameters:
      row - the row
      col - the col
      value - the value
      visibleIndex - the visible index
    • setEditable

      public void setEditable(boolean editable)
      Sets the editable.
      Parameters:
      editable - the new editable
    • setEditable

      public void setEditable(int column, boolean editable)
      Sets the editable.
      Parameters:
      column - the column
      editable - the editable
    • setEditable

      public void setEditable(int row, int col, boolean enable)
      Sets the editable.
      Parameters:
      row - the row
      col - the col
      enable - the enable
    • setEditor

      public void setEditor(int colunm, TableCellEditor cellEditor)
      Sets the editor.
      Parameters:
      colunm - the colunm
      cellEditor - the cell editor
    • setFormatter

      public void setFormatter(int col, Format formatter)
      Sets the formatter.
      Parameters:
      col - the col
      formatter - the formatter
    • setPreferredWidth

      public void setPreferredWidth(int col, int width)
      Sets the preferred width.
      Parameters:
      col - the col
      width - the width
    • setRenderer

      public void setRenderer(int col, TableCellRenderer cellRenderer)
      Sets the renderer.
      Parameters:
      col - the col
      cellRenderer - the cell renderer
    • setRequired

      public void setRequired(int col, boolean required)
      Sets the required.
      Parameters:
      col - the col
      required - the required
    • setValueAt

      public void setValueAt(Object value, int rowIndex, int visibleIndex)
      Sets the value at.
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class AbstractTableModel
      Parameters:
      value - the value
      rowIndex - the row index
      visibleIndex - the visible index
    • setVisible

      public void setVisible(int col, boolean visible)
      Sets the visible.
      Parameters:
      col - the col
      visible - the visible
    • setVisibleByActualIndex

      public void setVisibleByActualIndex(int colunmIndex, boolean visible)
      Sets the visible by actual index.
      Parameters:
      colunmIndex - the colunm index
      visible - the visible
    • addJKTableColumn

      public void addJKTableColumn(String keyLabel)
      Adds the JK table column.
      Parameters:
      keyLabel - the key label