1 11 package org.eclipse.jface.text.revisions; 12 13 import java.util.ArrayList ; 14 import java.util.Collections ; 15 import java.util.Date ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 19 import org.eclipse.swt.graphics.RGB; 20 21 import org.eclipse.jface.text.source.ILineRange; 22 23 import org.eclipse.jface.internal.text.revisions.ChangeRegion; 24 import org.eclipse.jface.internal.text.revisions.Hunk; 25 26 34 public abstract class Revision { 35 36 private final List fChangeRegions= new ArrayList (); 37 43 private List fRanges= null; 44 45 48 protected Revision() { 49 } 50 51 58 public final void addRange(ILineRange range) throws IndexOutOfBoundsException { 59 fChangeRegions.add(new ChangeRegion(this, range)); 60 } 61 62 69 public final List getRegions() { 70 if (fRanges == null) { 71 List ranges= new ArrayList (fChangeRegions.size()); 72 for (Iterator it= fChangeRegions.iterator(); it.hasNext();) { 73 ChangeRegion region= (ChangeRegion) it.next(); 74 for (Iterator inner= region.getAdjustedRanges().iterator(); inner.hasNext();) { 75 ILineRange range= (ILineRange) inner.next(); 76 ranges.add(new RevisionRange(this, range)); 77 } 78 } 79 fRanges= Collections.unmodifiableList(ranges); 80 } 81 return fRanges; 82 } 83 84 91 final void applyDiff(Hunk[] hunks) { 92 fRanges= null; for (Iterator regions= fChangeRegions.iterator(); regions.hasNext();) { 94 ChangeRegion region= (ChangeRegion) regions.next(); 95 region.clearDiff(); 96 for (int i= 0; i < hunks.length; i++) { 97 Hunk hunk= hunks[i]; 98 region.adjustTo(hunk); 99 } 100 } 101 } 102 103 109 public abstract Object getHoverInfo(); 110 111 118 public abstract RGB getColor(); 119 120 126 public abstract String getId(); 127 128 133 public abstract Date getDate(); 134 135 138 public String toString() { 139 return "Revision " + getId(); } 141 142 151 public String getAuthor() { 152 return ""; } 154 } 155 | Popular Tags |