Time for action – using subtasks and sub-progress monitors
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 ...
Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.