public class ParentRelationLoadingTask extends PleaseWaitRunnable
final ParentRelationLoadingTask task = new ParentRelationLoadingTask( child, // the child relation Main.main.getEditLayer(), // the edit layer true, // load fully new PleaseWaitProgressMonitor() // a progress monitor ); task.setContinuation( new Runnable() { public void run() { if (task.isCanceled() || task.hasError()) return; List<Relation> parents = task.getParents(); // do something with the parent relations } ); // start the task Main.worker.submit(task);
Modifier and Type | Field and Description |
---|---|
private boolean |
canceled |
private Relation |
child |
private Runnable |
continuation |
private boolean |
full |
private Exception |
lastException |
private OsmDataLayer |
layer |
private List<Relation> |
parents |
private DataSet |
referrers |
progressMonitor
Constructor and Description |
---|
ParentRelationLoadingTask(Relation child,
OsmDataLayer layer,
boolean full,
PleaseWaitProgressMonitor monitor)
Creates a new task for asynchronously downloading the parents of a child relation.
|
Modifier and Type | Method and Description |
---|---|
protected void |
cancel()
User pressed cancel button.
|
protected void |
finish()
Finish up the data work.
|
protected OsmDataLayer |
getLayer() |
List<Relation> |
getParents() |
boolean |
hasError()
Replies true if an exception has been caught during the execution of this task.
|
boolean |
isCanceled()
Replies true if this has been canceled by the user.
|
protected void |
realRun()
Called in the worker thread to do the actual work.
|
void |
setContinuation(Runnable continuation)
Set a continuation which is called upon the job finished.
|
protected void |
showLastException() |
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private boolean canceled
private Exception lastException
private boolean full
private OsmDataLayer layer
private Runnable continuation
public ParentRelationLoadingTask(Relation child, OsmDataLayer layer, boolean full, PleaseWaitProgressMonitor monitor)
child
- the child relation. Must not be null. Must have an id > 0.layer
- the OSM data layer. Must not be null.full
- if true, parent relations are fully downloaded (i.e. with their members)monitor
- the progress monitor to be usedIllegalArgumentException
- thrown if child is nullIllegalArgumentException
- thrown if layer is nullIllegalArgumentException
- thrown if child.getId() == 0public void setContinuation(Runnable continuation)
continuation
- the continuationpublic boolean isCanceled()
public boolean hasError()
protected OsmDataLayer getLayer()
public List<Relation> getParents()
protected void cancel()
PleaseWaitRunnable
cancel
in class PleaseWaitRunnable
protected void showLastException()
protected void finish()
PleaseWaitRunnable
finish
in class PleaseWaitRunnable
protected void realRun() throws SAXException, IOException, OsmTransferException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
SAXException
IOException
OsmTransferException