Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Loskutov2016-09-02 18:19:59 +0000
committerAndrey Loskutov2016-09-23 15:28:38 +0000
commita52c18ef6403a88c3e4d926503ae67b301858c98 (patch)
tree1a884b73ebd7106c40e81e40d788b771b1893819
parentdf057ac34e6919891a9502f0c42f6218a4c41be9 (diff)
downloadeclipse.platform.ui-a52c18ef6403a88c3e4d926503ae67b301858c98.tar.gz
eclipse.platform.ui-a52c18ef6403a88c3e4d926503ae67b301858c98.tar.xz
eclipse.platform.ui-a52c18ef6403a88c3e4d926503ae67b301858c98.zip
Bug 364735 - [Viewers] ViewerComparator violates its general contract
Don't use DecoratingLabelProvider for sorting, see bug 364735 comment 60. The results from this label provider are unstable by design and may change during the sort operation. Instead, use the original label provider enclosed by the DecoratingLabelProvider. A new system property is introduced to restore the old behavior in case someone relies on the decorations for sorting: "eclipse.disable.fix.for.bug364735". If this system property is set to "true", this fix will be disabled. Change-Id: I67dd03e62b8d32913aacc5670c4b864264d8bc1e Signed-off-by: Andrey Loskutov <loskutov@gmx.de> (cherry picked from commit 7defd6d25ecbb5f3e4c88ba228056cdff3b53677)
-rw-r--r--bundles/org.eclipse.jface/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.jface/pom.xml8
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java14
3 files changed, 18 insertions, 6 deletions
diff --git a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF
index 2dc8a6f0818..bbf77bffaee 100644
--- a/bundles/org.eclipse.jface/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.jface/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jface;singleton:=true
-Bundle-Version: 3.12.0.qualifier
+Bundle-Version: 3.12.1.qualifier
Bundle-ClassPath: .
Bundle-Vendor: %providerName
Bundle-Localization: plugin
diff --git a/bundles/org.eclipse.jface/pom.xml b/bundles/org.eclipse.jface/pom.xml
index 42f0f39b6aa..69927052fa7 100644
--- a/bundles/org.eclipse.jface/pom.xml
+++ b/bundles/org.eclipse.jface/pom.xml
@@ -20,11 +20,11 @@
</parent>
<groupId>org.eclipse.jface</groupId>
<artifactId>org.eclipse.jface</artifactId>
- <version>3.12.0-SNAPSHOT</version>
+ <version>3.12.1-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
-
+
<properties>
<code.ignoredWarnings>-warn:-deprecation,raw,unchecked</code.ignoredWarnings>
- </properties>
-
+ </properties>
+
</project>
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
index ea67e76a288..6fba2f92622 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ViewerComparator.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <Lars.Vogel@gmail.com> - Bug 430873
+ * Andrey Loskutov <loskutov@gmx.de> - Bug 364735
******************************************************************************/
package org.eclipse.jface.viewers;
@@ -43,6 +44,9 @@ import org.eclipse.jface.util.Policy;
* @since 3.2
*/
public class ViewerComparator {
+
+ private static final boolean DISABLE_FIX_FOR_364735 = Boolean.getBoolean("eclipse.disable.fix.for.bug364735"); //$NON-NLS-1$
+
/**
* The comparator to use to sort a viewer's contents.
*/
@@ -145,6 +149,14 @@ public class ViewerComparator {
.getLabelProvider();
if (prov instanceof ILabelProvider) {
ILabelProvider lprov = (ILabelProvider) prov;
+ if (lprov instanceof DecoratingLabelProvider && !DISABLE_FIX_FOR_364735) {
+ // Bug 364735: use the real label provider to avoid unstable
+ // sort behavior if the decoration is running while sorting.
+ // decorations are usually visual aids to the user and
+ // shouldn't be used in ordering.
+ DecoratingLabelProvider dprov = (DecoratingLabelProvider) lprov;
+ lprov = dprov.getLabelProvider();
+ }
name1 = lprov.getText(e1);
} else {
name1 = e1.toString();

Back to the top