Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » XWT and control binding
XWT and control binding [message #938020] Tue, 09 October 2012 13:34 Go to next message
Liudas Sodas is currently offline Liudas SodasFriend
Messages: 7
Registered: September 2012
Junior Member
Hi!

Maybe some of you knows how to make work control binding on XWT handler class?
What I have from wizard is really simple:
package dev;

import java.net.URL;

import org.eclipse.e4.xwt.IConstants;
import org.eclipse.e4.xwt.XWT;
import org.eclipse.e4.xwt.annotation.UI;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Event;

public class Showup {

	@UI
	Text myLabel;
	
	public static void main(String args[]) throws Exception {

                if(myLabel !=null){
			System.out.println("works");
		}

		URL url = Showup.class.getResource(Showup.class.getSimpleName()
				+ IConstants.XWT_EXTENSION_SUFFIX);
		Control control = XWT.load(url);
		Shell shell = control.getShell();
		shell.layout();
		centerInDisplay(shell);
		// run events loop
		shell.open();
		while (!shell.isDisposed()) {
			if (!shell.getDisplay().readAndDispatch())
				shell.getDisplay().sleep();
		}
	}

	public void onSelection(Event event) {
		System.out.println(event);
	}
}

<Shell xmlns="http://www.eclipse.org/xwt/presentation" xmlns:x="http://www.eclipse.org/xwt" x:Class="dev.Showup" text="XWT Application">
	<Shell.layout>
		<RowLayout/>
	</Shell.layout>
	<Button text="Double click me!" SelectionEvent="onSelection"/>
	<Label text="New Label" x:Name="myLabel" />
</Shell>


But myLabel is not injected.

Example an idea of injection is from E4/XWT wiki

Thanks in advance!
Re: XWT and control binding [message #938813 is a reply to message #938020] Wed, 10 October 2012 07:15 Go to previous messageGo to next message
Liudas Sodas is currently offline Liudas SodasFriend
Messages: 7
Registered: September 2012
Junior Member
Found other way around.

..
Control control = XWT.load(url);
Label myLabel = (Label)XWT.findElementByName(control, "myLabel");
..


Not the perfect way, but works. Injection would be nicer and easier to work with.
Re: XWT and control binding [message #939431 is a reply to message #938813] Wed, 10 October 2012 18:58 Go to previous message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I agree, and indeed, the injection should work, but I guess that has not been tested that much.
It might even be better to (re)use the javax.injection annotations. I would suggest to file a bug report and/or an enhancement request.

Liudas Sodas wrote on Wed, 10 October 2012 03:15
Found other way around.

..
Control control = XWT.load(url);
Label myLabel = (Label)XWT.findElementByName(control, "myLabel");
..


Not the perfect way, but works. Injection would be nicer and easier to work with.

Previous Topic:Blog: Why Eclipse e4
Next Topic:Eclipse 4 System Events
Goto Forum:
  


Current Time: Thu Mar 28 20:06:52 GMT 2024

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

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

Back to the top