|Loose coupling of objects with E4 [message #910699]
||Mon, 10 September 2012 04:35
| Georges Bachelier
Registered: May 2010
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:
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 !
Powered by FUDForum
. Page generated in 0.06587 seconds