1 11 package org.eclipse.team.internal.core.subscribers; 12 13 import java.util.*; 14 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.team.core.ITeamStatus; 17 import org.eclipse.team.core.synchronize.*; 18 19 22 public class SyncSetChangedEvent implements ISyncInfoSetChangeEvent { 23 24 private SyncInfoSet set; 25 26 private Map changedResources = new HashMap(); 29 private Set removedResources = new HashSet(); 30 private Map addedResources = new HashMap(); 31 32 private boolean reset = false; 33 34 private List errors = new ArrayList(); 35 36 public SyncSetChangedEvent(SyncInfoSet set) { 37 super(); 38 this.set = set; 39 } 40 41 public void added(SyncInfo info) { 42 if (removedResources.contains(info.getLocal())) { 43 removedResources.remove(info.getLocal()); 45 changed(info); 46 } else { 47 addedResources.put(info.getLocal(), info); 48 } 49 } 50 51 public void removed(IResource resource, SyncInfo info) { 52 if (changedResources.containsKey(resource)) { 53 changedResources.remove(resource); 55 } else if (addedResources.containsKey(resource)) { 56 addedResources.remove(resource); 58 return; 59 } 60 removedResources.add(resource); 61 } 62 63 public void changed(SyncInfo info) { 64 IResource resource = info.getLocal(); 65 if (addedResources.containsKey(resource)) { 66 addedResources.put(resource, info); 68 return; 69 } 70 changedResources.put(resource, info); 71 } 72 73 public SyncInfo[] getAddedResources() { 74 return (SyncInfo[]) addedResources.values().toArray(new SyncInfo[addedResources.size()]); 75 } 76 77 public SyncInfo[] getChangedResources() { 78 return (SyncInfo[]) changedResources.values().toArray(new SyncInfo[changedResources.size()]); 79 } 80 81 public IResource[] getRemovedResources() { 82 return (IResource[]) removedResources.toArray(new IResource[removedResources.size()]); 83 } 84 85 public SyncInfoSet getSet() { 86 return set; 87 } 88 89 public void reset() { 90 reset = true; 91 } 92 93 public boolean isReset() { 94 return reset; 95 } 96 97 public boolean isEmpty() { 98 return changedResources.isEmpty() && removedResources.isEmpty() && addedResources.isEmpty() && errors.isEmpty(); 99 } 100 101 public void errorOccurred(ITeamStatus status) { 102 errors.add(status); 103 } 104 105 public ITeamStatus[] getErrors() { 106 return (ITeamStatus[]) errors.toArray(new ITeamStatus[errors.size()]); 107 } 108 } 109 | Popular Tags |