Changeset 5627 in josm for trunk/src/org/openstreetmap/josm/gui/history/TwoColumnDiff.java
- Timestamp:
- 2012-12-20T22:43:02+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/history/TwoColumnDiff.java
r4689 r5627 3 3 /// Feel free to move me somewhere else. Maybe a bit specific for josm.tools? 4 4 5 import java.awt.Color; 5 6 import java.util.ArrayList; 6 7 8 import org.openstreetmap.josm.gui.history.TwoColumnDiff.Item.DiffItemType; 7 9 import org.openstreetmap.josm.tools.Diff; 8 10 … … 24 26 class TwoColumnDiff { 25 27 public static class Item { 26 public static final int INSERTED = 1; 27 public static final int DELETED = 2; 28 public static final int CHANGED = 3; 29 public static final int SAME = 4; 30 public static final int EMPTY = 5; // value should be null 31 public Item(int state, Object value) { 28 29 public enum DiffItemType { 30 INSERTED(new Color(0xDD, 0xFF, 0xDD)), DELETED(new Color(255,197,197)), CHANGED(new Color(255,234,213)), 31 SAME(new Color(234,234,234)), EMPTY(new Color(234,234,234)); 32 33 private final Color color; 34 private DiffItemType(Color color) { 35 this.color = color; 36 } 37 public Color getColor() { 38 return color; 39 } 40 } 41 42 public Item(DiffItemType state, Object value) { 32 43 this.state = state; 33 this.value = state == EMPTY ? null : value;44 this.value = state == DiffItemType.EMPTY ? null : value; 34 45 } 35 46 36 47 public final Object value; 37 public final intstate;48 public final DiffItemType state; 38 49 } 39 50 … … 72 83 while(ia < script.line0 && ib < script.line1){ 73 84 // System.out.println(" "+a[ia] + "\t "+b[ib]); 74 Item cell = new Item( Item.SAME, a[ia]);85 Item cell = new Item(DiffItemType.SAME, a[ia]); 75 86 referenceDiff.add(cell); 76 87 currentDiff.add(cell); … … 82 93 if(inserted > 0 && deleted > 0) { 83 94 // System.out.println("="+a[ia] + "\t="+b[ib]); 84 referenceDiff.add(new Item( Item.CHANGED, a[ia++]));85 currentDiff.add(new Item( Item.CHANGED, b[ib++]));95 referenceDiff.add(new Item(DiffItemType.CHANGED, a[ia++])); 96 currentDiff.add(new Item(DiffItemType.CHANGED, b[ib++])); 86 97 } else if(inserted > 0) { 87 98 // System.out.println("\t+" + b[ib]); 88 referenceDiff.add(new Item( Item.EMPTY, null));89 currentDiff.add(new Item( Item.INSERTED, b[ib++]));99 referenceDiff.add(new Item(DiffItemType.EMPTY, null)); 100 currentDiff.add(new Item(DiffItemType.INSERTED, b[ib++])); 90 101 } else if(deleted > 0) { 91 102 // System.out.println("-"+a[ia]); 92 referenceDiff.add(new Item( Item.DELETED, a[ia++]));93 currentDiff.add(new Item( Item.EMPTY, null));103 referenceDiff.add(new Item(DiffItemType.DELETED, a[ia++])); 104 currentDiff.add(new Item(DiffItemType.EMPTY, null)); 94 105 } 95 106 inserted--; … … 100 111 while(ia < a.length && ib < b.length) { 101 112 // System.out.println((ia < a.length ? " "+a[ia]+"\t" : "\t") + (ib < b.length ? " "+b[ib] : "")); 102 referenceDiff.add(new Item( Item.SAME, a[ia++]));103 currentDiff.add(new Item( Item.SAME, b[ib++]));113 referenceDiff.add(new Item(DiffItemType.SAME, a[ia++])); 114 currentDiff.add(new Item(DiffItemType.SAME, b[ib++])); 104 115 } 105 116 }
Note:
See TracChangeset
for help on using the changeset viewer.