1 11 package org.eclipse.team.internal.ui.synchronize; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.jface.viewers.Viewer; 15 import org.eclipse.team.internal.ui.Utils; 16 import org.eclipse.ui.views.navigator.ResourceSorter; 17 18 22 public class SynchronizeModelElementSorter extends ResourceSorter { 23 24 public SynchronizeModelElementSorter() { 25 super(ResourceSorter.NAME); 26 } 27 28 31 public int compare(Viewer viewer, Object o1, Object o2) { 32 IResource resource1 = getResource(o1); 33 IResource resource2 = getResource(o2); 34 int result; 35 if (resource1 != null && resource2 != null) { 36 result = super.compare(viewer, resource1, resource2); 37 } else { 38 result = super.compare(viewer, o1, o2); 39 } 40 return result; 41 } 42 43 protected IResource getResource(Object obj) { 44 IResource[] resources = Utils.getResources(new Object [] {obj}); 45 return resources.length == 1 ? resources[0] : null; 46 } 47 } 48 | Popular Tags |