Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-09-08 17:19:20 +0000
committerGerrit Code Review @ Eclipse.org2016-09-08 17:19:21 +0000
commit8d005606f73508917fb23b5ade4144304ac39442 (patch)
tree6fdae0d84d497c71b46062043ea2cf01c2459263
parent35ce88489716a46c2accb02952e68f721b8ff2eb (diff)
parentc874cca93dcd42ab675469b20774595a5b75ace7 (diff)
downloadegit-8d005606f73508917fb23b5ade4144304ac39442.tar.gz
egit-8d005606f73508917fb23b5ade4144304ac39442.tar.xz
egit-8d005606f73508917fb23b5ade4144304ac39442.zip
Merge "More efficient label provider for the staging view"
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java58
1 files changed, 43 insertions, 15 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index 8a0ee7456..999e6db6a 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -118,6 +118,7 @@ import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.LocalSelectionTransfer;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.BaseLabelProvider;
import org.eclipse.jface.viewers.ContentViewer;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.IBaseLabelProvider;
@@ -469,33 +470,60 @@ public class StagingView extends ViewPart implements IShowInSource {
}
}
- static class TreeDecoratingLabelProvider extends DecoratingLabelProvider {
-
- ILabelProvider provider;
+ /**
+ * A wrapped {@link DecoratingLabelProvider} to be used in the tree viewers
+ * of the staging view. We wrap it instead of deriving directly because a
+ * {@link DecoratingLabelProvider} is a
+ * {@link org.eclipse.jface.viewers.ITreePathLabelProvider
+ * ITreePathLabelProvider}, which makes the tree viewer compute a
+ * {@link org.eclipse.jface.viewers.TreePath TreePath} for each element,
+ * which is then ultimately unused because the
+ * {@link StagingViewLabelProvider} is <em>not</em> a
+ * {@link org.eclipse.jface.viewers.ITreePathLabelProvider
+ * ITreePathLabelProvider}. Computing the
+ * {@link org.eclipse.jface.viewers.TreePath TreePath} is a fairly expensive
+ * operation on GTK, and avoiding to compute it speeds up label updates
+ * significantly.
+ */
+ private static class TreeDecoratingLabelProvider extends BaseLabelProvider
+ implements ILabelProvider {
- ILabelDecorator decorator;
+ private final DecoratingLabelProvider provider;
public TreeDecoratingLabelProvider(ILabelProvider provider,
ILabelDecorator decorator) {
- super(provider, decorator);
- this.provider = provider;
- this.decorator = decorator;
+ this.provider = new DecoratingLabelProvider(provider, decorator);
}
- public Image getColumnImage(Object element) {
- Image image = provider.getImage(element);
- if (image != null && decorator != null) {
- Image decorated = decorator.decorateImage(image, element);
- if (decorated != null)
- return decorated;
- }
- return image;
+ @Override
+ public Image getImage(Object element) {
+ return provider.getImage(element);
}
@Override
public String getText(Object element) {
return provider.getText(element);
}
+
+ @Override
+ public void addListener(ILabelProviderListener listener) {
+ provider.addListener(listener);
+ }
+
+ @Override
+ public void removeListener(ILabelProviderListener listener) {
+ provider.removeListener(listener);
+ }
+
+ @Override
+ public void dispose() {
+ provider.dispose();
+ }
+
+ public ILabelProvider getLabelProvider() {
+ return provider.getLabelProvider();
+ }
+
}
static class StagingViewSearchThread extends Thread {

Back to the top