package org.jabref.gui.remote;

import java.util.Arrays;
import java.util.List;

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

public class JabRefMessageHandler implements MessageHandler {

    @Override
    public void handleCommandLineArguments(String[] message) {
        ArgumentProcessor argumentProcessor = new ArgumentProcessor(message, ArgumentProcessor.Mode.REMOTE_START);
        if (!(argumentProcessor.hasParserResults())) {
            throw new IllegalStateException("Could not start JabRef with arguments " + Arrays.toString(message));
        }

        List<ParserResult> loaded = argumentProcessor.getParserResults();
        for (int i = 0; i < loaded.size(); i++) {
            ParserResult pr = loaded.get(i);
            JabRefGUI.getMainFrame().addParserResult(pr, i == 0);
        }
    }
}

@@ -74,16 +74,53 @@
 .List;%0A%0A
+import javafx.application.Platform;%0A%0A
 import o
@@ -887,16 +887,162 @@
 get(i);%0A
+            boolean focusPanel = i == 0;%0A            Platform.runLater(() -%3E%0A                    // Need to run this on the JavaFX thread%0A        
         
@@ -1090,22 +1090,40 @@
 ult(pr, 
-i == 0
+focusPanel)%0A            
 );%0A     

Fix NotOnJavaFXThread exception for remote import