BUG: WB bind editor erases custom calls

Swing Designer allows you to quickly create the frames, panels, dialogs, applets and other UI elements that comprise Java Swing applications.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

BUG: WB bind editor erases custom calls

Postby Andrei.Pozolotin » Thu Oct 14, 2010 9:52 am

BUG: WB bind editor erases custom calls

1) when I create a binding with a validator it looks and works fine:

Code: Select all
    protected void initDataBindings() {
        BeanProperty<LoginModel, String> loginModelBeanProperty = BeanProperty
                .create("username");
        BeanProperty<JTextField, String> jTextFieldBeanProperty = BeanProperty
                .create("text");
        bindUsername = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
                model, loginModelBeanProperty, textUsername,
                jTextFieldBeanProperty);
        bindUsername.setValidator(new StringValidator());
        bindUsername.bind();
    }


2) however validator is pretty useless if there are no listeners; so I add one:
Code: Select all
    protected void initDataBindings() {
        BeanProperty<LoginModel, String> loginModelBeanProperty = BeanProperty
                .create("username");
        BeanProperty<JTextField, String> jTextFieldBeanProperty = BeanProperty
                .create("text");
        bindUsername = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE,
                model, loginModelBeanProperty, textUsername,
                jTextFieldBeanProperty);
        bindUsername.setValidator(new StringValidator());
        bindUsername.addBindingListener(new AbstractBindingListener() {
            @Override
            public void syncFailed(Binding binding, SyncFailure failure) {
                System.err.println("Failure " + failure);
            }

        });
        bindUsername.bind();
    }


3) now if I make any change to the binding int WB gui, my custom method call
Code: Select all
        bindUsername.addBindingListener(new AbstractBindingListener() {

is gone

what am I missing?

thank you
Andrei.Pozolotin
 
Posts: 55
Joined: Wed Sep 22, 2010 5:35 am

Re: BUG: WB bind editor erases custom calls

Postby Andrei.Pozolotin » Thu Oct 14, 2010 10:10 am

my current workaround is to move this

Code: Select all
        bindUsername.addBindingListener(new AbstractBindingListener() {
            @Override
            public void syncFailed(Binding binding, SyncFailure failure) {
                System.err.println("Failure " + failure);
            }
        });


outside of
Code: Select all
    protected void initDataBindings() {


I would expect that //$hide$ would work also, but instead it deadlocks
in the EDT on re-parse when opening WB bindings edit page;
Andrei.Pozolotin
 
Posts: 55
Joined: Wed Sep 22, 2010 5:35 am

Re: BUG: WB bind editor erases custom calls

Postby Eric Clayberg » Thu Oct 14, 2010 11:26 am

This is not a bug. It is working as designed.

The initBindings() method is a reflection of the state of the WB databinding model for that class and is completely regenerated based on changes made to the Bindings tab.

If you want to add code like that, do it outside of the initBindings() method (e.g., your work around is the correct solution in this case). This is exactly the reason that we provide an option to assign a binding to a field (so that you can modify it, add listeners, etc.).

You can add code to the initBindings() method, but it has to strictly adhere to the API that the code generator supports.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: BUG: WB bind editor erases custom calls

Postby Andrei.Pozolotin » Thu Oct 14, 2010 1:04 pm

got it - thanks!

so far experience with WB was like tightrope walking - wrong step and you are dead :-)

thats fine, I will adapt;
Andrei.Pozolotin
 
Posts: 55
Joined: Wed Sep 22, 2010 5:35 am

Re: BUG: WB bind editor erases custom calls

Postby Eric Clayberg » Thu Oct 14, 2010 1:56 pm

Andrei.Pozolotin wrote:so far experience with WB was like tightrope walking - wrong step and you are dead

How so? It is actually extraordinarily difficult to crash the tool itself. It does have some limitations as well (but far fewer than any of the alternatives).

Note that WB is not magic and not guaranteed to work with hand written code. Based on experience, it is able to handle ~90% of hand written code immediately. Other code can be made to work with minor modifications. Show me any other Java GUI builder that even comes close ;-)
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Re: BUG: WB bind editor erases custom calls

Postby Andrei.Pozolotin » Thu Oct 14, 2010 4:40 pm

It is actually extraordinarily difficult to crash the tool itself.

in my experience, I have it lock up eclipse some 5-10 times a day;
and "killall java && eclipse -clean" to rebuild workspace is not a happy making wait time :-)

on the other hand, it can be seen as a welcome opportunity to take a break :-)

basically, instead of bothering you with what I consider bugs
I just learn now to walk on a WB mine field since you have trained me already
to think they are really features :-)

Show me any other Java GUI builder that even comes close


yes, WB is the best builder I have seen so far,
I guess I am just a very demanding customer (for this market);
Andrei.Pozolotin
 
Posts: 55
Joined: Wed Sep 22, 2010 5:35 am

Re: BUG: WB bind editor erases custom calls

Postby Eric Clayberg » Thu Oct 14, 2010 6:28 pm

Andrei.Pozolotin wrote:in my experience, I have it lock up eclipse some 5-10 times a day

Hmmmm. That is extremely uncommon and suggests that something unusual is happening in your environment. I pretty much use it all day, every day (in Linux, OSX and Windows) and never have it lock up.

Can you provide java thread dumps any time this happens (i.e., run Eclipse using the console and issue the "kill -3 <pid>" command when it locks up)?

We should then be able to identify whether it us caused by a problem in Swing Designer or in something else. Either way, I'm sure we can likely solve that problem once we see those thread dumps.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to Swing Designer

Who is online

Users browsing this forum: No registered users and 1 guest

cron