diff options
-rw-r--r-- | org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java index 27285877c..02941308e 100644 --- a/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java +++ b/org.eclipse.help.ui/src/org/eclipse/help/ui/internal/views/ContextHelpSorter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2011 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 @@ -26,36 +26,34 @@ public class ContextHelpSorter extends ViewerComparator { list = new LinkedList(); this.context = context; } + + public void sort(Viewer viewer, Object[] elements) { + for (int i = 0; i < elements.length; i++) { + IHelpResource r1 = (IHelpResource) elements[i]; + String c1 = context.getCategory(r1); + if (!list.contains(c1)) { + list.add(c1); + } + } + super.sort(viewer, elements); + } /* (non-Javadoc) * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ public int compare(Viewer viewer, Object e1, Object e2) { - if (!(e2 instanceof IHelpResource)) + if (!(e2 instanceof IHelpResource)) { return -1; - if (!(e1 instanceof IHelpResource)) + } + if (!(e1 instanceof IHelpResource)) { return 1; + } IHelpResource r1 = (IHelpResource) e1; IHelpResource r2 = (IHelpResource) e2; String c1 = context.getCategory(r1); String c2 = context.getCategory(r2); int i1 = list.indexOf(c1); int i2 = list.indexOf(c2); - if (i1 == -1 && i2 == -1) { - list.add(c1); - i1 = list.indexOf(c1); - if (i1 != i2) - list.add(c2); - i2 = list.indexOf(c2); - } - if (i1 == -1) { - list.add(c1); - return 1; - } - if (i2 == -1) { - list.add(c2); - return -1; - } return i1 - i2; } } |