Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Events not working(Cannot get even one event handler to work)
Events not working [message #941400] Fri, 12 October 2012 13:39 Go to next message
John Bester is currently offline John BesterFriend
Messages: 5
Registered: October 2012
Junior Member
I am using Eclipse Juno on Ubuntu 12.04.1. I have tried everything short of saying the magic word and I cannot get even one event handler to be called. I have searched the net for 2 days now. For now, if I can catch a button press to fire, I will be ecstatic. This is how far I got:
I can create a display, shell and add components to it. I can run this app as an OSGI application and open it in a browser. The design at this point is fairly simple, since there is no real point in going any further without being able to handle events. I have tried the following in various different combinations and sequences, and nothing changes:
Display display = new org.eclipse.swt.widgets.Display();
Shell shell = new org.eclipse.swt.widgets.Shell(display, SWT.RESIZE);
Button button = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
button.setText("Hallo");

display.setData(RWT.ACTIVE_KEYS, new String[] { "X", "F2", "ENTER", "SPACE" });
shell.setData(RWT.ACTIVE_KEYS, new String[] { "X", "F2", "ENTER", "SPACE" });
button.setData(RWT.ACTIVE_KEYS, new String[] { "X", "F2", "ENTER", "SPACE" });
display.addFilter(SWT.KeyDown, new Listener() { ... });
display.addFilter(SWT.MouseDown, new Listener() { ... });
shell.addFilter(SWT.KeyDown, new Listener() { ... });
shell.addFilter(SWT.MouseDown, new Listener() { ... });
button.addFilter(SWT.KeyDown, new Listener() { ... });
button.addFilter(SWT.MouseDown, new Listener() { ... });
button.addSelectionListener(new SelectionListener() { ... });
button.addMouseListener(new MouseListener() { ... });
button.addKeyListener(new KeyListener() { ... });

If you were to put these statements in a bag, shake it a bit and let a few fall out and then take out the rest one by one, I would have probably tried the code you came up with. What am I missing? I have added dependencies, I have marked the "Optional" and "Re-export" flags on dependencies (all stuff I tried by doing tons of google). I have tried running the app as OGSI as well as RAP applications. I have tried different browsers (Chrome, Firefox, Eclipse built in browser). I even tried some of these options on MacOSX. I even tried running the app as a stand alone SWT app, but got a problem that seems to be unheard of: "java.lang.IllegalStateException: No context available outside of the request service lifecycle." But this has taken up yet another couple of hours of research to no avail.

If I cannot get past this obstacle, then I will have to go back to GWT or some other framework. That would be a pity, because I do like the quick development lifecycle of RAP.

Please help!!!

Re: Events not working [message #941451 is a reply to message #941400] Fri, 12 October 2012 14:28 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Hi.

Is it possible you forgot the main loop?

shell.open()
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() )
display.sleep();
}
display.dispose();

If you run a RAP application in SWT compatibility mode, the UI appears,
but does not get updated. In that case either add the main loop or use
JEE mode:

http://eclipse.org/rap/developers-guide/devguide.php?topic=advanced/application-setup.html#compat

If this is NOT your problem, please report back.

Greetings,
Tim

P.S.:
Next time i would suggest not to wait for two days before asking here ;-)

Am 12.10.2012 15:39, schrieb John Bester:
> I am using Eclipse Juno on Ubuntu 12.04.1. I have tried everything short
> of saying the magic word and I cannot get even one event handler to be
> called. I have searched the net for 2 days now. For now, if I can catch
> a button press to fire, I will be ecstatic. This is how far I got:
> I can create a display, shell and add components to it. I can run this
> app as an OSGI application and open it in a browser. The design at this
> point is fairly simple, since there is no real point in going any
> further without being able to handle events. I have tried the following
> in various different combinations and sequences, and nothing changes:
> Display display = new org.eclipse.swt.widgets.Display();
> Shell shell = new org.eclipse.swt.widgets.Shell(display, SWT.RESIZE);
> Button button = new org.eclipse.swt.widgets.Button(shell, SWT.PUSH);
> button.setText("Hallo");
>
> display.setData(RWT.ACTIVE_KEYS, new String[] { "X", "F2", "ENTER",
> "SPACE" });
> shell.setData(RWT.ACTIVE_KEYS, new String[] { "X", "F2", "ENTER",
> "SPACE" });
> button.setData(RWT.ACTIVE_KEYS, new String[] { "X", "F2", "ENTER",
> "SPACE" });
> display.addFilter(SWT.KeyDown, new Listener() { ... });
> display.addFilter(SWT.MouseDown, new Listener() { ... });
> shell.addFilter(SWT.KeyDown, new Listener() { ... });
> shell.addFilter(SWT.MouseDown, new Listener() { ... });
> button.addFilter(SWT.KeyDown, new Listener() { ... });
> button.addFilter(SWT.MouseDown, new Listener() { ... });
> button.addSelectionListener(new SelectionListener() { ... });
> button.addMouseListener(new MouseListener() { ... });
> button.addKeyListener(new KeyListener() { ... });
>
> If you were to put these statements in a bag, shake it a bit and let a
> few fall out and then take out the rest one by one, I would have
> probably tried the code you came up with. What am I missing? I have
> added dependencies, I have marked the "Optional" and "Re-export" flags
> on dependencies (all stuff I tried by doing tons of google). I have
> tried running the app as OGSI as well as RAP applications. I have tried
> different browsers (Chrome, Firefox, Eclipse built in browser). I even
> tried some of these options on MacOSX. I even tried running the app as a
> stand alone SWT app, but got a problem that seems to be unheard of:
> "java.lang.IllegalStateException: No context available outside of the
> request service lifecycle." But this has taken up yet another couple of
> hours of research to no avail.
>
> If I cannot get past this obstacle, then I will have to go back to GWT
> or some other framework. That would be a pity, because I do like the
> quick development lifecycle of RAP.
>
> Please help!!!
>
>

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Events not working [message #942238 is a reply to message #941451] Sat, 13 October 2012 09:40 Go to previous messageGo to next message
John Bester is currently offline John BesterFriend
Messages: 5
Registered: October 2012
Junior Member
Hi Tim,

No, this is not my problem. One of my attempts was to run the app as a Java app, in which case you need the loop (I found that already). But sadly I could not even do that, because the context was never initialized and I got this exception:

Exception in thread "main" java.lang.IllegalStateException: No context available outside of the request service lifecycle.
at org.eclipse.rwt.internal.service.ContextProvider.getContext(ContextProvider.java:105)

I tried to search for the exception text, but got nowhere. I did run the app as a jar with swt.jar in the classpath, but that did not help either. I even tried to create a war using war product - only to find that additional libs that I added as jars is not available (even though it was packaged in WEB-INF/lib in the war. So, I gave up on testing the app in Glassfish or Tomcat as well. The best results I got thus far was to run the app as an OSGI app and then open a link using a web browser. By doing this, I did get to a place where I can actually see the screen and components - but NO events. I am pretty sure if the IEntryPoint method had a loop (for use with OSGI), the app would hang.
Re: Events not working [message #944943 is a reply to message #942238] Mon, 15 October 2012 07:10 Go to previous messageGo to next message
Ivan Furnadjiev is currently offline Ivan FurnadjievFriend
Messages: 2426
Registered: July 2009
Location: Sofia, Bulgaria
Senior Member
John,
could you provide a test project that demonstrate your problem? With
some code in hands it will be easy to help you.
Best,
Ivan

On 10/13/2012 12:40 PM, John Bester wrote:
> Hi Tim,
>
> No, this is not my problem. One of my attempts was to run the app as a
> Java app, in which case you need the loop (I found that already). But
> sadly I could not even do that, because the context was never
> initialized and I got this exception:
>
> Exception in thread "main" java.lang.IllegalStateException: No context
> available outside of the request service lifecycle.
> at
> org.eclipse.rwt.internal.service.ContextProvider.getContext(ContextProvider.java:105)
>
> I tried to search for the exception text, but got nowhere. I did run
> the app as a jar with swt.jar in the classpath, but that did not help
> either. I even tried to create a war using war product - only to find
> that additional libs that I added as jars is not available (even
> though it was packaged in WEB-INF/lib in the war. So, I gave up on
> testing the app in Glassfish or Tomcat as well. The best results I got
> thus far was to run the app as an OSGI app and then open a link using
> a web browser. By doing this, I did get to a place where I can
> actually see the screen and components - but NO events. I am pretty
> sure if the IEntryPoint method had a loop (for use with OSGI), the app
> would hang.

--
Ivan Furnadjiev

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Events not working [message #947503 is a reply to message #944943] Wed, 17 October 2012 06:27 Go to previous messageGo to next message
John Bester is currently offline John BesterFriend
Messages: 5
Registered: October 2012
Junior Member
Hi Tim,

Attachment as per your request is attached.

It seems like there is light at the end of the tunnel, I just cannot figure out how to switch it on. I have created a new test from scratch. With this test I did basically the same as before, but I used a different template (I think the first one I used was "Hello RCP" and now one of the other ones). So the plugin.xml was different. In the first case I had to figure out how to add the IEntryPoint plugin and in the second test the plugin was populated for me with a bunch of extensions. I wrote my IEntryPoint as before, but in an attempt to run the app in different ways, I also added IApplication and implemented it from example code. When I open the app using the suggested URL in the launch configuration (http.../rap/view?startup=za.co.softco.rap.test.viewapp), then I get a demo page, but my event handlers are fired. When I open the app as http.../rap/test, then I get my page with a button, but no events. So I guess it has to do with implementing IApplication (even though all documentation I read made me believe that RAP works with IApplication or IEntryPoint).

Regards
John
  • Attachment: testapp.zip
    (Size: 9.36KB, Downloaded 221 times)
Re: Events not working [message #953476 is a reply to message #947503] Mon, 22 October 2012 09:17 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
Okay, so i imported your project into my workspace with RAP 1.5.1 as the
target platform. The problems view in the IDE printed:

Project 'za.co.softco.rap.test' is missing required library:
'\za.co.softco.test\lib\swt.jar'
The project cannot be built until build path errors are resolved

I removed SWT.jar from the .classpath file and started the application
with the included launch config. The browser opened
http://127.0.0.1:6080/rap/view?startup=za.co.softco.rap.test.viewapp
and showed a shell with a table and three items. (had to press F5 once)
Clicking the items prints on the console.

Does that help you?

Greetings,
Tim

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Events not working [message #956574 is a reply to message #953476] Wed, 24 October 2012 16:20 Go to previous messageGo to next message
John Bester is currently offline John BesterFriend
Messages: 5
Registered: October 2012
Junior Member
Hi Tim,

I typed up a response a few days ago, but it seems it got lost in thin air. In any case, in my previous post I mentioned that I did get an event handler to work, but my page was not displayed - in stead the demo project page was displayed - exactly as you suggested (http.../rap/view?startup=za.co.softco.rap.test.viewapp). However, when I opened the URL http.../rap/test, then my page was displayed, but events were not handled. I would rather like a solution whereby I get the screen I put together as well as event handling all in one. I tried to interpret the plugin.xml in order to figure out how to get my page to be displayed, but it was kind of cryptic and I did not get very far.

According to an introduction to some of the docs on the RAP web site, the rule of thumb is, "if it compiles, it should work". However, this does not seem to be the case if you only implement IEntryPoint. Where am I going wrong?
Re: Events not working [message #959389 is a reply to message #956574] Fri, 26 October 2012 17:21 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
Messages: 396
Registered: July 2009
Senior Member
> However, when
> I opened the URL http.../rap/test, then my page was displayed, but
> events were not handled.

Yes, because there is no main loop in your createUI, a possible issue I
pointed out in my very first response. Here, i fixed it:

@Override
public int createUI() {
Display display; // = new Display();
display = PlatformUI.createDisplay();
Shell shell = new Shell(display, SWT.RESIZE);
build(display, shell);
shell.open();
System.out.println("Shell opened");
while( !shell.isDisposed() ) {
if( !display.readAndDispatch() )
display.sleep();
}
display.dispose();
return 0;
}

Greetings,
Tim

--
Tim Buschtöns

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Re: Events not working [message #961466 is a reply to message #959389] Sun, 28 October 2012 09:44 Go to previous message
John Bester is currently offline John BesterFriend
Messages: 5
Registered: October 2012
Junior Member
Hi Tim,

My apologies - that does solve my problem and I should have tried it the first time round even though it did not make sense to me at the time.

Previous Topic:Mouse Wheel Scrolling very slow
Next Topic:Accessing default presentations while using a PresentationFactory
Goto Forum:
  


Current Time: Thu Mar 28 21:03:45 GMT 2024

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

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

Back to the top