1 11 package org.eclipse.team.internal.core.subscribers; 12 13 import java.util.Date ; 14 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.team.core.synchronize.SyncInfo; 17 import org.eclipse.team.core.synchronize.SyncInfoTree; 18 19 31 public abstract class CheckedInChangeSet extends ChangeSet { 32 33 private final SyncInfoTree set = new SyncInfoTree(); 34 35 public abstract String getAuthor(); 36 37 public abstract Date getDate(); 38 39 43 public SyncInfoTree getSyncInfoSet() { 44 return set; 45 } 46 47 51 public IResource[] getResources() { 52 return set.getResources(); 53 } 54 55 59 public boolean isEmpty() { 60 return set.isEmpty(); 61 } 62 63 68 public boolean contains(IResource local) { 69 return set.getSyncInfo(local) != null; 70 } 71 72 77 public void add(SyncInfo info) { 78 if (isValidChange(info)) { 79 set.add(info); 80 } 81 } 82 83 90 protected boolean isValidChange(SyncInfo info) { 91 return (info != null); 92 } 93 94 99 public void add(SyncInfo[] infos) { 100 try { 101 set.beginInput(); 102 for (int i = 0; i < infos.length; i++) { 103 SyncInfo info = infos[i]; 104 add(info); 105 } 106 } finally { 107 set.endInput(null); 108 } 109 } 110 111 115 public void remove(IResource resource) { 116 if (contains(resource)) { 117 set.remove(resource); 118 } 119 } 120 121 125 public void remove(IResource[] resources) { 126 for (int i = 0; i < resources.length; i++) { 127 IResource resource = resources[i]; 128 remove(resource); 129 } 130 } 131 132 138 public void rootRemoved(IResource resource, int depth) { 139 SyncInfo[] infos = set.getSyncInfos(resource, depth); 140 if (infos.length > 0) { 141 IResource[] resources = new IResource[infos.length]; 142 for (int i = 0; i < resources.length; i++) { 143 resources[i] = infos[i].getLocal(); 144 } 145 set.removeAll(resources); 146 } 147 } 148 149 public boolean containsChildren(IResource resource, int depth) { 150 return set.getSyncInfos(resource, depth).length > 0; 151 } 152 } 153 | Popular Tags |