Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Loose coupling of objects with E4
Loose coupling of objects with E4 [message #910699] Mon, 10 September 2012 08:35 Go to next message
Georges Bachelier is currently offline Georges Bachelier
Messages: 26
Registered: May 2010
Junior Member
Hello everybody !

I am writing an RCP application with E4. Among other widgets, the main window displays a SWT Text entry and a Browse button for the user to enter a file pathname.

As soon as a valid pathname is typed in the Text widget, the corresponding file must be parsed and some widgets updated with information read from the file. Simple, isn't it ?

Here is how I have written this:

- added a ModifyListener to the Text widget which modifyText method runs
eventBroker.post( ARP_FILE_EXISTS, arpFile );


- added a parseHandler method to my ArpParser class with the following content:
  @Inject
  @Optional
  void parseHandler( @UIEventTopic( ARP_FILE_EXISTS ) File arpFile ) throws IOException
  {
    parse( arpFile );

    // Signal the UI that values are available for update.
    eventBroker.post( TOPIC_NEW_RESOLUTION, resolution );
    eventBroker.post( TOPIC_NEW_MODE, mode );
    eventBroker.post( TOPIC_NEW_SAMPLESPERCODE, samplesPerCode );
    eventBroker.post( TOPIC_NEW_VREF, vref );
    eventBroker.post( TOPIC_NEW_LSBVALUE, lsbValue );
  }


- added the ArpParser to the Addons list of the Application.e4xmi file so that the parser gets instantiated by the framework and can react to the message sent by the listener.

The whole thing works perfectly, but after some readings about addons, I think that they are not the proper way to perform what I need. Am I right ? Is there an other way, more "E4-oriented" to force the framework to instantiate my parser before the GUI is built ?

Thanks a lot in advance for your help !

Georges

Re: Loose coupling of objects with E4 [message #910702 is a reply to message #910699] Mon, 10 September 2012 08:39 Go to previous messageGo to next message
Sopot Cela is currently offline Sopot Cela
Messages: 597
Registered: December 2010
Senior Member

Yes the life cycle hooks! But be ware that they are called really early. No contexts and stuff. Refer to http://www.vogella.com/articles/EclipseRCP/article.html#lifecycle
Re: Loose coupling of objects with E4 [message #910722 is a reply to message #910702] Mon, 10 September 2012 09:27 Go to previous message
Georges Bachelier is currently offline Georges Bachelier
Messages: 26
Registered: May 2010
Junior Member
It works perfectly with the lifeCycleURI and my parser as bundleclass.

Thanks a lot !
Previous Topic:Cannot replace menu items at runtime
Next Topic:Migrate XText based RCP to Eclipse 4.2
Goto Forum:
  


Current Time: Tue Sep 30 21:55:13 GMT 2014

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

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