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

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

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

Author:
Thiago da Rosa de Bustamante

Field Summary
protected  int currentPage
           
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
           
protected  int pageSize
           
 
Constructor Summary
LocalPagedDataSource()
           
 
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
 E getBoundObject()
          Return a copy of the current record object.
 E getBoundObject(DataSourceRecord<E> record)
          Return a copy of the record object.
 ColumnDefinitions<E> getColumnDefinitions()
          Return the DataSource definitions object.
 int getCurrentPage()
           
 int getCurrentPageSize()
           
 DataSourceRecord<T>[] getNewRecords()
          Return all records inserted on DataSource
 int getPageCount()
           
protected  int getPageEndRecord()
           
 int getPageSize()
           
protected  int getPageStartRecord()
           
 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 hasNextPage()
           
 boolean hasNextRecord()
          Verify if DataSource has more records.
 boolean hasPreviousPage()
           
 boolean hasPreviousRecord()
          Verify if DataSource has previous records.
 DataSourceRecord<T> insertRecord(int index)
          Insert a new record on DataSource
protected  boolean isRecordOnPage(int record)
           
 void lastRecord()
           
 boolean nextPage()
           
 void nextRecord()
          Points DataSource to next record
 boolean previousPage()
           
 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 selectRecord(int index, boolean selected)
           
 void setCallback(LocalDataSourceCallback callback)
           
 void setColumnDefinitions(ColumnDefinitions<E> columnDefinitions)
          Sets the DataSource definitions object.
 boolean setCurrentPage(int pageNumber)
           
 void setPageSize(int pageSize)
           
 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)
           
protected  void updateCurrentRecord()
           
 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, getBoundObject, getBoundObject, 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

pageSize

protected int pageSize

currentPage

protected int currentPage

definitions

protected ColumnDefinitions<E> definitions

data

protected DataSourceRecord<E>[] data

currentRecord

protected int currentRecord

loaded

protected boolean loaded

messages

protected ClientMessages messages
Constructor Detail

LocalPagedDataSource

public LocalPagedDataSource()
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[])

nextPage

public boolean nextPage()
Specified by:
nextPage in interface PagedDataSource<T>

previousPage

public boolean previousPage()
Specified by:
previousPage in interface PagedDataSource<T>

setCurrentPage

public boolean setCurrentPage(int pageNumber)
Specified by:
setCurrentPage in interface MeasurablePagedDataSource<T>

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)
Specified by:
getRecordIndex in interface PagedDataSource<T>

selectRecord

public void selectRecord(int index,
                         boolean selected)
Specified by:
selectRecord in interface PagedDataSource<T>

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)

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)

getCurrentPage

public int getCurrentPage()
Specified by:
getCurrentPage in interface PagedDataSource<E>

getPageCount

public int getPageCount()
Specified by:
getPageCount in interface MeasurablePagedDataSource<E>

getPageSize

public int getPageSize()
Specified by:
getPageSize in interface PagedDataSource<E>

getCurrentPageSize

public int getCurrentPageSize()
Specified by:
getCurrentPageSize in interface PagedDataSource<E>
See Also:
PagedDataSource.getCurrentPageSize()

hasNextPage

public boolean hasNextPage()
Specified by:
hasNextPage in interface PagedDataSource<E>

hasPreviousPage

public boolean hasPreviousPage()
Specified by:
hasPreviousPage in interface PagedDataSource<E>

setPageSize

public void setPageSize(int pageSize)
Specified by:
setPageSize in interface PagedDataSource<E>

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.

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.

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>

isRecordOnPage

protected boolean isRecordOnPage(int record)

getPageEndRecord

protected int getPageEndRecord()

getPageStartRecord

protected int getPageStartRecord()

updateCurrentRecord

protected void updateCurrentRecord()

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

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.

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>

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:

getBoundObject

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

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

getBoundObject

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

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


Copyright © 2014. All rights reserved.