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 120989 Details for
Bug 194734
[Databinding] Property-based observables
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]
Update
clipboard.txt (text/plain), 129.06 KB, created by
Matthew Hall
on 2008-12-20 01:59:41 EST
(
hide
)
Description:
Update
Filename:
MIME Type:
Creator:
Matthew Hall
Created:
2008-12-20 01:59:41 EST
Size:
129.06 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.core.databinding.beans >Index: src/org/eclipse/core/internal/databinding/beans/BeanSetProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/BeanSetProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 BeanSetProperty.java >--- src/org/eclipse/core/internal/databinding/beans/BeanSetProperty.java 18 Dec 2008 06:44:40 -0000 1.1.2.2 >+++ src/org/eclipse/core/internal/databinding/beans/BeanSetProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -33,7 +33,8 @@ > * > */ > public class BeanSetProperty extends SimpleSetProperty implements IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class elementType; > > /** > * @param propertyDescriptor >@@ -41,10 +42,14 @@ > */ > public BeanSetProperty(PropertyDescriptor propertyDescriptor, > Class elementType) { >- super(elementType == null ? BeanPropertyHelper >- .getCollectionPropertyElementType(propertyDescriptor) >- : elementType); > this.propertyDescriptor = propertyDescriptor; >+ this.elementType = elementType == null ? BeanPropertyHelper >+ .getCollectionPropertyElementType(propertyDescriptor) >+ : elementType; >+ } >+ >+ protected Object getElementType() { >+ return elementType; > } > > protected Set doGetSet(Object source) { >@@ -63,11 +68,12 @@ > return (Set) propertyValue; > } > >- protected void setSet(Object source, Set set, SetDiff diff) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, >- convertSetToBeanPropertyType(set)); >- } >+ protected boolean setSet(Object source, Set set, SetDiff diff) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, >+ convertSetToBeanPropertyType(set)); >+ return true; > } > > private Object convertSetToBeanPropertyType(Set set) { >@@ -139,7 +145,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + "{}"; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class elementType = (Class) getElementType(); > if (elementType != null) > s += " <" + elementType.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; >Index: src/org/eclipse/core/internal/databinding/beans/PojoValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/PojoValueProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 PojoValueProperty.java >--- src/org/eclipse/core/internal/databinding/beans/PojoValueProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/PojoValueProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -24,7 +24,8 @@ > */ > public class PojoValueProperty extends SimpleValueProperty implements > IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class valueType; > > /** > * @param propertyDescriptor >@@ -32,9 +33,13 @@ > */ > public PojoValueProperty(PropertyDescriptor propertyDescriptor, > Class valueType) { >- super(valueType == null ? propertyDescriptor.getPropertyType() >- : valueType); > this.propertyDescriptor = propertyDescriptor; >+ this.valueType = valueType == null ? propertyDescriptor >+ .getPropertyType() : valueType; >+ } >+ >+ protected Object getValueType() { >+ return valueType; > } > > public Object getValue(Object source) { >@@ -43,10 +48,11 @@ > return BeanPropertyHelper.readProperty(source, propertyDescriptor); > } > >- public void setValue(Object source, Object value) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, value); >- } >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, value); >+ return true; > } > > public PropertyDescriptor getPropertyDescriptor() { >@@ -70,7 +76,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + ""; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class valueType = (Class) getValueType(); > if (valueType != null) > s += " <" + valueType.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; >Index: src/org/eclipse/core/internal/databinding/beans/PojoSetProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/PojoSetProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 PojoSetProperty.java >--- src/org/eclipse/core/internal/databinding/beans/PojoSetProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/PojoSetProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -29,7 +29,8 @@ > * > */ > public class PojoSetProperty extends SimpleSetProperty implements IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class elementType; > > /** > * @param propertyDescriptor >@@ -37,10 +38,14 @@ > */ > public PojoSetProperty(PropertyDescriptor propertyDescriptor, > Class elementType) { >- super(elementType == null ? BeanPropertyHelper >- .getCollectionPropertyElementType(propertyDescriptor) >- : elementType); > this.propertyDescriptor = propertyDescriptor; >+ this.elementType = elementType == null ? BeanPropertyHelper >+ .getCollectionPropertyElementType(propertyDescriptor) >+ : elementType; >+ } >+ >+ protected Object getElementType() { >+ return elementType; > } > > protected Set doGetSet(Object source) { >@@ -59,11 +64,12 @@ > return (Set) propertyValue; > } > >- protected void setSet(Object source, Set set, SetDiff diff) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, >- convertSetToBeanPropertyType(set)); >- } >+ protected boolean setSet(Object source, Set set, SetDiff diff) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, >+ convertSetToBeanPropertyType(set)); >+ return true; > } > > private Object convertSetToBeanPropertyType(Set set) { >@@ -99,7 +105,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + "{}"; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class elementType = (Class) getElementType(); > if (elementType != null) > s += " <" + elementType.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; >Index: src/org/eclipse/core/internal/databinding/beans/BeanListProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/BeanListProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 BeanListProperty.java >--- src/org/eclipse/core/internal/databinding/beans/BeanListProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/BeanListProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -35,6 +35,7 @@ > public class BeanListProperty extends SimpleListProperty implements > IBeanProperty { > private final PropertyDescriptor propertyDescriptor; >+ private final Class elementType; > > /** > * @param propertyDescriptor >@@ -42,10 +43,14 @@ > */ > public BeanListProperty(PropertyDescriptor propertyDescriptor, > Class elementType) { >- super(elementType == null ? BeanPropertyHelper >- .getCollectionPropertyElementType(propertyDescriptor) >- : elementType); > this.propertyDescriptor = propertyDescriptor; >+ this.elementType = elementType == null ? BeanPropertyHelper >+ .getCollectionPropertyElementType(propertyDescriptor) >+ : elementType; >+ } >+ >+ protected Object getElementType() { >+ return elementType; > } > > protected List doGetList(Object source) { >@@ -64,11 +69,12 @@ > return (List) propertyValue; > } > >- protected void setList(Object source, List list, ListDiff diff) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, >- convertListToBeanPropertyType(list)); >- } >+ protected boolean setList(Object source, List list, ListDiff diff) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, >+ convertListToBeanPropertyType(list)); >+ return true; > } > > private Object convertListToBeanPropertyType(List list) { >@@ -141,7 +147,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + "[]"; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class elementType = (Class) getElementType(); > if (elementType != null) > s += " <" + elementType.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; >Index: src/org/eclipse/core/internal/databinding/beans/PojoMapProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/PojoMapProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 PojoMapProperty.java >--- src/org/eclipse/core/internal/databinding/beans/PojoMapProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/PojoMapProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -27,7 +27,9 @@ > * > */ > public class PojoMapProperty extends SimpleMapProperty implements IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class keyType; >+ private final Class valueType; > > /** > * @param propertyDescriptor >@@ -36,8 +38,17 @@ > */ > public PojoMapProperty(PropertyDescriptor propertyDescriptor, > Class keyType, Class valueType) { >- super(keyType, valueType); > this.propertyDescriptor = propertyDescriptor; >+ this.keyType = keyType; >+ this.valueType = valueType; >+ } >+ >+ protected Object getKeyType() { >+ return keyType; >+ } >+ >+ protected Object getValueType() { >+ return valueType; > } > > protected Map doGetMap(Object source) { >@@ -54,10 +65,11 @@ > return (Map) propertyValue; > } > >- protected void setMap(Object source, Map map, MapDiff diff) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, map); >- } >+ protected boolean setMap(Object source, Map map, MapDiff diff) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, map); >+ return true; > } > > public PropertyDescriptor getPropertyDescriptor() { >@@ -81,8 +93,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + "{:}"; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class keyType = (Class) getKeyType(); >- Class valueType = (Class) getValueType(); > if (keyType != null || valueType != null) { > s += " <" + keyType + ", " + valueType + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } >Index: src/org/eclipse/core/internal/databinding/beans/BeanMapProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/BeanMapProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 BeanMapProperty.java >--- src/org/eclipse/core/internal/databinding/beans/BeanMapProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/BeanMapProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -31,7 +31,9 @@ > * > */ > public class BeanMapProperty extends SimpleMapProperty implements IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class keyType; >+ private final Class valueType; > > /** > * @param propertyDescriptor >@@ -40,8 +42,17 @@ > */ > public BeanMapProperty(PropertyDescriptor propertyDescriptor, > Class keyType, Class valueType) { >- super(keyType, valueType); > this.propertyDescriptor = propertyDescriptor; >+ this.keyType = keyType; >+ this.valueType = valueType; >+ } >+ >+ protected Object getKeyType() { >+ return keyType; >+ } >+ >+ protected Object getValueType() { >+ return valueType; > } > > protected Map doGetMap(Object source) { >@@ -58,10 +69,11 @@ > return (Map) propertyValue; > } > >- protected void setMap(Object source, Map map, MapDiff diff) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, map); >- } >+ protected boolean setMap(Object source, Map map, MapDiff diff) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, map); >+ return true; > } > > public PropertyDescriptor getPropertyDescriptor() { >@@ -121,8 +133,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + "{:}"; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class keyType = (Class) getKeyType(); >- Class valueType = (Class) getValueType(); > if (keyType != null || valueType != null) { > s += " <" + keyType + ", " + valueType + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ > } >Index: src/org/eclipse/core/internal/databinding/beans/PojoListProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/PojoListProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 PojoListProperty.java >--- src/org/eclipse/core/internal/databinding/beans/PojoListProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/PojoListProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -30,7 +30,8 @@ > */ > public class PojoListProperty extends SimpleListProperty implements > IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class elementType; > > /** > * @param propertyDescriptor >@@ -38,10 +39,14 @@ > */ > public PojoListProperty(PropertyDescriptor propertyDescriptor, > Class elementType) { >- super(elementType == null ? BeanPropertyHelper >- .getCollectionPropertyElementType(propertyDescriptor) >- : elementType); > this.propertyDescriptor = propertyDescriptor; >+ this.elementType = elementType == null ? BeanPropertyHelper >+ .getCollectionPropertyElementType(propertyDescriptor) >+ : elementType; >+ } >+ >+ protected Object getElementType() { >+ return elementType; > } > > protected List doGetList(Object source) { >@@ -60,11 +65,12 @@ > return (List) propertyValue; > } > >- protected void setList(Object source, List list, ListDiff diff) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, >- convertListToBeanPropertyType(list)); >- } >+ protected boolean setList(Object source, List list, ListDiff diff) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, >+ convertListToBeanPropertyType(list)); >+ return true; > } > > private Object convertListToBeanPropertyType(List list) { >@@ -101,7 +107,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + "[]"; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class elementType = (Class) getElementType(); > if (elementType != null) > s += " <" + elementType.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; >Index: src/org/eclipse/core/internal/databinding/beans/BeanValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding.beans/src/org/eclipse/core/internal/databinding/beans/Attic/BeanValueProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 BeanValueProperty.java >--- src/org/eclipse/core/internal/databinding/beans/BeanValueProperty.java 17 Dec 2008 18:40:08 -0000 1.1.2.1 >+++ src/org/eclipse/core/internal/databinding/beans/BeanValueProperty.java 20 Dec 2008 06:51:28 -0000 >@@ -29,7 +29,8 @@ > */ > public class BeanValueProperty extends SimpleValueProperty implements > IBeanProperty { >- private PropertyDescriptor propertyDescriptor; >+ private final PropertyDescriptor propertyDescriptor; >+ private final Class valueType; > > /** > * @param propertyDescriptor >@@ -37,9 +38,13 @@ > */ > public BeanValueProperty(PropertyDescriptor propertyDescriptor, > Class valueType) { >- super(valueType == null ? propertyDescriptor.getPropertyType() >- : valueType); > this.propertyDescriptor = propertyDescriptor; >+ this.valueType = valueType == null ? propertyDescriptor >+ .getPropertyType() : valueType; >+ } >+ >+ protected Object getValueType() { >+ return valueType; > } > > public Object getValue(Object source) { >@@ -48,10 +53,11 @@ > return BeanPropertyHelper.readProperty(source, propertyDescriptor); > } > >- public void setValue(Object source, Object value) { >- if (source != null) { >- BeanPropertyHelper.writeProperty(source, propertyDescriptor, value); >- } >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; >+ BeanPropertyHelper.writeProperty(source, propertyDescriptor, value); >+ return true; > } > > public PropertyDescriptor getPropertyDescriptor() { >@@ -111,7 +117,6 @@ > String propertyName = propertyDescriptor.getName(); > String s = beanClass.getName() + "." + propertyName + ""; //$NON-NLS-1$ //$NON-NLS-2$ > >- Class valueType = (Class) getValueType(); > if (valueType != null) > s += " <" + valueType.getName() + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; >#P org.eclipse.jface.databinding >Index: src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderSingleSelectionProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/SelectionProviderSingleSelectionProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 SelectionProviderSingleSelectionProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderSingleSelectionProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderSingleSelectionProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -27,11 +27,8 @@ > */ > public class SelectionProviderSingleSelectionProperty extends > ViewerValueProperty { >- /** >- * >- */ >- public SelectionProviderSingleSelectionProperty() { >- super(null); >+ protected Object getValueType() { >+ return null; > } > > public Object getValue(Object source) { >@@ -42,10 +39,13 @@ > return null; > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((ISelectionProvider) source) > .setSelection(value == null ? StructuredSelection.EMPTY > : new StructuredSelection(value)); >+ return true; > } > > public INativePropertyListener adaptListener( >Index: src/org/eclipse/jface/internal/databinding/viewers/ViewerValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/ViewerValueProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ViewerValueProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/ViewerValueProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/viewers/ViewerValueProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -21,10 +21,6 @@ > * > */ > public abstract class ViewerValueProperty extends SimpleValueProperty { >- protected ViewerValueProperty(Object valueType) { >- super(valueType); >- } >- > protected Realm getPreferredRealm(Object source) { > if (source instanceof Viewer) { > return SWTObservables.getRealm(((Viewer) source).getControl() >Index: src/org/eclipse/jface/internal/databinding/viewers/ViewerListProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/ViewerListProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ViewerListProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/ViewerListProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/viewers/ViewerListProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -21,10 +21,6 @@ > * > */ > public abstract class ViewerListProperty extends SimpleListProperty { >- protected ViewerListProperty(Object elementType) { >- super(elementType); >- } >- > protected Realm getPreferredRealm(Object source) { > if (source instanceof Viewer) { > return SWTObservables.getRealm(((Viewer) source).getControl() >Index: src/org/eclipse/jface/internal/databinding/viewers/ViewerInputProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/ViewerInputProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 ViewerInputProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/ViewerInputProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/viewers/ViewerInputProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -20,19 +20,19 @@ > * > */ > public class ViewerInputProperty extends ViewerValueProperty { >- /** >- * >- */ >- public ViewerInputProperty() { >- super(null); >+ protected Object getValueType() { >+ return null; > } > > public Object getValue(Object source) { > return ((Viewer) source).getInput(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Viewer) source).setInput(value); >+ return true; > } > > public INativePropertyListener adaptListener( >Index: src/org/eclipse/jface/internal/databinding/viewers/ViewerSetProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/ViewerSetProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ViewerSetProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/ViewerSetProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/viewers/ViewerSetProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -21,10 +21,6 @@ > * > */ > public abstract class ViewerSetProperty extends SimpleSetProperty { >- protected ViewerSetProperty(Object elementType) { >- super(elementType); >- } >- > protected Realm getPreferredRealm(Object source) { > if (source instanceof Viewer) { > return SWTObservables.getRealm(((Viewer) source).getControl() >Index: src/org/eclipse/jface/internal/databinding/viewers/StructuredViewerFiltersProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/StructuredViewerFiltersProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 StructuredViewerFiltersProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/StructuredViewerFiltersProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/viewers/StructuredViewerFiltersProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -26,11 +26,8 @@ > * > */ > public class StructuredViewerFiltersProperty extends ViewerSetProperty { >- /** >- * >- */ >- public StructuredViewerFiltersProperty() { >- super(ViewerFilter.class); >+ protected Object getElementType() { >+ return ViewerFilter.class; > } > > protected Set doGetSet(Object source) { >@@ -38,7 +35,9 @@ > .getFilters())); > } > >- public void setSet(Object source, Set set, SetDiff diff) { >+ public boolean setSet(Object source, Set set, SetDiff diff) { >+ if (source == null) >+ return false; > StructuredViewer viewer = (StructuredViewer) source; > viewer.getControl().setRedraw(false); > try { >@@ -47,6 +46,7 @@ > } finally { > viewer.getControl().setRedraw(true); > } >+ return true; > } > > public INativePropertyListener adaptListener( >Index: src/org/eclipse/jface/internal/databinding/viewers/CheckableCheckedElementsProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/CheckableCheckedElementsProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 CheckableCheckedElementsProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/CheckableCheckedElementsProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/viewers/CheckableCheckedElementsProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -30,11 +30,17 @@ > * > */ > public class CheckableCheckedElementsProperty extends ViewerSetProperty { >+ private final Object elementType; >+ > /** > * @param elementType > */ > public CheckableCheckedElementsProperty(Object elementType) { >- super(elementType); >+ this.elementType = elementType; >+ } >+ >+ protected Object getElementType() { >+ return elementType; > } > > protected Set doGetSet(Object source) { >@@ -56,7 +62,9 @@ > return new HashSet(); > } > >- protected void setSet(Object source, Set set, SetDiff diff) { >+ protected boolean setSet(Object source, Set set, SetDiff diff) { >+ if (source == null) >+ return false; > ICheckable checkable = (ICheckable) source; > for (Iterator it = diff.getAdditions().iterator(); it.hasNext();) { > checkable.setChecked(it.next(), true); >@@ -64,6 +72,7 @@ > for (Iterator it = diff.getRemovals().iterator(); it.hasNext();) { > checkable.setChecked(it.next(), false); > } >+ return true; > } > > public INativePropertyListener adaptListener( >@@ -106,8 +115,8 @@ > > public String toString() { > String s = "ICheckable.checkedElements{}"; //$NON-NLS-1$ >- if (getElementType() != null) >- s += " <" + getElementType() + ">"; //$NON-NLS-1$//$NON-NLS-2$ >+ if (elementType != null) >+ s += " <" + elementType + ">"; //$NON-NLS-1$//$NON-NLS-2$ > return s; > } > } >Index: src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderMultipleSelectionProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/viewers/Attic/SelectionProviderMultipleSelectionProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 SelectionProviderMultipleSelectionProperty.java >--- src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderMultipleSelectionProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/viewers/SelectionProviderMultipleSelectionProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -31,10 +31,8 @@ > */ > public class SelectionProviderMultipleSelectionProperty extends > ViewerListProperty { >- /** >- */ >- public SelectionProviderMultipleSelectionProperty() { >- super(Object.class); >+ protected Object getElementType() { >+ return Object.class; > } > > protected List doGetList(Object source) { >@@ -45,9 +43,12 @@ > return Collections.EMPTY_LIST; > } > >- protected void setList(Object source, List list, ListDiff diff) { >+ protected boolean setList(Object source, List list, ListDiff diff) { >+ if (source == null) >+ return false; > ((ISelectionProvider) source) > .setSelection(new StructuredSelection(list)); >+ return true; > } > > public INativePropertyListener adaptListener( >Index: src/org/eclipse/jface/internal/databinding/swt/WidgetBooleanValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/WidgetBooleanValueProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 WidgetBooleanValueProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/WidgetBooleanValueProperty.java 17 Dec 2008 18:39:54 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/WidgetBooleanValueProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -16,26 +16,33 @@ > * > */ > public abstract class WidgetBooleanValueProperty extends WidgetValueProperty { >- WidgetBooleanValueProperty(int[] events) { >- super(events, Boolean.TYPE); >+ WidgetBooleanValueProperty() { >+ super(); > } > > WidgetBooleanValueProperty(int event) { >- super(event, Boolean.TYPE); >+ super(event); > } > >- WidgetBooleanValueProperty() { >- super(Boolean.TYPE); >+ WidgetBooleanValueProperty(int[] events) { >+ super(events); >+ } >+ >+ protected Object getValueType() { >+ return Boolean.TYPE; > } > > public Object getValue(Object source) { > return doGetBooleanValue(source) ? Boolean.TRUE : Boolean.FALSE; > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > if (value == null) > value = Boolean.FALSE; > doSetBooleanValue(source, ((Boolean) value).booleanValue()); >+ return true; > } > > abstract boolean doGetBooleanValue(Object source); >Index: src/org/eclipse/jface/internal/databinding/swt/ControlStringListProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlStringListProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 ControlStringListProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlStringListProperty.java 19 Dec 2008 03:03:37 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlStringListProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -24,13 +24,16 @@ > * > */ > public abstract class ControlStringListProperty extends WidgetListProperty { >- protected ControlStringListProperty() { >- super(String.class); >+ protected Object getElementType() { >+ return String.class; > } > >- protected void setList(Object source, List list, ListDiff diff) { >+ protected boolean setList(Object source, List list, ListDiff diff) { >+ if (source == null) >+ return false; > String[] strings = (String[]) list.toArray(new String[list.size()]); > doSetStringList((Control) source, strings); >+ return true; > } > > abstract void doSetStringList(Control control, String[] list); >Index: src/org/eclipse/jface/internal/databinding/swt/ControlBackgroundProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlBackgroundProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ControlBackgroundProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlBackgroundProperty.java 17 Dec 2008 18:39:54 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlBackgroundProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -19,19 +19,19 @@ > * > */ > public class ControlBackgroundProperty extends WidgetValueProperty { >- /** >- * >- */ >- public ControlBackgroundProperty() { >- super(Color.class); >+ protected Object getValueType() { >+ return Color.class; > } > > public Object getValue(Object source) { > return ((Control) source).getBackground(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Control) source).setBackground((Color) value); >+ return true; > } > > public String toString() { >Index: src/org/eclipse/jface/internal/databinding/swt/ControlSizeProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlSizeProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ControlSizeProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlSizeProperty.java 17 Dec 2008 18:39:54 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlSizeProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -25,15 +25,22 @@ > * > */ > public ControlSizeProperty() { >- super(SWT.Resize, Point.class); >+ super(SWT.Resize); >+ } >+ >+ protected Object getValueType() { >+ return Point.class; > } > > public Object getValue(Object source) { > return ((Control) source).getSize(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Control) source).setSize((Point) value); >+ return true; > } > > public String toString() { >Index: src/org/eclipse/jface/internal/databinding/swt/WidgetStringValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/WidgetStringValueProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 WidgetStringValueProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/WidgetStringValueProperty.java 17 Dec 2008 18:39:56 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/WidgetStringValueProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -16,20 +16,27 @@ > * > */ > public abstract class WidgetStringValueProperty extends WidgetValueProperty { >+ WidgetStringValueProperty() { >+ super(); >+ } >+ > WidgetStringValueProperty(int event) { >- super(event, String.class); >+ super(event); > } > >- WidgetStringValueProperty() { >- super(String.class); >+ protected Object getValueType() { >+ return String.class; > } > > public Object getValue(Object source) { > return doGetStringValue(source); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > doSetStringValue(source, (String) value); >+ return true; > } > > abstract String doGetStringValue(Object source); >Index: src/org/eclipse/jface/internal/databinding/swt/ControlFontProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlFontProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ControlFontProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlFontProperty.java 17 Dec 2008 18:39:54 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlFontProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -19,19 +19,19 @@ > * > */ > public class ControlFontProperty extends WidgetValueProperty { >- /** >- * >- */ >- public ControlFontProperty() { >- super(Font.class); >+ protected Object getValueType() { >+ return Font.class; > } > > public Object getValue(Object source) { > return ((Control) source).getFont(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Control) source).setFont((Font) value); >+ return true; > } > > public String toString() { >Index: src/org/eclipse/jface/internal/databinding/swt/ControlBoundsProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlBoundsProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ControlBoundsProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlBoundsProperty.java 17 Dec 2008 18:39:56 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlBoundsProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -25,15 +25,22 @@ > * > */ > public ControlBoundsProperty() { >- super(new int[] { SWT.Resize, SWT.Move }, Rectangle.class); >+ super(new int[] { SWT.Resize, SWT.Move }); >+ } >+ >+ protected Object getValueType() { >+ return Rectangle.class; > } > > public Object getValue(Object source) { > return ((Control) source).getBounds(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Control) source).setBounds((Rectangle) value); >+ return true; > } > > public String toString() { >Index: src/org/eclipse/jface/internal/databinding/swt/WidgetValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/WidgetValueProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 WidgetValueProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/WidgetValueProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.2 >+++ src/org/eclipse/jface/internal/databinding/swt/WidgetValueProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -25,16 +25,15 @@ > abstract class WidgetValueProperty extends SimpleValueProperty { > private int[] events; > >- WidgetValueProperty(Object valueType) { >- this(null, valueType); >+ WidgetValueProperty() { >+ this(null); > } > >- WidgetValueProperty(int event, Object valueType) { >- this(new int[] { event }, valueType); >+ WidgetValueProperty(int event) { >+ this(new int[] { event }); > } > >- WidgetValueProperty(int[] events, Object valueType) { >- super(valueType); >+ WidgetValueProperty(int[] events) { > this.events = events; > } > >Index: src/org/eclipse/jface/internal/databinding/swt/ControlForegroundProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlForegroundProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ControlForegroundProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlForegroundProperty.java 17 Dec 2008 18:39:54 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlForegroundProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -19,19 +19,19 @@ > * > */ > public class ControlForegroundProperty extends WidgetValueProperty { >- /** >- * >- */ >- public ControlForegroundProperty() { >- super(Color.class); >+ protected Object getValueType() { >+ return Color.class; > } > > public Object getValue(Object source) { > return ((Control) source).getForeground(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Control) source).setForeground((Color) value); >+ return true; > } > > public String toString() { >Index: src/org/eclipse/jface/internal/databinding/swt/ControlLocationProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/ControlLocationProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ControlLocationProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/ControlLocationProperty.java 17 Dec 2008 18:39:55 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/ControlLocationProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -25,15 +25,22 @@ > * > */ > public ControlLocationProperty() { >- super(SWT.Move, Point.class); >+ super(SWT.Move); >+ } >+ >+ protected Object getValueType() { >+ return Point.class; > } > > public Object getValue(Object source) { > return ((Control) source).getLocation(); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > ((Control) source).setLocation((Point) value); >+ return true; > } > > public String toString() { >Index: src/org/eclipse/jface/internal/databinding/swt/WidgetListProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/WidgetListProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 WidgetListProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/WidgetListProperty.java 19 Dec 2008 03:03:38 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/WidgetListProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -21,10 +21,6 @@ > * > */ > public abstract class WidgetListProperty extends SimpleListProperty { >- protected WidgetListProperty(Object elementType) { >- super(elementType); >- } >- > protected Realm getPreferredRealm(Object source) { > if (source instanceof Widget) > return SWTObservables.getRealm(((Widget) source).getDisplay()); >Index: src/org/eclipse/jface/internal/databinding/swt/WidgetIntValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/Attic/WidgetIntValueProperty.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 WidgetIntValueProperty.java >--- src/org/eclipse/jface/internal/databinding/swt/WidgetIntValueProperty.java 17 Dec 2008 18:39:54 -0000 1.1.2.1 >+++ src/org/eclipse/jface/internal/databinding/swt/WidgetIntValueProperty.java 20 Dec 2008 06:51:30 -0000 >@@ -17,23 +17,30 @@ > */ > public abstract class WidgetIntValueProperty extends WidgetValueProperty { > WidgetIntValueProperty() { >- super(Integer.TYPE); >+ super(); > } > > WidgetIntValueProperty(int event) { >- super(event, Integer.TYPE); >+ super(event); > } > > WidgetIntValueProperty(int[] events) { >- super(events, Integer.TYPE); >+ super(events); >+ } >+ >+ protected Object getValueType() { >+ return Integer.TYPE; > } > > public Object getValue(Object source) { > return new Integer(doGetIntValue(source)); > } > >- public void setValue(Object source, Object value) { >+ public boolean setValue(Object source, Object value) { >+ if (source == null) >+ return false; > doSetIntValue(source, ((Integer) value).intValue()); >+ return true; > } > > abstract int doGetIntValue(Object source); >#P org.eclipse.core.databinding >Index: src/org/eclipse/core/databinding/property/set/SimpleSetPropertyObservableSet.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/set/Attic/SimpleSetPropertyObservableSet.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 SimpleSetPropertyObservableSet.java >--- src/org/eclipse/core/databinding/property/set/SimpleSetPropertyObservableSet.java 17 Dec 2008 18:40:04 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/set/SimpleSetPropertyObservableSet.java 20 Dec 2008 06:51:32 -0000 >@@ -57,7 +57,7 @@ > > protected void firstListenerAdded() { > if (!isDisposed()) { >- cachedSet = property.getSet(source); >+ cachedSet = getSet(); > > if (listener == null) { > listener = property >@@ -96,7 +96,7 @@ > } > > protected Set getWrappedSet() { >- return property.getSet(source); >+ return getSet(); > } > > public Object getElementType() { >@@ -105,8 +105,37 @@ > > // Queries > >+ private Set getSet() { >+ return property.getSet(source); >+ } >+ >+ public boolean contains(Object o) { >+ getterCalled(); >+ return getSet().contains(o); >+ } >+ >+ public boolean containsAll(Collection c) { >+ getterCalled(); >+ return getSet().containsAll(c); >+ } >+ > protected int doGetSize() { >- return property.size(source); >+ return getSet().size(); >+ } >+ >+ public boolean isEmpty() { >+ getterCalled(); >+ return getSet().isEmpty(); >+ } >+ >+ public Object[] toArray() { >+ getterCalled(); >+ return getSet().toArray(); >+ } >+ >+ public Object[] toArray(Object[] a) { >+ getterCalled(); >+ return getSet().toArray(a); > } > > // Single change operations >@@ -114,22 +143,27 @@ > public boolean add(Object o) { > checkRealm(); > >- boolean changed; >+ Set set = new HashSet(getSet()); >+ if (!set.add(o)) >+ return false; >+ >+ SetDiff diff = Diffs.createSetDiff(Collections.singleton(o), >+ Collections.EMPTY_SET); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- changed = property.add(source, o); >+ changed = property.setSet(source, set, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >- >- if (changed) >- fireSetChange(Diffs.createSetDiff(Collections.singleton(o), >- Collections.EMPTY_SET)); >+ if (changed) { >+ cachedSet = getSet(); >+ fireSetChange(diff); >+ } > > return changed; > } >@@ -138,19 +172,20 @@ > getterCalled(); > return new Iterator() { > int expectedModCount = modCount; >- Iterator delegate = new HashSet(property.getSet(source)).iterator(); >+ Set set = new HashSet(getSet()); >+ Iterator iterator = set.iterator(); > Object last = null; > > public boolean hasNext() { > getterCalled(); > checkForComodification(); >- return delegate.hasNext(); >+ return iterator.hasNext(); > } > > public Object next() { > getterCalled(); > checkForComodification(); >- last = delegate.next(); >+ last = iterator.next(); > return last; > } > >@@ -158,24 +193,27 @@ > checkRealm(); > checkForComodification(); > >- delegate.remove(); // stay in sync >+ iterator.remove(); // stay in sync >+ SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, >+ Collections.singleton(last)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.remove(source, last); >+ changed = property.setSet(source, set, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >+ if (changed) { >+ cachedSet = getSet(); >+ fireSetChange(diff); > >- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, >- Collections.singleton(last))); >- >- last = null; >- expectedModCount = modCount; >+ last = null; >+ expectedModCount = modCount; >+ } > } > > private void checkForComodification() { >@@ -188,20 +226,27 @@ > public boolean remove(Object o) { > getterCalled(); > >- boolean changed; >+ Set set = new HashSet(getSet()); >+ if (!set.remove(o)) >+ return false; >+ >+ SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, Collections >+ .singleton(o)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- changed = property.remove(source, o); >+ changed = property.setSet(source, set, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, Collections >- .singleton(o))); >+ if (changed) { >+ cachedSet = property.getSet(source); >+ fireSetChange(diff); >+ } > > return changed; > } >@@ -214,56 +259,84 @@ > if (c.isEmpty()) > return false; > >+ Set set = new HashSet(getSet()); >+ > Set additions = new HashSet(c); >- additions.removeAll(property.getSet(source)); >+ for (Iterator it = c.iterator(); it.hasNext();) { >+ Object element = it.next(); >+ if (set.add(element)) >+ additions.add(element); >+ } >+ > if (additions.isEmpty()) > return false; > >+ SetDiff diff = Diffs.createSetDiff(additions, Collections.EMPTY_SET); >+ > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.addAll(source, c); >+ changed = property.setSet(source, set, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >- fireSetChange(Diffs.createSetDiff(additions, Collections.EMPTY_SET)); >+ if (changed) { >+ cachedSet = property.getSet(source); >+ fireSetChange(diff); >+ } > >- return true; >+ return changed; > } > > public boolean removeAll(Collection c) { > getterCalled(); > >- if (property.isEmpty(source) || c.isEmpty()) >+ Set set = getSet(); >+ if (set.isEmpty()) >+ return false; >+ if (c.isEmpty()) > return false; > >+ set = new HashSet(set); >+ > Set removals = new HashSet(c); >- removals.retainAll(property.getSet(source)); >+ for (Iterator it = c.iterator(); it.hasNext();) { >+ Object element = it.next(); >+ if (set.remove(element)) >+ removals.add(element); >+ } >+ > if (removals.isEmpty()) > return false; > >+ SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, removals); >+ > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.removeAll(source, c); >+ changed = property.setSet(source, set, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removals)); >+ if (changed) { >+ cachedSet = property.getSet(source); >+ fireSetChange(diff); >+ } > >- return true; >+ return changed; > } > > public boolean retainAll(Collection c) { > getterCalled(); > >- if (property.isEmpty(source)) >+ Set set = getSet(); >+ if (set.isEmpty()) > return false; > > if (c.isEmpty()) { >@@ -271,55 +344,73 @@ > return true; > } > >- Set removals = new HashSet(property.getSet(source)); >- removals.removeAll(c); >+ set = new HashSet(set); >+ >+ Set removals = new HashSet(); >+ for (Iterator it = set.iterator(); it.hasNext();) { >+ Object element = it.next(); >+ if (!c.contains(element)) { >+ it.remove(); >+ removals.add(element); >+ } >+ } >+ > if (removals.isEmpty()) > return false; > >+ SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, removals); >+ > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.retainAll(source, c); >+ changed = property.setSet(source, set, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removals)); >+ if (changed) { >+ cachedSet = property.getSet(source); >+ fireSetChange(diff); >+ } > >- return true; >+ return changed; > } > > public void clear() { > getterCalled(); > >- if (property.isEmpty(source)) >+ Set set = getSet(); >+ if (set.isEmpty()) > return; > >- Set removals = new HashSet(property.getSet(source)); >+ SetDiff diff = Diffs.createSetDiff(Collections.EMPTY_SET, set); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.clear(source); >+ changed = property.setSet(source, Collections.EMPTY_SET, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedSet = property.getSet(source); >- fireSetChange(Diffs.createSetDiff(Collections.EMPTY_SET, removals)); >+ if (changed) { >+ cachedSet = property.getSet(source); >+ fireSetChange(diff); >+ } > } > > public boolean equals(Object o) { > getterCalled(); >- return property.equals(source, o); >+ return getSet().equals(o); > } > > public int hashCode() { > getterCalled(); >- return property.hashCode(source); >+ return getSet().hashCode(); > } > > public Object getObserved() { >Index: src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/set/Attic/SimpleSetProperty.java,v >retrieving revision 1.1.2.2 >diff -u -r1.1.2.2 SimpleSetProperty.java >--- src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java 19 Dec 2008 01:46:56 -0000 1.1.2.2 >+++ src/org/eclipse/core/databinding/property/set/SimpleSetProperty.java 20 Dec 2008 06:51:32 -0000 >@@ -11,13 +11,9 @@ > > package org.eclipse.core.databinding.property.set; > >-import java.util.Collection; > import java.util.Collections; >-import java.util.HashSet; >-import java.util.Iterator; > import java.util.Set; > >-import org.eclipse.core.databinding.observable.Diffs; > import org.eclipse.core.databinding.observable.IObservable; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; >@@ -47,10 +43,19 @@ > * @since 1.2 > */ > public abstract class SimpleSetProperty extends SetProperty { >- private final Object elementType; >+ public IObservableSet observeSet(Realm realm, Object source) { >+ return new SimpleSetPropertyObservableSet(realm, source, this); >+ } > >- protected SimpleSetProperty(Object elementType) { >- this.elementType = elementType; >+ public IObservableSet observeDetailSet(IObservableValue master) { >+ final Realm realm = master.getRealm(); >+ IObservableFactory factory = new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return SimpleSetProperty.this.observeSet(realm, target); >+ } >+ }; >+ return MasterDetailObservables.detailSet(master, factory, >+ getElementType()); > } > > /** >@@ -61,41 +66,9 @@ > * if untyped > * @noreference This method is not intended to be referenced by clients. > */ >- protected final Object getElementType() { >- return elementType; >- } >- >- /** >- * Returns whether the source's collection property contains the given >- * element. >- * >- * @param source >- * the property source >- * @param o >- * the element >- * @return whether the source's collection property contains the given >- * element. >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean contains(Object source, Object o) { >- return getSet(source).contains(o); >- } >+ protected abstract Object getElementType(); > >- /** >- * Returns whether the source's collection property contains all elements in >- * the given collection >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to test for >- * @return whether the source's collection property contains all elements in >- * the given collection >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean containsAll(Object source, Collection c) { >- return getSet(source).containsAll(c); >- } >+ // Accessors > > /** > * Returns a Set with the current contents of the source's set property >@@ -121,85 +94,7 @@ > */ > protected abstract Set doGetSet(Object source); > >- /** >- * Returns whether the source's collection property is equal to the >- * argument. >- * >- * @param source >- * the property source >- * @param o >- * the object to test for equality to the source's collection >- * property >- * @return whether the source's collection property is equal to the argument >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean equals(Object source, Object o) { >- return getSet(source).equals(o); >- } >- >- /** >- * Returns the hash code of the source's collection property. >- * >- * @param source >- * the property source >- * @return the hash code of the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int hashCode(Object source) { >- return getSet(source).hashCode(); >- } >- >- /** >- * Returns whether the source's collection property is empty >- * >- * @param source >- * the property source >- * @return whether the source's collection property is empty >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean isEmpty(Object source) { >- return getSet(source).isEmpty(); >- } >- >- /** >- * Returns the size of the source's collection property >- * >- * @param source >- * the property source >- * @return the size of the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int size(Object source) { >- return getSet(source).size(); >- } >- >- /** >- * Returns an array of all elements in the source's collection property >- * >- * @param source >- * the property source >- * @param array >- * the array into which the elements will be copied. If the array >- * is not large enough to hold all elements, the elements will be >- * returned in a new array of the same runtime type. >- * @return an array of all elements in the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object[] toArray(Object source, Object[] array) { >- return getSet(source).toArray(array); >- } >- >- /** >- * Returns an array of all elements in the source's collection property >- * >- * @param source >- * the property source >- * @return an array of all elements in the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object[] toArray(Object source) { >- return getSet(source).toArray(); >- } >+ // Mutators > > /** > * Updates the property on the source with the specified change. >@@ -210,174 +105,13 @@ > * the new set > * @param diff > * a diff describing the change >+ * @return true if the property was modified on the source object, false >+ * otherwise > * @noreference This method is not intended to be referenced by clients. > */ >- protected abstract void setSet(Object source, Set set, SetDiff diff); >- >- /** >- * Adds the element to the source's collection property >- * >- * @param source >- * the property source >- * @param o >- * the element to add >- * @return whether the element was added to the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean add(Object source, Object o) { >- Set set = getSet(source); >- if (!set.contains(o)) { >- set = new HashSet(set); >- boolean added = set.add(o); >- if (added) { >- setSet(source, set, Diffs.createSetDiff(Collections >- .singleton(o), Collections.EMPTY_SET)); >- } >- return added; >- } >- return false; >- } >- >- /** >- * Adds all elements in the specified collection to the source's collection >- * property. >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to add. >- * @return whether the source's collection property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean addAll(Object source, Collection c) { >- if (c.isEmpty()) >- return false; >- >- Set set = getSet(source); >- Set additions = new HashSet(); >- for (Iterator it = c.iterator(); it.hasNext();) { >- Object o = it.next(); >- if (!set.contains(o)) { >- additions.add(o); >- } >- } >- boolean changed = !additions.isEmpty(); >- if (changed) { >- set = new HashSet(set); >- set.addAll(additions); >- >- setSet(source, set, Diffs.createSetDiff(additions, >- Collections.EMPTY_SET)); >- } >- return changed; >- } >+ protected abstract boolean setSet(Object source, Set set, SetDiff diff); > >- /** >- * Removes all elements from the source's collection property. >- * >- * @param source >- * the property source >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected void clear(Object source) { >- if (!isEmpty(source)) { >- setSet(source, new HashSet(), Diffs.createSetDiff( >- Collections.EMPTY_SET, getSet(source))); >- } >- } >- >- /** >- * Removes the element from the source's collection property >- * >- * @param source >- * the property source >- * @param o >- * the element to remove >- * @return whether the element was removed from the source's collection >- * property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean remove(Object source, Object o) { >- Set set = getSet(source); >- if (set.contains(o)) { >- set = new HashSet(set); >- boolean removed = set.remove(o); >- if (removed) { >- setSet(source, set, Diffs.createSetDiff(Collections.EMPTY_SET, >- Collections.singleton(o))); >- } >- return removed; >- } >- return false; >- } >- >- /** >- * Removes all elements from the source's collection property which are >- * contained in the specified collection. >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to be removed >- * @return whether the source's collection property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean removeAll(Object source, Collection c) { >- if (c.isEmpty()) >- return false; >- >- Set set = new HashSet(getSet(source)); >- Set removals = new HashSet(); >- for (Iterator it = set.iterator(); it.hasNext();) { >- Object o = it.next(); >- if (c.contains(o)) { >- removals.add(o); >- it.remove(); >- } >- } >- boolean changed = !removals.isEmpty(); >- if (changed) { >- setSet(source, set, Diffs.createSetDiff(Collections.EMPTY_SET, >- removals)); >- } >- return changed; >- } >- >- /** >- * Removes all elements from the source's collection property which are not >- * contained in the specified collection. >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to retain >- * @return whether the source's collection property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean retainAll(Object source, Collection c) { >- if (isEmpty(source)) >- return false; >- if (c.isEmpty()) { >- clear(source); >- return true; >- } >- >- Set set = new HashSet(getSet(source)); >- Set removals = new HashSet(); >- for (Iterator it = set.iterator(); it.hasNext();) { >- Object o = it.next(); >- if (!c.contains(o)) { >- removals.add(o); >- it.remove(); >- } >- } >- boolean changed = !removals.isEmpty(); >- if (changed) { >- setSet(source, set, Diffs.createSetDiff(Collections.EMPTY_SET, >- removals)); >- } >- return changed; >- } >+ // Listeners > > /** > * Returns a listener which implements the correct listener interface for >@@ -430,19 +164,4 @@ > */ > protected abstract void removeListener(Object source, > INativePropertyListener listener); >- >- public IObservableSet observeSet(Realm realm, Object source) { >- return new SimpleSetPropertyObservableSet(realm, source, this); >- } >- >- public IObservableSet observeDetailSet(IObservableValue master) { >- final Realm realm = master.getRealm(); >- IObservableFactory factory = new IObservableFactory() { >- public IObservable createObservable(Object target) { >- return SimpleSetProperty.this.observeSet(realm, target); >- } >- }; >- return MasterDetailObservables.detailSet(master, factory, >- getElementType()); >- } > } >Index: src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/map/Attic/SimpleMapProperty.java,v >retrieving revision 1.1.2.3 >diff -u -r1.1.2.3 SimpleMapProperty.java >--- src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java 19 Dec 2008 01:46:56 -0000 1.1.2.3 >+++ src/org/eclipse/core/databinding/property/map/SimpleMapProperty.java 20 Dec 2008 06:51:32 -0000 >@@ -12,13 +12,8 @@ > package org.eclipse.core.databinding.property.map; > > import java.util.Collections; >-import java.util.HashMap; >-import java.util.HashSet; >-import java.util.Iterator; > import java.util.Map; >-import java.util.Set; > >-import org.eclipse.core.databinding.observable.Diffs; > import org.eclipse.core.databinding.observable.IObservable; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.map.IObservableMap; >@@ -27,7 +22,6 @@ > import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; > import org.eclipse.core.databinding.observable.value.IObservableValue; > import org.eclipse.core.databinding.property.INativePropertyListener; >-import org.eclipse.core.internal.databinding.Util; > > /** > * Simplified abstract implementation of IMapProperty. This class takes care of >@@ -50,12 +44,18 @@ > */ > public abstract class SimpleMapProperty extends MapProperty implements > IMapProperty { >- private final Object keyType; >- private final Object valueType; >+ public IObservableMap observeMap(Realm realm, Object source) { >+ return new SimpleMapPropertyObservableMap(realm, source, this); >+ } > >- protected SimpleMapProperty(Object keyType, Object valueType) { >- this.keyType = keyType; >- this.valueType = valueType; >+ public IObservableMap observeDetailMap(IObservableValue master) { >+ final Realm realm = master.getRealm(); >+ IObservableFactory factory = new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return SimpleMapProperty.this.observeMap(realm, target); >+ } >+ }; >+ return MasterDetailObservables.detailMap(master, factory); > } > > /** >@@ -66,9 +66,7 @@ > * key set is untyped. > * @noreference This method is not intended to be referenced by clients. > */ >- protected final Object getKeyType() { >- return keyType; >- } >+ protected abstract Object getKeyType(); > > /** > * Returns the element type of the map's values collection or >@@ -78,9 +76,9 @@ > * <code>null</code> if the collection is untyped. > * @noreference This method is not intended to be referenced by clients. > */ >- protected final Object getValueType() { >- return valueType; >- } >+ protected abstract Object getValueType(); >+ >+ // Accessors > > /** > * Returns an unmodifiable Map with the current contents of the source's map >@@ -105,6 +103,25 @@ > */ > protected abstract Map doGetMap(Object source); > >+ // Mutators >+ >+ /** >+ * Updates the property on the source with the specified change. >+ * >+ * @param source >+ * the property source >+ * @param map >+ * the new map >+ * @param diff >+ * a diff describing the change >+ * @return true if the property was modified on the source object, false >+ * otherwise >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ protected abstract boolean setMap(Object source, Map map, MapDiff diff); >+ >+ // Listeners >+ > /** > * Returns a listener which implements the correct listener interface for > * the expected source object, and which parlays property change events from >@@ -155,229 +172,4 @@ > */ > protected abstract void removeListener(Object source, > INativePropertyListener listener); >- >- /** >- * Returns whether the specified key is contained in the key set of the >- * source's map property >- * >- * @param source >- * the property source >- * @param key >- * the key >- * @return whether the specified key is contained in the key set of the >- * source's map property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean containsKey(Object source, Object key) { >- return getMap(source).containsKey(key); >- } >- >- /** >- * Returns whether the specified value is contains in the values collection >- * of the source's map property >- * >- * @param source >- * the property source >- * @param value >- * the value >- * @return whether the specified value is contains in the values collection >- * of the source's map property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean containsValue(Object source, Object value) { >- return getMap(source).containsValue(value); >- } >- >- /** >- * Returns whether the source's map property is equal to the argument >- * >- * @param source >- * the property source >- * @param o >- * the object to test for equality >- * @return whether the source's map property is equal to the argument >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean equals(Object source, Object o) { >- return getMap(source).equals(o); >- } >- >- /** >- * Returns the value associated with the specified key in the source's map >- * property >- * >- * @param source >- * the property source >- * @param key >- * the key >- * @return the value associated with the specified key in the source's map >- * property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object get(Object source, Object key) { >- return getMap(source).get(key); >- } >- >- /** >- * Returns the hash code of the source's map property >- * >- * @param source >- * the property source >- * @return the hash code of the source's map property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int hashCode(Object source) { >- return getMap(source).hashCode(); >- } >- >- /** >- * Returns whether the source's map property is empty >- * >- * @param source >- * the property source >- * @return whether the source's map property is empty >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean isEmpty(Object source) { >- return getMap(source).isEmpty(); >- } >- >- /** >- * Returns the size of the source's map property >- * >- * @param source >- * the property source >- * @return the size of the source's map property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int size(Object source) { >- return getMap(source).size(); >- } >- >- /** >- * Updates the property on the source with the specified change. >- * >- * @param source >- * the property source >- * @param map >- * the new map >- * @param diff >- * a diff describing the change >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected abstract void setMap(Object source, Map map, MapDiff diff); >- >- /** >- * Removes all mapping from the source's map property >- * >- * @param source >- * the property source >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected void clear(Object source) { >- if (!isEmpty(source)) { >- setMap(source, new HashMap(), Diffs >- .createMapDiffRemoveAll(new HashMap(getMap(source)))); >- } >- } >- >- /** >- * Associates the specified value with the specified key in the source's map >- * property >- * >- * @param source >- * the property source >- * @param key >- * the key >- * @param value >- * the value >- * @return the value that was previously associated with the given key in >- * the source's map property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object put(Object source, Object key, Object value) { >- Map map = new HashMap(getMap(source)); >- boolean addition = !map.containsKey(key); >- Object result = map.put(key, value); >- MapDiff diff; >- if (addition) { >- diff = Diffs.createMapDiffSingleAdd(key, value); >- } else { >- diff = Diffs.createMapDiffSingleChange(key, result, value); >- } >- setMap(source, map, diff); >- return result; >- } >- >- /** >- * Adds all mappings in the specified map to the source's map property. >- * >- * @param source >- * the property source >- * @param t >- * the map >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected void putAll(Object source, Map t) { >- if (t.isEmpty()) >- return; >- >- Map map = new HashMap(getMap(source)); >- Set addedKeys = new HashSet(); >- Set changedKeys = new HashSet(); >- Map oldValues = new HashMap(); >- Map newValues = new HashMap(); >- for (Iterator it = t.entrySet().iterator(); it.hasNext();) { >- Map.Entry entry = (Map.Entry) it.next(); >- Object key = entry.getKey(); >- Object newValue = entry.getValue(); >- boolean addition = !map.containsKey(key); >- Object oldValue = map.put(key, newValue); >- if (addition) { >- addedKeys.add(key); >- } else if (!Util.equals(oldValue, newValue)) { >- changedKeys.add(key); >- oldValues.put(key, oldValue); >- } >- newValues.put(key, newValue); >- } >- setMap(source, map, Diffs.createMapDiff(addedKeys, >- Collections.EMPTY_SET, changedKeys, oldValues, newValues)); >- } >- >- /** >- * Removes the mapping for the specified key from the source's map property >- * >- * @param source >- * the property source >- * @param key >- * the key >- * @return the value that was previously associated with the specified key >- * in the source's map property, or null if no such mapping exists >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object remove(Object source, Object key) { >- Map map = getMap(source); >- if (map.containsKey(key)) { >- map = new HashMap(map); >- Object result = map.remove(key); >- setMap(source, map, Diffs.createMapDiffSingleRemove(key, result)); >- return result; >- } >- return null; >- } >- >- public IObservableMap observeMap(Realm realm, Object source) { >- return new SimpleMapPropertyObservableMap(realm, source, this); >- } >- >- public IObservableMap observeDetailMap(IObservableValue master) { >- final Realm realm = master.getRealm(); >- IObservableFactory factory = new IObservableFactory() { >- public IObservable createObservable(Object target) { >- return SimpleMapProperty.this.observeMap(realm, target); >- } >- }; >- return MasterDetailObservables.detailMap(master, factory); >- } > } >Index: src/org/eclipse/core/databinding/property/map/SimpleMapPropertyObservableMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/map/Attic/SimpleMapPropertyObservableMap.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 SimpleMapPropertyObservableMap.java >--- src/org/eclipse/core/databinding/property/map/SimpleMapPropertyObservableMap.java 17 Dec 2008 18:40:05 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/map/SimpleMapPropertyObservableMap.java 20 Dec 2008 06:51:32 -0000 >@@ -11,8 +11,11 @@ > > package org.eclipse.core.databinding.property.map; > >+import java.util.AbstractSet; > import java.util.Collection; > import java.util.Collections; >+import java.util.ConcurrentModificationException; >+import java.util.HashMap; > import java.util.HashSet; > import java.util.Iterator; > import java.util.Map; >@@ -23,8 +26,8 @@ > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.map.AbstractObservableMap; > import org.eclipse.core.databinding.observable.map.MapDiff; >-import org.eclipse.core.databinding.property.IProperty; > import org.eclipse.core.databinding.property.INativePropertyListener; >+import org.eclipse.core.databinding.property.IProperty; > import org.eclipse.core.databinding.property.IPropertyObservable; > > /** >@@ -55,6 +58,14 @@ > this.property = property; > } > >+ public Object getKeyType() { >+ return property.getKeyType(); >+ } >+ >+ public Object getValueType() { >+ return property.getValueType(); >+ } >+ > private void getterCalled() { > ObservableTracker.getterCalled(this); > } >@@ -99,141 +110,175 @@ > cachedMap = null; > } > >- public boolean containsKey(Object key) { >- getterCalled(); >- return property.containsKey(source, key); >- } >+ // Queries > >- public boolean containsValue(Object value) { >- getterCalled(); >- return property.containsValue(source, value); >+ private Map getMap() { >+ return property.getMap(source); > } > >+ // Single change operations >+ >+ private EntrySet es = new EntrySet(); >+ > public Set entrySet() { > getterCalled(); >- // unmodifiable for now >- return Collections.unmodifiableSet(property.getMap(source).entrySet()); >+ return es; > } > >- public Object get(Object key) { >- getterCalled(); >- return property.get(source, key); >+ private class EntrySet extends AbstractSet { >+ public Iterator iterator() { >+ return new EntrySetIterator(); >+ } >+ >+ public int size() { >+ return getMap().size(); >+ } > } > >- public boolean isEmpty() { >- getterCalled(); >- return property.isEmpty(source); >+ private class EntrySetIterator implements Iterator { >+ private volatile int expectedModCount = modCount; >+ Map map = new HashMap(getMap()); >+ Iterator iterator = map.entrySet().iterator(); >+ Map.Entry last = null; >+ >+ public boolean hasNext() { >+ getterCalled(); >+ checkForComodification(); >+ return iterator.hasNext(); >+ } >+ >+ public Object next() { >+ getterCalled(); >+ checkForComodification(); >+ last = (Map.Entry) iterator.next(); >+ return last; >+ } >+ >+ public void remove() { >+ getterCalled(); >+ checkForComodification(); >+ >+ iterator.remove(); // stay in sync >+ MapDiff diff = Diffs.createMapDiffSingleRemove(last.getKey(), last >+ .getValue()); >+ >+ boolean wasUpdating = updating; >+ boolean changed; >+ updating = true; >+ try { >+ changed = property.setMap(source, map, diff); >+ } finally { >+ updating = wasUpdating; >+ } >+ >+ if (changed) { >+ cachedMap = getMap(); >+ fireMapChange(diff); >+ >+ last = null; >+ expectedModCount = modCount; >+ } >+ } >+ >+ private void checkForComodification() { >+ if (expectedModCount != modCount) >+ throw new ConcurrentModificationException(); >+ } > } > > public Set keySet() { > getterCalled(); >- return Collections.unmodifiableSet(property.getMap(source).keySet()); >+ // AbstractMap depends on entrySet() to fulfil keySet() API, so all >+ // getterCalled() and comodification checks will still be handled >+ return super.keySet(); > } > > public Object put(Object key, Object value) { > checkRealm(); > >- boolean add; >- Object oldValue; >+ Map map = new HashMap(getMap()); >+ >+ boolean add = !map.containsKey(key); >+ >+ Object oldValue = map.put(key, value); >+ >+ MapDiff diff; >+ if (add) >+ diff = Diffs.createMapDiffSingleAdd(key, value); >+ else >+ diff = Diffs.createMapDiffSingleChange(key, oldValue, value); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- add = !property.containsKey(source, key); >- oldValue = property.put(source, key, value); >+ changed = property.setMap(source, map, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedMap = property.getMap(source); >- MapDiff diff; >- if (add) >- diff = Diffs.createMapDiffSingleAdd(key, value); >- else >- diff = Diffs.createMapDiffSingleChange(key, oldValue, value); >- fireMapChange(diff); >+ if (changed) { >+ cachedMap = property.getMap(source); >+ fireMapChange(diff); >+ } > >- return property.put(source, key, value); >+ return oldValue; > } > > public void putAll(Map m) { > checkRealm(); > >- Map oldValues = cachedMap; >+ Map map = new HashMap(getMap()); >+ >+ Map oldValues = new HashMap(); >+ Map newValues = new HashMap(); > Set changedKeys = new HashSet(); > Set addedKeys = new HashSet(); > for (Iterator it = m.entrySet().iterator(); it.hasNext();) { > Map.Entry entry = (Entry) it.next(); > Object key = entry.getKey(); >- if (property.containsKey(source, key)) { >+ Object newValue = entry.getValue(); >+ if (map.containsKey(key)) { > changedKeys.add(key); >+ oldValues.put(key, map.get(key)); > } else { > addedKeys.add(key); > } >- } >+ map.put(key, newValue); > >- boolean wasUpdating = updating; >- updating = true; >- try { >- property.putAll(source, m); >- modCount++; >- } finally { >- updating = wasUpdating; >+ newValues.put(key, newValue); > } > >- Map newValues = cachedMap = property.getMap(source); >- fireMapChange(Diffs.createMapDiff(addedKeys, Collections.EMPTY_SET, >- changedKeys, oldValues, newValues)); >- } >- >- public Object remove(Object key) { >- checkRealm(); >- >- if (!property.containsKey(source, key)) >- return null; >- >- Object oldValue; >+ MapDiff diff = Diffs.createMapDiff(addedKeys, Collections.EMPTY_SET, >+ changedKeys, oldValues, newValues); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- oldValue = property.remove(source, key); >+ changed = property.setMap(source, map, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedMap = property.getMap(source); >- fireMapChange(Diffs.createMapDiffSingleRemove(key, oldValue)); >- >- return oldValue; >+ if (changed) { >+ cachedMap = getMap(); >+ fireMapChange(diff); >+ } > } > >- public int size() { >- getterCalled(); >- return property.size(source); >+ public Object remove(Object key) { >+ checkRealm(); >+ return super.remove(key); > } > > public Collection values() { > getterCalled(); >- return Collections.unmodifiableCollection(property.getMap(source) >- .values()); >- } >- >- public void clear() { >- getterCalled(); >- property.clear(source); >- } >- >- public boolean equals(Object o) { >- getterCalled(); >- return property.equals(source, o); >- } >- >- public int hashCode() { >- getterCalled(); >- return property.hashCode(source); >+ // AbstractMap depends on entrySet() to fulfil keySet() API, so all >+ // getterCalled() and comodification checks will still be handled >+ return super.values(); > } > > public Object getObserved() { >Index: src/org/eclipse/core/databinding/property/value/ObservableListSimpleValuePropertyObservableList.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/value/Attic/ObservableListSimpleValuePropertyObservableList.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ObservableListSimpleValuePropertyObservableList.java >--- src/org/eclipse/core/databinding/property/value/ObservableListSimpleValuePropertyObservableList.java 17 Dec 2008 18:40:04 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/value/ObservableListSimpleValuePropertyObservableList.java 20 Dec 2008 06:51:32 -0000 >@@ -374,18 +374,30 @@ > if (!haveIterated) > throw new IllegalStateException(); > >+ Object oldValue = cachedValues.get(new IdentityWrapper( >+ lastMasterElement)); >+ > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- detailProperty.setValue(lastElement, o); >+ changed = detailProperty.setValue(lastElement, o); > } finally { > updating = wasUpdating; > } > >- cachedValues.put(new IdentityWrapper(lastMasterElement), o); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry( >- lastIndex, false, lastElement), Diffs >- .createListDiffEntry(lastIndex, true, o))); >+ if (changed) { >+ Object newValue = detailProperty.getValue(lastElement); >+ >+ if (!Util.equals(oldValue, newValue)) { >+ cachedValues.put( >+ new IdentityWrapper(lastMasterElement), o); >+ fireListChange(Diffs.createListDiff(Diffs >+ .createListDiffEntry(lastIndex, false, >+ lastElement), Diffs >+ .createListDiffEntry(lastIndex, true, o))); >+ } >+ } > > lastElement = o; > } >@@ -402,16 +414,24 @@ > Object oldValue = detailProperty.getValue(masterElement); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- detailProperty.setValue(masterElement, o); >+ changed = detailProperty.setValue(masterElement, o); > } finally { > updating = wasUpdating; > } > >- cachedValues.put(new IdentityWrapper(masterElement), o); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, >- false, oldValue), Diffs.createListDiffEntry(index, true, o))); >+ if (changed) { >+ Object newValue = detailProperty.getValue(masterElement); >+ >+ if (!Util.equals(oldValue, newValue)) { >+ cachedValues.put(new IdentityWrapper(masterElement), o); >+ fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry( >+ index, false, oldValue), Diffs.createListDiffEntry( >+ index, true, o))); >+ } >+ } > > return oldValue; > } >Index: src/org/eclipse/core/databinding/property/value/ObservableSetSimpleValuePropertyObservableMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/value/Attic/ObservableSetSimpleValuePropertyObservableMap.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ObservableSetSimpleValuePropertyObservableMap.java >--- src/org/eclipse/core/databinding/property/value/ObservableSetSimpleValuePropertyObservableMap.java 17 Dec 2008 18:40:04 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/value/ObservableSetSimpleValuePropertyObservableMap.java 20 Dec 2008 06:51:32 -0000 >@@ -106,19 +106,24 @@ > protected Object doPut(Object key, Object value) { > Object oldValue = detailProperty.getValue(key); > >+ boolean changed; > updating = true; > try { >- detailProperty.setValue(key, value); >+ changed = detailProperty.setValue(key, value); > } finally { > updating = false; > } >- Object newValue = detailProperty.getValue(key); >- cachedValues.put(key, newValue); >- >- if (oldValue != newValue) { >- fireMapChange(Diffs.createMapDiffSingleChange(key, oldValue, >- newValue)); >+ >+ if (changed) { >+ Object newValue = detailProperty.getValue(key); >+ cachedValues.put(key, newValue); >+ >+ if (oldValue != newValue) { >+ fireMapChange(Diffs.createMapDiffSingleChange(key, oldValue, >+ newValue)); >+ } > } >+ > return oldValue; > } > >Index: src/org/eclipse/core/databinding/property/value/ObservableMapSimpleValuePropertyObservableMap.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/value/Attic/ObservableMapSimpleValuePropertyObservableMap.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 ObservableMapSimpleValuePropertyObservableMap.java >--- src/org/eclipse/core/databinding/property/value/ObservableMapSimpleValuePropertyObservableMap.java 17 Dec 2008 18:40:04 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/value/ObservableMapSimpleValuePropertyObservableMap.java 20 Dec 2008 06:51:32 -0000 >@@ -283,18 +283,21 @@ > > Object oldValue = detailProperty.getValue(source); > >+ boolean changed; > updating = true; > try { >- detailProperty.setValue(source, value); >+ changed = detailProperty.setValue(source, value); > } finally { > updating = false; > } > >- Object newValue = detailProperty.getValue(source); >- >- if (!Util.equals(oldValue, newValue)) { >- fireMapChange(Diffs.createMapDiffSingleChange(key, oldValue, >- newValue)); >+ if (changed) { >+ Object newValue = detailProperty.getValue(source); >+ >+ if (!Util.equals(oldValue, newValue)) { >+ fireMapChange(Diffs.createMapDiffSingleChange(key, oldValue, >+ newValue)); >+ } > } > > return oldValue; >Index: src/org/eclipse/core/databinding/property/value/SimpleValueProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/value/Attic/SimpleValueProperty.java,v >retrieving revision 1.1.2.3 >diff -u -r1.1.2.3 SimpleValueProperty.java >--- src/org/eclipse/core/databinding/property/value/SimpleValueProperty.java 19 Dec 2008 01:46:56 -0000 1.1.2.3 >+++ src/org/eclipse/core/databinding/property/value/SimpleValueProperty.java 20 Dec 2008 06:51:32 -0000 >@@ -41,21 +41,13 @@ > * @since 1.2 > */ > public abstract class SimpleValueProperty extends ValueProperty { >- private final Object valueType; >- >- protected SimpleValueProperty(Object valueType) { >- this.valueType = valueType; >- } >- > /** > * Returns the value type of the property, or <code>null</code> if untyped. > * > * @return the value type of the property, or <code>null</code> if untyped. > * @noreference This method is not intended to be referenced by clients. > */ >- protected final Object getValueType() { >- return valueType; >- } >+ protected abstract Object getValueType(); > > /** > * Returns the source's value property >@@ -74,9 +66,11 @@ > * the property source > * @param value > * the new value >+ * @return true if the property was modified on the source object, false >+ * otherwise > * @noreference This method is not intended to be referenced by clients. > */ >- protected abstract void setValue(Object source, Object value); >+ protected abstract boolean setValue(Object source, Object value); > > /** > * Returns a listener which implements the correct listener interface for >@@ -140,7 +134,8 @@ > return SimpleValueProperty.this.observeValue(realm, target); > } > }; >- return MasterDetailObservables.detailValue(master, factory, valueType); >+ return MasterDetailObservables.detailValue(master, factory, >+ getValueType()); > } > > public IObservableList observeDetailValues(IObservableList master) { >Index: src/org/eclipse/core/databinding/property/value/SimpleValuePropertyObservableValue.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/value/Attic/SimpleValuePropertyObservableValue.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 SimpleValuePropertyObservableValue.java >--- src/org/eclipse/core/databinding/property/value/SimpleValuePropertyObservableValue.java 17 Dec 2008 18:40:04 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/value/SimpleValuePropertyObservableValue.java 20 Dec 2008 06:51:32 -0000 >@@ -105,16 +105,19 @@ > if (hasListeners()) { > Object oldValue = cachedValue; > >+ boolean changed; > updating = true; > try { >- property.setValue(source, value); >+ changed = property.setValue(source, value); > } finally { > updating = false; > } > >- Object newValue = cachedValue = property.getValue(source); >- if (hasListeners() && !Util.equals(oldValue, newValue)) { >- fireValueChange(Diffs.createValueDiff(oldValue, newValue)); >+ if (changed) { >+ Object newValue = cachedValue = property.getValue(source); >+ if (hasListeners() && !Util.equals(oldValue, newValue)) { >+ fireValueChange(Diffs.createValueDiff(oldValue, newValue)); >+ } > } > } else { > property.setValue(source, value); >Index: src/org/eclipse/core/databinding/property/list/SimpleListProperty.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/list/Attic/SimpleListProperty.java,v >retrieving revision 1.1.2.3 >diff -u -r1.1.2.3 SimpleListProperty.java >--- src/org/eclipse/core/databinding/property/list/SimpleListProperty.java 19 Dec 2008 01:46:56 -0000 1.1.2.3 >+++ src/org/eclipse/core/databinding/property/list/SimpleListProperty.java 20 Dec 2008 06:51:32 -0000 >@@ -11,19 +11,13 @@ > > package org.eclipse.core.databinding.property.list; > >-import java.util.ArrayList; >-import java.util.Collection; > import java.util.Collections; >-import java.util.Iterator; > import java.util.List; >-import java.util.ListIterator; > >-import org.eclipse.core.databinding.observable.Diffs; > import org.eclipse.core.databinding.observable.IObservable; > import org.eclipse.core.databinding.observable.Realm; > import org.eclipse.core.databinding.observable.list.IObservableList; > import org.eclipse.core.databinding.observable.list.ListDiff; >-import org.eclipse.core.databinding.observable.list.ListDiffEntry; > import org.eclipse.core.databinding.observable.masterdetail.IObservableFactory; > import org.eclipse.core.databinding.observable.masterdetail.MasterDetailObservables; > import org.eclipse.core.databinding.observable.value.IObservableValue; >@@ -49,10 +43,19 @@ > * @since 1.2 > */ > public abstract class SimpleListProperty extends ListProperty { >- private final Object elementType; >+ public IObservableList observeList(Realm realm, Object source) { >+ return new SimpleListPropertyObservableList(realm, source, this); >+ } > >- protected SimpleListProperty(Object elementType) { >- this.elementType = elementType; >+ public IObservableList observeDetailList(IObservableValue master) { >+ final Realm realm = master.getRealm(); >+ IObservableFactory factory = new IObservableFactory() { >+ public IObservable createObservable(Object target) { >+ return SimpleListProperty.this.observeList(realm, target); >+ } >+ }; >+ return MasterDetailObservables.detailList(master, factory, >+ getElementType()); > } > > /** >@@ -63,121 +66,52 @@ > * if untyped > * @noreference This method is not intended to be referenced by clients. > */ >- protected final Object getElementType() { >- return elementType; >- } >- >- /** >- * Returns whether the source's collection property contains all elements in >- * the given collection >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to test for >- * @return whether the source's collection property contains all elements in >- * the given collection >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean containsAll(Object source, Collection c) { >- return getList(source).containsAll(c); >- } >- >- /** >- * Returns whether the source's collection property contains the given >- * element. >- * >- * @param source >- * the property source >- * @param o >- * the element >- * @return whether the source's collection property contains the given >- * element. >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean contains(Object source, Object o) { >- return getList(source).contains(o); >- } >+ protected abstract Object getElementType(); > >- /** >- * Returns whether the source's collection property is equal to the >- * argument. >- * >- * @param source >- * the property source >- * @param o >- * the object to test for equality to the source's collection >- * property >- * @return whether the source's collection property is equal to the argument >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean equals(Object source, Object o) { >- return getList(source).equals(o); >- } >+ // Accessors > > /** >- * Returns the hash code of the source's collection property. >+ * Returns an unmodifiable List with the current contents of the source's >+ * list property > * > * @param source > * the property source >- * @return the hash code of the source's collection property >+ * @return an unmodifiable List with the current contents of the source's >+ * list property > * @noreference This method is not intended to be referenced by clients. > */ >- protected int hashCode(Object source) { >- return getList(source).hashCode(); >+ protected final List getList(Object source) { >+ return Collections.unmodifiableList(doGetList(source)); > } > > /** >- * Returns whether the source's collection property is empty >+ * Returns a List with the current contents of the source's list property > * > * @param source > * the property source >- * @return whether the source's collection property is empty >+ * @return a List with the current contents of the source's list property > * @noreference This method is not intended to be referenced by clients. > */ >- protected boolean isEmpty(Object source) { >- return getList(source).isEmpty(); >- } >+ protected abstract List doGetList(Object source); > >- /** >- * Returns the size of the source's collection property >- * >- * @param source >- * the property source >- * @return the size of the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int size(Object source) { >- return getList(source).size(); >- } >+ // Mutators > > /** >- * Returns an array of all elements in the source's collection property >+ * Updates the property on the source with the specified change. > * > * @param source > * the property source >- * @param array >- * the array into which the elements will be copied. If the array >- * is not large enough to hold all elements, the elements will be >- * returned in a new array of the same runtime type. >- * @return an array of all elements in the source's collection property >+ * @param list >+ * the new list >+ * @param diff >+ * a diff describing the change >+ * @return true if the property was modified on the source object, false >+ * otherwise > * @noreference This method is not intended to be referenced by clients. > */ >- protected Object[] toArray(Object source, Object[] array) { >- return getList(source).toArray(array); >- } >+ protected abstract boolean setList(Object source, List list, ListDiff diff); > >- /** >- * Returns an array of all elements in the source's collection property >- * >- * @param source >- * the property source >- * @return an array of all elements in the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object[] toArray(Object source) { >- return getList(source).toArray(); >- } >+ // Listeners > > /** > * Returns a listener which implements the correct listener interface for >@@ -200,93 +134,6 @@ > IListPropertyChangeListener listener); > > /** >- * Inserts the element into the source's list property at the specified >- * position >- * >- * @param source >- * the property source >- * @param index >- * the insertion index >- * @param element >- * the element to insert >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected void add(Object source, int index, Object element) { >- List list = new ArrayList(getList(source)); >- list.add(index, element); >- setList(source, list, Diffs.createListDiff(Diffs.createListDiffEntry( >- index, true, element))); >- } >- >- /** >- * Adds the element to the source's collection property >- * >- * @param source >- * the property source >- * @param o >- * the element to add >- * @return whether the element was added to the source's collection property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean add(Object source, Object o) { >- add(source, size(source), o); >- return true; >- } >- >- /** >- * Adds all elements in the specified collection to the source's collection >- * property. >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to add. >- * @return whether the source's collection property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean addAll(Object source, Collection c) { >- if (c.isEmpty()) >- return false; >- addAll(source, size(source), c); >- return true; >- } >- >- /** >- * Inserts all elements in the specified collection into the source's list >- * property at the specified index. >- * >- * @param source >- * the property source >- * @param index >- * the insertion index >- * @param c >- * the collection of elements to add >- * @return whether the source's list property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean addAll(Object source, int index, Collection c) { >- if (c.isEmpty()) { >- return false; >- } >- >- List list = new ArrayList(getList(source)); >- List entries = new ArrayList(); >- int i = index; >- for (Iterator it = c.iterator(); it.hasNext(); i++) { >- Object o = it.next(); >- list.add(i, o); >- entries.add(Diffs.createListDiffEntry(i, true, o)); >- } >- boolean changed = !entries.isEmpty(); >- if (changed) { >- ListDiffEntry[] ea = (ListDiffEntry[]) entries >- .toArray(new ListDiffEntry[entries.size()]); >- setList(source, list, Diffs.createListDiff(ea)); >- } >- return changed; >- } >- >- /** > * Adds the specified listener as a listener for this property on the > * specified property source. If the source object has no listener API for > * this property (i.e. {@link #adaptListener(IListPropertyChangeListener)} >@@ -303,212 +150,6 @@ > INativePropertyListener listener); > > /** >- * Removes all elements from the source's collection property. >- * >- * @param source >- * the property source >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected void clear(Object source) { >- if (!isEmpty(source)) { >- List list = getList(source); >- ListDiffEntry[] entries = new ListDiffEntry[list.size()]; >- int i = 0; >- for (Iterator it = getList(source).iterator(); it.hasNext(); i++) { >- entries[i] = Diffs.createListDiffEntry(0, false, it.next()); >- } >- setList(source, new ArrayList(), Diffs.createListDiff(entries)); >- } >- } >- >- /** >- * Returns the element at the specified position in the source's list >- * property >- * >- * @param source >- * the property source >- * @param index >- * the element position >- * @return the element at the given position in the source's list property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object get(Object source, int index) { >- return getList(source).get(index); >- } >- >- /** >- * Returns an unmodifiable List with the current contents of the source's >- * list property >- * >- * @param source >- * the property source >- * @return an unmodifiable List with the current contents of the source's >- * list property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected final List getList(Object source) { >- return Collections.unmodifiableList(doGetList(source)); >- } >- >- /** >- * Returns a List with the current contents of the source's list property >- * >- * @param source >- * the property source >- * @return a List with the current contents of the source's list property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected abstract List doGetList(Object source); >- >- /** >- * Returns the index of the first location of the given element in the >- * source's list property, or -1 if the list does not contain the element. >- * >- * @param source >- * the property source >- * @param o >- * the element >- * @return the index of the first location of the given element in the >- * source's list property, or -1 if the list does not contain the >- * element >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int indexOf(Object source, Object o) { >- return getList(source).indexOf(o); >- } >- >- /** >- * Returns the index of the last location of the given element in the >- * source's list property, or -1 if the list does not contain the given >- * element. >- * >- * @param source >- * @param o >- * @return the index of the last location of the given element in the >- * source's list property, or -1 if the list does not contain the >- * element >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected int lastIndexOf(Object source, Object o) { >- return getList(source).lastIndexOf(o); >- } >- >- /** >- * Moves the element at the specified old position in the source's list >- * property to the specified new position >- * >- * @param source >- * the property source >- * @param oldIndex >- * the old element position >- * @param newIndex >- * the new element position >- * @return the element that was moved >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object move(Object source, int oldIndex, int newIndex) { >- if (oldIndex == newIndex) >- return get(source, oldIndex); >- List list = new ArrayList(getList(source)); >- Object result = list.remove(oldIndex); >- list.add(newIndex, result); >- setList(source, list, Diffs.createListDiff(Diffs.createListDiffEntry( >- oldIndex, false, result), Diffs.createListDiffEntry(newIndex, >- true, result))); >- return result; >- } >- >- public IObservableList observeList(Realm realm, Object source) { >- return new SimpleListPropertyObservableList(realm, source, this); >- } >- >- public IObservableList observeDetailList(IObservableValue master) { >- final Realm realm = master.getRealm(); >- IObservableFactory factory = new IObservableFactory() { >- public IObservable createObservable(Object target) { >- return SimpleListProperty.this.observeList(realm, target); >- } >- }; >- return MasterDetailObservables.detailList(master, factory, >- getElementType()); >- } >- >- /** >- * Removes the element from the source's list property which is located at >- * the specified position >- * >- * @param source >- * the property source >- * @param index >- * the index of the element to remove >- * @return the element that was removed from the source's list property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object remove(Object source, int index) { >- List list = new ArrayList(getList(source)); >- Object result = list.remove(index); >- setList(source, list, Diffs.createListDiff(Diffs.createListDiffEntry( >- index, false, result))); >- return result; >- } >- >- /** >- * Removes the element from the source's collection property >- * >- * @param source >- * the property source >- * @param o >- * the element to remove >- * @return whether the element was removed from the source's collection >- * property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean remove(Object source, Object o) { >- int i = indexOf(source, o); >- if (i == -1) >- return false; >- remove(source, i); >- return true; >- } >- >- /** >- * Removes all elements from the source's collection property which are >- * contained in the specified collection. >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to be removed >- * @return whether the source's collection property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean removeAll(Object source, Collection c) { >- if (isEmpty(source)) { >- return false; >- } >- if (c.isEmpty()) { >- return false; >- } >- List list = new ArrayList(getList(source)); >- List entries = new ArrayList(); >- for (ListIterator it = list.listIterator(); it.hasNext();) { >- Object o = it.next(); >- if (c.contains(o)) { >- entries.add(Diffs.createListDiffEntry(it.previousIndex(), >- false, o)); >- it.remove(); >- } >- } >- boolean changed = !entries.isEmpty(); >- if (changed) { >- ListDiffEntry[] ea = (ListDiffEntry[]) entries >- .toArray(new ListDiffEntry[entries.size()]); >- setList(source, list, Diffs.createListDiff(ea)); >- } >- return changed; >- } >- >- /** > * Removes the specified listener as a listener for this property on the > * specified property source. If the source object has no listener API for > * this property (i.e. {@link #adaptListener(IListPropertyChangeListener)} >@@ -524,77 +165,4 @@ > protected abstract void removeListener(Object source, > INativePropertyListener listener); > >- /** >- * Removes all elements from the source's collection property which are not >- * contained in the specified collection. >- * >- * @param source >- * the property source >- * @param c >- * the collection of elements to retain >- * @return whether the source's collection property was changed >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected boolean retainAll(Object source, Collection c) { >- if (isEmpty(source)) { >- return false; >- } >- if (c.isEmpty()) { >- clear(source); >- return true; >- } >- List list = new ArrayList(getList(source)); >- List entries = new ArrayList(); >- for (ListIterator it = list.listIterator(); it.hasNext();) { >- Object o = it.next(); >- if (!c.contains(o)) { >- entries.add(Diffs.createListDiffEntry(it.previousIndex(), >- false, o)); >- it.remove(); >- } >- } >- boolean changed = !entries.isEmpty(); >- if (changed) { >- ListDiffEntry[] ea = (ListDiffEntry[]) entries >- .toArray(new ListDiffEntry[entries.size()]); >- setList(source, list, Diffs.createListDiff(ea)); >- } >- return changed; >- } >- >- /** >- * Replaces the element at the specified position in the source's list >- * property with the given element. >- * >- * @param source >- * the property source >- * @param index >- * the element position >- * @param element >- * the replacement element >- * @return the element previously at the specified position in the source's >- * list property >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected Object set(Object source, int index, Object element) { >- List list = new ArrayList(getList(source)); >- Object result = list.set(index, element); >- setList(source, list, Diffs.createListDiff(Diffs.createListDiffEntry( >- index, false, result), Diffs.createListDiffEntry(index, true, >- element))); >- return result; >- } >- >- /** >- * Updates the property on the source with the specified change. >- * >- * @param source >- * the property source >- * @param list >- * the new list >- * @param diff >- * a diff describing the change >- * @noreference This method is not intended to be referenced by clients. >- */ >- protected abstract void setList(Object source, List list, ListDiff diff); > } >Index: src/org/eclipse/core/databinding/property/list/SimpleListPropertyObservableList.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.core.databinding/src/org/eclipse/core/databinding/property/list/Attic/SimpleListPropertyObservableList.java,v >retrieving revision 1.1.2.1 >diff -u -r1.1.2.1 SimpleListPropertyObservableList.java >--- src/org/eclipse/core/databinding/property/list/SimpleListPropertyObservableList.java 17 Dec 2008 18:40:04 -0000 1.1.2.1 >+++ src/org/eclipse/core/databinding/property/list/SimpleListPropertyObservableList.java 20 Dec 2008 06:51:32 -0000 >@@ -60,7 +60,7 @@ > > protected void firstListenerAdded() { > if (!isDisposed()) { >- cachedList = property.getList(source); >+ cachedList = getList(); > > if (listener == null) { > listener = property >@@ -72,8 +72,7 @@ > getRealm().exec(new Runnable() { > public void run() { > List oldList = cachedList; >- List newList = cachedList = property >- .getList(source); >+ List newList = cachedList = getList(); > ListDiff diff = event.diff; > if (diff == null) { > diff = Diffs.computeListDiff( >@@ -108,80 +107,90 @@ > > // Queries > >+ private List getList() { >+ return property.getList(source); >+ } >+ > protected int doGetSize() { >- return property.size(source); >+ return getList().size(); > } > > public boolean contains(Object o) { > getterCalled(); >- return property.contains(source, o); >+ return getList().contains(o); > } > > public boolean containsAll(Collection c) { > getterCalled(); >- return property.containsAll(source, c); >+ return getList().containsAll(c); > } > > public Object get(int index) { > getterCalled(); >- return property.get(source, index); >+ return getList().get(index); > } > > public int indexOf(Object o) { > getterCalled(); >- return property.indexOf(source, o); >+ return getList().indexOf(o); > } > > public boolean isEmpty() { > getterCalled(); >- return property.isEmpty(source); >+ return getList().isEmpty(); > } > > public int lastIndexOf(Object o) { > getterCalled(); >- return property.lastIndexOf(source, o); >+ return getList().lastIndexOf(o); > } > > public Object[] toArray() { > getterCalled(); >- return property.toArray(source); >+ return getList().toArray(); > } > > public Object[] toArray(Object[] a) { > getterCalled(); >- return property.toArray(source, a); >+ return getList().toArray(a); > } > > // Single change operations > > public boolean add(Object o) { > checkRealm(); >- add(property.size(source), o); >+ add(getList().size(), o); > return true; > } > > public void add(int index, Object o) { > checkRealm(); > boolean wasUpdating = updating; >+ boolean changed; > updating = true; >+ List list = new ArrayList(getList()); >+ list.add(index, o); >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry(index, >+ true, o)); > try { >- property.add(source, index, o); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, >- true, o))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > } > > public Iterator iterator() { > getterCalled(); > return new Iterator() { > int expectedModCount = modCount; >- ListIterator delegate = new ArrayList(property.getList(source)) >- .listIterator(); >+ List list = new ArrayList(getList()); >+ ListIterator iterator = list.listIterator(); > > Object lastElement = null; > int lastIndex = -1; >@@ -189,14 +198,14 @@ > public boolean hasNext() { > getterCalled(); > checkForComodification(); >- return delegate.hasNext(); >+ return iterator.hasNext(); > } > > public Object next() { > getterCalled(); > checkForComodification(); >- Object next = lastElement = delegate.next(); >- lastIndex = delegate.previousIndex(); >+ Object next = lastElement = iterator.next(); >+ lastIndex = iterator.previousIndex(); > return next; > } > >@@ -206,25 +215,29 @@ > if (lastIndex == -1) > throw new IllegalStateException(); > >- delegate.remove(); // stay in sync >+ iterator.remove(); // stay in sync >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry( >+ lastIndex, false, lastElement)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.remove(source, lastIndex); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry( >- lastIndex, false, lastElement))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); > >- lastElement = null; >- lastIndex = -1; >+ lastElement = null; >+ lastIndex = -1; > >- expectedModCount = modCount; >+ expectedModCount = modCount; >+ } > } > > private void checkForComodification() { >@@ -237,28 +250,37 @@ > public Object move(int oldIndex, int newIndex) { > checkRealm(); > >- int size = property.size(source); >+ List list = getList(); >+ int size = list.size(); > if (oldIndex < 0 || oldIndex >= size || newIndex < 0 > || newIndex >= size) > throw new IndexOutOfBoundsException(); >+ > if (oldIndex == newIndex) >- return property.get(source, oldIndex); >+ return list.get(oldIndex); > >- Object element; >+ list = new ArrayList(list); >+ Object element = list.remove(oldIndex); >+ list.add(newIndex, element); >+ >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry( >+ oldIndex, false, element), Diffs.createListDiffEntry(newIndex, >+ true, element)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- element = property.move(source, oldIndex, newIndex); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(oldIndex, >- false, element), Diffs.createListDiffEntry(newIndex, true, >- element))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > > return element; > } >@@ -266,7 +288,7 @@ > public boolean remove(Object o) { > checkRealm(); > >- int index = property.indexOf(source, o); >+ int index = getList().indexOf(o); > if (index == -1) > return false; > >@@ -283,8 +305,8 @@ > getterCalled(); > return new ListIterator() { > int expectedModCount = modCount; >- ListIterator delegate = new ArrayList(property.getList(source)) >- .listIterator(index); >+ List list = new ArrayList(getList()); >+ ListIterator iterator = list.listIterator(index); > > Object lastElement = null; > int lastIndex = -1; >@@ -292,91 +314,101 @@ > public boolean hasNext() { > getterCalled(); > checkForComodification(); >- return delegate.hasNext(); >+ return iterator.hasNext(); > } > > public int nextIndex() { > getterCalled(); > checkForComodification(); >- return delegate.nextIndex(); >+ return iterator.nextIndex(); > } > > public Object next() { > getterCalled(); > checkForComodification(); >- lastElement = delegate.next(); >- lastIndex = delegate.previousIndex(); >+ lastElement = iterator.next(); >+ lastIndex = iterator.previousIndex(); > return lastElement; > } > > public boolean hasPrevious() { > getterCalled(); > checkForComodification(); >- return delegate.hasPrevious(); >+ return iterator.hasPrevious(); > } > > public int previousIndex() { > getterCalled(); > checkForComodification(); >- return delegate.previousIndex(); >+ return iterator.previousIndex(); > } > > public Object previous() { > getterCalled(); > checkForComodification(); >- lastElement = delegate.previous(); >- lastIndex = delegate.nextIndex(); >+ lastElement = iterator.previous(); >+ lastIndex = iterator.nextIndex(); > return lastElement; > } > > public void add(Object o) { > checkRealm(); > checkForComodification(); >- int index = delegate.nextIndex(); >+ int index = iterator.nextIndex(); > >- delegate.add(o); // keep in sync >+ iterator.add(o); // keep in sync > >+ List list = getList(); >+ list.add(index, o); >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry( >+ index, true, o)); > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.add(source, index, o); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry( >- index, true, o))); >- >- lastElement = null; >- lastIndex = -1; >- expectedModCount = modCount; >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ >+ lastElement = null; >+ lastIndex = -1; >+ expectedModCount = modCount; >+ } > } > > public void set(Object o) { > checkRealm(); > checkForComodification(); > >- delegate.set(o); >+ iterator.set(o); >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry( >+ lastIndex, false, lastElement), Diffs >+ .createListDiffEntry(lastIndex, true, o)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.set(source, lastIndex, o); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry( >- lastIndex, false, lastElement), Diffs >- .createListDiffEntry(lastIndex, true, o))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); > >- lastElement = o; >+ lastElement = o; > >- expectedModCount = modCount; >+ expectedModCount = modCount; >+ } > } > > public void remove() { >@@ -385,24 +417,28 @@ > if (lastIndex == -1) > throw new IllegalStateException(); > >- delegate.remove(); // keep in sync >+ iterator.remove(); // keep in sync >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry( >+ lastIndex, false, lastElement)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.remove(source, lastIndex); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry( >- lastIndex, false, lastElement))); >- >- lastElement = null; >- lastIndex = -1; >- expectedModCount = modCount; >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ >+ lastElement = null; >+ lastIndex = -1; >+ expectedModCount = modCount; >+ } > } > > private void checkForComodification() { >@@ -415,20 +451,25 @@ > public Object remove(int index) { > checkRealm(); > >- Object element; >+ List list = new ArrayList(getList()); >+ Object element = list.remove(index); >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry(index, >+ false, element)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- element = property.remove(source, index); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, >- false, element))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > > return element; > } >@@ -436,28 +477,34 @@ > public Object set(int index, Object o) { > checkRealm(); > >- Object oldElement; >+ List list = new ArrayList(getList()); >+ Object oldElement = list.set(index, o); >+ >+ ListDiff diff = Diffs.createListDiff(Diffs.createListDiffEntry(index, >+ false, oldElement), Diffs.createListDiffEntry(index, true, o)); > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- oldElement = property.set(source, index, o); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff(Diffs.createListDiffEntry(index, >- false, oldElement), Diffs.createListDiffEntry(index, true, o))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > > return oldElement; > } > > public List subList(int fromIndex, int toIndex) { > getterCalled(); >- return Collections.unmodifiableList(property.getList(source).subList( >- fromIndex, toIndex)); >+ return Collections.unmodifiableList(getList().subList(fromIndex, >+ toIndex)); > } > > // Bulk change operations >@@ -465,7 +512,7 @@ > public boolean addAll(Collection c) { > checkRealm(); > >- return addAll(property.size(source), c); >+ return addAll(getList().size(), c); > } > > public boolean addAll(int index, Collection c) { >@@ -474,6 +521,9 @@ > if (c.isEmpty()) > return false; > >+ List list = new ArrayList(getList()); >+ list.addAll(index, c); >+ > ListDiffEntry[] entries = new ListDiffEntry[c.size()]; > int offsetIndex = 0; > for (Iterator it = c.iterator(); it.hasNext();) { >@@ -482,21 +532,23 @@ > + offsetIndex, true, element); > offsetIndex++; > } >+ ListDiff diff = Diffs.createListDiff(entries); > > boolean changed; > > boolean wasUpdating = updating; > updating = true; > try { >- changed = property.addAll(source, index, c); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- if (changed) >- fireListChange(Diffs.createListDiff(entries)); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > > return changed; > } >@@ -504,17 +556,21 @@ > public boolean removeAll(Collection c) { > checkRealm(); > >- if (property.isEmpty(source) || c.isEmpty()) >+ if (c.isEmpty()) > return false; > >- boolean changed; >+ List list = getList(); >+ if (list.isEmpty()) >+ return false; > >+ list = new ArrayList(list); > List entries = new ArrayList(); >+ ListDiff diff; > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- List list = new ArrayList(property.getList(source)); > for (ListIterator it = list.listIterator(); it.hasNext();) { > Object element = it.next(); > int index = it.previousIndex(); >@@ -524,17 +580,21 @@ > .createListDiffEntry(index, false, element)); > } > } >- changed = property.removeAll(source, c); >+ if (entries.isEmpty()) >+ return false; >+ >+ diff = Diffs.createListDiff((ListDiffEntry[]) entries >+ .toArray(new ListDiffEntry[entries.size()])); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- >- if (changed) >- fireListChange(Diffs.createListDiff((ListDiffEntry[]) entries >- .toArray(new ListDiffEntry[entries.size()]))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > > return changed; > } >@@ -542,7 +602,8 @@ > public boolean retainAll(Collection c) { > checkRealm(); > >- if (property.isEmpty(source)) >+ List list = getList(); >+ if (list.isEmpty()) > return false; > > if (c.isEmpty()) { >@@ -550,14 +611,14 @@ > return true; > } > >- boolean changed; >- >+ list = new ArrayList(list); > List entries = new ArrayList(); >+ ListDiff diff; > > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- List list = new ArrayList(property.getList(source)); > for (ListIterator it = list.listIterator(); it.hasNext();) { > Object element = it.next(); > int index = it.previousIndex(); >@@ -567,17 +628,21 @@ > .createListDiffEntry(index, false, element)); > } > } >- changed = property.retainAll(source, c); >+ if (entries.isEmpty()) >+ return false; >+ >+ diff = Diffs.createListDiff((ListDiffEntry[]) entries >+ .toArray(new ListDiffEntry[entries.size()])); >+ changed = property.setList(source, list, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- >- if (changed) >- fireListChange(Diffs.createListDiff((ListDiffEntry[]) entries >- .toArray(new ListDiffEntry[entries.size()]))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > > return changed; > } >@@ -585,37 +650,42 @@ > public void clear() { > checkRealm(); > >- if (property.isEmpty(source)) >+ List list = getList(); >+ if (list.isEmpty()) > return; > > List entries = new ArrayList(); >- for (Iterator it = property.getList(source).iterator(); it.hasNext();) { >+ for (Iterator it = list.iterator(); it.hasNext();) { > // always report 0 as the remove index > entries.add(Diffs.createListDiffEntry(0, false, it.next())); > } > >+ ListDiff diff = Diffs.createListDiff((ListDiffEntry[]) entries >+ .toArray(new ListDiffEntry[entries.size()])); > boolean wasUpdating = updating; >+ boolean changed; > updating = true; > try { >- property.clear(source); >+ changed = property.setList(source, Collections.EMPTY_LIST, diff); > modCount++; > } finally { > updating = wasUpdating; > } > >- cachedList = property.getList(source); >- fireListChange(Diffs.createListDiff((ListDiffEntry[]) entries >- .toArray(new ListDiffEntry[entries.size()]))); >+ if (changed) { >+ cachedList = getList(); >+ fireListChange(diff); >+ } > } > > public boolean equals(Object o) { > getterCalled(); >- return property.equals(source, o); >+ return getList().equals(o); > } > > public int hashCode() { > getterCalled(); >- return property.hashCode(source); >+ return getList().hashCode(); > } > > public Object getObserved() {
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 194734
:
106529
|
107000
|
107001
|
107041
|
107042
|
111164
|
111165
|
111335
|
111336
|
111448
|
111449
|
111640
|
111641
|
111717
|
111719
|
111845
|
111846
|
111897
|
111898
|
111993
|
111994
|
112161
|
112162
|
112268
|
112269
|
112360
|
112361
|
112370
|
112371
|
112471
|
112472
|
112606
|
112607
|
112629
|
112630
|
113149
|
113150
|
113165
|
113166
|
114858
|
114859
|
115196
|
115197
|
115284
|
115458
|
115459
|
117500
|
117501
|
117990
|
117991
|
119231
|
119232
|
119274
|
120541
|
120542
|
120651
|
120652
|
120653
|
120654
|
120914
|
120915
| 120989 |
120990
|
121020
|
121021
|
121141
|
121142
|
122228
|
122229
|
122234
|
122235
|
122288
|
122289
|
122609
|
122610
|
122613
|
122614
|
122775
|
122776
|
122813
|
122814
|
122852
|
122853
|
122864
|
122865
|
123137
|
123138