org.granite.client.tide.collections.javafx
Class PagedQuery<E,F>

java.lang.Object
  extended by org.granite.client.tide.collections.AbstractPagedCollection<E>
      extended by org.granite.client.tide.collections.javafx.PagedCollection<E>
          extended by org.granite.client.tide.collections.javafx.PagedQuery<E,F>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>, javafx.beans.Observable, javafx.collections.ObservableList<E>, ContextAware, TideEventObserver, Initializable, NameAware, PropertyHolder, Component

@Named
public class PagedQuery<E,F>
extends PagedCollection<E>
implements Component, PropertyHolder, NameAware, ContextAware, Initializable

Implementation of the Tide paged collection with an generic service backend.

By default the corresponding service should have the same name and expose a 'find' method
that returns a Map with the following properties :

  resultCount
  resultList
  firstResult
  maxResults
  
The name of the remote service can be overriden by setting the remoteComponentName property. The name of the remote method can by set by the remoteMethodName property.

Author:
William DRAI

Nested Class Summary
 
Nested classes/interfaces inherited from class org.granite.client.tide.collections.javafx.PagedCollection
PagedCollection.ListChangeWrapper, PagedCollection.WrappedListListChangeListener
 
Nested classes/interfaces inherited from class org.granite.client.tide.collections.AbstractPagedCollection
AbstractPagedCollection.PagedCollectionIterator, AbstractPagedCollection.PagedCollectionResponder
 
Field Summary
protected  Component component
           
protected  String methodName
           
protected  boolean methodNameSet
           
protected  SortAdapter sortAdapter
           
protected  boolean usePage
           
 
Fields inherited from class org.granite.client.tide.collections.javafx.PagedCollection
wrappedList
 
Fields inherited from class org.granite.client.tide.collections.AbstractPagedCollection
count, filterRefresh, first, fullRefresh, initializing, last, max
 
Constructor Summary
protected PagedQuery()
           
  PagedQuery(ServerSession serverSession)
           
 
Method Summary
<T> Future<T>
call(String operation, Object... args)
           
 void clear()
          Clear collection content
protected  void doFind(Object filter, int first, int max, AbstractPagedCollection.PagedCollectionResponder findResponder)
           
 javafx.beans.property.ObjectProperty<F> filterProperty()
           
protected  void find(int first, int last)
          Trigger a results query for the current filter
 F getFilter()
           
 String getName()
           
 Object getObject()
          PropertyHolder interface
protected  org.granite.tide.data.model.Page<E> getResult(TideResultEvent<?> event, int first, int max)
          Build a result object from the result event
 SortAdapter getSortAdapter()
           
 void init()
           
 boolean refresh()
          Refresh collection with new filter/sort parameters
 void reset()
           
 void resetFilter()
           
 void resetSort()
           
 void setContext(Context context)
           
 void setFilter(F filter)
           
 void setFilterClass(Class<F> filterClass)
           
 void setMethodName(String methodName)
           
 void setName(String componentName)
           
 void setProperty(String propName, Object value)
           
 void setRemoteComponentClass(Class<? extends ComponentImpl> remoteComponentClass)
           
 void setRemoteComponentName(String remoteComponentName)
           
 void setSortAdapter(SortAdapter sortAdapter)
           
 void setUsePage(boolean usePage)
           
 
Methods inherited from class org.granite.client.tide.collections.javafx.PagedCollection
add, add, addAll, addAll, addAll, addListener, addListener, addListener, fireItemsUpdated, firePageChange, getInternalWrappedList, getWrappedList, remove, remove, remove, removeAll, removeAll, removeListener, removeListener, removeListener, retainAll, retainAll, set, setAll, setAll, subList, toArray, toArray
 
Methods inherited from class org.granite.client.tide.collections.AbstractPagedCollection
contains, containsAll, findFault, findResult, fullRefresh, get, handleEvent, handleFault, handleResult, indexOf, initialize, isEmpty, iterator, lastIndexOf, listIterator, listIterator, setElementClass, setMaxResults, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, size
 

Field Detail

component

protected Component component

methodName

protected String methodName

methodNameSet

protected boolean methodNameSet

usePage

protected boolean usePage

sortAdapter

protected SortAdapter sortAdapter
Constructor Detail

PagedQuery

protected PagedQuery()

PagedQuery

public PagedQuery(ServerSession serverSession)
Method Detail

setName

public void setName(String componentName)
Specified by:
setName in interface NameAware

setContext

public void setContext(Context context)
Specified by:
setContext in interface ContextAware

init

public void init()
Specified by:
init in interface Initializable

setSortAdapter

public void setSortAdapter(SortAdapter sortAdapter)

getSortAdapter

public SortAdapter getSortAdapter()

resetSort

public void resetSort()

filterProperty

public javafx.beans.property.ObjectProperty<F> filterProperty()

getFilter

public F getFilter()

setFilter

public void setFilter(F filter)

setFilterClass

public void setFilterClass(Class<F> filterClass)
                    throws IllegalAccessException,
                           InstantiationException
Throws:
IllegalAccessException
InstantiationException

resetFilter

public void resetFilter()

clear

@PreDestroy
public void clear()
Description copied from class: AbstractPagedCollection
Clear collection content

Specified by:
clear in interface Collection<E>
Specified by:
clear in interface List<E>
Overrides:
clear in class PagedCollection<E>

reset

public void reset()

refresh

public boolean refresh()
Description copied from class: AbstractPagedCollection
Refresh collection with new filter/sort parameters

Overrides:
refresh in class AbstractPagedCollection<E>
Returns:
always false

getName

public String getName()
Specified by:
getName in interface Component

setRemoteComponentName

public void setRemoteComponentName(String remoteComponentName)

setRemoteComponentClass

public void setRemoteComponentClass(Class<? extends ComponentImpl> remoteComponentClass)
                             throws IllegalAccessException,
                                    InstantiationException
Throws:
IllegalAccessException
InstantiationException

setMethodName

public void setMethodName(String methodName)

setUsePage

public void setUsePage(boolean usePage)

find

protected void find(int first,
                    int last)
Trigger a results query for the current filter

Overrides:
find in class AbstractPagedCollection<E>
Parameters:
first - : index of first required result
last - : index of last required result

doFind

protected void doFind(Object filter,
                      int first,
                      int max,
                      AbstractPagedCollection.PagedCollectionResponder findResponder)

getResult

protected org.granite.tide.data.model.Page<E> getResult(TideResultEvent<?> event,
                                                        int first,
                                                        int max)
Description copied from class: AbstractPagedCollection
Build a result object from the result event

Specified by:
getResult in class AbstractPagedCollection<E>
Parameters:
event - the result event
first - first index requested
max - max elements requested
Returns:
an object containing data from the collection resultList : the retrieved data resultCount : the total count of elements (non paged) firstResult : the index of the first retrieved element maxResults : the maximum count of retrieved elements

getObject

public Object getObject()
PropertyHolder interface

Specified by:
getObject in interface PropertyHolder

setProperty

public void setProperty(String propName,
                        Object value)
Specified by:
setProperty in interface PropertyHolder

call

public <T> Future<T> call(String operation,
                          Object... args)
Specified by:
call in interface Component