[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-devel] Wizards with progress!
|
I have finally enabled the WMS Wizard with a progress bar. Below is the attached
code that does so! Quite simple really. Not that you cannot perform UI work in
the thread, which is why there is a call to displayError().
getContainer().run(true, false, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
monitor.beginTask("Connecting to the WMS :", IProgressMonitor.UNKNOWN);
wms = new WebMapServer(url);
if (wms.getCapabilities() == null) {
displayError("Unable to parse capabilities document at this URL properly.");
}
monitor.done();
} catch (UnknownHostException e) {
displayError("Host - " + e.getLocalizedMessage()+" - not found.");
} catch (FileNotFoundException e) {
displayError("No document found at that URL.");
} catch (IOException e) {
displayError("Unable to parse this capabilities document properly. ");
}
}
});
and displayError, which does UI stuff:
private void displayError(final String message) {
Display.getDefault().asyncExec(new Runnable() {
public void run() {
startPage.setErrorMessage(message);
getContainer().updateMessage();
}
});
}
Richard