org.jdesktop.dataset.provider
Class LoadTask

java.lang.Object
  extended by org.jdesktop.dataset.provider.AbstractTask
      extended by org.jdesktop.dataset.provider.LoadTask
All Implemented Interfaces:
java.lang.Runnable, Task

public abstract class LoadTask
extends AbstractTask

Author:
rbair

Nested Class Summary
static class LoadTask.LoadItem<E>
          Represents a Unit of data, ready to be loaded.
 
Constructor Summary
LoadTask(DataTable[] tables)
          Creates a new LoadTask.
 
Method Summary
 boolean cancel()
           
 java.lang.String getDescription()
           
 javax.swing.Icon getIcon()
           
 java.lang.String getMessage()
           
protected abstract  void loadData(LoadTask.LoadItem[] items)
          Invoked internally once the readData method calls scheduleLoad to schedule the loading of an increment of data to the DataTable.
protected abstract  void readData(DataTable[] tables)
          Subclasses must implement this method to read the data from the data store and place it in a data structure which is disconnected from the DataTable.
 void run()
           
protected  void scheduleLoad()
          Same as scheduleLoad(LoadItem), except that this method will simply schedule a load operation for any remaining items in the queue, but will not add any items to the queue.
protected  void scheduleLoad(LoadTask.LoadItem item)
          Invoked by the readData method from the "reader" thread to schedule a subsequent call to loadData on the event dispatch thread.
 void setLoadOnEDT(boolean val)
           
 
Methods inherited from class org.jdesktop.dataset.provider.AbstractTask
canCancel, getMaximum, getMinimum, getProgress, isIndeterminate, isModal, setCanCancel, setIndeterminate, setMaximum, setMinimum, setModel, setProgress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoadTask

public LoadTask(DataTable[] tables)
Creates a new LoadTask. The param is the array of DataTables to be loaded on this thread

Method Detail

setLoadOnEDT

public void setLoadOnEDT(boolean val)

run

public void run()

readData

protected abstract void readData(DataTable[] tables)
                          throws java.lang.Exception
Subclasses must implement this method to read the data from the data store and place it in a data structure which is disconnected from the DataTable. When increments of data are ready to be loaded into the model, this method should invoke scheduleLoad, which will cause loadData to be called on the event dispatch thread, where the model may be safely updated. Progress events may be fired from this method.

A final scheduleLoad will be called automatically at the conclusion of the loading process, so it is not technically necessary for this method to call scheduleLoad at all unless you want to support partial loads.

Throws:
java.lang.Exception - if errors occur while reading data
See Also:
scheduleLoad(org.jdesktop.dataset.provider.LoadTask.LoadItem)

loadData

protected abstract void loadData(LoadTask.LoadItem[] items)
Invoked internally once the readData method calls scheduleLoad to schedule the loading of an increment of data to the DataTable. This method is called on the event dispatch thread, therefore it is safe to mutate the model from this method. Subclasses must implement this method to load the current contents of the disconnected data structure into the DataTable. Note that because there is an unpredictable delay between the time scheduleLoad is called from the "reader" thread and loadData executes on the event dispatch thread, there may be more data available for loading than was available when scheduleLoad was invoked. All available data should be loaded from this method.

This method should fire an appropriate progress event to notify progress listeners when:


scheduleLoad

protected void scheduleLoad(LoadTask.LoadItem item)
Invoked by the readData method from the "reader" thread to schedule a subsequent call to loadData on the event dispatch thread. If readData invokes scheduleLoad multiple times before loadData has the opportunity to execute on the event dispatch thread, those requests will be collapsed, resulting in only a single call to loadData.

See Also:
readData(org.jdesktop.dataset.DataTable[]), loadData(org.jdesktop.dataset.provider.LoadTask.LoadItem[])

scheduleLoad

protected void scheduleLoad()
Same as scheduleLoad(LoadItem), except that this method will simply schedule a load operation for any remaining items in the queue, but will not add any items to the queue.


getDescription

public java.lang.String getDescription()

getIcon

public javax.swing.Icon getIcon()

getMessage

public java.lang.String getMessage()

cancel

public boolean cancel()
               throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2005 Sun Microsystems All Rights Reserved.