Oracle Data-aware Controls Reference

oracle.dacf.control.swing
Class GridDataSource

java.lang.Object
  extended byjavax.swing.table.AbstractTableModel
      extended byoracle.dacf.control.swing.GridDataSource
All Implemented Interfaces:
javax.swing.event.ChangeListener, javax.infobus.DataItemChangeListener, java.util.EventListener, java.io.Serializable, javax.swing.table.TableModel

public class GridDataSource
extends javax.swing.table.AbstractTableModel
implements javax.infobus.DataItemChangeListener, javax.swing.event.ChangeListener

This class provides data to the JFC GridControl.

The data is obtained from a bound InfoBus data item that implements the ScrollableRowsetAccess interface. Other access interfaces (such as ArrayAccess) are not supported.

If the data item also implements the DataItemView interface, data retrieval will be much faster. Since the JTable object frequently requests data (for example, whenever it repaints a cell), performance of the JTable will be unacceptable unless the data item implements the DataItemView interface.

See Also:
Serialized Form

Field Summary
protected  java.lang.String[] _columnLabels
           
protected  javax.infobus.ScrollableRowsetAccess _cursor
           
protected  GridControl _gridControl
           
protected  int _rangeSize
           
protected  int _rangeStart
           
protected  int _rowCount
           
protected  javax.infobus.ScrollableRowsetAccess _rowset
           
protected  javax.swing.JTable _table
           
protected  javax.infobus.DataItemView _view
           
protected  javax.swing.JViewport _viewPort
           
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
GridDataSource(GridControl gridControl, boolean forceReadOnly)
          Creates the data source.
 
Method Summary
protected  oracle.dacf.control.swing.GridTableColumnModel _buildColumnModel(javax.infobus.ScrollableRowsetAccess rowset)
          build a table column model, based on the widths specified.
protected  int _computeVisibleRowcount()
           
protected  void _fireTableChanged(javax.swing.event.TableModelEvent event)
          Fires the TableChanged event to the table.
protected  java.lang.Object _getColumnItem(javax.infobus.RowsetAccess rsAccess, int colIndex)
           
protected  void _getColumnLabels(javax.infobus.ScrollableRowsetAccess rowset)
           
protected  java.lang.Object _getItemAt(int rowIndex, int columnIndex)
          Returns the data item value for the cell at columnIndex and rowIndex.
protected  int _getRecommendedRangeSize()
           
protected  void _handleDataItemAdded(javax.infobus.DataItemAddedEvent e)
          Indicates that a new item was added to the bound aggregate data item (e.g.
protected  void _handleDataItemDeleted(javax.infobus.DataItemDeletedEvent e)
          Indicates that an item was deleted from the bound aggregate data item (e.
protected  void _handleDataItemValueChanged(javax.infobus.DataItemValueChangedEvent e)
          Indicates a changed value in the bound data item.
protected  boolean _shouldUpdateRowcount(javax.infobus.DataItemValueChangedEvent e)
           
 void dataItemAdded(javax.infobus.DataItemAddedEvent e)
          Indicates that a new item was added to the bound aggregate data item (e.g.
 void dataItemChanged(java.lang.Object oldDataItem, java.lang.Object newDataItem)
          Notifies the data source that the bound data item has changed.
 void dataItemDeleted(javax.infobus.DataItemDeletedEvent e)
          Indicates that an item was deleted from the bound aggregate data item (e.
 void dataItemRevoked(javax.infobus.DataItemRevokedEvent e)
          Indicates that the bound data item (and its sub-items, if any) has been revoked, and is temporarily unavailable.
 void dataItemValueChanged(javax.infobus.DataItemValueChangedEvent e)
          Indicates a changed value in the bound data item.
 java.lang.Class getColumnClass(int columnIndex)
          Returns the lowest common denominator Class in the column.
 int getColumnCount()
          Returns the number of columns managed by the data source object.
 java.lang.String getColumnName(int columnIndex)
          Returns the name of the column at columnIndex.
 int getRowCount()
          Returns the number of records managed by the data source object.
protected  int getRowCountFromRowsetAccess(javax.infobus.ScrollableRowsetAccess scr)
           
 java.lang.Object getValueAt(int rowIndex, int columnIndex)
          Returns an attribute value for the cell at columnIndex and rowIndex.
 void init()
           
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns true if the cell at rowIndex and columnIndex is editable.
protected  boolean isForceReadOnly()
          should the grid be forced to work in read only mode
 void rowsetCursorMoved(javax.infobus.RowsetCursorMovedEvent e)
          Indicates that the cursor for the bound RowsetAccess data item has changed rows.
protected  void setForceReadOnly(boolean forceReadOnly)
          set the grid to work in read only mode
 void setValueAt(java.lang.Object value, int rowIndex, int columnIndex)
          Sets an attribute value for the record in the cell at columnIndex and rowIndex.
 void stateChanged(javax.swing.event.ChangeEvent e)
           
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_gridControl

protected GridControl _gridControl

_table

protected javax.swing.JTable _table

_rowset

protected javax.infobus.ScrollableRowsetAccess _rowset

_cursor

protected javax.infobus.ScrollableRowsetAccess _cursor

_view

protected javax.infobus.DataItemView _view

_rowCount

protected int _rowCount

_columnLabels

protected java.lang.String[] _columnLabels

_viewPort

protected javax.swing.JViewport _viewPort

_rangeStart

protected int _rangeStart

_rangeSize

protected int _rangeSize
Constructor Detail

GridDataSource

public GridDataSource(GridControl gridControl,
                      boolean forceReadOnly)
Creates the data source.

Parameters:
gridControl - The JFC GridControl.
Method Detail

init

public void init()

stateChanged

public void stateChanged(javax.swing.event.ChangeEvent e)
Specified by:
stateChanged in interface javax.swing.event.ChangeListener

isForceReadOnly

protected boolean isForceReadOnly()
should the grid be forced to work in read only mode


setForceReadOnly

protected void setForceReadOnly(boolean forceReadOnly)
set the grid to work in read only mode

Parameters:
forceReadOnly - true if the grid should work in read only mode

dataItemChanged

public void dataItemChanged(java.lang.Object oldDataItem,
                            java.lang.Object newDataItem)
Notifies the data source that the bound data item has changed.

This method is invoked by the GridControl.

Parameters:
oldDataItem - The previously bound data item.
newDataItem - The new data item to bind to.

dataItemValueChanged

public void dataItemValueChanged(javax.infobus.DataItemValueChangedEvent e)
Indicates a changed value in the bound data item.

A reference to the data item that changed can be obtained from the event.

Specified by:
dataItemValueChanged in interface javax.infobus.DataItemChangeListener
See Also:
DataItemChangeListener.dataItemValueChanged(javax.infobus.DataItemValueChangedEvent)

dataItemAdded

public void dataItemAdded(javax.infobus.DataItemAddedEvent e)
Indicates that a new item was added to the bound aggregate data item (e.g. ArrayAccess, a JDK Collection, etc).

A reference to the data item that was added, and a reference to the one that gained it, can be obtained from the event.

Specified by:
dataItemAdded in interface javax.infobus.DataItemChangeListener
See Also:
DataItemChangeListener.dataItemAdded(javax.infobus.DataItemAddedEvent)

dataItemDeleted

public void dataItemDeleted(javax.infobus.DataItemDeletedEvent e)
Indicates that an item was deleted from the bound aggregate data item (e. g. ArrayAccess, a JDK Collection, etc).

A reference to the data item that was deleted, and a reference to the one that lost it, can be obtained from the event.

Specified by:
dataItemDeleted in interface javax.infobus.DataItemChangeListener
See Also:
DataItemChangeListener.dataItemDeleted(javax.infobus.DataItemDeletedEvent)

dataItemRevoked

public void dataItemRevoked(javax.infobus.DataItemRevokedEvent e)
Indicates that the bound data item (and its sub-items, if any) has been revoked, and is temporarily unavailable.

A reference to the data item that was revoked can be obtained from the event.

Specified by:
dataItemRevoked in interface javax.infobus.DataItemChangeListener
See Also:
DataItemChangeListener.dataItemRevoked(javax.infobus.DataItemRevokedEvent)

rowsetCursorMoved

public void rowsetCursorMoved(javax.infobus.RowsetCursorMovedEvent e)
Indicates that the cursor for the bound RowsetAccess data item has changed rows.

A reference to the rowset data item can be obtained from the event.

Specified by:
rowsetCursorMoved in interface javax.infobus.DataItemChangeListener
See Also:
DataItemChangeListener.rowsetCursorMoved(javax.infobus.RowsetCursorMovedEvent)

getColumnName

public java.lang.String getColumnName(int columnIndex)
Returns the name of the column at columnIndex.

This is used to initialize the table's column header name. Note, this name does not need to be unique. Two columns on a table can have the same name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Parameters:
columnIndex - The column index.
Returns:
The name of the column.

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns the lowest common denominator Class in the column.

This is used by the table to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Parameters:
columnIndex - The column index.
Returns:
The common ancestor class of the object values in the model.

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.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Parameters:
rowIndex - The row whose value is to be looked up.
columnIndex - The column whose value is to be looked up.
Returns:
true if the cell is editable.
See Also:
#setValueAt()

getColumnCount

public int getColumnCount()
Returns the number of columns managed by the data source object.

A JTable uses this method to determine how many columns it should create and display on initialization.

Specified by:
getColumnCount in interface javax.swing.table.TableModel
Returns:
The number of columns in the model.
See Also:
getRowCount()

getRowCount

public int getRowCount()
Returns the number of records managed by the data source object.

A JTable uses this method to determine how many rows it should create and display.

This method should be quick, as it is called by JTable quite frequently.

Specified by:
getRowCount in interface javax.swing.table.TableModel
Returns:
The number or rows in the model.
See Also:
getColumnCount()

getRowCountFromRowsetAccess

protected int getRowCountFromRowsetAccess(javax.infobus.ScrollableRowsetAccess scr)

getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Returns an attribute value for the cell at columnIndex and rowIndex.

Specified by:
getValueAt in interface javax.swing.table.TableModel
Parameters:
rowIndex - The row whose value is to be looked up.
columnIndex - The column whose value is to be looked up.
Returns:
The value Object at the specified cell.

setValueAt

public void setValueAt(java.lang.Object value,
                       int rowIndex,
                       int columnIndex)
Sets an attribute value for the record in the cell at columnIndex and rowIndex.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Parameters:
value - The new value.
rowIndex - The row whose value is to be changed.
columnIndex - The column whose value is to be changed.
See Also:
#getValueAt(), #isCellEditable()

_getItemAt

protected java.lang.Object _getItemAt(int rowIndex,
                                      int columnIndex)
Returns the data item value for the cell at columnIndex and rowIndex.

This method is used internally and is invoked by the GridControl directly for validation support.

Parameters:
rowIndex - The row whose value is to be looked up.
columnIndex - The column whose value is to be looked up.
Returns:
The data item value at the specified cell.

_getRecommendedRangeSize

protected int _getRecommendedRangeSize()

_computeVisibleRowcount

protected int _computeVisibleRowcount()

_handleDataItemValueChanged

protected void _handleDataItemValueChanged(javax.infobus.DataItemValueChangedEvent e)
Indicates a changed value in the bound data item.

Does the real work of handling the DataItemValueChanged event. A reference to the data item that changed can be obtained from the event.

See Also:
DataItemChangeListener.dataItemValueChanged(javax.infobus.DataItemValueChangedEvent)

_shouldUpdateRowcount

protected boolean _shouldUpdateRowcount(javax.infobus.DataItemValueChangedEvent e)

_handleDataItemAdded

protected void _handleDataItemAdded(javax.infobus.DataItemAddedEvent e)
Indicates that a new item was added to the bound aggregate data item (e.g. ArrayAccess, a JDK Collection, etc).

A reference to the data item that was added, and a reference to the one that gained it, can be obtained from the event.

See Also:
DataItemChangeListener.dataItemAdded(javax.infobus.DataItemAddedEvent)

_handleDataItemDeleted

protected void _handleDataItemDeleted(javax.infobus.DataItemDeletedEvent e)
Indicates that an item was deleted from the bound aggregate data item (e. g. ArrayAccess, a JDK Collection, etc).

A reference to the data item that was deleted, and a reference to the one that lost it, can be obtained from the event.

See Also:
DataItemChangeListener.dataItemDeleted(javax.infobus.DataItemDeletedEvent)

_fireTableChanged

protected void _fireTableChanged(javax.swing.event.TableModelEvent event)
Fires the TableChanged event to the table.

This class is not thread-safe for Swing.

See Also:
#_fireTableChangedLater

_getColumnLabels

protected void _getColumnLabels(javax.infobus.ScrollableRowsetAccess rowset)

_buildColumnModel

protected oracle.dacf.control.swing.GridTableColumnModel _buildColumnModel(javax.infobus.ScrollableRowsetAccess rowset)
build a table column model, based on the widths specified.

Parameters:
rowset - for which the table column model has to be built
Returns:
TableColumnModel built from the rowset

_getColumnItem

protected java.lang.Object _getColumnItem(javax.infobus.RowsetAccess rsAccess,
                                          int colIndex)

Oracle Data-aware Controls Reference

 

Copyright © 1997, 2003, Oracle. All rights reserved.