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.core.runtime.jobs.Job; 16 import org.eclipse.team.core.subscribers.Subscriber; 17 import org.eclipse.team.core.synchronize.*; 18 import org.eclipse.team.internal.core.Policy; 19 20 31 public final class SubscriberSyncInfoCollector extends SubscriberResourceCollector { 32 33 private final SyncSetInputFromSubscriber subscriberInput; 34 private SyncSetInputFromSyncSet filteredInput; 35 private SubscriberSyncInfoEventHandler eventHandler; 36 private IResource[] roots; 37 38 47 public SubscriberSyncInfoCollector(Subscriber subscriber, IResource[] roots) { 48 super(subscriber); 49 this.roots = roots; 50 this.eventHandler = new SubscriberSyncInfoEventHandler(subscriber, roots); 51 this.subscriberInput = eventHandler.getSyncSetInput(); 52 filteredInput = new SyncSetInputFromSyncSet(subscriberInput.getSyncSet(), getEventHandler()); 53 filteredInput.setFilter(new SyncInfoFilter() { 54 public boolean select(SyncInfo info, IProgressMonitor monitor) { 55 return true; 56 } 57 }); 58 59 } 60 61 public void setProgressGroup(IProgressMonitor monitor, int ticks) { 62 getEventHandler().setProgressGroupHint(monitor, ticks); 63 } 64 65 68 public void start() { 69 eventHandler.start(); 70 } 71 72 77 public void waitForCollector(IProgressMonitor monitor) { 78 monitor.worked(1); 79 while(eventHandler.getEventHandlerJob().getState() != Job.NONE) { 81 monitor.worked(1); 82 try { 83 Thread.sleep(10); 84 } catch (InterruptedException e) { 85 } 86 Policy.checkCanceled(monitor); 87 } 88 monitor.worked(1); 89 } 90 91 97 public void reset() { 98 eventHandler.reset(getRoots()); 99 } 100 101 106 public void dispose() { 107 eventHandler.shutdown(); 108 subscriberInput.disconnect(); 109 if(filteredInput != null) { 110 filteredInput.disconnect(); 111 } 112 super.dispose(); 113 } 114 115 121 public IResource[] getRoots() { 122 if (roots == null) { 123 return super.getRoots(); 124 } else { 125 return roots; 126 } 127 } 128 129 135 public boolean isAllRootsIncluded() { 136 return roots == null; 137 } 138 139 146 protected SubscriberEventHandler getEventHandler() { 147 return eventHandler; 148 } 149 150 157 public SyncInfoTree getSubscriberSyncInfoSet() { 158 return subscriberInput.getSyncSet(); 159 } 160 161 public SyncInfoTree getSyncInfoSet() { 162 return filteredInput.getSyncSet(); 163 } 164 165 170 public void setFilter(SyncInfoFilter filter) { 171 filteredInput.setFilter(filter); 172 filteredInput.reset(); 173 } 174 175 public void setRoots(IResource[] roots) { 176 this.roots = roots; 177 reset(); 178 } 179 180 183 protected boolean hasMembers(IResource resource) { 184 return getSubscriberSyncInfoSet().hasMembers(resource); 185 } 186 187 190 protected void remove(IResource resource) { 191 eventHandler.remove(resource); 192 } 193 194 197 protected void change(IResource resource, int depth) { 198 eventHandler.change(resource, depth); 199 } 200 } 201 | Popular Tags |