superwaba.ext.xplat.ui
Interface GridModel


public interface GridModel

The GridModel interface specifies the methods the Grid will use to interrogate a tabular data model.

The Grid can be set up to display any data model which implements the GridModel interface with a couple of lines of code:

 GridModel myData = new MyTableModel();
 Grid table = new Grid(myData);


Method Summary
 int getColumnCount()
          Returns the number of columns in the model.
 int getItemCount()
          Returns the number of items this model contains
 int getPreferredColumnWidth(int columnIndex)
          Returns the preferred width of the column with index columnIndex.
 int getPreferredRowHeight(int rowIndex)
          Returns the preferred height of the row with index rowIndex.
 int getRowCount()
          Returns the number of rows in the model.
 Object getSelected(int rowIndex, int colIndex)
          Returns the value at the current cell
 String getValidChars(int rowIndex, int colIndex)
          Returns the chars that are allowed to be entered into this cell Only makes sense for cells that are editable
 Object getValueAt(int rowIndex, int columnIndex)
          Returns the value for the cell at columnIndex and rowIndex.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell at rowIndex and columnIndex is editable.
 boolean isHeader(int rowIndex)
          Returns if the row is a header.
 void setValueAt(Object aValue, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to aValue.
 

Method Detail

getColumnCount

public int getColumnCount()
Returns the number of columns in the model. A Grid uses this method to determine how many columns it should display.
Returns:
the number of columns in the model

getItemCount

public int getItemCount()
Returns the number of items this model contains
Returns:
the number of items

getPreferredColumnWidth

public int getPreferredColumnWidth(int columnIndex)
Returns the preferred width of the column with index columnIndex.
Parameters:
columnIndex - the column which is queried for its width
Returns:
the preferred width for this column. If the Grid should use best-fit for the current font/text, return -1

getPreferredRowHeight

public int getPreferredRowHeight(int rowIndex)
Returns the preferred height of the row with index rowIndex.
Parameters:
rowIndex - the row which is queried for its height
Returns:
the preferred height for this row. If the Grid should use best-fit for the current font, return -1

getRowCount

public int getRowCount()
Returns the number of rows in the model. A Grid uses this method to determine how many rows it should display.
Returns:
the number of rows in the model

getSelected

public Object getSelected(int rowIndex,
                          int colIndex)
Returns the value at the current cell
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the value that is associated with this cell. The implementation decides how this is associated.

getValidChars

public String getValidChars(int rowIndex,
                            int colIndex)
Returns the chars that are allowed to be entered into this cell Only makes sense for cells that are editable
Parameters:
rowIndex - the row whose valid chars are requested
colIndex - the column whose valid chars are requested
Returns:
the valid chars for this cell

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Returns the value for the cell at columnIndex and rowIndex. A Grid uses this method to determine how many rows it should display.
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
the value Object at the specified cell

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt on the cell will not change the value of that cell.
Parameters:
rowIndex - the row whose value is to be queried
columnIndex - the column whose value is to be queried
Returns:
true if the cell is editable

isHeader

public boolean isHeader(int rowIndex)
Returns if the row is a header. A Grid uses this method to determine if the row should be displayed diffrently from others (bold font).
Returns:
true if the row is a header

setValueAt

public void setValueAt(Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to aValue.
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed
Returns:
the value Object at the specified cell