Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Problem with databinding
Problem with databinding [message #763682] Sat, 10 December 2011 09:51 Go to next message
Kai Hackemesser is currently offline Kai Hackemesser
Messages: 6
Registered: July 2009
Junior Member
Hi,

This is one of my first steps using Windowbuilder. My environment is Eclipse 3.7.1 running on 32bit Win7 with Java 1.7.0_01.

I use Windowbuilder to create a simple SWT Dialog for user/password entering. I want to bind the fields to a bean that is as same as simple. The default Windowbuilder dialog class returns a 'result' field of type 'Object'. I can see 'result' as a bean in the bindings view. When I change results to be my model bean type, it disappears from the bindings view and all menues used for bindings. Why?

Cheers,
Kai
Re: Problem with databinding [message #763747 is a reply to message #763682] Sat, 10 December 2011 13:28 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric Clayberg
Messages: 862
Registered: July 2009
Location: Boston, MA
Senior Member
I'm sorry, but I know what kind of problem you are describing from your description. Please provide a complete test case and any relevant screen shots of what you are seeing.
Re: Problem with databinding [message #764358 is a reply to message #763747] Mon, 12 December 2011 02:37 Go to previous messageGo to next message
Kai Hackemesser is currently offline Kai Hackemesser
Messages: 6
Registered: July 2009
Junior Member
package com.hackemesser.util.ui;

import org.eclipse.swt.SWT;

public class LoginDialog extends Dialog {

	private LoginBean m_result = new LoginBean();
	protected Shell shlLogin;
	private Text username;
	private Text password;

	/**
	 * Create the dialog.
	 * 
	 * @param parent
	 * @param style
	 */
	public LoginDialog(Shell parent, int style) {
		super(parent, style);
		setText("Login");
	}

	/**
	 * Open the dialog.
	 * 
	 * @return the result
	 */
	public LoginBean open() {
		createContents();
		shlLogin.open();
		shlLogin.layout();
		Display display = getParent().getDisplay();
		while (!shlLogin.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return m_result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shlLogin = new Shell(getParent(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
		shlLogin.setText("Login");
		shlLogin.setMinimumSize(new Point(200, 50));
		shlLogin.setSize(302, 212);
		shlLogin.setLayout(new FormLayout());

		Label lblUsername = new Label(shlLogin, SWT.NONE);
		FormData fd_lblUsername = new FormData();
		fd_lblUsername.top = new FormAttachment(0, 13);
		fd_lblUsername.left = new FormAttachment(0, 10);
		lblUsername.setLayoutData(fd_lblUsername);
		lblUsername.setText("&Username:");

		Label lblPassword = new Label(shlLogin, SWT.NONE);
		FormData fd_lblPassword = new FormData();
		fd_lblPassword.top = new FormAttachment(lblUsername, 12);
		fd_lblPassword.right = new FormAttachment(lblUsername, 0, SWT.RIGHT);
		lblPassword.setLayoutData(fd_lblPassword);
		lblPassword.setText("&Password:");

		username = new Text(shlLogin, SWT.BORDER);
		FormData fd_username = new FormData();
		fd_username.top = new FormAttachment(lblUsername, -3, SWT.TOP);
		fd_username.left = new FormAttachment(lblUsername, 6);
		username.setLayoutData(fd_username);
		

		password = new Text(shlLogin, SWT.BORDER | SWT.PASSWORD);
		fd_username.right = new FormAttachment(password, 0, SWT.RIGHT);
		FormData fd_password = new FormData();
		fd_password.right = new FormAttachment(100, -22);
		fd_password.left = new FormAttachment(lblPassword, 6);
		fd_password.top = new FormAttachment(lblPassword, -3, SWT.TOP);
		password.setLayoutData(fd_password);

		Button btnOk = new Button(shlLogin, SWT.NONE);
		FormData fd_btnOk = new FormData();
		fd_btnOk.left = new FormAttachment(0, 33);
		btnOk.setLayoutData(fd_btnOk);
		btnOk.setText("&Ok");

		Button btnCancel = new Button(shlLogin, SWT.NONE);
		fd_btnOk.top = new FormAttachment(btnCancel, 0, SWT.TOP);
		fd_btnOk.right = new FormAttachment(btnCancel, -6);
		FormData fd_btnCancel = new FormData();
		fd_btnCancel.bottom = new FormAttachment(100, -10);
		fd_btnCancel.right = new FormAttachment(username, 0, SWT.RIGHT);
		fd_btnCancel.left = new FormAttachment(100, -157);
		btnCancel.setLayoutData(fd_btnCancel);
		btnCancel.setText("&Cancel");

		Button btnStorePassword = new Button(shlLogin, SWT.CHECK);
		FormData fd_btnStorePassword = new FormData();
		fd_btnStorePassword.top = new FormAttachment(password, 6);
		fd_btnStorePassword.left = new FormAttachment(username, 0, SWT.LEFT);
		btnStorePassword.setLayoutData(fd_btnStorePassword);
		btnStorePassword.setText("&Store Password");

		shlLogin.setTabList(new Control[] { username, password, btnOk, btnCancel });
	}
}

package com.hackemesser.util.ui;

public class LoginBean {
private String username;
private String password;
private boolean storePassword;
public String getUsername() {
	return username;
}
public void setUsername(String username) {
	this.username = username;
}
public String getPassword() {
	return password;
}
public void setPassword(String password) {
	this.password = password;
}
public boolean isStorePassword() {
	return storePassword;
}
public void setStorePassword(boolean storePassword) {
	this.storePassword = storePassword;
}

}


Displaying that code shows the following in the windowbuilder bindings view:
index.php/fa/6429/0/
The bean/field m_result is missing in the bindings view.

I just need to change the type of m_result to 'Object' and it looks like this:

index.php/fa/6430/0/
As you can see, m_object appears in the beans list.

See my problem?

Cheers,
Kai
Re: Problem with databinding [message #764729 is a reply to message #764358] Mon, 12 December 2011 19:01 Go to previous messageGo to next message
Andrey Sablin is currently offline Andrey Sablin
Messages: 12
Registered: March 2011
Junior Member
What WB version you using (build Identifier like 20110615-0604)?
Re: Problem with databinding [message #764775 is a reply to message #764729] Mon, 12 December 2011 20:35 Go to previous messageGo to next message
Kai Hackemesser is currently offline Kai Hackemesser
Messages: 6
Registered: July 2009
Junior Member
Help/About shows Windowbuilder Core with 1.2.0.r37x201109270310
Re: Problem with databinding [message #764960 is a reply to message #764775] Tue, 13 December 2011 07:11 Go to previous messageGo to next message
Andrey Sablin is currently offline Andrey Sablin
Messages: 12
Registered: March 2011
Junior Member
Can not reproduce this case.

In test project (see attached) all shown (with given sources).

index.php/fa/6452/0/
  • Attachment: binding.png
    (Size: 171.47KB, Downloaded 719 times)
  • Attachment: rcp-test.zip
    (Size: 6.80KB, Downloaded 72 times)
Re: Problem with databinding [message #765441 is a reply to message #764960] Wed, 14 December 2011 04:08 Go to previous messageGo to next message
Kai Hackemesser is currently offline Kai Hackemesser
Messages: 6
Registered: July 2009
Junior Member
Tried that on Java 7 as well? Could that come by a missing dependency? (My project is Maven dependency managed)
Re: Problem with databinding [message #767114 is a reply to message #765441] Sat, 17 December 2011 03:43 Go to previous messageGo to next message
Kai Hackemesser is currently offline Kai Hackemesser
Messages: 6
Registered: July 2009
Junior Member
I've analysed your rcp-test project. You used Eclipse 3.6.2 to tell me you couldn't reproduce it where I wrote I have this problem with Eclipse 3.7.1. I use Java 7, you use Java 6. Can you try that again in the given environment, please?

Cheers,
Kai

[Updated on: Sat, 17 December 2011 03:47]

Report message to a moderator

Re: Problem with databinding [message #769531 is a reply to message #767114] Thu, 22 December 2011 08:59 Go to previous messageGo to next message
Andrey Sablin is currently offline Andrey Sablin
Messages: 12
Registered: March 2011
Junior Member
All works properly!
Used Eclipse 3.7.1 with Java 7u2.

index.php/fa/6530/0/
Re: Problem with databinding [message #769860 is a reply to message #769531] Thu, 22 December 2011 19:52 Go to previous message
Eric Clayberg is currently offline Eric Clayberg
Messages: 862
Registered: July 2009
Location: Boston, MA
Senior Member
I also tried it with Eclipse 3.7 and JDK 7 and it worked fine for me as well.
Previous Topic:Confusing code
Next Topic:Swing DataBinding Rollback changes when cancel button is pressed
Goto Forum:
  


Current Time: Wed Oct 01 16:38:36 GMT 2014

Powered by FUDForum. Page generated in 0.01814 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software