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.importer.ParseException;
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) {
        try {
            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)
                );
            }
        } catch (ParseException e) {
            LOGGER.error("Error when parsing CLI args", e);
        }
    }
}

@@ -207,57 +207,8 @@
 lt;%0A
-import org.jabref.logic.importer.ParseException;%0A
 impo
@@ -554,26 +554,9 @@
 ) %7B%0A
-        try %7B%0A    
+%0A
     
@@ -675,20 +675,16 @@
         
-   
- 
 List%3CPar
@@ -741,20 +741,16 @@
 ults();%0A
-    
         
@@ -803,20 +803,16 @@
         
-    
 ParserRe
@@ -848,20 +848,16 @@
         
- 
-   
 boolean 
@@ -889,20 +889,16 @@
         
-    
 Platform
@@ -933,20 +933,16 @@
         
-   
- 
 // Need 
@@ -974,20 +974,16 @@
  thread%0A
-    
         
@@ -1067,123 +1067,8 @@
     
-    );%0A            %7D%0A        %7D catch (ParseException e) %7B%0A            LOGGER.error(%22Error when parsing CLI args%22, e
 );%0A 

remove parser exception