Why is it needed for java bean to implement property change support [message #328349] |
Thu, 22 May 2008 15:49 |
Hao Missing name Messages: 115 Registered: July 2009 |
Senior Member |
|
|
jface databinding framwork has provided a lot of help classes, such as
BeansObservables and WritableValue. Why is it still needed for java bean
to implement property change support, such as
public class Message extends ModelObject {
...
}
public class ModelObject {
private final PropertyChangeSupport propertyChangeSupport = new
PropertyChangeSupport(
this);
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(listener);
}
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
propertyChangeSupport.addPropertyChangeListener(propertyName , listener);
}
public void removePropertyChangeListener(PropertyChangeListener listener)
{
propertyChangeSupport.removePropertyChangeListener(listener) ;
}
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener) {
propertyChangeSupport.removePropertyChangeListener(propertyN ame,
listener);
}
protected void firePropertyChange(String propertyName, Object oldValue,
Object newValue) {
propertyChangeSupport.firePropertyChange(propertyName, oldValue,
newValue);
}
protected void fireIndexedPropertyChange(String propertyName, int index,
Object oldValue, Object newValue) {
propertyChangeSupport.fireIndexedPropertyChange( propertyName, index,
oldValue, newValue);
}
}
|
|
|
|
[DataBinding] Re: Why is it needed for java bean to implement property change support [message #328351 is a reply to message #328349] |
Thu, 22 May 2008 16:19 |
Eclipse User |
|
|
|
Originally posted by: eclipse-news.rizzoweb.com
hao wrote:
> jface databinding framwork has provided a lot of help classes, such as
> BeansObservables and WritableValue. Why is it still needed for java bean
> to implement property change support
In Eclipse 3.4, there is a new class,
org.eclipse.core.databinding.beans.PojoObservables, that supports
creating observables on objects that do not fire property change events.
The limitation, of course, is that the framework isn't notified if the
underlying objects are changed directly - that's what the property
change events provide. So if your model objects don't do that they can't
tell the data binding framework when their properties have changed.
Hope this helps,
Eric
|
|
|
|
Powered by
FUDForum. Page generated in 0.03132 seconds