xwt databinding trouble [message #902220] |
Thu, 16 August 2012 08:21  |
Eclipse User |
|
|
|
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>
|
|
|
|
Re: xwt databinding trouble [message #902292 is a reply to message #902243] |
Thu, 16 August 2012 16:05  |
Eclipse User |
|
|
|
Hey! thanks for the fast reply 
Now i had time to try out your proposal and changed the code to
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(propertyName, listener);
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
support.addPropertyChangeListener(listener);
}
public void removePropertyChangeListener(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");
}
}
I found the propertyChange code from an old tutorial with jface databinding and there it worked. Also the breakpoint at addSupportListener(..,..) is reached (with propertyName="testText" and a BeanValueProperty. But unfortunately i got still the same results.
Thanks for the help . Maybe you have any other suggestion? (maybe some class or jar i forgot, but there's no error message).
Could this be a problem with the realms. I don't looked into that topic in details.
What i don't understand is, why the data- and eventbinding works at the startup but the data doesn't get updated later.
Is there any documentation about xwt, i can't find something realy usefull?
regards weinma
[Updated on: Thu, 16 August 2012 16:12] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05042 seconds