Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
JFace Data Binding/PojoBindable
< JFace Data Binding
Revision as of 12:09, 29 March 2010 by Azerr.redhat.com (Talk | contribs) (New page: {{JFace Data Binding}} == Target == Work is underway to support binding with Pojo by using BeansObservable WITHOUT coding firePropertyChange (into setter method)/addPropertyChangeListene...)
JFace Data Binding |
Home |
How to Contribute |
FAQ |
Snippets |
Concepts |
Binding |
Converter |
Observable |
Realm |
Contents
Target
Work is underway to support binding with Pojo by using BeansObservable WITHOUT coding firePropertyChange (into setter method)/addPropertyChangeListener/removePropertyChangeListener. See (for the moment) Bug 307417- you can find 4 plug-in projects that provide Pojo Bindable :
- org.eclipse.core.databinding.pojo.bindable : Pojo Bindable source.
- org.eclipse.core.examples.databinding.pojo.bindable : Pojo Bindable samples.
- org.eclipse.core.tests.databinding.beans.bindable : Pojo Bindable tests.
- com.springsource.org.objectweb.asm : ASM bundle "org.objectweb.asm" version of 3.2.0 getted from SpringSource Enterprise Bundle Repository.
Sample
You can find this sample on org.eclipse.core.examples.databinding.pojo.bindable project.
PojoPerson
package org.eclipse.core.examples.databinding.pojo.bindable.model; /** * POJO model Person. * */ public class PojoPerson { String name = "HelloWorld"; public String getName() { return name; } public void setName(String name) { this.name = name; } }
HelloWorldWithBeansObservablesWithBindableAgent
PojoPerson person = new PojoPerson(); ... bindingContext.bindValue(SWTObservables.observeText(name, SWT.Modify), BeansObservables.observeValue(person, "name"));
Use BeansObservables althought it's a Pojo.
Bindable Java Agent
Lanch the program with Bindable JavaAgent filled into JVM Parameters :
-javaagent:lib/org.eclipse.core.databinding.pojo.bindable_1.0.0.jar -Dbindable.packages=org.eclipse.core.examples.databinding.pojo.bindable.model
The Bindable Java Agent transform the PojoPerson class with this code :
package org.eclipse.core.examples.databinding.pojo.bindable.model; import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; /** * POJO model Person. * */ public class PojoPerson { private PropertyChangeSupport _bindable_propertyChangeSupport = null; String name = "HelloWorld"; public String getName() { return name; } public void setName(String name) { Object oldValue = this.name; Object newValue = name; this.name = name; _bindable_getPropertyChangeSupport().firePropertyChange("name ", oldValue, newValue); } private PropertyChangeSupport _bindable_getPropertyChangeSupport() { if (_bindable_propertyChangeSupport == null) { this._bindable_propertyChangeSupport = new PropertyChangeSupport( this); } return _bindable_propertyChangeSupport; } public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) { _bindable_getPropertyChangeSupport().addPropertyChangeListener( propertyName, listener); } public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) { _bindable_getPropertyChangeSupport().removePropertyChangeListener( propertyName, listener); } }