1 11 12 package org.eclipse.jdt.internal.ui.search; 13 14 import org.eclipse.core.resources.IMarker; 15 import org.eclipse.jface.viewers.Viewer; 16 import org.eclipse.jface.viewers.ViewerSorter; 17 import org.eclipse.search.ui.ISearchResultViewEntry; 18 import org.eclipse.ui.texteditor.MarkerUtilities; 19 20 23 public class MatchPositionSorter extends ViewerSorter { 24 27 public int compare(Viewer viewer, Object e1, Object e2) { 28 int pos1= 0; 29 int pos2= 0; 30 31 if (e1 instanceof ISearchResultViewEntry) 32 pos1= getMatchPosition((ISearchResultViewEntry)e1); 33 if (e2 instanceof ISearchResultViewEntry) 34 pos2= getMatchPosition((ISearchResultViewEntry)e2); 35 return pos1-pos2; 36 } 37 38 private int getMatchPosition(ISearchResultViewEntry entry) { 39 IMarker marker= entry.getSelectedMarker(); 40 if (marker == null) 41 return 0; 42 return MarkerUtilities.getCharStart(marker); 43 } 44 45 48 public boolean isSorterProperty(Object element, String property) { 49 return true; 50 } 51 } 52 | Popular Tags |