Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 06:55 Go to next message
Nagesh Y J is currently offline Nagesh Y JFriend
Messages: 11
Registered: July 2009
Junior Member
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();
}
}


});


Regards,
Nagesh Y.J.
Re: ProgressMonitorDialog cancel button not listening by progress monitor [message #481473 is a reply to message #481460] Fri, 21 August 2009 08:05 Go to previous messageGo to next message
Jeeeyul Lee is currently offline Jeeeyul LeeFriend
Messages: 117
Registered: July 2009
Location: Seoul
Senior Member

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 09:45 Go to previous message
Nagesh Y J is currently offline Nagesh Y JFriend
Messages: 11
Registered: July 2009
Junior Member
Thanks Jiyul.

Regards,
Nagesh Y.J.
Previous Topic:cvs plugin
Next Topic:Load Jar from system variable
Goto Forum:
  


Current Time: Sat Apr 27 00:38:11 GMT 2024

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

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

Back to the top