Class AsyncTableDataProvider<Bean,​Query,​Result>

  • Type Parameters:
    Bean - the class representing a row in the table
    Query - the class representing the request for the data (e.g. a Collection of IDs)
    Result - the class representing the collection of retrieved data (e.g. a Map 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 Detail

      • changeSupport

        protected final java.beans.PropertyChangeSupport changeSupport
    • Constructor Detail

      • AsyncTableDataProvider

        public AsyncTableDataProvider()
    • Method Detail

      • addStateChangeListener

        public void addStateChangeListener​(java.beans.PropertyChangeListener listener)
        Description copied from interface: TableDataProvider
        Add PropertyChangeListener to be notified when the data has been loaded.
        Specified by:
        addStateChangeListener in interface TableDataProvider<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 queue
        newQuery - a query to be added to the queue
        Returns:
        true if newQuery is included in pendingQuery
      • submitIfNotPending

        protected void submitIfNotPending​(Query query)
        Submit query 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.