|
Lines 98-108
Link Here
|
| 98 |
|
98 |
|
| 99 |
public Iterator iterator() { |
99 |
public Iterator iterator() { |
| 100 |
getterCalled(); |
100 |
getterCalled(); |
| 101 |
final Iterator wrappedIterator = wrappedList.iterator(); |
101 |
final ListIterator wrappedIterator = wrappedList.listIterator(); |
| 102 |
return new Iterator() { |
102 |
return new Iterator() { |
|
|
103 |
|
| 104 |
int currentIndex = -1; |
| 103 |
|
105 |
|
| 104 |
public void remove() { |
106 |
public void remove() { |
| 105 |
throw new UnsupportedOperationException(); |
107 |
ObservableList.this.remove(currentIndex); |
|
|
108 |
currentIndex = -1; |
| 106 |
} |
109 |
} |
| 107 |
|
110 |
|
| 108 |
public boolean hasNext() { |
111 |
public boolean hasNext() { |
|
Lines 110-115
Link Here
|
| 110 |
} |
113 |
} |
| 111 |
|
114 |
|
| 112 |
public Object next() { |
115 |
public Object next() { |
|
|
116 |
currentIndex = wrappedIterator.nextIndex(); |
| 113 |
return wrappedIterator.next(); |
117 |
return wrappedIterator.next(); |
| 114 |
} |
118 |
} |
| 115 |
}; |
119 |
}; |
|
Lines 176-181
Link Here
|
| 176 |
final ListIterator wrappedIterator = wrappedList.listIterator(index); |
180 |
final ListIterator wrappedIterator = wrappedList.listIterator(index); |
| 177 |
return new ListIterator() { |
181 |
return new ListIterator() { |
| 178 |
|
182 |
|
|
|
183 |
int currentIndex = -1; |
| 184 |
boolean currentIsPrevious; |
| 185 |
|
| 179 |
public int nextIndex() { |
186 |
public int nextIndex() { |
| 180 |
return wrappedIterator.nextIndex(); |
187 |
return wrappedIterator.nextIndex(); |
| 181 |
} |
188 |
} |
|
Lines 185-191
Link Here
|
| 185 |
} |
192 |
} |
| 186 |
|
193 |
|
| 187 |
public void remove() { |
194 |
public void remove() { |
| 188 |
throw new UnsupportedOperationException(); |
195 |
ObservableList.this.remove(currentIndex); |
| 189 |
} |
196 |
} |
| 190 |
|
197 |
|
| 191 |
public boolean hasNext() { |
198 |
public boolean hasNext() { |
|
Lines 197-215
Link Here
|
| 197 |
} |
204 |
} |
| 198 |
|
205 |
|
| 199 |
public Object next() { |
206 |
public Object next() { |
|
|
207 |
currentIndex = wrappedIterator.nextIndex(); |
| 208 |
currentIsPrevious = false; |
| 200 |
return wrappedIterator.next(); |
209 |
return wrappedIterator.next(); |
| 201 |
} |
210 |
} |
| 202 |
|
211 |
|
| 203 |
public Object previous() { |
212 |
public Object previous() { |
|
|
213 |
currentIndex = wrappedIterator.previousIndex(); |
| 214 |
currentIsPrevious = true; |
| 204 |
return wrappedIterator.previous(); |
215 |
return wrappedIterator.previous(); |
| 205 |
} |
216 |
} |
| 206 |
|
217 |
|
| 207 |
public void add(Object o) { |
218 |
public void add(Object o) { |
| 208 |
throw new UnsupportedOperationException(); |
219 |
if (currentIsPrevious) { |
|
|
220 |
ObservableList.this.add(++currentIndex, o); |
| 221 |
currentIsPrevious = false; |
| 222 |
} else { |
| 223 |
ObservableList.this.add(currentIndex++, o); |
| 224 |
} |
| 209 |
} |
225 |
} |
| 210 |
|
226 |
|
| 211 |
public void set(Object o) { |
227 |
public void set(Object o) { |
| 212 |
throw new UnsupportedOperationException(); |
228 |
ObservableList.this.set(currentIndex, o); |
| 213 |
} |
229 |
} |
| 214 |
}; |
230 |
}; |
| 215 |
} |
231 |
} |