org.cruxframework.crux.core.client.datasource
Class LocalScrollableDataSource<T>

java.lang.Object
  extended by org.cruxframework.crux.core.client.datasource.LocalScrollableDataSource<T>
All Implemented Interfaces:
DataSource<T>, LocalDataSource<T>, MeasurableDataSource<T>

public abstract class LocalScrollableDataSource<T>
extends Object
implements LocalDataSource<T>

Author:
Thiago da Rosa de Bustamante

Field Summary
protected  int currentRecord
           
protected  DataSourceRecord<E>[] data
           
protected  ColumnDefinitions<E> definitions
           
protected  LocalDataSourceCallback loadCallback
           
protected  boolean loaded
           
protected  ClientMessages messages
           
protected  org.cruxframework.crux.core.client.datasource.DataSourceOperations<T> operations
           
 
Constructor Summary
LocalScrollableDataSource()
           
 
Method Summary
 void clearChanges()
          Undo all changes
 T cloneDTO(DataSourceRecord<?> record)
          Clones the recordObject of a given DataSourceRecord
 void copyValueToWidget(com.google.gwt.user.client.ui.HasValue<?> valueContainer, String key, DataSourceRecord<?> dataSourceRecord)
          Copies the value from data record to the given widget
protected  void ensureLoaded()
           
 void firstRecord()
          Points DataSource to first record
 E getBindedObject()
          Deprecated. Use getBoundObject instead
 E getBindedObject(DataSourceRecord<E> record)
          Deprecated. Use getBoundObject instead
 T getBoundObject()
          Return a copy of the current record object.
 T getBoundObject(DataSourceRecord<T> record)
          Return a copy of the record object.
 ColumnDefinitions<E> getColumnDefinitions()
          Return the DataSource definitions object.
 DataSourceRecord<T>[] getNewRecords()
          Return all records inserted on DataSource
 DataSourceRecord<E> getRecord()
          Return the DataSourceRecord object, representing the current record
 DataSourceRecord<E> getRecord(int index)
          Deprecated. 
 int getRecordCount()
           
 int getRecordIndex(T boundObject)
           
 DataSourceRecord<T>[] getRemovedRecords()
          Return all records removed from DataSource
 DataSourceRecord<T>[] getSelectedRecords()
          Return all records selected on DataSource
 DataSourceRecord<T>[] getUpdatedRecords()
          Return all records modified on DataSource
 Object getValue(String columnName)
          Return the column value
 Object getValue(String columnName, DataSourceRecord<?> dataSourceRecord)
          Return the column value
 boolean hasNextRecord()
          Verify if DataSource has more records.
 boolean hasPreviousRecord()
          Verify if DataSource has previous records.
 DataSourceRecord<T> insertRecord(int index)
          Insert a new record on DataSource
 void lastRecord()
           
 void nextRecord()
          Points DataSource to next record
 void previousRecord()
          Points DataSource to previous record
 DataSourceRecord<T> removeRecord(int index)
          Remove a record from DataSource
 void reset()
          Reset DataSource, as if it was never loaded before.
 void setCallback(LocalDataSourceCallback callback)
           
 void setColumnDefinitions(ColumnDefinitions<E> columnDefinitions)
          Sets the DataSource definitions object.
 void setValue(Object value, String columnKey, DataSourceRecord<?> dataSourceRecord)
          Sets the value on the given column of the give record
 void sort(String columnName, boolean ascending)
          Sort dataSource records, based on column informed
 void sort(String columnName, boolean ascending, boolean caseSensitive)
          Sort dataSource records, based on column informed
protected  void sortArray(DataSourceRecord<E>[] array, String columnName, boolean ascending, boolean caseSensitive)
           
 void update(DataSourceRecord<T>[] records)
           
 void updateData(List<T> data)
           
 void updateData(T[] data)
           
 void updateState(DataSourceRecord<T> record, DataSourceRecord.DataSourceRecordState previousState)
          Update a record on DataSource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.cruxframework.crux.core.client.datasource.LocalDataSource
load
 
Methods inherited from interface org.cruxframework.crux.core.client.datasource.DataSource
firstRecord, getColumnDefinitions, getRecord, getValue, getValue, hasNextRecord, hasPreviousRecord, nextRecord, previousRecord, setColumnDefinitions, sort, sort
 

Field Detail

loadCallback

protected LocalDataSourceCallback loadCallback

operations

protected org.cruxframework.crux.core.client.datasource.DataSourceOperations<T> operations

definitions

protected ColumnDefinitions<E> definitions

data

protected DataSourceRecord<E>[] data

currentRecord

protected int currentRecord

loaded

protected boolean loaded

messages

protected ClientMessages messages
Constructor Detail

LocalScrollableDataSource

public LocalScrollableDataSource()
Method Detail

clearChanges

public void clearChanges()
Description copied from interface: DataSource
Undo all changes

Specified by:
clearChanges in interface DataSource<T>
See Also:
DataSource.clearChanges()

getNewRecords

public DataSourceRecord<T>[] getNewRecords()
Description copied from interface: DataSource
Return all records inserted on DataSource

Specified by:
getNewRecords in interface DataSource<T>
Returns:
all new records
See Also:
DataSource.getNewRecords()

getRemovedRecords

public DataSourceRecord<T>[] getRemovedRecords()
Description copied from interface: DataSource
Return all records removed from DataSource

Specified by:
getRemovedRecords in interface DataSource<T>
Returns:
all removed records
See Also:
DataSource.getRemovedRecords()

getSelectedRecords

public DataSourceRecord<T>[] getSelectedRecords()
Description copied from interface: DataSource
Return all records selected on DataSource

Specified by:
getSelectedRecords in interface DataSource<T>
Returns:
all selected records
See Also:
DataSource.getSelectedRecords()

getUpdatedRecords

public DataSourceRecord<T>[] getUpdatedRecords()
Description copied from interface: DataSource
Return all records modified on DataSource

Specified by:
getUpdatedRecords in interface DataSource<T>
Returns:
all modified records
See Also:
DataSource.getUpdatedRecords()

insertRecord

public DataSourceRecord<T> insertRecord(int index)
Description copied from interface: DataSource
Insert a new record on DataSource

Specified by:
insertRecord in interface DataSource<T>
Returns:
See Also:
DataSource.insertRecord(int)

removeRecord

public DataSourceRecord<T> removeRecord(int index)
Description copied from interface: DataSource
Remove a record from DataSource

Specified by:
removeRecord in interface DataSource<T>
Returns:
See Also:
DataSource.removeRecord(int)

reset

public void reset()
Description copied from interface: DataSource
Reset DataSource, as if it was never loaded before.

Specified by:
reset in interface DataSource<T>

setCallback

public void setCallback(LocalDataSourceCallback callback)
Specified by:
setCallback in interface LocalDataSource<T>
See Also:
LocalDataSource.setCallback(org.cruxframework.crux.core.client.datasource.LocalDataSourceCallback)

update

public void update(DataSourceRecord<T>[] records)
Specified by:
update in interface LocalDataSource<T>
See Also:
org.cruxframework.crux.core.client.datasource.LocalDataSource#update(R[])

updateData

public void updateData(T[] data)
Specified by:
updateData in interface LocalDataSource<T>

updateData

public void updateData(List<T> data)
Specified by:
updateData in interface LocalDataSource<T>

copyValueToWidget

public void copyValueToWidget(com.google.gwt.user.client.ui.HasValue<?> valueContainer,
                              String key,
                              DataSourceRecord<?> dataSourceRecord)
Description copied from interface: DataSource
Copies the value from data record to the given widget

Specified by:
copyValueToWidget in interface DataSource<T>

setValue

public void setValue(Object value,
                     String columnKey,
                     DataSourceRecord<?> dataSourceRecord)
Description copied from interface: DataSource
Sets the value on the given column of the give record

Specified by:
setValue in interface DataSource<T>

getRecordIndex

public int getRecordIndex(T boundObject)

updateState

public void updateState(DataSourceRecord<T> record,
                        DataSourceRecord.DataSourceRecordState previousState)
Description copied from interface: DataSource
Update a record on DataSource

Specified by:
updateState in interface DataSource<T>
See Also:
DataSource.updateState(org.cruxframework.crux.core.client.datasource.DataSourceRecord, org.cruxframework.crux.core.client.datasource.DataSourceRecord.DataSourceRecordState)

getBoundObject

public T getBoundObject()
Description copied from interface: DataSource
Return a copy of the current record object.

Specified by:
getBoundObject in interface DataSource<T>
Returns:
See Also:
DataSource.getBoundObject()

getBoundObject

public T getBoundObject(DataSourceRecord<T> record)
Description copied from interface: DataSource
Return a copy of the record object.

Specified by:
getBoundObject in interface DataSource<T>
Returns:
See Also:
DataSource.getBoundObject(org.cruxframework.crux.core.client.datasource.DataSourceRecord)

cloneDTO

public T cloneDTO(DataSourceRecord<?> record)
Description copied from interface: DataSource
Clones the recordObject of a given DataSourceRecord

Specified by:
cloneDTO in interface DataSource<T>
Returns:
See Also:
DataSource.cloneDTO(org.cruxframework.crux.core.client.datasource.DataSourceRecord)

getColumnDefinitions

public ColumnDefinitions<E> getColumnDefinitions()
Description copied from interface: DataSource
Return the DataSource definitions object.

Specified by:
getColumnDefinitions in interface DataSource<E>
Returns:
Definitions object

setColumnDefinitions

public void setColumnDefinitions(ColumnDefinitions<E> columnDefinitions)
Description copied from interface: DataSource
Sets the DataSource definitions object.

Specified by:
setColumnDefinitions in interface DataSource<E>

getValue

public Object getValue(String columnName)
Description copied from interface: DataSource
Return the column value

Specified by:
getValue in interface DataSource<E>
Parameters:
columnName - name of the column
Returns:
value of the column

hasNextRecord

public boolean hasNextRecord()
Description copied from interface: DataSource
Verify if DataSource has more records.

Specified by:
hasNextRecord in interface DataSource<E>
Returns:
true if more records exist.

nextRecord

public void nextRecord()
Description copied from interface: DataSource
Points DataSource to next record

Specified by:
nextRecord in interface DataSource<E>

getRecord

@Deprecated
public DataSourceRecord<E> getRecord(int index)
Deprecated. 


getRecord

public DataSourceRecord<E> getRecord()
Description copied from interface: DataSource
Return the DataSourceRecord object, representing the current record

Specified by:
getRecord in interface DataSource<E>
Returns:
current DataSourceRecord object.

hasPreviousRecord

public boolean hasPreviousRecord()
Description copied from interface: DataSource
Verify if DataSource has previous records.

Specified by:
hasPreviousRecord in interface DataSource<E>
Returns:
true if previous records exist.

previousRecord

public void previousRecord()
Description copied from interface: DataSource
Points DataSource to previous record

Specified by:
previousRecord in interface DataSource<E>

sort

public void sort(String columnName,
                 boolean ascending)
Description copied from interface: DataSource
Sort dataSource records, based on column informed

Specified by:
sort in interface DataSource<E>
Parameters:
columnName - Base column for sorting.
ascending - If true, sort ascending.

sort

public void sort(String columnName,
                 boolean ascending,
                 boolean caseSensitive)
Description copied from interface: DataSource
Sort dataSource records, based on column informed

Specified by:
sort in interface DataSource<E>
Parameters:
columnName - Base column for sorting.
ascending - If true, sort ascending.
caseSensitive - indicate if the columns sort are or not key sensitive

sortArray

protected void sortArray(DataSourceRecord<E>[] array,
                         String columnName,
                         boolean ascending,
                         boolean caseSensitive)

getRecordCount

public int getRecordCount()
Specified by:
getRecordCount in interface MeasurableDataSource<E>

firstRecord

public void firstRecord()
Description copied from interface: DataSource
Points DataSource to first record

Specified by:
firstRecord in interface DataSource<E>

lastRecord

public void lastRecord()
Specified by:
lastRecord in interface MeasurableDataSource<E>

ensureLoaded

protected void ensureLoaded()

getValue

public Object getValue(String columnName,
                       DataSourceRecord<?> dataSourceRecord)
Description copied from interface: DataSource
Return the column value

Specified by:
getValue in interface DataSource<E>
Returns:
See Also:
DataSource.getValue(java.lang.String, org.cruxframework.crux.core.client.datasource.DataSourceRecord)

getBindedObject

@Deprecated
public E getBindedObject()
Deprecated. Use getBoundObject instead

Returns:

getBindedObject

@Deprecated
public E getBindedObject(DataSourceRecord<E> record)
Deprecated. Use getBoundObject instead

Parameters:
record -
Returns:


Copyright © 2014. All rights reserved.