Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Show Dialog after Job is finished
Show Dialog after Job is finished [message #467808] Thu, 10 May 2007 17:10 Go to next message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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
Previous Topic:Programmatically minimize view stack to trim
Next Topic:RCP Based Standalone Help
Goto Forum:
  


Current Time: Fri May 23 05:42:27 EDT 2025

Powered by FUDForum. Page generated in 9.99429 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top