Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-03-14 16:14:07 +0000
committerJean Michel-Lemieux2002-03-14 16:14:07 +0000
commit3025329e824ac5ddceadd7c24b83f2fed118b136 (patch)
tree1e36642b5a22eff6e48757fb949c652d38645c62
parenta4ed1140ff01dc74f57b5646a84f8d0f0b4141dc (diff)
downloadeclipse.platform.team-3025329e824ac5ddceadd7c24b83f2fed118b136.tar.gz
eclipse.platform.team-3025329e824ac5ddceadd7c24b83f2fed118b136.tar.xz
eclipse.platform.team-3025329e824ac5ddceadd7c24b83f2fed118b136.zip
Batching of decorations in runnable.
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java62
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java46
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IDecorationNotifier.java7
4 files changed, 71 insertions, 45 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
index 07d842ee0..7ba31ad73 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorationRunnable.java
@@ -52,6 +52,11 @@ public class CVSDecorationRunnable implements Runnable {
// Provides resources to be decorated and is notified when decoration has been calculated
private IDecorationNotifier notifier;
+ // Remember the non posted decorated resources
+ List resources = new ArrayList();
+ List decorations = new ArrayList();
+ private final static int NUM_TO_BATCH = 50;
+
/*
* Define a cached image descriptor which only creates the image data once
*/
@@ -90,33 +95,48 @@ public class CVSDecorationRunnable implements Runnable {
if (resource == null) {
return;
}
- // it is possible that the resource to be decorated is no longer associated
- // with a CVS provider. This could happen if the team nature was removed
- // between the time the decoration event was posted to the thread and the time
- // the thread processes the decoration.
- ITeamProvider provider = TeamPlugin.getManager().getProvider(resource);
- if(!resource.exists() || provider==null || !(provider instanceof CVSTeamProvider)) {
- continue;
- }
- // determine a if resource has outgoing changes (e.g. is dirty).
- IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
- boolean isDirty = false;
- boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY);
- int type = resource.getType();
- if(type == IResource.FILE || computeDeepDirtyCheck) {
- isDirty = isDirty(resource);
- }
-
- // compute decorations
- CVSDecoration decoration = computeTextLabelFor(resource, isDirty, provider);
- decoration.setOverlays(computeLabelOverlaysFor(resource, isDirty, provider));
+ CVSDecoration decoration = decorate(resource);
// notify that decoration is ready
- notifier.decorated(resource, decoration);
+ if(decoration!=null) {
+ resources.add(resource);
+ decorations.add(decoration);
+ if(!resources.isEmpty() && (notifier.remaining()==0 || resources.size() >= NUM_TO_BATCH)) {
+ notifier.decorated((IResource[])resources.toArray(new IResource[resources.size()]),
+ (CVSDecoration[])decorations.toArray(new CVSDecoration[decorations.size()]));
+ resources.clear();
+ decorations.clear();
+ }
+ }
}
}
+ public CVSDecoration decorate(IResource resource) {
+ // it is possible that the resource to be decorated is no longer associated
+ // with a CVS provider. This could happen if the team nature was removed
+ // between the time the decoration event was posted to the thread and the time
+ // the thread processes the decoration.
+ ITeamProvider provider = TeamPlugin.getManager().getProvider(resource);
+ if(!resource.exists() || provider==null || !(provider instanceof CVSTeamProvider)) {
+ return null;
+ }
+
+ // determine a if resource has outgoing changes (e.g. is dirty).
+ IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
+ boolean isDirty = false;
+ boolean computeDeepDirtyCheck = store.getBoolean(ICVSUIConstants.PREF_CALCULATE_DIRTY);
+ int type = resource.getType();
+ if(type == IResource.FILE || computeDeepDirtyCheck) {
+ isDirty = isDirty(resource);
+ }
+
+ // compute decorations
+ CVSDecoration decoration = computeTextLabelFor(resource, isDirty, provider);
+ decoration.setOverlays(computeLabelOverlaysFor(resource, isDirty, provider));
+ return decoration;
+ }
+
private CVSDecoration computeTextLabelFor(IResource resource, boolean isDirty, ITeamProvider provider) {
Map bindings = new HashMap(3);
String format = ""; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
index 33d9a66d7..f6e949eec 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSDecorator.java
@@ -82,6 +82,7 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
}
protected void finished() {
resourceStateChanged((IResource[])changedResources.toArray(new IResource[changedResources.size()]));
+ changedResources.clear();
}
protected int getEventMask() {
return IResourceChangeEvent.PRE_AUTO_BUILD;
@@ -89,15 +90,14 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
}
public CVSDecorator() {
- // The decorator is a singleton, there should never be more than one instance.
- // temporary until the UI component properly calls dispose when the workbench shutsdown
- // UI Bug 9633
- Assert.isTrue(theDecorator==null);
- theDecorator = this;
-
+ // thread that calculates the decoration for a resource
decoratorUpdateThread = new Thread(new CVSDecorationRunnable(this), "CVS"); //$NON-NLS-1$
decoratorUpdateThread.start();
+
+ // listener for cvs state change (e.g. any sync info changes)
TeamPlugin.getManager().addResourceStateChangeListener(this);
+
+ // listener for workspace resource changes
changeListener = new ChangeListener();
changeListener.register();
}
@@ -190,20 +190,28 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
}
/*
- * @see IDecorationNotifier#notify(IResource, CVSDecoration)
+ * @see IDecorationNotifier#decorated(IResource[], CVSDecoration[])
*/
- public synchronized void decorated(IResource resource, CVSDecoration decoration) {
- // ignore resources that aren't in the workbench anymore.
- if(resource.exists() && !shutdown) {
- cache.put(resource, decoration);
- postLabelEvents(new LabelProviderChangedEvent[] { new LabelProviderChangedEvent(this, resource)});
+ public synchronized void decorated(IResource[] resources, CVSDecoration[] decorations) {
+ List events = new ArrayList();
+ if(!shutdown) {
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource= resources[i];
+ if(resource.exists()) {
+ cache.put(resource, decorations[i]);
+ events.add(new LabelProviderChangedEvent(this, resource));
+ }
+ }
+ postLabelEvents((LabelProviderChangedEvent[]) events.toArray(new LabelProviderChangedEvent[events.size()]));
}
}
/*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
+ * @see IDecorationNotifier#remaining()
*/
-
+ public int remaining() {
+ return decoratorNeedsUpdating.size();
+ }
/*
* @see IResourceStateChangeListener#resourceStateChanged(IResource[])
*/
@@ -345,13 +353,7 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
} catch (InterruptedException e) {
}
}
-
- public static void shutdownAll() {
- if(theDecorator!=null) {
- theDecorator.dispose();
- }
- }
-
+
/*
* @see IBaseLabelProvider#dispose()
*/
@@ -362,7 +364,7 @@ public class CVSDecorator extends LabelProvider implements ILabelDecorator, IRes
shutdown();
// unregister change listeners
- changeListener.register();
+ changeListener.deregister();
TeamPlugin.getManager().removeResourceStateChangeListener(this);
// dispose of images created as overlays
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index 6ecfad7ec..a6dd3d465 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -246,7 +246,6 @@ public class CVSUIPlugin extends AbstractUIPlugin {
* @see Plugin#shutdown()
*/
public void shutdown() throws CoreException {
- CVSDecorator.shutdownAll();
changeListener.deregister();
super.shutdown();
try {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IDecorationNotifier.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IDecorationNotifier.java
index 541086bfa..d465f5893 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IDecorationNotifier.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/IDecorationNotifier.java
@@ -17,5 +17,10 @@ public interface IDecorationNotifier {
/**
* Called to associate a decoration to a resource.
*/
- public void decorated(IResource resource, CVSDecoration decoration);
+ public void decorated(IResource[] resource, CVSDecoration[] decoration);
+
+ /**
+ * Number of resources remaining to be decorated
+ */
+ public int remaining();
}

Back to the top