1 11 package org.eclipse.jdt.internal.ui.search; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.jdt.core.IJavaElement; 15 import org.eclipse.jface.viewers.Viewer; 16 import org.eclipse.jface.viewers.ViewerSorter; 17 18 public class NameSorter extends ViewerSorter { 19 public int compare(Viewer viewer, Object e1, Object e2) { 20 String property1= getProperty(e1); 21 String property2= getProperty(e2); 22 return collator.compare(property1, property2); 23 } 24 25 protected String getProperty(Object element) { 26 if (element instanceof IJavaElement) 27 return ((IJavaElement)element).getElementName(); 28 if (element instanceof IResource) 29 return ((IResource)element).getName(); 30 return ""; } 32 } 33 | Popular Tags |