Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Open file from command line (Pure E4 RCP)
Open file from command line (Pure E4 RCP) [message #1021151] Tue, 19 March 2013 15:25 Go to next message
Severin Raevskiy is currently offline Severin Raevskiy
Messages: 5
Registered: March 2013
Junior Member
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 #1021480 is a reply to message #1021151] Wed, 20 March 2013 07:40 Go to previous messageGo to next message
Severin Raevskiy is currently offline Severin Raevskiy
Messages: 5
Registered: March 2013
Junior Member
Sorry, I meant this article: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fproduct_open_file.htm&cp=2_0_21_8
Re: Open file from command line (Pure E4 RCP) [message #1022120 is a reply to message #1021480] Thu, 21 March 2013 09:59 Go to previous messageGo to next message
Severin Raevskiy is currently offline Severin Raevskiy
Messages: 5
Registered: March 2013
Junior Member
It works, when I put an argument in <launcher>.ini. It also works when I connect with a remote debugger and start step-by-step debugging of "getNonFramework" method calls in EclipseEnvironmentInfo class. Looks like a race between threads. Any ideas?
Re: Open file from command line (Pure E4 RCP) [message #1022589 is a reply to message #1021151] Fri, 22 March 2013 07:29 Go to previous message
Severin Raevskiy is currently offline Severin Raevskiy
Messages: 5
Registered: March 2013
Junior Member
Maybe a minimal application can help? I moved listener attachment from addon to "getApplicationDisplay()" method in my own application class.
Previous Topic:Inject JPA EntityManager
Next Topic:Drag and Drop UI application using e4
Goto Forum:
  


Current Time: Fri Oct 24 10:24:08 GMT 2014

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

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