qx.ui.table.model
Class Remote

java.lang.Object
  extended by qx.core.Object
      extended by qx.core.Target
          extended by qx.ui.table.model.Abstract
              extended by qx.ui.table.model.Remote
All Implemented Interfaces:
ITableModel

public class Remote
extends Abstract

A table model that loads its data from a backend.

Only those rows are loaded that are near the area the user is currently viewing. If the user scrolls, the rows he will see soon are loaded asynchroniously in the background. All loaded data is managed in a cache that automatically removes the last resently used rows when it gets full.

This class is abstract: The actual loading of row data must be done by subclasses.


Constructor Summary
Remote()
           
 
Method Summary
 boolean _cancelCurrentRequest()
          Cancels the current request if possible.
 void _loadRowCount()
          Implementing classes have to call _onRowCountLoaded() when the server response arrived.
 void _loadRowData(java.lang.Integer firstRow, java.lang.Integer lastRow)
          Loads some row data from the server.
 void _onRowCountLoaded(java.lang.Integer rowCount)
          Sets the row count.
 void _onRowDataLoaded(java.lang.Object rowDataArr)
          Sets row data.
 void _setRowBlockData(java.lang.Integer block, java.lang.Object rowDataArr)
          Sets the data of one block.
 void clearCache()
          Clears the cache.
 java.lang.Integer getBlockSize()
          Returns the (computed) value of the property blockSize.
 java.lang.Object getCacheContent()
          Returns the current state of the cache.
 boolean getClearCacheOnRemove()
          Returns the (computed) value of the property clearCacheOnRemove.
 java.lang.Integer getMaxCachedBlockCount()
          Returns the (computed) value of the property maxCachedBlockCount.
 java.lang.Integer getRowCount()
          Returns the number of rows in the model.
 java.lang.Object getRowData(java.lang.Integer rowIndex)
          See overridden method for details.
 java.lang.Integer getSortColumnIndex()
          Returns the column index the model is sorted by.
 java.lang.Object getValue(java.lang.Integer columnIndex, java.lang.Integer rowIndex)
          Returns a cell value by column index.
 void initBlockSize(java.lang.Integer arg)
          Calls the apply method and dispatches the change event of the property blockSize with the default value defined by the class developer.
 void initClearCacheOnRemove(boolean arg)
          Calls the apply method and dispatches the change event of the property clearCacheOnRemove with the default value defined by the class developer.
 void initMaxCachedBlockCount(java.lang.Integer arg)
          Calls the apply method and dispatches the change event of the property maxCachedBlockCount with the default value defined by the class developer.
 boolean isClearCacheOnRemove()
          Check whether the (computed) value of the boolean property clearCacheOnRemove equals true.
 boolean isColumnSortable(java.lang.Integer columnIndex)
          Returns whether a column is sortable.
 boolean isSortAscending()
          Returns whether the model is sorted ascending.
 void iterateCachedRows(java.lang.Object iterator, java.lang.Object object)
          Iterates through all cached rows.
 void prefetchRows(java.lang.Integer firstRowIndex, java.lang.Integer lastRowIndex)
          Prefetches some rows.
 void reloadData()
          Reloads the model and clears the local cache.
 void removeRow(java.lang.Integer rowIndex)
          Removes a rows from the model.
 void resetBlockSize()
          Resets the user value of the property blockSize.
 void resetClearCacheOnRemove()
          Resets the user value of the property clearCacheOnRemove.
 void resetMaxCachedBlockCount()
          Resets the user value of the property maxCachedBlockCount.
 void restoreCacheContent(java.lang.Object cacheContent)
          Restores a cache state created by getCacheContent().
 void setBlockSize(java.lang.Integer arg)
          Sets the user value of the property blockSize.
 void setClearCacheOnRemove(boolean arg)
          Sets the user value of the property clearCacheOnRemove.
 void setColumnSortable(java.lang.Integer columnIndex, boolean sortable)
          Sets whether a column is sortable.
 void setMaxCachedBlockCount(java.lang.Integer arg)
          Sets the user value of the property maxCachedBlockCount.
 void setValue(java.lang.Integer columnIndex, java.lang.Integer rowIndex, java.lang.Object value)
          Sets a cell value by column index.
 void sortByColumn(java.lang.Integer columnIndex, boolean ascending)
          Sorts the model by a column.
 boolean toggleClearCacheOnRemove()
          Toggles the (computed) value of the boolean property clearCacheOnRemove.
 
Methods inherited from class qx.ui.table.model.Abstract
getColumnCount, getColumnId, getColumnIndexById, getColumnName, getValueById, isColumnEditable, setColumnIds, setColumnNamesById, setColumnNamesByIndex, setColumns, setValueById
 
Methods inherited from class qx.core.Target
_dispatchEvent, addChangeSelectionListener, addChangeValueListener, addEventListener, addExecuteListener, addJavaEventListener, createDispatchChangeEvent, createDispatchDataEvent, createDispatchEvent, dispatchEvent, hasEventListeners, removeEventListener
 
Methods inherited from class qx.core.Object
_disposeFields, _disposeObjectDeep, _disposeObjects, base, dispose, get, getDisposed, isDisposed, reset, self, set, toHashCode, toString_
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Remote

public Remote()
Method Detail

_cancelCurrentRequest

public boolean _cancelCurrentRequest()

Cancels the current request if possible.

Should be overridden by subclasses if they are able to cancel requests. This allows sending a new request directly after a call of reloadData().


_loadRowCount

public void _loadRowCount()

Implementing classes have to call _onRowCountLoaded() when the server response arrived. That method has to be called! Even when there was an error.


_loadRowData

public void _loadRowData(java.lang.Integer firstRow,
                         java.lang.Integer lastRow)

Loads some row data from the server.

Implementing classes have to call _onRowDataLoaded() when the server response arrived. That method has to be called! Even when there was an error.


_onRowCountLoaded

public void _onRowCountLoaded(java.lang.Integer rowCount)

Sets the row count.

Has to be called by _loadRowCount().


_onRowDataLoaded

public void _onRowDataLoaded(java.lang.Object rowDataArr)

Sets row data.

Has to be called by _loadRowData().


_setRowBlockData

public void _setRowBlockData(java.lang.Integer block,
                             java.lang.Object rowDataArr)

Sets the data of one block.


clearCache

public void clearCache()

Clears the cache.


getBlockSize

public java.lang.Integer getBlockSize()

Returns the (computed) value of the property blockSize.

For further details take a look at the property definition: blockSize.


getCacheContent

public java.lang.Object getCacheContent()

Returns the current state of the cache.

Do not change anything in the returned data. This breaks the model state. Use this method only together with restoreCacheContent(java.lang.Object) for backing up state for a later restore.


getClearCacheOnRemove

public boolean getClearCacheOnRemove()

Returns the (computed) value of the property clearCacheOnRemove.

For further details take a look at the property definition: clearCacheOnRemove.


getMaxCachedBlockCount

public java.lang.Integer getMaxCachedBlockCount()

Returns the (computed) value of the property maxCachedBlockCount.

For further details take a look at the property definition: maxCachedBlockCount.


getRowCount

public java.lang.Integer getRowCount()
Description copied from interface: ITableModel

Returns the number of rows in the model.

Specified by:
getRowCount in interface ITableModel
Overrides:
getRowCount in class Abstract

getRowData

public java.lang.Object getRowData(java.lang.Integer rowIndex)

See overridden method for details.

Specified by:
getRowData in interface ITableModel
Overrides:
getRowData in class Abstract

getSortColumnIndex

public java.lang.Integer getSortColumnIndex()
Description copied from interface: ITableModel

Returns the column index the model is sorted by. If the model is not sorted -1 is returned.

Specified by:
getSortColumnIndex in interface ITableModel
Overrides:
getSortColumnIndex in class Abstract

getValue

public java.lang.Object getValue(java.lang.Integer columnIndex,
                                 java.lang.Integer rowIndex)
Description copied from interface: ITableModel

Returns a cell value by column index.

Specified by:
getValue in interface ITableModel
Overrides:
getValue in class Abstract

initBlockSize

public void initBlockSize(java.lang.Integer arg)

Calls the apply method and dispatches the change event of the property blockSize with the default value defined by the class developer. This function can only be called from the constructor of a class.

For further details take a look at the property definition: blockSize.


initClearCacheOnRemove

public void initClearCacheOnRemove(boolean arg)

Calls the apply method and dispatches the change event of the property clearCacheOnRemove with the default value defined by the class developer. This function can only be called from the constructor of a class.

For further details take a look at the property definition: clearCacheOnRemove.


initMaxCachedBlockCount

public void initMaxCachedBlockCount(java.lang.Integer arg)

Calls the apply method and dispatches the change event of the property maxCachedBlockCount with the default value defined by the class developer. This function can only be called from the constructor of a class.

For further details take a look at the property definition: maxCachedBlockCount.


isClearCacheOnRemove

public boolean isClearCacheOnRemove()

Check whether the (computed) value of the boolean property clearCacheOnRemove equals true.

For further details take a look at the property definition: clearCacheOnRemove.


isColumnSortable

public boolean isColumnSortable(java.lang.Integer columnIndex)
Description copied from interface: ITableModel

Returns whether a column is sortable.

Specified by:
isColumnSortable in interface ITableModel
Overrides:
isColumnSortable in class Abstract

isSortAscending

public boolean isSortAscending()
Description copied from interface: ITableModel

Returns whether the model is sorted ascending.

Specified by:
isSortAscending in interface ITableModel
Overrides:
isSortAscending in class Abstract

iterateCachedRows

public void iterateCachedRows(java.lang.Object iterator,
                              java.lang.Object object)

Iterates through all cached rows.

The iterator will be called for each cached row with two parameters: The row index of the current row (Integer) and the row data of that row (var[]). If the iterator returns something this will be used as new row data.

The iterator is called in the same order as the rows are in the model (the row index is always ascending).


prefetchRows

public void prefetchRows(java.lang.Integer firstRowIndex,
                         java.lang.Integer lastRowIndex)
Description copied from interface: ITableModel

Prefetches some rows. This is a hint to the model that the specified rows will be read soon.

Specified by:
prefetchRows in interface ITableModel
Overrides:
prefetchRows in class Abstract

reloadData

public void reloadData()

Reloads the model and clears the local cache.


removeRow

public void removeRow(java.lang.Integer rowIndex)

Removes a rows from the model.


resetBlockSize

public void resetBlockSize()

Resets the user value of the property blockSize.

The computed value falls back to the next available value e.g. appearance, init or inheritance value depeneding on the property configuration and value availability.

For further details take a look at the property definition: blockSize.


resetClearCacheOnRemove

public void resetClearCacheOnRemove()

Resets the user value of the property clearCacheOnRemove.

The computed value falls back to the next available value e.g. appearance, init or inheritance value depeneding on the property configuration and value availability.

For further details take a look at the property definition: clearCacheOnRemove.


resetMaxCachedBlockCount

public void resetMaxCachedBlockCount()

Resets the user value of the property maxCachedBlockCount.

The computed value falls back to the next available value e.g. appearance, init or inheritance value depeneding on the property configuration and value availability.

For further details take a look at the property definition: maxCachedBlockCount.


restoreCacheContent

public void restoreCacheContent(java.lang.Object cacheContent)

Restores a cache state created by getCacheContent().


setBlockSize

public void setBlockSize(java.lang.Integer arg)

Sets the user value of the property blockSize.

For further details take a look at the property definition: blockSize.


setClearCacheOnRemove

public void setClearCacheOnRemove(boolean arg)

Sets the user value of the property clearCacheOnRemove.

For further details take a look at the property definition: clearCacheOnRemove.


setColumnSortable

public void setColumnSortable(java.lang.Integer columnIndex,
                              boolean sortable)

Sets whether a column is sortable.


setMaxCachedBlockCount

public void setMaxCachedBlockCount(java.lang.Integer arg)

Sets the user value of the property maxCachedBlockCount.

For further details take a look at the property definition: maxCachedBlockCount.


setValue

public void setValue(java.lang.Integer columnIndex,
                     java.lang.Integer rowIndex,
                     java.lang.Object value)
Description copied from interface: ITableModel

Sets a cell value by column index.

Specified by:
setValue in interface ITableModel
Overrides:
setValue in class Abstract

sortByColumn

public void sortByColumn(java.lang.Integer columnIndex,
                         boolean ascending)
Description copied from interface: ITableModel

Sorts the model by a column.

Specified by:
sortByColumn in interface ITableModel
Overrides:
sortByColumn in class Abstract

toggleClearCacheOnRemove

public boolean toggleClearCacheOnRemove()

Toggles the (computed) value of the boolean property clearCacheOnRemove.

For further details take a look at the property definition: clearCacheOnRemove.



Copyright © 2008 1&1. All Rights Reserved.