1 11 package org.eclipse.team.internal.core.subscribers; 12 13 import org.eclipse.core.resources.IFile; 14 import org.eclipse.core.resources.IResource; 15 import org.eclipse.core.runtime.Assert; 16 import org.eclipse.core.runtime.IProgressMonitor; 17 import org.eclipse.team.core.diff.DiffFilter; 18 import org.eclipse.team.core.diff.IDiff; 19 import org.eclipse.team.core.history.IFileRevision; 20 import org.eclipse.team.core.mapping.provider.ResourceDiffTree; 21 import org.eclipse.team.internal.core.mapping.SyncInfoToDiffConverter; 22 23 public class ContentComparisonDiffFilter extends DiffFilter { 24 ContentComparator criteria = new ContentComparator(false); 25 26 29 public ContentComparisonDiffFilter() { 30 this(false); 31 } 32 36 public ContentComparisonDiffFilter(boolean ignoreWhitespace) { 37 criteria = new ContentComparator(ignoreWhitespace); 38 } 39 40 49 public boolean compareContents(IFile local, IFileRevision remote, IProgressMonitor monitor) { 50 Assert.isNotNull(local); 51 Assert.isNotNull(remote); 52 return criteria.compare(local, remote, monitor); 53 } 54 55 public boolean select(IDiff diff, IProgressMonitor monitor) { 56 IFileRevision remote = SyncInfoToDiffConverter.getRemote(diff); 57 IResource local = ResourceDiffTree.getResourceFor(diff); 58 if (local == null || local.getType() != IResource.FILE) return true; 59 if (remote == null) return !local.exists(); 60 if (!local.exists()) return false; 61 return compareContents((IFile)local, remote, monitor); 62 } 63 } | Popular Tags |