Search code examples
javaswtrcpe4

E4 RCP application doesn't respond at double click events


I am working at an E4 RCP application and I want to make it to respond properly when the user double clicks on a specific file type. So far the extension of the file is associated with the operating system by writing in registers and when double-clicking on it, the application is started. The problem that I am facing is that when I double click on the file, the application doesn't know how to handle the file, it starts but it doesn't load the data from the file. I will really appreciate your help if you can advice me what to do. I think that I need a listener but I don't know where. Thanks in advance.


Solution

  • An e4 application will not do anything about opening a file unless you write some code to make it do that.

    You can inject the IApplicationContext to get information about the command line arguments to the program:

    final String [] args = (String [])applicationContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
    

    the arguments will include the name of the file to open.

    If you want to do something like opening a MPart then you need to wait for the application startup complete event by subscribing to the event in the event broker:

    eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, handler);
    

    you would set this up in the @PostContextCreate create method of a life cycle class.