Search code examples
javaeclipseeclipse-pluginruntime

Eclipse Plugin Development stop button in progress bar


My plugin runs a job and is shown in progress bar but i am unable to stop the job from progress bar , i figured out there is IProgressMonitor.setcanceled(True) but i can't figure out where or how can there be a listener to the stop button on progress bar

For your reference https://help.eclipse.org/latest/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/IProgressMonitor.html#isCanceled()


Solution

  • It's not via a listener. Your job has to execute the following on a regular basis (say a few times per second):

    if (monitor.isCanceled())
        return Status.CANCEL_STATUS;
    

    Otherwise, hitting the stop button will not stop the running job.

    See: Eclipse help: Platform Plug-in Developer Guide > Reporting progress