Skip to main content



      Home
Home » Eclipse Projects » Rich Client Platform (RCP) » ProgressMonitorDialog cancel button not listening by progress monitor
ProgressMonitorDialog cancel button not listening by progress monitor [message #481460] Fri, 21 August 2009 02:55 Go to next message
Eclipse UserFriend
Hello,

ProgressMonitorDialog cancel button not listening by progress monitor.
Even if I say cancelable true, the button got enabled but progress monitor
not listening to cancel button click. Please help me. Code which I have
used.

ProgressMonitorDialog dialog = new
ProgressMonitorDialog(Display.getCurrent().getActiveShell()) ;

dialog.run(false, true, new IRunnableWithProgress() {
public void run(final IProgressMonitor monitor)
{
//some code
if(monitor.isCanceled()){
throw new OperationCanceledException();
}
}


});
Re: ProgressMonitorDialog cancel button not listening by progress monitor [message #481473 is a reply to message #481460] Fri, 21 August 2009 04:05 Go to previous messageGo to next message
Eclipse UserFriend
You didn't fork to run your IRunnable instance, So your code ran on
UI-thread, so you couldn't press cancel button till the IRunnable finished.

More general approach is:

Define some task as Job. And

public class TestCommandHandler extends AbstractHandler{
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
TestJob job = new TestJob();
job.setUser(true); // it shows progress dialog to user which allows
// cancelation

job.addJobChangeListener(new JobChangeAdapter() {
@Override
public void done(IJobChangeEvent event) {
handleJobFinished();
}
});

job.schedule();
return null;
}

protected void handleJobFinished() {
System.out.println("Job has been done :)");
}

}
Re: ProgressMonitorDialog cancel button not listening by progress monitor [message #481494 is a reply to message #481473] Fri, 21 August 2009 05:45 Go to previous message
Eclipse UserFriend
Thanks Jiyul.
Previous Topic:cvs plugin
Next Topic:Load Jar from system variable
Goto Forum:
  


Current Time: Thu Jul 10 23:19:27 EDT 2025

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

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

Back to the top