1 11 package org.eclipse.team.core.synchronize; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 15 25 public class FastSyncInfoFilter extends SyncInfoFilter { 26 27 37 public static FastSyncInfoFilter getDirectionAndChangeFilter(int direction, int change) { 38 return new AndSyncInfoFilter(new FastSyncInfoFilter[]{new SyncInfoDirectionFilter(direction), new SyncInfoChangeTypeFilter(change)}); 39 } 40 41 46 public static abstract class CompoundSyncInfoFilter extends FastSyncInfoFilter { 47 50 protected FastSyncInfoFilter[] filters; 51 55 protected CompoundSyncInfoFilter(FastSyncInfoFilter[] filters) { 56 this.filters = filters; 57 } 58 } 59 60 63 public static class AndSyncInfoFilter extends CompoundSyncInfoFilter { 64 68 public AndSyncInfoFilter(FastSyncInfoFilter[] filters) { 69 super(filters); 70 } 71 74 public boolean select(SyncInfo info) { 75 for (int i = 0; i < filters.length; i++) { 76 FastSyncInfoFilter filter = filters[i]; 77 if (!filter.select(info)) { 78 return false; 79 } 80 } 81 return true; 82 } 83 } 84 85 88 public static class AutomergableFilter extends FastSyncInfoFilter { 89 92 public boolean select(SyncInfo info) { 93 return (info.getKind() & SyncInfo.AUTOMERGE_CONFLICT) != 0; 94 } 95 } 96 97 100 public static class PseudoConflictFilter extends FastSyncInfoFilter { 101 104 public boolean select(SyncInfo info) { 105 return info.getKind() != 0 && (info.getKind() & SyncInfo.PSEUDO_CONFLICT) == 0; 106 } 107 } 108 109 112 public static class OrSyncInfoFilter extends CompoundSyncInfoFilter { 113 117 public OrSyncInfoFilter(FastSyncInfoFilter[] filters) { 118 super(filters); 119 } 120 123 public boolean select(SyncInfo info) { 124 for (int i = 0; i < filters.length; i++) { 125 FastSyncInfoFilter filter = filters[i]; 126 if (filter.select(info)) { 127 return true; 128 } 129 } 130 return false; 131 } 132 } 133 134 137 public static class SyncInfoChangeTypeFilter extends FastSyncInfoFilter { 138 private int[] changeFilters = new int[]{SyncInfo.ADDITION, SyncInfo.DELETION, SyncInfo.CHANGE}; 139 145 public SyncInfoChangeTypeFilter(int[] changeFilters) { 146 this.changeFilters = changeFilters; 147 } 148 154 public SyncInfoChangeTypeFilter(int change) { 155 this(new int[]{change}); 156 } 157 160 public boolean select(SyncInfo info) { 161 int syncKind = info.getKind(); 162 for (int i = 0; i < changeFilters.length; i++) { 163 int filter = changeFilters[i]; 164 if ((syncKind & SyncInfo.CHANGE_MASK) == filter) 165 return true; 166 } 167 return false; 168 } 169 } 170 171 174 public static class SyncInfoDirectionFilter extends FastSyncInfoFilter { 175 int[] directionFilters = new int[] {SyncInfo.OUTGOING, SyncInfo.INCOMING, SyncInfo.CONFLICTING}; 176 182 public SyncInfoDirectionFilter(int[] directionFilters) { 183 this.directionFilters = directionFilters; 184 } 185 191 public SyncInfoDirectionFilter(int direction) { 192 this(new int[] { direction }); 193 } 194 197 public boolean select(SyncInfo info) { 198 int syncKind = info.getKind(); 199 for (int i = 0; i < directionFilters.length; i++) { 200 int filter = directionFilters[i]; 201 if ((syncKind & SyncInfo.DIRECTION_MASK) == filter) 202 return true; 203 } 204 return false; 205 } 206 } 207 208 215 public boolean select(SyncInfo info) { 216 return info.getKind() != 0; 217 } 218 219 222 public final boolean select(SyncInfo info, IProgressMonitor monitor) { 223 return select(info); 224 } 225 } 226 | Popular Tags |