Asynchronous job which should be cancelable [message #1087996] |
Fri, 16 August 2013 12:18 |
|
Hi
I want to implement an dialog, which triggers a long running execution after clicking on an button.
You should even be able to cancel this execution by clicking on a Cancel button.
And the execution itself changes some states (e.g. progress bar, status messages...) that are showed in this dialog.
I tried with
new Job("Building all distributions") {
protected IStatus run(IProgressMonitor progress) {
new UIJob("Building all distributions") {
public IStatus runInUIThread(IProgressMonitor monitor) {
//-> some long running actions
service.run (new ISomeProgressInterface () {
@Override
public void distributionStarted(blabla) {
//Changing state of visible elements
lblSomeLabel.setText("Started building distribution " + currentDistro);
update ();
}
@Override
public boolean isCanceled() {
return buildingCancelled;
}
}
return Status.OK_STATUS;
}.schedule();
return Status.OK_STATUS;
}.schedule();
btnCancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
LOGGER.info("Canceling build");
buildingCancelled = true;
}
But with this construction the selection adapter doesn't notice any clicking.
Could you show me an example how to implement this best possible?
Thanks
Cheers
Markus
|
|
|
|
Powered by
FUDForum. Page generated in 0.03937 seconds