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 178816 Details for
Bug 325236
[DataBinding] Provide a replaceWith method in WritableList/Set
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Patch for writable set
WritableSet.patch (text/plain), 2.98 KB, created by
Ulli Hafner
on 2010-09-14 08:33:12 EDT
(
hide
)
Description:
Patch for writable set
Filename:
MIME Type:
Creator:
Ulli Hafner
Created:
2010-09-14 08:33:12 EDT
Size:
2.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.databinding.observable >Index: src/org/eclipse/core/databinding/observable/set/WritableSet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.observable/src/org/eclipse/core/databinding/observable/set/WritableSet.java,v >retrieving revision 1.8 >diff -u -r1.8 WritableSet.java >--- src/org/eclipse/core/databinding/observable/set/WritableSet.java 4 Mar 2008 23:53:55 -0000 1.8 >+++ src/org/eclipse/core/databinding/observable/set/WritableSet.java 14 Sep 2010 12:31:55 -0000 >@@ -45,9 +45,9 @@ > } > > /** >- * Constructs a new instance in the default realm containing the >- * elements of the given collection. Changes to the given collection after >- * calling this method do not affect the contents of the created WritableSet. >+ * Constructs a new instance in the default realm containing the elements of >+ * the given collection. Changes to the given collection after calling this >+ * method do not affect the contents of the created WritableSet. > * > * @param c > * @param elementType >@@ -87,7 +87,8 @@ > getterCalled(); > boolean added = wrappedSet.add(o); > if (added) { >- fireSetChange(Diffs.createSetDiff(Collections.singleton(o), Collections.EMPTY_SET)); >+ fireSetChange(Diffs.createSetDiff(Collections.singleton(o), >+ Collections.EMPTY_SET)); > } > return added; > } >@@ -113,8 +114,9 @@ > getterCalled(); > boolean removed = wrappedSet.remove(o); > if (removed) { >- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, Collections >- .singleton(o))); >+ fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, >+ Collections >+ .singleton(o))); > } > return removed; > } >@@ -162,7 +164,45 @@ > } > > /** >- * @param elementType can be <code>null</code> >+ * Replaces the elements of this set with the specified elements. >+ * >+ * @param elements >+ * the elements to replace this collection with >+ * @return <code>true</code> if this set has been changed, >+ * <code>false</code> otherwise >+ */ >+ public boolean replaceWith(final Collection elements) { >+ getterCalled(); >+ Set removes = new HashSet(); >+ Iterator wrappedIterator = wrappedSet.iterator(); >+ while (wrappedIterator.hasNext()) { >+ Object element = wrappedIterator.next(); >+ if (!elements.contains(element)) { >+ wrappedIterator.remove(); >+ removes.add(element); >+ } >+ } >+ >+ Set additions = new HashSet(); >+ Iterator elementsIterator = elements.iterator(); >+ while (elementsIterator.hasNext()) { >+ Object element = elementsIterator.next(); >+ if (wrappedSet.add(element)) { >+ additions.add(element); >+ } >+ } >+ >+ if (!additions.isEmpty() || !removes.isEmpty()) { >+ fireSetChange(Diffs.createSetDiff(additions, removes)); >+ >+ return true; >+ } >+ return false; >+ } >+ >+ /** >+ * @param elementType >+ * can be <code>null</code> > * @return new instance with the default realm > */ > public static WritableSet withElementType(Object elementType) {
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 Raw
Actions:
View
Attachments on
bug 325236
:
178811
| 178816