Show Dialog after Job is finished [message #467808] |
Thu, 10 May 2007 17:10  |
Eclipse User |
|
|
|
Hi,
I'm trying to show an OK dialog that says either that the job has
completed successfully or it has been canceled, but the dialog window
does not come up after the job completes, is this possible?
Thanks,
Roshan
Job job = new Job("Design 2 .NET Generation") {
protected IStatus run(IProgressMonitor monitor) {
//monitor.work();
...
...
//
monitor.done();
return Status.OK_STATUS;
}
};
job.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
if (event.getResult().isOK())
{
MessageBox msgBox = new MessageBox(new Shell(),
SWT.OK|SWT.ICON_INFORMATION);
msgBox.setMessage("Completed successfully");
msgBox.open();
}
else
{
MessageBox msgBox = new MessageBox(new Shell(),
SWT.OK|SWT.ICON_ERROR);
msgBox.setMessage("Did not complete successfully");
msgBox.open();
}
}
});
job.setUser(true); // displays progress bar dialog
job.schedule(); // start as soon as possible
|
|
|
Re: Show Dialog after Job is finished [message #467810 is a reply to message #467808] |
Thu, 10 May 2007 17:41  |
Eclipse User |
|
|
|
You need to put your dialog code in a Display.asyncExec since the job
will be executing outside the UI thread.
--
Roshan Soni wrote:
> Hi,
> I'm trying to show an OK dialog that says either that the job has
> completed successfully or it has been canceled, but the dialog window
> does not come up after the job completes, is this possible?
>
> Thanks,
> Roshan
>
> Job job = new Job("Design 2 .NET Generation") {
> protected IStatus run(IProgressMonitor monitor) {
> //monitor.work();
> ...
> ...
> //
> monitor.done();
> return Status.OK_STATUS;
> }
> };
> job.addJobChangeListener(new JobChangeAdapter() {
> public void done(IJobChangeEvent event) {
> if (event.getResult().isOK())
> {
> MessageBox msgBox = new MessageBox(new Shell(),
> SWT.OK|SWT.ICON_INFORMATION);
> msgBox.setMessage("Completed successfully");
> msgBox.open();
>
> }
> else
> {
> MessageBox msgBox = new MessageBox(new Shell(),
> SWT.OK|SWT.ICON_ERROR);
> msgBox.setMessage("Did not complete successfully");
> msgBox.open();
>
> }
> }
> });
> job.setUser(true); // displays progress bar dialog
> job.schedule(); // start as soon as possible
|
|
|
Powered by
FUDForum. Page generated in 9.99429 seconds