Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsOpen file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973716/#msg_973716
Problem is I cannot find a good place to hook into for checking the command line arguments.
Has anyone ever done this with E4? Can someone give me a hint, please?]]>Markus Wiederkehr2012-11-06T15:11:19-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973723/#msg_973723
Markus Wiederkehr wrote on Tue, 06 November 2012 16:11
Problem is I cannot find a good place to hook into for checking the command line arguments.
Tha't pretty easy. If you want to do it in a lifecycle handler or pretty much from anywhere you can inject the IApplicationContext (it is in the MApplication's context so anything below it can access it too)and get the args you want.
]]>2012-11-06T15:18:55-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973728/#msg_973728
You can access the command line parameters through the IApplicatContext
which is pushed to the IEclipseContext of your application, so you have
access to it e.g. in addons.
Tom
Am 06.11.12 16:11, schrieb Markus Wiederkehr:
> I'd like to associate my E4 application with a certain file extension
> and open the specified file if a file name is given in the command line
> parameters.
>
> Problem is I cannot find a good place to hook into for checking the
> command line arguments.
>
> Has anyone ever done this with E4? Can someone give me a hint, please?]]>Thomas Schindl2012-11-06T15:20:02-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973734/#msg_973734
> Isn't there an event generated by the launcher when it detects this?
Just to make sure: This is needed only if your application is already
running and someone clicks on a file because then you certainly don't
want to open the file in the running application, instead of launching a
new one.
Tom]]>Thomas Schindl2012-11-06T15:22:25-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973736/#msg_973736
The problem is that I cannot find a place (or rather a point in the lifecycle) to hook into to actually open the file. I mean all the available lifecycle callbacks (@PostContextCreate, @ProcessAdditions) happen far too early for me to open the files. I need something that happens later, when everything is up and running. Right about the time the @CanExecute methods are invoked for the first time.]]>Markus Wiederkehr2012-11-06T15:29:23-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973753/#msg_973753
Phill Perryman2012-11-06T15:41:08-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973758/#msg_973758
But first I have to deal with the simpler case where the application is not running and the user double-clicks a file. Is there a callback I can use?]]>Markus Wiederkehr2012-11-06T15:45:20-00:00Re: Open file from command line
https://www.eclipse.org/forums/index.php/mv/msg/429376/973906/#msg_973906
window is renderered but at start up you could simply modify the model
directly, creating an MPart instance and adding it to the MPartStack.
Tom
Am 06.11.12 16:29, schrieb Markus Wiederkehr:
> Sorry, I was unclear. Accessing the command line parameters is not the
> problems (and it also seems to be working with
> Platform.getCommandLineArgs()).
>
> The problem is that I cannot find a place (or rather a point in the
> lifecycle) to hook into to actually open the file. I mean all the
> available lifecycle callbacks (@PostContextCreate, @ProcessAdditions)
> happen far too early for me to open the files. I need something that
> happens later, when everything is up and running. Right about the time
> the @CanExecute methods are invoked for the first time.]]>Thomas Schindl2012-11-06T18:10:04-00:00