aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Cortell2013-02-12 17:48:44 (EST)
committerJohn Arthorne2013-02-12 17:48:44 (EST)
commitf092d6459601a6ff565dbc6c46b1f2e96bcf43bf (patch)
tree15461e86aee14d0c7e826352321256ff964905d7
parent31f5b20dec86da15875a8b5caed595cabc7a4513 (diff)
downloadeclipse.platform.ui-f092d6459601a6ff565dbc6c46b1f2e96bcf43bf.zip
eclipse.platform.ui-f092d6459601a6ff565dbc6c46b1f2e96bcf43bf.tar.gz
eclipse.platform.ui-f092d6459601a6ff565dbc6c46b1f2e96bcf43bf.tar.bz2
Bug 395645 - Progress view can show finished job as unfinished
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java113
1 files changed, 68 insertions, 45 deletions
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java
index 33946a9..0893aa4 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressViewUpdater.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2009 IBM Corporation and others.
+ * Copyright (c) 2003, 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,6 @@ package org.eclipse.ui.internal.progress;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -38,6 +37,16 @@ class ProgressViewUpdater implements IJobProgressManagerListener {
Object updateLock = new Object();
+ class MutableBoolean {
+ boolean value;
+ }
+
+ /*
+ * True when update job is scheduled or running. This is used to limit the
+ * update job to no more than once every 100 ms. See bug 258352 and 395645.
+ */
+ MutableBoolean updateScheduled = new MutableBoolean();
+
boolean debug;
@@ -217,21 +226,20 @@ class ProgressViewUpdater implements IJobProgressManagerListener {
}
}
- /** keep track of how often we schedule the job to avoid overloading the JobManager */
- private long lastUpdateJobScheduleRequest = 0;
-
/**
* Schedule an update.
*/
void scheduleUpdate() {
if (PlatformUI.isWorkbenchRunning()) {
// make sure we don't schedule too often
- long now = System.currentTimeMillis();
- if (now - lastUpdateJobScheduleRequest >= 100) {
- //Add in a 100ms delay so as to keep priority low
- updateJob.schedule(100);
- lastUpdateJobScheduleRequest = now;
+ boolean scheduleUpdate = false;
+ synchronized (updateScheduled) {
+ if (!updateScheduled.value) {
+ updateScheduled.value = scheduleUpdate = true;
+ }
}
+ if (scheduleUpdate)
+ updateJob.schedule(100);
}
}
@@ -246,51 +254,66 @@ class ProgressViewUpdater implements IJobProgressManagerListener {
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus runInUIThread(IProgressMonitor monitor) {
-
- //Abort the job if there isn't anything
- if (collectors.length == 0) {
+ synchronized (updateScheduled) {
+ // updates requested while we are running should cause it to
+ // be rescheduled
+ updateScheduled.value = false;
+ }
+ // Abort the job if there isn't anything
+ if (collectors.length == 0) {
return Status.CANCEL_STATUS;
}
- if (currentInfo.updateAll) {
- synchronized (updateLock) {
- currentInfo.reset();
- }
- for (int i = 0; i < collectors.length; i++) {
- collectors[i].refresh();
- }
-
- } else {
- //Lock while getting local copies of the caches.
- Object[] updateItems;
- Object[] additionItems;
- Object[] deletionItems;
- synchronized (updateLock) {
- currentInfo.processForUpdate();
-
- updateItems = currentInfo.refreshes.toArray();
- additionItems = currentInfo.additions.toArray();
- deletionItems = currentInfo.deletions.toArray();
-
- currentInfo.reset();
- }
-
- for (int v = 0; v < collectors.length; v++) {
- IProgressUpdateCollector collector = collectors[v];
-
- if (updateItems.length > 0) {
+ if (currentInfo.updateAll) {
+ synchronized (updateLock) {
+ currentInfo.reset();
+ }
+ for (int i = 0; i < collectors.length; i++) {
+ collectors[i].refresh();
+ }
+
+ } else {
+ // Lock while getting local copies of the caches.
+ Object[] updateItems;
+ Object[] additionItems;
+ Object[] deletionItems;
+ synchronized (updateLock) {
+ currentInfo.processForUpdate();
+
+ updateItems = currentInfo.refreshes.toArray();
+ additionItems = currentInfo.additions.toArray();
+ deletionItems = currentInfo.deletions.toArray();
+
+ currentInfo.reset();
+ }
+
+ for (int v = 0; v < collectors.length; v++) {
+ IProgressUpdateCollector collector = collectors[v];
+
+ if (updateItems.length > 0) {
collector.refresh(updateItems);
}
- if (additionItems.length > 0) {
+ if (additionItems.length > 0) {
collector.add(additionItems);
}
- if (deletionItems.length > 0) {
+ if (deletionItems.length > 0) {
collector.remove(deletionItems);
}
- }
- }
+ }
+ }
- return Status.OK_STATUS;
+ return Status.OK_STATUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.runtime.jobs.Job#canceling()
+ */
+ protected void canceling() {
+ synchronized (updateScheduled) {
+ updateScheduled.value = false;
+ }
}
};
updateJob.setSystem(true);