KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > ui > internal > search > SorterByTitle


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.help.ui.internal.search;
12 import org.eclipse.help.internal.search.*;
13 import org.eclipse.jface.viewers.*;
14 /**
15  * Sorts results of help sarch in search view by title.
16  */

17 public class SorterByTitle extends ViewerSorter {
18     /**
19      * @see org.eclipse.jface.viewers.ViewerSorter#compare(org.eclipse.jface.viewers.Viewer,java.lang.Object,java.lang.Object)
20      */

21     public int compare(Viewer viewer, Object JavaDoc e1, Object JavaDoc e2) {
22         try {
23             String JavaDoc title1 = ((SearchHit) e1).getLabel();
24             String JavaDoc title2 = ((SearchHit) e2).getLabel();
25             return super.getCollator().compare(title1, title2);
26         } catch (Exception JavaDoc e) {
27         }
28         return super.compare(viewer, e1, e2);
29     }
30 }
Popular Tags