Reputation: 23
I develop an eclipse plugin and I added an eclipse progress view to it. There is an stop button on the progress view and I want to create some kind of listener to handle the events of the cancel button, but I don't know how I can do it. I know the monitor has an isCanceled() method, but I have to create come kind of listener to listen when user clicks the stop button, while the plugin works. Please give me some advice. Thanks
Upvotes: 0
Views: 979
Reputation: 4617
What you have to do here is check the isCanceled
method often while you are on your long-running code. If isCanceled
returns true, you return from your code properly.
Upvotes: 2
Reputation: 81674
The progress view normally monitors Job
objects; you extend org.eclipse.core.runtime.jobs.Job
and implement run()
to define a Job. That class has a canceling()
method; you can override canceling()
and set a flag to true
. Then in your run()
method, you just loop until that flag becomes true
(or the work is done), at which point you cleanup and return.
Upvotes: 1