JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table
Class TableDataView

java.lang.Object
  |
  +--com.klg.jclass.table.BaseDataView
        |
        +--com.klg.jclass.table.TableDataView
All Implemented Interfaces:
DataViewModel, EventListener, JCTableDataListener, JCTableDataModel, Serializable, SortableDataViewModel, TableDataModel

public class TableDataView
extends BaseDataView
implements SortableDataViewModel, Serializable

The TableDataView serves an an intermediary between the Table and the data source (TableData).

See Also:
Serialized Form

Field Summary
protected  com.klg.jclass.table.TableDataModel dataSource
           
protected  boolean isEditable
           
 
Fields inherited from class com.klg.jclass.table.BaseDataView
editors, renderers, table
 
Constructor Summary
TableDataView()
          Creates a TableDataView instance that initializes the editor and renderer tables but does not link it to table.
TableDataView(com.klg.jclass.table.JCTable table)
          Creates a TableDataView instance and initializes the editor and renderer tables
 
Method Summary
 void addTableDataListener(com.klg.jclass.table.JCTableDataListener l)
          Adds a JCTableDataListener to this object.
 void dataChanged(com.klg.jclass.table.JCTableDataEvent e)
          Method to change the data based on the passed in event
 void dispose()
          Ensures that TableDataView can be disposed.
 boolean dragColumn(int column1, int column2)
          Drags a column to a new position.
 boolean dragRow(int row1, int row2)
          Drags a row to a new position.
 int[] getColumnMap()
          Returns an array of column numbers that map view to data.
 int getDataColumn(int column)
          Returns the data column mapped to the view column.
 int getDataRow(int row)
          Returns the data row mapped to the view row.
 com.klg.jclass.table.TableDataModel getDataSource()
          Returns the bound data source.
 int getNumColumns()
          Returns the number of columns of data the data source contains.
 int getNumRows()
          Returns the number of rows of data the data source contains.
 Object getObject(int row, int column)
          Returns the object given a row or column.
 int[] getRowMap()
          Returns an array of row numbers that map view to data.
 Object getTableColumnLabel(int column)
          Returns the value for the column label at the specified column.
 Object getTableDataItem(int row, int column)
          Returns the value for the cell at the specified location.
 Object getTableRowLabel(int row)
          Returns the value for the row label at the specified row.
 int getViewColumn(int column)
          Returns the column in the view for the data column.
 int getViewRow(int row)
          Returns the row in the view for the data row.
 boolean isEditable()
          Returns true if the data source implements EditableTableData.
protected  int[] removeMapElement(int[] array, int element)
          Removes an element from the map array.
 void removeTableDataListener(com.klg.jclass.table.JCTableDataListener l)
          Removes a JCTableDataListener from this object
protected  void repaintRange(int start_row, int start_column, int end_row, int end_column)
          Issues a range repaint.
 void resetColumnMap()
          Reset the mapped columns array to a one-to-one mapping.
 void resetRowMap()
          Reset the mapped rows array to a one-to-one mapping.
protected  void resizeColumnMap()
          Initializes the mapped columns array any time it is accessed and the number of columns in the datasource does not match the number of columns in the map array.
protected  void resizeRowMap()
          Initializes the mapped rows array any time it is accessed and the number of rows in the datasource does not match the number of rows in the map array.
 boolean setColumnMap(int[] new_map)
          Sets a new column map array.
 void setDataSource(com.klg.jclass.table.TableDataModel tableData)
          Sets the bound data source.
 boolean setRowMap(int[] new_map)
          Sets a new row map array.
 boolean setTableDataItem(Object o, int row, int column)
          Sets the cell value for editable data sources.
protected  int[] shiftMappedArray(int[] array, int item1, int item2)
          Repositions a row or column to a new location in the mapped array.
 boolean swapColumns(int column1, int column2)
          Swaps two columns.
 boolean swapRows(int row1, int row2)
          Swaps two rows.
 
Methods inherited from class com.klg.jclass.table.BaseDataView
getCellEditor, getCellEditor, getCellEditor, getCellRenderer, getCellRenderer, getCellRenderer, getCellRenderer, getEditorsTable, getRenderersTable, getTable, loadFieldEditors, loadFieldRenderers, setEditorsTable, setRenderersTable, setTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.klg.jclass.table.DataViewModel
getCellEditor, getCellEditor, getCellRenderer, getCellRenderer, getCellRenderer, getEditorsTable, getRenderersTable, getTable, setEditorsTable, setRenderersTable, setTable
 

Field Detail

dataSource

protected com.klg.jclass.table.TableDataModel dataSource

isEditable

protected boolean isEditable
Constructor Detail

TableDataView

public TableDataView()
Creates a TableDataView instance that initializes the editor and renderer tables but does not link it to table.


TableDataView

public TableDataView(com.klg.jclass.table.JCTable table)
Creates a TableDataView instance and initializes the editor and renderer tables

Parameters:
table - The table controlled by this DataView.
Method Detail

dataChanged

public void dataChanged(com.klg.jclass.table.JCTableDataEvent e)
Method to change the data based on the passed in event

Specified by:
dataChanged in interface JCTableDataListener
Specified by:
dataChanged in class BaseDataView
Parameters:
e - The event used to change the data

getDataSource

public com.klg.jclass.table.TableDataModel getDataSource()
Returns the bound data source.

Specified by:
getDataSource in interface DataViewModel
Specified by:
getDataSource in class BaseDataView
Returns:
The current bound data source

setDataSource

public void setDataSource(com.klg.jclass.table.TableDataModel tableData)
Sets the bound data source.

Specified by:
setDataSource in interface DataViewModel
Specified by:
setDataSource in class BaseDataView
Parameters:
tableData - The new bound data source

isEditable

public boolean isEditable()
Returns true if the data source implements EditableTableData.

Specified by:
isEditable in interface DataViewModel
Specified by:
isEditable in class BaseDataView
Returns:
Is the data source editable?

getObject

public Object getObject(int row,
                        int column)
Returns the object given a row or column. This convenience method handles both cells and labels.

Specified by:
getObject in interface DataViewModel
Specified by:
getObject in class BaseDataView
Parameters:
row - The row index
column - The column index
Returns:
The data object based on the given row and column

setTableDataItem

public boolean setTableDataItem(Object o,
                                int row,
                                int column)
Sets the cell value for editable data sources.

Specified by:
setTableDataItem in interface DataViewModel
Specified by:
setTableDataItem in class BaseDataView
Parameters:
o - The new cell value
row - The row index
column - The column index
Returns:
The status of the edit. Note that if the datasource is not editable, no edit is done and true is returned.

getTableDataItem

public Object getTableDataItem(int row,
                               int column)
Returns the value for the cell at the specified location.

Specified by:
getTableDataItem in interface JCTableDataModel
Specified by:
getTableDataItem in class BaseDataView
Parameters:
row - The row index
column - The column index
Returns:
The data object based on the given row and column

getNumRows

public int getNumRows()
Returns the number of rows of data the data source contains.

Specified by:
getNumRows in interface JCTableDataModel
Returns:
The number of rows in the datasource

getNumColumns

public int getNumColumns()
Returns the number of columns of data the data source contains.

Specified by:
getNumColumns in interface JCTableDataModel
Returns:
The number of columns in the datasource

getTableRowLabel

public Object getTableRowLabel(int row)
Returns the value for the row label at the specified row.

Specified by:
getTableRowLabel in interface JCTableDataModel
Specified by:
getTableRowLabel in class BaseDataView
Parameters:
row - The row index
Returns:
The label value for the given row

getTableColumnLabel

public Object getTableColumnLabel(int column)
Returns the value for the column label at the specified column.

Specified by:
getTableColumnLabel in interface JCTableDataModel
Specified by:
getTableColumnLabel in class BaseDataView
Parameters:
column - The column index
Returns:
The label value for the given column

addTableDataListener

public void addTableDataListener(com.klg.jclass.table.JCTableDataListener l)
Adds a JCTableDataListener to this object.

Specified by:
addTableDataListener in interface TableDataModel
Parameters:
l - The table data listenere to be added
See Also:
JCTableDataListener, JCTableDataEvent

removeTableDataListener

public void removeTableDataListener(com.klg.jclass.table.JCTableDataListener l)
Removes a JCTableDataListener from this object

Specified by:
removeTableDataListener in interface TableDataModel
Parameters:
l - The table data listenere to be removed
See Also:
JCTableDataListener, JCTableDataEvent

getColumnMap

public int[] getColumnMap()
Returns an array of column numbers that map view to data. For example, columnMap[1] = 3 indicates that column 1 is column 3 in the data source.

Specified by:
getColumnMap in interface SortableDataViewModel
Returns:
A array of integers mapping column numbers to where they reside in the data source

getRowMap

public int[] getRowMap()
Returns an array of row numbers that map view to data. For example, rowMap[1] = 3 indicates that row 1 is row 3 in the data source.

Specified by:
getRowMap in interface SortableDataViewModel
Returns:
A array of integers mapping row numbers to where they reside in the data source

getDataColumn

public int getDataColumn(int column)
Returns the data column mapped to the view column.

Specified by:
getDataColumn in interface SortableDataViewModel
Parameters:
column - The column number in the view
Returns:
The column where the view column resides in the datasource

getDataRow

public int getDataRow(int row)
Returns the data row mapped to the view row.

Specified by:
getDataRow in interface SortableDataViewModel
Parameters:
row - The row number in the view
Returns:
The row where the view row resides in the datasource

getViewColumn

public int getViewColumn(int column)
Returns the column in the view for the data column.

Specified by:
getViewColumn in interface SortableDataViewModel
Parameters:
column - The column number in the datasource
Returns:
The view column corresponding to the datasource column

getViewRow

public int getViewRow(int row)
Returns the row in the view for the data row.

Specified by:
getViewRow in interface SortableDataViewModel
Parameters:
row - The row number in the datasource
Returns:
The view row corresponding to the datasource row

resizeColumnMap

protected void resizeColumnMap()
Initializes the mapped columns array any time it is accessed and the number of columns in the datasource does not match the number of columns in the map array.


resizeRowMap

protected void resizeRowMap()
Initializes the mapped rows array any time it is accessed and the number of rows in the datasource does not match the number of rows in the map array.


resetColumnMap

public void resetColumnMap()
Reset the mapped columns array to a one-to-one mapping.

Specified by:
resetColumnMap in interface SortableDataViewModel

resetRowMap

public void resetRowMap()
Reset the mapped rows array to a one-to-one mapping.

Specified by:
resetRowMap in interface SortableDataViewModel

shiftMappedArray

protected int[] shiftMappedArray(int[] array,
                                 int item1,
                                 int item2)
Repositions a row or column to a new location in the mapped array.

Parameters:
array - The input array of row or column indices
item1 - The current position of the row/column to be moved
item2 - The destination of the row/column
Returns:
The new shifted array

removeMapElement

protected int[] removeMapElement(int[] array,
                                 int element)
Removes an element from the map array.

Parameters:
array - The input array of row or column indices
element - The element to be removed
Returns:
The new array with the element removed

swapColumns

public boolean swapColumns(int column1,
                           int column2)
Swaps two columns. Returns true if the columns are valid and the swap occurs.

Specified by:
swapColumns in interface SortableDataViewModel
Parameters:
column1 - The view index of the first column to be swapped
column2 - The view index of the second column to be swapped
Returns:
Whether swap succeeded.

swapRows

public boolean swapRows(int row1,
                        int row2)
Swaps two rows. Returns true if the rows are valid and the swap occurs.

Specified by:
swapRows in interface SortableDataViewModel
Parameters:
row1 - The view index of the first row to be swapped
row2 - The view index of the second row to be swapped
Returns:
Whether swap succeeded.

setColumnMap

public boolean setColumnMap(int[] new_map)
Sets a new column map array.

Specified by:
setColumnMap in interface SortableDataViewModel
Parameters:
new_map - Integer array where initial unsorted new_map resides
Returns:
If process succeeded

setRowMap

public boolean setRowMap(int[] new_map)
Sets a new row map array.

Specified by:
setRowMap in interface SortableDataViewModel
Parameters:
new_map - Integer array where initial unsorted new_map resides
Returns:
If process succeeded

dragColumn

public boolean dragColumn(int column1,
                          int column2)
Drags a column to a new position. Use JCTableEnum.MAXINT for the destination if the first column should be at the end.

Specified by:
dragColumn in interface SortableDataViewModel
Parameters:
column1 - Current index of column to be dragged
column2 - Index where dragged column is to be placed
Returns:
Whether drag succeeded

dragRow

public boolean dragRow(int row1,
                       int row2)
Drags a row to a new position. Use JCTableEnum.MAXINT for the destination if the first row should be at the end.

Specified by:
dragRow in interface SortableDataViewModel
Parameters:
row1 - Current index of row to be dragged
row2 - Index where dragged row is to be placed
Returns:
Whether drag succeeded

repaintRange

protected void repaintRange(int start_row,
                            int start_column,
                            int end_row,
                            int end_column)
Issues a range repaint. Defers to the appropriate cell area renderer.

Parameters:
start_row - The starting row of the range to be repainted
start_column - The starting column of the range to be repainted
end_row - The ending row of the range to be repainted
end_column - The ending column of the range to be repainted

dispose

public void dispose()
Ensures that TableDataView can be disposed.


Copyright © 2004 Quest Software Inc..
All rights reserved.