Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Custom event listeners in views
Custom event listeners in views [message #541734] Tue, 22 June 2010 11:26 Go to next message
Philipp Leusmann is currently offline Philipp LeusmannFriend
Messages: 36
Registered: July 2009
Member
Hi,

currently I am being thrown into the development of a RAP Application
while I have no experience with RCP/RAP. Instead I was doing Swing
development before.

Now my task is writing an event-listener/-handler which receives events
from a non-GUI component. Now Gui-components (views) should be notified
if events occcur.

In swing I would start doing something like this:

public class EventListeningComponent extends Component {

public void handleEvent(String event) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(event);
}
}
}
}

Of course this is oversimplified, but I hope you get the point: Handling
non-gui-events within the gui and in the right context
(EventDispatchThread).


Could somebody please give m some advice on best practices to do
something like this in RAP.

How does the event-system work in RAP? Is there something like an
EventDispatchThread? How is the component in the browser notified, if a
java-event occurs?

Regards,
Philipp
Re: Custom event listeners in views [message #541830 is a reply to message #541734] Tue, 22 June 2010 16:26 Go to previous message
Austin Riddle is currently offline Austin RiddleFriend
Messages: 128
Registered: July 2009
Senior Member
Hi Philipp,

There are various web resources to help get you started:

Just search for : SWT tutorial

Also, the RAP FAQ:

http://wiki.eclipse.org/RAP/FAQ

is very useful and has many helpful examples.

But in reference to your specific task:

public class EventListener {
  
   Display display;

   public void handleEvent(String event) {
     if (display != null)
       display.asyncExec(new Runnable() {
          public void run() {
             MessageDialog.openInformation(null, "Message", event);
          }
       }
  }

  public void setDisplay (Display disp) {
    display = disp;
  }

}


will get you started... First you need a reference to the display. You can obtain that from any widget that you have a reference to.... or from the workbench.... or from Display.getCurrent() if you are already in the "ui" thread.

With that reference, you can from a "non-ui" thread, queue a runnable to be executed in the display thread using async().

Hope this helps.
Previous Topic:Serving static content with RAP-application
Next Topic:BrowserFunktion and return value
Goto Forum:
  


Current Time: Fri Apr 19 12:12:41 GMT 2024

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

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

Back to the top