[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform] Re: how to use databinding to bind dynamic data
|
hao wrote:
I am using jface databinding feature to bind between GUI objects and
model objects. When the GUI is created, the DataBindingContext is used
to bind GUI objects and model. During the operation of the application,
the model data might be changed (model structure is not changed.). How
could I use DataBindingContext to re-bind the GUI objects to the changed
model data.
Your objects have expose an observer pattern in your model API, and use
an IObservable tailored to use that specific observer pattern.
Currently there are two options supported by Eclipse:
* Implement the official bean specification, and use BeansObservables to
observe bean properties.
* Implement model objects using EMF, and use EMFObservables to observe
EStructuralFeatures.
I'm not very familiar with EMF so I won't be much help there. However
with the bean spec there are just a few methods required:
public void addPropertyChangeListener(PropertyChangeListener listener)
public void removePropertyChangeListener(PropertyChangeListener listener)
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
This is commonly implemented using by extending a superclass such as
ModelObject as you have seen in the examples. The common pattern I use
in my setter methods is:
public void setName(String name) {
firePropertyChange("name", this.name, this.name = name);
}
Hope this helps,
Matthew