Hey!
Sorry this may be a stupid question but i can't see what i am doing wrong.
I have a simple testcase to experiment with the databinding of xwt.
I just try to bind a textbox to a string in my class in both ways. At the startup the textbox is filled with the text set by the attribute. But when i change the text in the text field the attribute in my object won't be updated. Also the otherway around when i press the button the event is called but the textbox will not change.
Maybe anyone has an idea. By the way i am using eclipse 3.6
package helloWorld;
import java.net.URL;
import org.eclipse.e4.xwt.IConstants;
import org.eclipse.e4.xwt.XWT;
public class Main {
private static TestMe testme = new TestMe();
public static void main(String args[]) throws Exception {
URL url = TestMe.class.getResource(TestMe.class.getSimpleName()
+ IConstants.XWT_EXTENSION_SUFFIX);
XWT.open(url,testme);
}
}
package helloWorld;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import org.eclipse.swt.widgets.Event;
public class TestMe {
private String testText;
private PropertyChangeSupport support = new PropertyChangeSupport(this);
public void addPropertyChangeListener(String propertyName,PropertyChangeListener listener) {
support.addPropertyChangeListener(propertyName, listener);
}
public void removePropertyChangeListener(String propertyName,PropertyChangeListener listener) {
support.removePropertyChangeListener(listener);
}
public TestMe() {
setTestText("This is a Test");
}
public String getTestText() {
return testText;
}
public void setTestText(String testText) {
support.firePropertyChange("testText", this.testText, testText);
this.testText = testText;
}
public void onSelection(Event event) {
System.out.println(testText);
setTestText("Hello World");
}
}
<Composite xmlns="http://www.eclipse.org/xwt/presentation"
xmlns:x="http://www.eclipse.org/xwt"
xmlns:y="clr-namespace:helloWorld"
x:Class="helloWorld.TestMe">
<Composite.layout>
<RowLayout/>
</Composite.layout>
<Text x:Style="BORDER" text="{Binding path=testText}"/>
<Button text="New Button" SelectionEvent="onSelection"/>
</Composite>