When performing a set of operations, subtasks can give the user additional details about the state of the operation. A subtask is merely a named message that is displayed along with the task name in the Progress view.
Add a
monitor.subTask
during the operation to give feedback:for (int i=0; i<50 && !monitor.isCanceled(); i++) { if (i == 10) { monitor.subTask("Doing something"); } else if (i == 25) { monitor.subTask("Doing something else"); } else if (i == 40) { monitor.subTask("Nearly there"); } Thread.sleep(100); monitor.worked(100); }
Run the Eclipse instance, and look at the Progress view. The subtask should be shown underneath the status bar:
When calling another method with a progress monitor, if the monitor is passed as is, it can have undesirable effects. Add a new method,
checkDozen
, to the anonymousJob
class inside theHelloHandler
class, and add a condition in thefor
loop that breaks out...