Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 88735 Details for
Bug 208434
[DataBinding] ObservableList iterator implementation does not delegate back to outer class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
work in progress
clipboard.txt (text/plain), 4.08 KB, created by
Boris Bokowski
on 2008-02-03 22:58:49 EST
(
hide
)
Description:
work in progress
Filename:
MIME Type:
Creator:
Boris Bokowski
Created:
2008-02-03 22:58:49 EST
Size:
4.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.databinding >Index: src/org/eclipse/core/databinding/observable/list/ObservableList.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/observable/list/ObservableList.java,v >retrieving revision 1.9 >diff -u -r1.9 ObservableList.java >--- src/org/eclipse/core/databinding/observable/list/ObservableList.java 4 Feb 2008 03:31:19 -0000 1.9 >+++ src/org/eclipse/core/databinding/observable/list/ObservableList.java 4 Feb 2008 03:56:59 -0000 >@@ -98,11 +98,14 @@ > > public Iterator iterator() { > getterCalled(); >- final Iterator wrappedIterator = wrappedList.iterator(); >+ final ListIterator wrappedIterator = wrappedList.listIterator(); > return new Iterator() { >+ >+ int currentIndex = -1; > > public void remove() { >- throw new UnsupportedOperationException(); >+ ObservableList.this.remove(currentIndex); >+ currentIndex = -1; > } > > public boolean hasNext() { >@@ -110,6 +113,7 @@ > } > > public Object next() { >+ currentIndex = wrappedIterator.nextIndex(); > return wrappedIterator.next(); > } > }; >@@ -176,6 +180,9 @@ > final ListIterator wrappedIterator = wrappedList.listIterator(index); > return new ListIterator() { > >+ int currentIndex = -1; >+ boolean currentIsPrevious; >+ > public int nextIndex() { > return wrappedIterator.nextIndex(); > } >@@ -185,7 +192,7 @@ > } > > public void remove() { >- throw new UnsupportedOperationException(); >+ ObservableList.this.remove(currentIndex); > } > > public boolean hasNext() { >@@ -197,19 +204,28 @@ > } > > public Object next() { >+ currentIndex = wrappedIterator.nextIndex(); >+ currentIsPrevious = false; > return wrappedIterator.next(); > } > > public Object previous() { >+ currentIndex = wrappedIterator.previousIndex(); >+ currentIsPrevious = true; > return wrappedIterator.previous(); > } > > public void add(Object o) { >- throw new UnsupportedOperationException(); >+ if (currentIsPrevious) { >+ ObservableList.this.add(++currentIndex, o); >+ currentIsPrevious = false; >+ } else { >+ ObservableList.this.add(currentIndex++, o); >+ } > } > > public void set(Object o) { >- throw new UnsupportedOperationException(); >+ ObservableList.this.set(currentIndex, o); > } > }; > } >#P org.eclipse.jface.tests.databinding >Index: src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.tests.databinding/src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java,v >retrieving revision 1.3 >diff -u -r1.3 WritableListTest.java >--- src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java 28 Sep 2007 15:30:10 -0000 1.3 >+++ src/org/eclipse/core/tests/databinding/observable/list/WritableListTest.java 4 Feb 2008 03:57:00 -0000 >@@ -14,6 +14,7 @@ > > import java.util.ArrayList; > import java.util.Collections; >+import java.util.ListIterator; > > import junit.framework.Test; > import junit.framework.TestCase; >@@ -159,6 +160,29 @@ > assertEquals(Realm.getDefault(), list.getRealm()); > assertEquals(elementType, list.getElementType()); > } >+ >+ public void testListIterator() { >+ RealmTester.setDefault(SWTObservables.getRealm(Display.getDefault())); >+ >+ Object elementType = String.class; >+ WritableList list = WritableList.withElementType(elementType); >+ >+ list.add("zero"); >+ list.add("one"); >+ list.add("two"); >+ list.add("three"); >+ >+ ListIterator li = list.listIterator(1); >+ assertEquals("one", li.next()); >+ li.remove(); >+ assertEquals("two", li.next()); >+ li.add("one"); >+ assertEquals("one", li.previous()); >+ li.add("one and a half"); >+ assertEquals("one", list.get(1)); >+ assertEquals("one and a half", list.get(2)); >+ assertEquals("two", list.get(3)); >+ } > > public static Test suite() { > Delegate delegate = new Delegate();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208434
: 88735 |
88736
|
93650
|
93651