Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 12:57 Go to next message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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 12:59]

Report message to a moderator

Re: Call XWT.findElementByName Method in User-Interface Thread [message #522221 is a reply to message #522218] Sun, 21 March 2010 13:21 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
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 14:14 Go to previous messageGo to next message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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 18:45 Go to previous messageGo to next message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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 15:03 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
You can try to set breakpoint and debug this problem yourself.
Don't forget to post your results. Wink


Konstantin Scheglov,
Google, Inc.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522487 is a reply to message #522406] Mon, 22 March 2010 18:54 Go to previous messageGo to next message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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 19:41 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
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,
Google, Inc.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #522529 is a reply to message #522501] Mon, 22 March 2010 22:06 Go to previous message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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 22:08]

Report message to a moderator

Re: Call XWT.findElementByName Method in User-Interface Thread [message #571349 is a reply to message #522250] Mon, 22 March 2010 15:03 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
You can try to set breakpoint and debug this problem yourself.
Don't forget to post your results. ;)
--
Konstantin Scheglov,
Instantiations, Inc.


Konstantin Scheglov,
Google, Inc.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #571390 is a reply to message #571349] Mon, 22 March 2010 18:54 Go to previous message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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 19:41 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
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.


Konstantin Scheglov,
Google, Inc.
Re: Call XWT.findElementByName Method in User-Interface Thread [message #571442 is a reply to message #571416] Mon, 22 March 2010 22:06 Go to previous message
can kayacan is currently offline can kayacanFriend
Messages: 16
Registered: March 2010
Junior Member
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: Tue Apr 23 09:33:12 GMT 2024

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

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

Back to the top