Class AsyncTableDataProvider<Bean,Query,Result>
- java.lang.Object
-
- io.github.jonestimd.swing.table.model.AsyncTableDataProvider<Bean,Query,Result>
-
- Type Parameters:
Bean
- the class representing a row in the tableQuery
- the class representing the request for the data (e.g. aCollection
of IDs)Result
- the class representing the collection of retrieved data (e.g. aMap
of IDs to row data)
- All Implemented Interfaces:
TableDataProvider<Bean>
public abstract class AsyncTableDataProvider<Bean,Query,Result> extends java.lang.Object implements TableDataProvider<Bean>
Base class for loading table data in a background thread.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.beans.PropertyChangeSupport
changeSupport
-
Fields inherited from interface io.github.jonestimd.swing.table.model.TableDataProvider
STATE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AsyncTableDataProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
activeQueries()
void
addStateChangeListener(java.beans.PropertyChangeListener listener)
AddPropertyChangeListener
to be notified when the data has been loaded.protected void
firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
protected void
fireStateChanged()
protected abstract Result
getData(Query query)
Execute a query on a background thread.protected abstract boolean
matches(Query pendingQuery, Query newQuery)
Compare two queries for redundancy.void
removeStateChangeListener(java.beans.PropertyChangeListener listener)
protected abstract void
setResult(Result result)
Update the model with the result of a query.protected void
submitIfNotPending(Query query)
Submitquery
if it is not already in the queue.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.github.jonestimd.swing.table.model.TableDataProvider
addBean, getColumnAdapters, removeBean, setBeans, updateBean
-
-
-
-
Method Detail
-
addStateChangeListener
public void addStateChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface:TableDataProvider
AddPropertyChangeListener
to be notified when the data has been loaded.- Specified by:
addStateChangeListener
in interfaceTableDataProvider<Bean>
-
removeStateChangeListener
public void removeStateChangeListener(java.beans.PropertyChangeListener listener)
- Specified by:
removeStateChangeListener
in interfaceTableDataProvider<Bean>
-
firePropertyChange
protected void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
-
fireStateChanged
protected void fireStateChanged()
-
getData
protected abstract Result getData(Query query) throws java.lang.Exception
Execute a query on a background thread.- Throws:
java.lang.Exception
-
setResult
protected abstract void setResult(Result result)
Update the model with the result of a query. This method will only be called from the Event Dispatch Thread.
-
matches
protected abstract boolean matches(Query pendingQuery, Query newQuery)
Compare two queries for redundancy.- Parameters:
pendingQuery
- a query on the queuenewQuery
- a query to be added to the queue- Returns:
- true if
newQuery
is included inpendingQuery
-
submitIfNotPending
protected void submitIfNotPending(Query query)
Submitquery
if it is not already in the queue.Note: this method should only be called from the Event Dispatch Thread.
- See Also:
matches(Object, Object)
-
activeQueries
public int activeQueries()
- Returns:
- the number of queries in the queue.
-
-