public class ParentRelationLoadingTask extends PleaseWaitRunnable
final ParentRelationLoadingTask task = new ParentRelationLoadingTask( child, // the child relation Main.getLayerManager().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 java.lang.Runnable |
continuation |
private boolean |
full |
private java.lang.Exception |
lastException |
private OsmDataLayer |
layer |
private java.util.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() |
java.util.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(java.lang.Runnable continuation)
Set a continuation which is called upon the job finished.
|
protected void |
showLastException() |
afterFinish, canRunInBackground, getProgressMonitor, operationCanceled, run
private boolean canceled
private java.lang.Exception lastException
private final boolean full
private final OsmDataLayer layer
private java.lang.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 usedjava.lang.IllegalArgumentException
- if child is nulljava.lang.IllegalArgumentException
- if layer is nulljava.lang.IllegalArgumentException
- if child.getId() == 0public void setContinuation(java.lang.Runnable continuation)
continuation
- the continuationpublic boolean isCanceled()
public boolean hasError()
protected OsmDataLayer getLayer()
public java.util.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 org.xml.sax.SAXException, java.io.IOException, OsmTransferException
PleaseWaitRunnable
realRun
in class PleaseWaitRunnable
org.xml.sax.SAXException
- if a SAX error occursjava.io.IOException
- if an I/O error occursOsmTransferException
- if a communication error with the OSM server occurs