View Javadoc
1   package org.vaadin.aceeditor.client;
2   
3   import java.io.Serializable;
4   import java.util.Map;
5   import java.util.Set;
6   
7   import org.vaadin.aceeditor.client.TransportDoc.TransportMarker;
8   import org.vaadin.aceeditor.client.TransportDoc.TransportMarkerAnnotation;
9   import org.vaadin.aceeditor.client.TransportDoc.TransportRowAnnotation;
10  
11  /**
12   * 
13   * Diff kinda classes to be used internally by the ace editor component,
14   * for transporting between client and server, etc.
15   * 
16   * This may seem a bit overkill???
17   * 
18   */
19  @SuppressWarnings("serial")
20  public class TransportDiff implements Serializable {
21  	
22  	public static class TransportMarkerSetDiff implements Serializable {
23  		public Map<String, TransportMarkerAddition> added;
24  		public Map<String, TransportMarkerDiff> moved;
25  		public Set<String> removed;
26  		@Override
27  		public String toString() {
28  			return "added: " + added + "\n" +
29  					"moved: " + moved + "\n" +
30  					"removed: " + removed;
31  		}
32  	}
33  	
34  	public static class TransportMarkerAddition implements Serializable {
35  		public TransportMarkerAddition() {}
36  		public TransportMarkerAddition(TransportMarker marker, String startContext, String endContext) {
37  			this.marker = marker;
38  			this.startContext = startContext;
39  			this.endContext = endContext;
40  		}
41  		public TransportMarker marker;
42  		public String startContext;
43  		public String endContext;
44  	}
45  	
46  	public static class TransportMarkerDiff implements Serializable {
47  		public TransportRangeDiff rangeDiff;
48  		public TransportMarkerDiff() {}
49  		public TransportMarkerDiff(TransportRangeDiff rangeDiff) {
50  			this.rangeDiff = rangeDiff;
51  		}
52  		@Override
53  		public String toString() {
54  			return rangeDiff.toString();
55  		}
56  	}
57  	
58  	public static class TransportRangeDiff implements Serializable {
59  		public int drow1;
60  		public int dcol1;
61  		public int drow2;
62  		public int dcol2;
63  		public TransportRangeDiff() {}
64  		public TransportRangeDiff(int drow1, int dcol1, int drow2, int dcol2) {
65  			this.drow1 = drow1;
66  			this.dcol1 = dcol1;
67  			this.drow2 = drow2;
68  			this.dcol2 = dcol2;
69  		}
70  		@Override
71  		public String toString() {
72  			return "(("+drow1+","+dcol1+"), ("+drow2+","+dcol2+"))";
73  		}
74  	}
75  	
76  	public static class TransportSetDiff<V> implements Serializable {
77  		public Set<V> added;
78  		public Set<V> removed;
79  		public TransportSetDiff() {}
80  		public TransportSetDiff(Set<V> added, Set<V> removed) {
81  			this.added = added;
82  			this.removed = removed;
83  		}
84  		@Override
85  		public String toString() {
86  			return "added: " + added + ", removed: " + removed;
87  		}
88  	}
89  
90  	// XXX unnecessary copy-pasting
91  	public static class TransportSetDiffForMarkerAnnotations implements Serializable {
92  		public Set<TransportMarkerAnnotation> added;
93  		public Set<TransportMarkerAnnotation> removed;
94  		public TransportSetDiffForMarkerAnnotations() {}
95  		public TransportSetDiffForMarkerAnnotations(Set<TransportMarkerAnnotation> added, Set<TransportMarkerAnnotation> removed) {
96  			this.added = added;
97  			this.removed = removed;
98  		}
99  		@Override
100 		public String toString() {
101 			return "added: " + added + ", removed: " + removed;
102 		}
103 	}
104 	
105 	// XXX unnecessary copy-pasting
106 	public static class TransportSetDiffForRowAnnotations implements Serializable {
107 		public Set<TransportRowAnnotation> added;
108 		public Set<TransportRowAnnotation> removed;
109 		public TransportSetDiffForRowAnnotations() {}
110 		public TransportSetDiffForRowAnnotations(Set<TransportRowAnnotation> added, Set<TransportRowAnnotation> removed) {
111 			this.added = added;
112 			this.removed = removed;
113 		}
114 		@Override
115 		public String toString() {
116 			return "added: " + added + ", removed: " + removed;
117 		}
118 	}
119 	
120 	public String patchesAsString;
121 	public TransportMarkerSetDiff markerSetDiff;
122 	public TransportSetDiffForRowAnnotations rowAnnDiff;
123 	public TransportSetDiffForMarkerAnnotations markerAnnDiff;
124 	
125 	@Override
126 	public String toString() {
127 		return "///// DIFF\n" + patchesAsString+"\n|||| Markers\n" + markerSetDiff+"\n//////\nrad:" + rowAnnDiff + ", mad:" + markerAnnDiff;
128 	}
129 }