Class SortableTableModel

java.lang.Object
com.codename1.ui.table.AbstractTableModel
com.codename1.ui.table.SortableTableModel
All Implemented Interfaces:
TableModel

public class SortableTableModel extends AbstractTableModel
A proxy that wraps the table model providing sorting API that can be leveraged by the table
  • Constructor Details

    • SortableTableModel

      public SortableTableModel(int column, boolean asc, TableModel model, Comparator cmp)

      Sorts a table based on the given column

      Parameters
      • column: the column to sort

      • asc: the direction ascending/descending

      • model: the underlying model that will be sorted

      • cmp: a comparator used for comparing the cells in the column

  • Method Details

    • getUnderlying

      public TableModel getUnderlying()

      Returns the underlying table model

      Returns

      the model

    • getSortedPosition

      public int getSortedPosition(int row)

      Returns the position of the row when sorted

      Parameters
      • row: the row in the visual table
      Returns

      the position in the underlying model

    • getRowCount

      public int getRowCount()

      Returns the number of rows in the table

      Returns

      the number of rows in the table

    • getColumnCount

      public int getColumnCount()

      Returns the number of columns in the table

      Returns

      the number of columns in the table

    • getColumnName

      public String getColumnName(int i)

      Returns the name of the column at the given offset

      Parameters
      • i: the offset for the column name
      Returns

      name to display at the top of the table

    • isCellEditable

      public boolean isCellEditable(int row, int column)

      Returns true if the cell at the given location is an editable cell

      Parameters
      • row: the cell row

      • column: the cell column

      Returns

      true if the cell at the given location is an editable cell

    • getValueAt

      public Object getValueAt(int row, int column)

      Returns the value of the cell at the given location

      Parameters
      • row: the cell row

      • column: the cell column

      Returns

      the value of the cell at the given location

    • setValueAt

      public void setValueAt(int row, int column, Object o)

      Sets the value of the cell at the given location

      Parameters
      • row: the cell row

      • column: the cell column

      • o: the value of the cell at the given location

    • addDataChangeListener

      public void addDataChangeListener(DataChangedListener d)

      Adds a listener to the data changed event

      Parameters
      • d: the new listener
    • removeDataChangeListener

      public void removeDataChangeListener(DataChangedListener d)

      Removes a listener to the data changed event

      Parameters
      • d: the listener to remove
    • getValidationConstraint

      public Constraint getValidationConstraint(int row, int column)

      If the cell has a validation constraint it's returned here

      Parameters
      • row: the row

      • column: the column for the cell

      Returns

      null for no constraints

      Overrides:
      getValidationConstraint in class AbstractTableModel
    • getCellType

      public Class getCellType(int row, int column)

      Allows the table to hint the class type of a specific cell

      Parameters
      • row: the row in the table

      • column: the column

      Returns

      the class representing this cell

      Overrides:
      getCellType in class AbstractTableModel
    • getMultipleChoiceOptions

      public String[] getMultipleChoiceOptions(int row, int column)

      Allows the table cell to feature multiple choice for a specific entry

      Parameters
      • row: the row in the table

      • column: the column

      Returns
      Overrides:
      getMultipleChoiceOptions in class AbstractTableModel
      Returns:
      the string values matching the entries or null if this isn't a multiple choice option
    • getValidator

      public Validator getValidator()
      Description copied from class: AbstractTableModel

      A validator can be defined here so a validation constraint can bind to a table model cell

      Returns

      the validator

      Overrides:
      getValidator in class AbstractTableModel
    • setValidator

      public void setValidator(Validator validator)
      Description copied from class: AbstractTableModel

      A validator can be defined here so a validation constraint can bind to a table model cell

      Parameters
      • validator: the validator to set
      Overrides:
      setValidator in class AbstractTableModel