Class TableUpdateJob<T>
- java.lang.Object
-
- docking.widgets.table.threaded.TableUpdateJob<T>
-
- Type Parameters:
T
- the type of data that each row in the table represents.
- Direct Known Subclasses:
AddRemoveJob
,FilterJob
,LoadJob
,LoadSpecificDataJob
,SortJob
public class TableUpdateJob<T> extends java.lang.Object
State machine object for performing the various update functions on a ThreadedTableModel. The general pattern is to:- Load
- Filter
- Process individual adds and removes
- Sort
- Set the processed data back on the model
Not all the update functions are performed on a run of a TableUpdateJob. If the reloadData flag is not set, the the data is just copied from the model's current list, instead of calling the model's loadData() method. If the sortComparator is null, then the data is not sorted (for example, when only filtering needs to be done). If there are no add/removes in the list, then that step does nothing.
Before the job completes, new calls to sort and filter can be called. If the job is past the stage of the new call, the
monitor
is cancelled, causing the current stage to abort. The next state of this job is set to the appropriate state for the call, the monitor is reset, and the job begins executing the next stage, based upon the new call.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<AddRemoveListItem<T>>
addRemoveList
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addRemove(AddRemoveListItem<T> item, int maxAddRemoveCount)
Adds the Add/Remove item to the list of items to be processed in the add/remove phase.void
cancel()
void
reload()
Forces this job to completely reload the data, instead of copying from the model's current data.boolean
requestFilter()
Tells the job that the filter criteria has changed.boolean
requestSort(TableSortingContext<T> newSortingContext, boolean forceSort)
Sets the TableColumnComparator to use for sorting the data.void
run()
The basic run() method that executes the state machine.protected void
setData(TableData<T> data)
Meant to be called by subclasses, not clients.protected void
setForceFilter(boolean force)
Allows the precise disabling of the filter operation.java.lang.String
toString()
-
-
-
Field Detail
-
addRemoveList
protected java.util.List<AddRemoveListItem<T>> addRemoveList
-
-
Method Detail
-
setData
protected void setData(TableData<T> data)
Meant to be called by subclasses, not clients. This method will trigger this job not to load data, but rather to use the given data.- Parameters:
data
- The data to process.
-
setForceFilter
protected void setForceFilter(boolean force)
Allows the precise disabling of the filter operation. For example, when the user sorts, no filtering is needed. If the filter has changed, then a filter will take place, regardless of the state of this variable.- Parameters:
force
- false to reuse the current filter, if possible.
-
run
public void run()
The basic run() method that executes the state machine.
-
reload
public void reload()
Forces this job to completely reload the data, instead of copying from the model's current data. This call is not allowed on the currently running job and is only appropriate for a pending job.
-
addRemove
public void addRemove(AddRemoveListItem<T> item, int maxAddRemoveCount)
Adds the Add/Remove item to the list of items to be processed in the add/remove phase. This call is not allowed on running jobs, only pending jobs.- Parameters:
item
- the add/remove item to add to the list of items to be processed in the add/remove phase of this job.maxAddRemoveCount
- the maximum number of add/remove jobs to queue before performing a full reload
-
requestSort
public boolean requestSort(TableSortingContext<T> newSortingContext, boolean forceSort)
Sets the TableColumnComparator to use for sorting the data. This method can be called on the currently running job as well as the pending job. If called on the running job, the effect depends on the running job's state:- If the sort state hasn't happened yet, all it does is set the comparator for when the sort occurs.
- If the sort state has already been started or completed, then this method attempts to stop the current process phase and cause the state machine to return to the sort phase.
- If the current job has already entered the DONE state, then the sort cannot take effect in this job and a false value is returned to indicate the sort was not handled by this job.
- Parameters:
newSortingContext
- the TableColumnComparator to use to sort the data.forceSort
- True signals to re-sort, even if this is already sorted- Returns:
- true if the sort can be processed by this job, false if this job is essentially already completed and therefor cannot perform the sort job.
-
requestFilter
public boolean requestFilter()
Tells the job that the filter criteria has changed. This method can be called on the currently running job as well as the pending job. If called on the running job, the effect depends on the running job's state:- If the filter state hasn't happened yet, then nothing needs to be done as this job will filter later anyway.
- If the filter state has already been started or completed, then this method attempts to stop the current process phase and cause the state machine to return to the filter phase.
- If the current job has already entered the DONE state, then the filter cannot take effect in this job and a false value is returned to indicate the filter was not handled by this job.
- Returns:
- true if the filter can be processed by this job, false if this job is essentially already completed and therefor cannot perform the filter job.
-
cancel
public void cancel()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-