public abstract class QueryJob<T>
extends org.eclipse.core.runtime.jobs.Job
org.eclipse.core.runtime.jobs.Job
class to run the queries asynchronously. This job is a user job by default.
Usage:
Create the job:
QueryJob job = new QueryJob("Example Query") {
protected Collection doRun(IProgressMonitor monitor) {
// create the index context
IndexContext context = IndexContext.createDefaultContext(new ResourceSetImpl());
// run the query
Collection result = Collections.EMPTY_LIST;
result = IIndexSearchManager.INSTANCE.findEObjects(context, EXTLibraryPackage.eINSTANCE.
.getBookOnTape(), monitor);
// return the result
return result;
};
};
Schedule the job:
job.schedule();
Get the results:
job.getResults();
| Constructor and Description |
|---|
QueryJob(java.lang.String name)
The constructor
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
belongsTo(java.lang.Object family) |
protected abstract java.util.Collection<T> |
doRun(org.eclipse.core.runtime.IProgressMonitor monitor)
Runs this query.
|
java.lang.String |
getJobFamily()
Returns the family
|
java.util.Collection<T> |
getResults()
Returns the results
|
protected org.eclipse.core.runtime.IStatus |
run(org.eclipse.core.runtime.IProgressMonitor monitor) |
addJobChangeListener, cancel, canceling, create, create, createSystem, createSystem, done, getJobGroup, getJobManager, getName, getPriority, getProperty, getResult, getRule, getState, getThread, isBlocking, isSystem, isUser, join, join, removeJobChangeListener, schedule, schedule, setJobGroup, setName, setPriority, setProgressGroup, setProperty, setRule, setSystem, setThread, setUser, shouldRun, shouldSchedule, sleep, toString, wakeUp, wakeUp, yieldRulepublic QueryJob(java.lang.String name)
name - the name of the jobpublic final boolean belongsTo(java.lang.Object family)
belongsTo in class org.eclipse.core.runtime.jobs.Jobpublic final java.lang.String getJobFamily()
public final java.util.Collection<T> getResults()
protected final org.eclipse.core.runtime.IStatus run(org.eclipse.core.runtime.IProgressMonitor monitor)
run in class org.eclipse.core.runtime.jobs.Jobprotected abstract java.util.Collection<T> doRun(org.eclipse.core.runtime.IProgressMonitor monitor)
QueryJob's
run method, which supplies the progress monitor. A request
to cancel the operation should be honored and acknowledged by throwing
OperationCanceledException.monitor - the progress monitor to use to display progress and receive
requests for cancelationorg.eclipse.core.runtime.OperationCanceledException - if the operation detects a request to cancel, using
IProgressMonitor.isCanceled(), it should
exit by throwing OperationCanceledException