package org.jabref.gui.remote;

import java.util.List;

import javafx.application.Platform;

import org.jabref.JabRefGUI;
import org.jabref.cli.ArgumentProcessor;
import org.jabref.logic.importer.ParserResult;
import org.jabref.logic.remote.server.MessageHandler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class JabRefMessageHandler implements MessageHandler {
    private static final Logger LOGGER = LoggerFactory.getLogger(JabRefMessageHandler.class);

    @Override
    public void handleCommandLineArguments(String[] message) {

        ArgumentProcessor argumentProcessor = new ArgumentProcessor(message, ArgumentProcessor.Mode.REMOTE_START);

        List<ParserResult> loaded = argumentProcessor.getParserResults();
        for (int i = 0; i < loaded.size(); i++) {
            ParserResult pr = loaded.get(i);
            boolean focusPanel = i == 0;
            Platform.runLater(() ->
                    // Need to run this on the JavaFX thread
                    JabRefGUI.getMainFrame().addParserResult(pr, focusPanel)
            );
        }
    }
}

@@ -258,16 +258,62 @@
 ndler;%0A%0A
+import org.apache.commons.cli.ParseException;%0A
 import o
@@ -596,17 +596,34 @@
 sage) %7B%0A
-%0A
+        try %7B%0A    
         
@@ -738,16 +738,20 @@
         
+   
+ 
 List%3CPar
@@ -808,16 +808,20 @@
 ults();%0A
+    
         
@@ -874,16 +874,20 @@
         
+    
 ParserRe
@@ -923,16 +923,20 @@
         
+ 
+   
 boolean 
@@ -968,16 +968,20 @@
         
+    
 Platform
@@ -1016,16 +1016,20 @@
         
+   
+ 
 // Need 
@@ -1061,16 +1061,20 @@
  thread%0A
+    
         
@@ -1154,16 +1154,131 @@
         
+    );%0A            %7D%0A        %7D catch (ParseException e) %7B%0A            LOGGER.error(%22Error when parsing CLI args%22, e
 );%0A     

revert exception removal