1 11 package org.eclipse.team.internal.core.subscribers; 12 13 import org.eclipse.core.resources.IResource; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.team.core.TeamException; 16 import org.eclipse.team.core.synchronize.*; 17 import org.eclipse.team.internal.core.Policy; 18 19 22 public abstract class SyncSetInput { 23 24 private SubscriberSyncInfoSet syncSet; 25 private SyncInfoFilter filter = new FastSyncInfoFilter(); 26 27 public SyncSetInput(SubscriberEventHandler handler) { 28 syncSet = new SubscriberSyncInfoSet(handler); 29 } 30 31 public SubscriberSyncInfoSet getSyncSet() { 32 return syncSet; 33 } 34 35 39 protected abstract void fetchInput(IProgressMonitor monitor) throws TeamException; 40 41 44 public abstract void disconnect(); 45 46 50 public void reset(IProgressMonitor monitor) throws TeamException { 51 52 try { 53 syncSet.beginInput(); 54 monitor = Policy.monitorFor(monitor); 55 monitor.beginTask(null, 100); 56 syncSet.clear(); 57 fetchInput(Policy.subMonitorFor(monitor, 90)); 58 } finally { 59 syncSet.endInput(Policy.subMonitorFor(monitor, 10)); 60 monitor.done(); 61 } 62 } 63 64 67 protected void collect(SyncInfo info, IProgressMonitor monitor) { 68 boolean isOutOfSync = filter.select(info, monitor); 69 SyncInfo oldInfo = syncSet.getSyncInfo(info.getLocal()); 70 boolean wasOutOfSync = oldInfo != null; 71 if (isOutOfSync) { 72 syncSet.add(info); 73 } else if (wasOutOfSync) { 74 syncSet.remove(info.getLocal()); 75 } 76 } 77 78 protected void remove(IResource resource) { 79 SyncInfo oldInfo = syncSet.getSyncInfo(resource); 80 if (oldInfo != null) { 81 syncSet.remove(resource); 82 } 83 } 84 85 public SyncInfoFilter getFilter() { 86 return filter; 87 } 88 89 public void setFilter(SyncInfoFilter filter) { 90 this.filter = filter; 91 } 92 93 } 94 | Popular Tags |