Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 207651 Details for
Bug 364735
[Viewers] ViewerComparator violates its general contract
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Logging of state at the time of the exception
Bug-364735.patch (text/plain), 3.40 KB, created by
Paul Webster
on 2011-11-29 09:00:32 EST
(
hide
)
Description:
Logging of state at the time of the exception
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2011-11-29 09:00:32 EST
Size:
3.40 KB
patch
obsolete
>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 893cfd1..578a562 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 >@@ -14,6 +14,8 @@ > import java.util.Arrays; > import java.util.Comparator; > >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; > import org.eclipse.jface.util.Policy; > > /** >@@ -121,34 +123,32 @@ > return cat1 - cat2; > } > >- String name1; >- String name2; >- >- if (viewer == null || !(viewer instanceof ContentViewer)) { >- name1 = e1.toString(); >- name2 = e2.toString(); >- } else { >- IBaseLabelProvider prov = ((ContentViewer) viewer) >- .getLabelProvider(); >- if (prov instanceof ILabelProvider) { >- ILabelProvider lprov = (ILabelProvider) prov; >- name1 = lprov.getText(e1); >- name2 = lprov.getText(e2); >- } else { >- name1 = e1.toString(); >- name2 = e2.toString(); >- } >- } >- if (name1 == null) { >- name1 = "";//$NON-NLS-1$ >- } >- if (name2 == null) { >- name2 = "";//$NON-NLS-1$ >- } >+ String name1 = getLabel(viewer, e1); >+ String name2 = getLabel(viewer, e2); > > // use the comparator to compare the strings > return getComparator().compare(name1, name2); > } >+ >+ private String getLabel(Viewer viewer, Object e1) { >+ String name1; >+ if (viewer == null || !(viewer instanceof ContentViewer)) { >+ name1 = e1.toString(); >+ } else { >+ IBaseLabelProvider prov = ((ContentViewer) viewer) >+ .getLabelProvider(); >+ if (prov instanceof ILabelProvider) { >+ ILabelProvider lprov = (ILabelProvider) prov; >+ name1 = lprov.getText(e1); >+ } else { >+ name1 = e1.toString(); >+ } >+ } >+ if (name1 == null) { >+ name1 = "";//$NON-NLS-1$ >+ } >+ return name1; >+ } > > /** > * Returns whether this viewer sorter would be affected >@@ -181,11 +181,24 @@ > * @param viewer the viewer > * @param elements the elements to sort > */ >- public void sort(final Viewer viewer, Object[] elements) { >- Arrays.sort(elements, new Comparator() { >- public int compare(Object a, Object b) { >- return ViewerComparator.this.compare(viewer, a, b); >- } >- }); >- } >+ public void sort(final Viewer viewer, Object[] elements) { >+ try { >+ Arrays.sort(elements, new Comparator() { >+ public int compare(Object a, Object b) { >+ return ViewerComparator.this.compare(viewer, a, b); >+ } >+ }); >+ } catch (IllegalArgumentException e) { >+ String msg = "Workaround for comparator violation:\n\t- set system property java.util.Arrays.useLegacyMergeSort=true\n\t- use a 1.6 JRE " //$NON-NLS-1$ >+ + "\nmessage: " + e.getLocalizedMessage() //$NON-NLS-1$ >+ + "\nthis: " + getClass().getName() //$NON-NLS-1$ >+ + "\ncomparator: " + comparator.getClass().getName() //$NON-NLS-1$ >+ + "\narray:"; //$NON-NLS-1$ >+ for (int i = 0; i < elements.length; i++) { >+ msg += "\n\t" + getLabel(viewer, elements[i]); //$NON-NLS-1$ >+ } >+ Policy.getLog().log(new Status(IStatus.ERROR, "org.eclipse.jface", msg)); //$NON-NLS-1$ >+ throw e; >+ } >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 364735
:
207491
|
207574
|
207577
|
207626
| 207651 |
208126
|
233895
|
233896
|
238137