Skip to main content



      Home
Home » Eclipse Projects » Eclipse 4 » Call XWT.findElementByName Method in User-Interface Thread
Call XWT.findElementByName Method in User-Interface Thread [message #522218] Sun, 21 March 2010 08:57 Go to next message
Eclipse UserFriend
Hi,

My XWT UI Element implements the java.util.Observer class.

in the update method of the Observer class, I want to get the canvas element by calling XWT.findElementByName but it always returns null.

@Override
public void update(Observable o, Object arg) {
this.getDisplay().asyncExec(new Runnable() {
public void run() {
Canvas pitchCanvas = (Canvas) XWT.findElementByName(this, "PitchCanvas"); // RETURNS NULL
}
});

But if I call the same in the paint events it works:

public void onPaintEvent(Object object, Event event) {
Canvas pitchCanvas = (Canvas) XWT.findElementByName(this, "PitchCanvas"); // WORKS

XWT has problems to be invoked within the user-interface thread?

Is it a bug?

[Updated on: Sun, 21 March 2010 08:59] by Moderator

Re: Call XWT.findElementByName Method in User-Interface Thread [message #522221 is a reply to message #522218] Sun, 21 March 2010 09:21 Go to previous messageGo to next message
Eclipse UserFriend
You have to execute the code in the xwt realm, see:

XWT.getRealm().
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522224 is a reply to message #522221] Sun, 21 March 2010 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately, the result is the same by using the Realm like:

XWT.getRealm().asyncExec(new Runnable() {
...
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522250 is a reply to message #522224] Sun, 21 March 2010 14:45 Go to previous messageGo to next message
Eclipse UserFriend
I prepared a simple demo application for this problem,

somebody may try it easily...

http://cid-05452aee1eda70dc.skydrive.live.com/self.aspx/Publ ic/DemoFindElementThread.tar.gz
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522406 is a reply to message #522250] Mon, 22 March 2010 11:03 Go to previous messageGo to next message
Eclipse UserFriend
You can try to set breakpoint and debug this problem yourself.
Don't forget to post your results. Wink
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522487 is a reply to message #522406] Mon, 22 March 2010 14:54 Go to previous messageGo to next message
Eclipse UserFriend
How clever... Thank you for the suggestion, genius!
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522501 is a reply to message #522487] Mon, 22 March 2010 15:41 Go to previous messageGo to next message
Eclipse UserFriend
Really, use debugger.

If you are programmer, why do you afraid debugger?
You probably would find answer in less time than it was required to write question in forum.

I've read that author is now on EclipseCon, so most probably you will not receive answer this week.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522529 is a reply to message #522501] Mon, 22 March 2010 18:06 Go to previous message
Eclipse UserFriend
Hmm sorry. Sad As a new Java convert from .Net, I have never thought that I would be able to debug the findElementByName method itself. This is kinda weird but good that lead me to solve the problem: I was just passing the Runnable object to the method instead of the Composite. Thanks for the guidance Konstantin. Smile

[Updated on: Mon, 22 March 2010 18:08] by Moderator

Re: Call XWT.findElementByName Method in User-Interface Thread [message #571349 is a reply to message #522250] Mon, 22 March 2010 11:03 Go to previous message
Eclipse UserFriend
You can try to set breakpoint and debug this problem yourself.
Don't forget to post your results. ;)
--
Konstantin Scheglov,
Instantiations, Inc.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #571390 is a reply to message #571349] Mon, 22 March 2010 14:54 Go to previous message
Eclipse UserFriend
How clever... Thank you for the suggestion, genius!
Re: Call XWT.findElementByName Method in User-Interface Thread [message #571416 is a reply to message #571390] Mon, 22 March 2010 15:41 Go to previous message
Eclipse UserFriend
Really, use debugger.

If you are programmer, why do you afraid debugger?
You probably would find answer in less time than it was required to write question in forum.

I've read that author is now on EclipseCon, so most probably you will not receive answer this week.
--
Konstantin Scheglov,
Instantiations, Inc.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #571442 is a reply to message #571416] Mon, 22 March 2010 18:06 Go to previous message
Eclipse UserFriend
Hmm sorry. :( As a new .Net convert, I have never thought that I would be able to debug the findElementByName method itself. This is kinda weird but good that lead me to solve the problem: I was just passing the Runnable object to the method instead of the Composite. Thanks for the guidance Konstantin. :)
Previous Topic:problem opening Application.e4xmi in e4 windows 64bit
Next Topic:XWT : access widget element
Goto Forum:
  


Current Time: Mon Jul 07 16:16:53 EDT 2025

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

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

Back to the top