diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java index 11655f14cc8..07109b4d251 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java @@ -57,6 +57,7 @@ public class ProgressMessages extends NLS { public static String ProgressManager_rejectedRefreshException; public static String ProgressMonitorJobsDialog_DetailsTitle; public static String ProgressMonitorJobsDialog_HideTitle; + public static String ProgressToolItem_Update; public static String AnimationManager_AnimationStart; public static String ProgressFloatingWindow_EllipsisValue; public static String BlockedJobsDialog_BlockedTitle; diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java index 13fa07fc675..47e8ca2a8e1 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/TaskBarProgressManager.java @@ -20,7 +20,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Optional; import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -45,9 +44,7 @@ public class TaskBarProgressManager { private IJobProgressManagerListener listener; - private WorkbenchJob animationUpdateJob; - - private boolean isAnimated = false; + private WorkbenchJob updateJob; private List jobs = Collections.synchronizedList(new ArrayList()); @@ -67,8 +64,8 @@ public class TaskBarProgressManager { public TaskBarProgressManager(TaskItem taskItem) { Assert.isNotNull(taskItem); this.taskItem = taskItem; - animationUpdateJob = getAnimationUpdateJob(); - animationUpdateJob.setSystem(true); + updateJob = getUpdateJob(); + updateJob.setSystem(true); listener = getProgressListener(); // Register the IJobProgressManagerListener so we can display progress @@ -83,46 +80,17 @@ public TaskBarProgressManager(TaskItem taskItem) { */ public void dispose() { ProgressManager.getInstance().removeListener(listener); - setAnimated(false); disposeOverlay(); } - private WorkbenchJob getAnimationUpdateJob() { - return new WorkbenchJob(ProgressMessages.AnimationManager_AnimationStart) { + private WorkbenchJob getUpdateJob() { + return new WorkbenchJob(ProgressMessages.ProgressToolItem_Update) { @Override public IStatus runInUIThread(IProgressMonitor monitor) { - if (isAnimated) { - if (!taskItem.isDisposed() && !jobs.isEmpty()) { - Job job = jobs.get(0); - JobInfo jobInfo = jobInfoMap.get(job); - if (job != null && jobInfo != null) { - int percentDone = getPercentDone(jobInfo); - Optional optionalInfo = jobInfo.getTaskInfo(); - if (percentDone == IProgressMonitor.UNKNOWN - || (optionalInfo.isPresent() && optionalInfo.get().totalWork == IProgressMonitor.UNKNOWN)) { - setProgressState(SWT.INDETERMINATE); - } else { - setProgressState(SWT.NORMAL); - if (!taskItem.isDisposed()) { - taskItem.setProgress(percentDone); - } - } - } else { - setProgressState(SWT.DEFAULT); - } - updateImage(job); - } else { - updateImage(null); - } - } else { - setProgressState(SWT.DEFAULT); - updateImage(null); - } + setProgressState(SWT.DEFAULT); + updateImage(null); - if (isAnimated && taskItem != null && !taskItem.isDisposed()) { - schedule(400); - } return Status.OK_STATUS; } @@ -132,24 +100,6 @@ private void setProgressState(int state) { taskItem.setProgressState(state); } } - - private int getPercentDone(JobTreeElement info) { - if (info.isJobInfo()) { - return ((JobInfo) info).getPercentDone(); - } - - if (info.hasChildren()) { - Object[] roots = ((GroupInfo) info).getChildren(); - if (roots.length == 1 && roots[0] instanceof JobTreeElement) { - Optional optionalInfo = ((JobInfo) roots[0]).getTaskInfo(); - if (optionalInfo.isPresent()) { - return optionalInfo.get().getPercentDone(); - } - } - return ((GroupInfo) info).getPercentDone(); - } - return 0; - } }; } @@ -207,9 +157,6 @@ public void addJob(JobInfo info) { if (isNotTracked(info)) { return; } - if (jobs.isEmpty()) { - setAnimated(true); - } if (!jobs.contains(info.getJob())) { jobs.add(info.getJob()); } @@ -231,7 +178,6 @@ public void refreshAll() { ProgressManager manager = ProgressManager.getInstance(); jobs.clear(); jobInfoMap.clear(); - setAnimated(false); for (JobInfo currentInfo : manager.getJobInfos(showsDebug())) { addJob(currentInfo); } @@ -241,9 +187,6 @@ public void refreshAll() { public void removeJob(JobInfo info) { jobs.remove(info.getJob()); jobInfoMap.remove(info.getJob()); - if (jobs.isEmpty()) { - setAnimated(false); - } } @Override @@ -289,8 +232,4 @@ public void refreshGroup(GroupInfo info) { }; } - private synchronized void setAnimated(boolean animated) { - isAnimated = animated; - animationUpdateJob.schedule(); - } } diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties index 2eb211a43f9..b2b04b14c43 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties @@ -52,6 +52,7 @@ ProgressManager_rejectedRefreshException=This exception is logged merely as a de ProgressMonitorJobsDialog_DetailsTitle=&Details >> ProgressMonitorJobsDialog_HideTitle=<< &Details +ProgressToolItem_Update=Updating progress tool item start AnimationManager_AnimationStart=Animation start ProgressFloatingWindow_EllipsisValue=...