1 11 package org.eclipse.team.internal.core.mapping; 12 13 import java.util.*; 14 15 import org.eclipse.core.runtime.IPath; 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.team.core.diff.*; 18 19 22 public class DiffChangeEvent implements IDiffChangeEvent { 23 24 private final IDiffTree tree; 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 40 public DiffChangeEvent(IDiffTree tree) { 41 this.tree = tree; 42 } 43 44 47 public IDiffTree getTree() { 48 return tree; 49 } 50 51 54 public IDiff[] getAdditions() { 55 return (IDiff[]) addedResources.values().toArray(new IDiff[addedResources.size()]); 56 } 57 58 61 public IPath[] getRemovals() { 62 return (IPath[]) removedResources.toArray(new IPath[removedResources.size()]); 63 } 64 65 68 public IDiff[] getChanges() { 69 return (IDiff[]) changedResources.values().toArray(new IDiff[changedResources.size()]); 70 } 71 72 public void added(IDiff delta) { 73 if (removedResources.contains(delta.getPath())) { 74 removedResources.remove(delta.getPath()); 76 changed(delta); 77 } else { 78 addedResources.put(delta.getPath(), delta); 79 } 80 } 81 82 public void removed(IPath path, IDiff delta) { 83 if (changedResources.containsKey(path)) { 84 changedResources.remove(path); 86 } else if (addedResources.containsKey(path)) { 87 addedResources.remove(path); 89 return; 90 } 91 removedResources.add(path); 92 } 93 94 public void changed(IDiff delta) { 95 if (addedResources.containsKey(delta.getPath())) { 96 addedResources.put(delta.getPath(), delta); 98 return; 99 } 100 changedResources.put(delta.getPath(), delta); 101 } 102 103 public void reset() { 104 reset = true; 105 } 106 107 public boolean isReset() { 108 return reset; 109 } 110 111 public boolean isEmpty() { 112 return changedResources.isEmpty() && removedResources.isEmpty() && addedResources.isEmpty(); 113 } 114 115 public void errorOccurred(IStatus status) { 116 errors .add(status); 117 } 118 119 public IStatus[] getErrors() { 120 return (IStatus[]) errors.toArray(new IStatus[errors.size()]); 121 } 122 123 } 124 | Popular Tags |