1 11 package org.eclipse.core.internal.events; 12 13 import java.util.*; 14 import org.eclipse.core.internal.resources.*; 15 import org.eclipse.core.resources.*; 16 17 public class ResourceChangeEvent extends EventObject implements IResourceChangeEvent { 18 19 private static final IMarkerDelta[] NO_MARKER_DELTAS = new IMarkerDelta[0]; 20 private static final long serialVersionUID = 1L; 21 IResourceDelta delta; 22 IResource resource; 23 24 27 private int trigger = 0; 28 int type; 29 30 protected ResourceChangeEvent(Object source, int type, IResource resource) { 31 super(source); 32 this.resource = resource; 33 this.type = type; 34 } 35 36 public ResourceChangeEvent(Object source, int type, int buildKind, IResourceDelta delta) { 37 super(source); 38 this.delta = delta; 39 this.trigger = buildKind; 40 this.type = type; 41 } 42 43 46 public IMarkerDelta[] findMarkerDeltas(String findType, boolean includeSubtypes) { 47 if (delta == null) 48 return NO_MARKER_DELTAS; 49 ResourceDeltaInfo info = ((ResourceDelta) delta).getDeltaInfo(); 50 if (info == null) 51 return NO_MARKER_DELTAS; 52 Map markerDeltas = info.getMarkerDeltas(); 54 if (markerDeltas == null || markerDeltas.size() == 0) 55 return NO_MARKER_DELTAS; 56 ArrayList matching = new ArrayList(); 57 Iterator deltaSets = markerDeltas.values().iterator(); 58 while (deltaSets.hasNext()) { 59 MarkerSet deltas = (MarkerSet) deltaSets.next(); 60 IMarkerSetElement[] elements = deltas.elements(); 61 for (int i = 0; i < elements.length; i++) { 62 MarkerDelta markerDelta = (MarkerDelta) elements[i]; 63 if (findType == null || (includeSubtypes ? markerDelta.isSubtypeOf(findType) : markerDelta.getType().equals(findType))) 65 matching.add(markerDelta); 66 } 67 } 68 return (IMarkerDelta[]) matching.toArray(new IMarkerDelta[matching.size()]); 69 } 70 71 74 public int getBuildKind() { 75 return trigger; 76 } 77 78 81 public IResourceDelta getDelta() { 82 return delta; 83 } 84 85 88 public IResource getResource() { 89 return resource; 90 } 91 92 95 public int getType() { 96 return type; 97 } 98 99 public void setDelta(IResourceDelta value) { 100 delta = value; 101 } 102 } 103 | Popular Tags |