org.cruxframework.crux.core.client.dataprovider
Class SyncScrollableDataProvider<T>

java.lang.Object
  extended by org.cruxframework.crux.core.client.dataprovider.SyncScrollableDataProvider<T>
All Implemented Interfaces:
DataProvider<T>, MeasurableDataProvider<T>, SyncDataProvider<T>

public abstract class SyncScrollableDataProvider<T>
extends Object
implements SyncDataProvider<T>

Author:
Thiago da Rosa de Bustamante

Field Summary
protected  int currentRecord
           
protected  DataProviderRecord<T>[] data
           
protected  boolean loaded
           
protected  org.cruxframework.crux.core.client.dataprovider.DataProviderOperations<T> operations
           
protected  SyncDataProviderCallback synchronousCallback
           
 
Constructor Summary
SyncScrollableDataProvider()
           
 
Method Summary
 void clearChanges()
          Undo all changes
protected  SynchronousDataProviderEvent<T> createSynchronousDataProviderEvent()
           
protected  void ensureLoaded()
           
 void firstRecord()
          Points DataProvider to first record
 T getBoundObject()
          Return a copy of the current record object.
 int getIndex(T boundObject)
          Retrieve the index of the given object
 DataProviderRecord<T>[] getNewRecords()
          Return all records inserted on DataProvider
 DataProviderRecord<T> getRecord()
          Return the DataProviderRecord object, representing the current record
 int getRecordCount()
           
 DataProviderRecord<T>[] getRemovedRecords()
          Return all records removed from DataProvider
 DataProviderRecord<T>[] getSelectedRecords()
          Return all records selected on DataProvider
 DataProviderRecord<T>[] getUpdatedRecords()
          Return all records modified on DataProvider
 boolean hasNextRecord()
          Verify if DataProvider has more records.
 boolean hasPreviousRecord()
          Verify if DataProvider has previous records.
 DataProviderRecord<T> insertRecord(int index)
          Insert a new record on DataProvider
 void lastRecord()
           
 void nextRecord()
          Points DataProvider to next record
 void previousRecord()
          Points DataProvider to previous record
 DataProviderRecord<T> removeRecord(int index)
          Remove a record from DataProvider
 void reset()
          Reset DataProvider, as if it was never loaded before.
 void selectRecord(int index, boolean selected)
          Mark the given record as selected
 void setCallback(SyncDataProviderCallback callback)
           
 void sort(Comparator<T> comparator)
          Sort DataProvider records, based on column informed
protected  void sortArray(DataProviderRecord<T>[] array, Comparator<T> comparator)
           
protected  void update(DataProviderRecord<T>[] records)
           
 void updateData(Array<T> data)
          Method called to bind some data to the DataProvider
 void updateData(List<T> data)
          Method called to bind some data to the DataProvider
 void updateData(T[] data)
          Method called to bind some data to the DataProvider
 void updateState(DataProviderRecord<T> record, DataProviderRecord.DataProviderRecordState previousState)
          Update a record on DataProvider
 
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.dataprovider.SyncDataProvider
load
 
Methods inherited from interface org.cruxframework.crux.core.client.dataprovider.DataProvider
firstRecord, getBoundObject, getRecord, hasNextRecord, hasPreviousRecord, nextRecord, previousRecord, sort, updateData, updateData, updateData
 

Field Detail

synchronousCallback

protected SyncDataProviderCallback synchronousCallback

operations

protected org.cruxframework.crux.core.client.dataprovider.DataProviderOperations<T> operations

data

protected DataProviderRecord<T>[] data

currentRecord

protected int currentRecord

loaded

protected boolean loaded
Constructor Detail

SyncScrollableDataProvider

public SyncScrollableDataProvider()
Method Detail

clearChanges

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

Specified by:
clearChanges in interface DataProvider<T>

getNewRecords

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

Specified by:
getNewRecords in interface DataProvider<T>
Returns:
all new records

getRemovedRecords

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

Specified by:
getRemovedRecords in interface DataProvider<T>
Returns:
all removed records

getSelectedRecords

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

Specified by:
getSelectedRecords in interface DataProvider<T>
Returns:
all selected records

getUpdatedRecords

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

Specified by:
getUpdatedRecords in interface DataProvider<T>
Returns:
all modified records

insertRecord

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

Specified by:
insertRecord in interface DataProvider<T>
Returns:

removeRecord

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

Specified by:
removeRecord in interface DataProvider<T>
Returns:

reset

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

Specified by:
reset in interface DataProvider<T>

setCallback

public void setCallback(SyncDataProviderCallback callback)
Specified by:
setCallback in interface SyncDataProvider<T>

selectRecord

public void selectRecord(int index,
                         boolean selected)
Description copied from interface: DataProvider
Mark the given record as selected

Specified by:
selectRecord in interface DataProvider<T>

getIndex

public int getIndex(T boundObject)
Description copied from interface: DataProvider
Retrieve the index of the given object

Specified by:
getIndex in interface DataProvider<T>
Returns:

updateState

public void updateState(DataProviderRecord<T> record,
                        DataProviderRecord.DataProviderRecordState previousState)
Description copied from interface: DataProvider
Update a record on DataProvider

Specified by:
updateState in interface DataProvider<T>

update

protected void update(DataProviderRecord<T>[] records)

createSynchronousDataProviderEvent

protected SynchronousDataProviderEvent<T> createSynchronousDataProviderEvent()

hasNextRecord

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

Specified by:
hasNextRecord in interface DataProvider<T>
Returns:
true if more records exist.

nextRecord

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

Specified by:
nextRecord in interface DataProvider<T>

getRecord

public DataProviderRecord<T> getRecord()
Description copied from interface: DataProvider
Return the DataProviderRecord object, representing the current record

Specified by:
getRecord in interface DataProvider<T>
Returns:
current DataProviderRecord object.

hasPreviousRecord

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

Specified by:
hasPreviousRecord in interface DataProvider<T>
Returns:
true if previous records exist.

previousRecord

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

Specified by:
previousRecord in interface DataProvider<T>

sort

public void sort(Comparator<T> comparator)
Description copied from interface: DataProvider
Sort DataProvider records, based on column informed

Specified by:
sort in interface DataProvider<T>
Parameters:
comparator - Comparator used for sorting.

getRecordCount

public int getRecordCount()
Specified by:
getRecordCount in interface MeasurableDataProvider<T>

firstRecord

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

Specified by:
firstRecord in interface DataProvider<T>

lastRecord

public void lastRecord()
Specified by:
lastRecord in interface MeasurableDataProvider<T>

getBoundObject

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

Specified by:
getBoundObject in interface DataProvider<T>
Returns:

updateData

public void updateData(T[] data)
Description copied from interface: DataProvider
Method called to bind some data to the DataProvider

Specified by:
updateData in interface DataProvider<T>

updateData

public void updateData(List<T> data)
Description copied from interface: DataProvider
Method called to bind some data to the DataProvider

Specified by:
updateData in interface DataProvider<T>

updateData

public void updateData(Array<T> data)
Description copied from interface: DataProvider
Method called to bind some data to the DataProvider

Specified by:
updateData in interface DataProvider<T>

ensureLoaded

protected void ensureLoaded()

sortArray

protected void sortArray(DataProviderRecord<T>[] array,
                         Comparator<T> comparator)


Copyright © 2014. All rights reserved.