@Override public int compare(Viewer viewer, Object e1, Object e2) { Integer result = comparator.invoke(e1, e2); return result == null ? super.compare(viewer, e1, e2) : result; }
/** * @see ViewerSorter#compare(Viewer, Object, Object) */ public int compare(Viewer viewer, Object e1, Object e2) { if (shouldSort(e1, e2)) return super.compare(viewer, e1, e2); return 0; }
public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof IConnectionProfile && e2 instanceof IConnectionProfile) { return ((IConnectionProfile)e1).getName().compareToIgnoreCase(((IConnectionProfile)e2).getName()); } return super.compare(viewer, e1, e2); }
@Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof StashedCommitNode && e2 instanceof StashedCommitNode) { // ok for positive indexes < ~2 billion return ((StashedCommitNode)e1).getIndex() - ((StashedCommitNode)e1).getIndex(); } else return super.compare(viewer, e1, e2); } }
@Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof RepositoryCategory && e2 instanceof RepositoryCategory) { RepositoryCategory category1 = (RepositoryCategory) e1; RepositoryCategory category2 = (RepositoryCategory) e2; int result = category1.getRank() - category2.getRank(); if (result != 0) { return result; } } // fall back to comparing by label return super.compare(viewer, e1, e2); }
public int compare(Viewer viewer, Object object1, Object object2) { if ((object1 instanceof Template) && (object2 instanceof Template)) { Template left = (Template) object1; Template right = (Template) object2; int result = left.getName().compareToIgnoreCase(right.getName()); if (result != 0) { return result; } return left.getDescription().compareToIgnoreCase(right.getDescription()); } return super.compare(viewer, object1, object2); }
@Override public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof GitModelBlob && !(e2 instanceof GitModelBlob)) return 1; if (e2 instanceof GitModelBlob && !(e1 instanceof GitModelBlob)) return -1; if (e1 instanceof GitModelWorkingTree) return -1; if (e2 instanceof GitModelWorkingTree) return 1; if (e1 instanceof GitModelCache) return -2; if (e2 instanceof GitModelCache) return 2; if ((e1 instanceof GitModelTree && e2 instanceof GitModelTree) || (e1 instanceof GitModelBlob && e2 instanceof GitModelBlob)) return super.compare(viewer, e1, e2); if (e1 instanceof GitModelTree && e2 instanceof GitModelCommit) return 1; if (e1 instanceof GitModelCommit && e2 instanceof GitModelCommit) { Commit rc1 = ((GitModelCommit) e1).getCachedCommitObj(); Commit rc2 = ((GitModelCommit) e2).getCachedCommitObj(); return rc2.getCommitDate().compareTo(rc1.getCommitDate()); } return super.compare(viewer, e1, e2); }
public int compare(Viewer viewer, Object e1, Object e2) { // Make sure the local repository node is the first item in the tree if (e1 instanceof LocalRepositoryNode) { return -1; } else if (e2 instanceof LocalRepositoryNode) { return 1; } if (e1 instanceof IConnectionProfile && e2 instanceof IConnectionProfile) { IConnectionProfile icp1 = (IConnectionProfile) e1; IConnectionProfile icp2 = (IConnectionProfile) e2; return icp1.getName().compareToIgnoreCase(icp2.getName()); } if (e1 instanceof ICategory && e2 instanceof ICategory) { ICategory icat1 = (ICategory) e1; ICategory icat2 = (ICategory) e2; return icat1.getName().compareToIgnoreCase(icat2.getName()); } return super.compare(viewer, e1, e2); }
public int compare(Viewer viewer, Object object1, Object object2) { if(!(object1 instanceof RulePreferenceData) || !(object2 instanceof RulePreferenceData)) { return super.compare(viewer,object1,object2); } RulePreferenceData data1 = (RulePreferenceData)object1; RulePreferenceData data2 = (RulePreferenceData)object2; if(data1.getPosition() > data2.getPosition()) { return 1; } if(data1.getPosition() < data2.getPosition()) { return -1; } if(data1.getPosition() == data2.getPosition()) { return 0; } return super.compare(viewer, object1, object2); }
@Override public int compare(Viewer viewer, Object e1, Object e2) { String name1 = null; String name2 = null; if (e1 instanceof IArtifact) { name1 = ((IArtifact) e1).getName(); } else if (e1 instanceof ArtifactFolder) { name1 = ((ArtifactFolder) e1).getName(); } if (e2 instanceof IArtifact) { name2 = ((IArtifact) e2).getName(); } else if (e1 instanceof ArtifactFolder) { name2 = ((ArtifactFolder) e2).getName(); } if (name1 != null && name2 != null) { return name1.compareToIgnoreCase(name2); } return super.compare(viewer, e1, e2); }
public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof RepositoryCommit && e2 instanceof RepositoryCommit) { PersonIdent person1 = ((RepositoryCommit) e1).getRevCommit() .getAuthorIdent(); PersonIdent person2 = ((RepositoryCommit) e2).getRevCommit() .getAuthorIdent(); if (person1 != null && person2 != null) return person2.getWhen().compareTo(person1.getWhen()); } else if (e1 instanceof RepositoryMatch && e2 instanceof RepositoryMatch) return ((RepositoryMatch) e1).getLabel(e1).compareToIgnoreCase( ((RepositoryMatch) e2).getLabel(e2)); return super.compare(viewer, e1, e2); } }
public int compare(Viewer viewer, Object e1, Object e2) { if (e1 instanceof FetchResultAdapter && e2 instanceof FetchResultAdapter) { FetchResultAdapter f1 = (FetchResultAdapter) e1; FetchResultAdapter f2 = (FetchResultAdapter) e2; if (f1.getChildren(f1).length > 0 && f2.getChildren(f2).length == 0) return 1; if (f1.getChildren(f1).length == 0 && f2.getChildren(f2).length > 0) return -1; return f1.getLabel(f1).compareToIgnoreCase(f2.getLabel(f2)); } // Leave commits order alone if (e1 instanceof RepositoryCommit && e2 instanceof RepositoryCommit) return 0; if (e1 instanceof FileDiff && e2 instanceof FileDiff) { FileDiff f1 = (FileDiff) e1; FileDiff f2 = (FileDiff) e2; return f1.getPath().compareTo(f2.getPath()); } return super.compare(viewer, e1, e2); }
public int compare(Viewer viewer, TreePath parentPath, Object e1, Object e2) { if (contentService == null) return -1; INavigatorContentDescriptor sourceOfLvalue = contentService.getSourceOfContribution(e1); INavigatorContentDescriptor sourceOfRvalue = contentService.getSourceOfContribution(e2); if (sourceOfLvalue == null) sourceOfLvalue = getSource(e1); if (sourceOfRvalue == null) sourceOfRvalue = getSource(e2); // identity comparison if (sourceOfLvalue != null && sourceOfLvalue == sourceOfRvalue) { Object parent; if (parentPath == null) { parent = viewer.getInput(); } else { parent = parentPath.getLastSegment(); } ViewerSorter sorter = sorterService.findSorter(sourceOfLvalue, parent, e1, e2); if (sorter != null) { return sorter.compare(viewer, e1, e2); } } int categoryDelta = category(e1) - category(e2); if (categoryDelta == 0) { return super.compare(viewer, e1, e2); } return categoryDelta; }
return 0; return super.compare(viewer, e1, e2);
ViewerSorter embeddedSorter = provider.getEmbeddedSorter(); if (embeddedSorter != null) { return embeddedSorter.compare(viewer, o1, o2); } else { compareNames(((ISynchronizeModelElement)o1).getName(), ((ISynchronizeModelElement)o2).getName());
ViewerSorter embeddedSorter = provider.getEmbeddedSorter(); if (embeddedSorter != null) { return embeddedSorter.compare(viewer, o1, o2); } else { return compareNames(((ISynchronizeModelElement)o1).getName(), ((ISynchronizeModelElement)o2).getName());