Open file from command line (Pure E4 RCP) [message #1021151] |
Tue, 19 March 2013 11:25  |
Eclipse User |
|
|
|
Hello. I would like to open files passed as command line arguments in my pure E4 RCP application (Eclipse 4.2). So I am using this article http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html and and I am tring to rewrite everything in E4 style.
I have created a listener class
public class OpenKmlEventProcessor implements Listener
{
@Override
public void handleEvent(Event event)
{
if (event.text != null)
{
...
}
}
}
and attached in to Display in @PostConstruct method of my Addon
@PostConstruct
void hookListeners(...)
{
...
Display.getDefault().addListener(SWT.OpenDocument, openKmlProcessor);
}
In the same addon I am processing command line arguments
@Inject
void proccessCmdLineArguments(IApplicationContext appContext)
{
...
String[] args = (String[])appContext.getArguments().get(IApplicationContext.APPLICATION_ARGS);
...
}
My product appName property matches my launcher name. And
--launcher.defaultAction
openFile
is present in my <launcher>.ini
Everything works fine in 2 cases:
1. I launch my application with the command line argument only once. Here "proccessCmdLineArguments" method works.
2. For the first time I launch my application without command line arguments. And then I can launch it with a command line argument as many times as I wish. Here "handleEvent" method works.
The problem is the third case, when I launch my application with the command line argument for the first time and do it again for the second time. After the default timeout (60 sec) Eclipse tries to create a new instance of my application instead of opening the file in the running instance. What am I doing wrong?
|
|
|
|
|
|
|
|
Re: Open file from command line (Pure E4 RCP) [message #1821906 is a reply to message #1779307] |
Sat, 22 February 2020 10:43  |
Eclipse User |
|
|
|
Hi there,
I'm facing the same problem (pure E4 RCP on Windows), but setting the VM to a specific version of javaw.exe (which would solve the problem) is not an option for me.
I experimented with the Eclipse IDE and there all works as expected. But in my pure E4 RCP it works only, if the first instance is started w/o any files on the command line. In essence the IDE itself is also an E4 application, therefore I expect, that there exists an solution and I (we) just miss something...
Does anyone have a clue / any hint what is going wrong here?
Thanks in advance!
Addendum: I think I figured out the reason: https://bugs.eclipse.org/bugs/show_bug.cgi?id=560428
As a workaround until the bug is fixed in the native launcher, you can use your own E4Application class. At the beginning of the start() method you should take the current time (long timeOnEntryInMillis = System.currentTimeMillis();) and just before calling workbench.createAndRunUI(workbench.getApplication());
insert this:
while (display.readAndDispatch() || ((System.currentTimeMillis() - timeOnEntryInMillis) < 1000))
{
// nothing in here
}
[Updated on: Sun, 23 February 2020 05:38] by Moderator
|
|
|
Powered by
FUDForum. Page generated in 0.24993 seconds