Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue 6487: Opening BibTex file (doubleclick) from Folder with spaces not working #7551

Merged
merged 14 commits into from
Mar 19, 2021
Prev Previous commit
Next Next commit
backtracking file path argument
who invoked the method sendMessage(type=SEND_COMMAND_LINE_ARGUMENTS) when double-clicking
XDZhelheim committed Mar 17, 2021
commit 2f8e1516cc74fd5dce836a13f539086367bb5a3b
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/cli/ArgumentProcessor.java
Original file line number Diff line number Diff line change
@@ -64,6 +64,9 @@ public class ArgumentProcessor {
private boolean noGUINeeded;

public ArgumentProcessor(String[] args, Mode startupMode) throws org.apache.commons.cli.ParseException {
for (String s:args) {
LOGGER.info("constructor arg = " + s);
}
cli = new JabRefCLI(args);
this.startupMode = startupMode;
parserResults = processArguments();
@@ -318,6 +321,7 @@ private List<ParserResult> importAndOpenFiles() {
// Leftover arguments that have a "bib" extension are interpreted as
// BIB files to open. Other files, and files that could not be opened
// as bib, we try to import instead.
LOGGER.info("aLeftOver = " + aLeftOver);
boolean bibExtension = aLeftOver.toLowerCase(Locale.ENGLISH).endsWith("bib");
ParserResult pr = new ParserResult();
if (bibExtension) {
4 changes: 4 additions & 0 deletions src/main/java/org/jabref/cli/JabRefCLI.java
Original file line number Diff line number Diff line change
@@ -26,6 +26,10 @@ public JabRefCLI(String[] args) throws ParseException {

this.cl = new DefaultParser().parse(options, args, true);
this.leftOver = cl.getArgList();

for (String s:args) {
LOGGER.info("constructor arg = " + s);
}
}

public static String getExportMatchesSyntax() {
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/remote/JabRefMessageHandler.java
Original file line number Diff line number Diff line change
@@ -18,6 +18,9 @@ public class JabRefMessageHandler implements MessageHandler {

@Override
public void handleCommandLineArguments(String[] message) {
for (String s:message) {
LOGGER.info("message = " + s);
}
try {
ArgumentProcessor argumentProcessor = new ArgumentProcessor(message, ArgumentProcessor.Mode.REMOTE_START);

1 change: 1 addition & 0 deletions src/main/java/org/jabref/logic/importer/OpenDatabase.java
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ public static ParserResult loadDatabase(String name, ImportFormatPreferences imp
*/
public static ParserResult loadDatabase(Path fileToOpen, ImportFormatPreferences importFormatPreferences, TimestampPreferences timestampPreferences, FileUpdateMonitor fileMonitor)
throws IOException {
LOGGER.info("db path: " + fileToOpen.toString());
ParserResult result = new BibtexImporter(importFormatPreferences, fileMonitor).importDatabase(fileToOpen,
importFormatPreferences.getEncoding());

Original file line number Diff line number Diff line change
@@ -58,6 +58,9 @@ private void handleMessage(Protocol protocol, RemoteMessage type, Object argumen
break;
case SEND_COMMAND_LINE_ARGUMENTS:
if (argument instanceof String[]) {
for (String s:(String[]) argument) {
LOGGER.info("arg: " + s);
}
messageHandler.handleCommandLineArguments((String[]) argument);
protocol.sendMessage(RemoteMessage.OK);
} else {
9 changes: 9 additions & 0 deletions src/main/java/org/jabref/logic/remote/shared/Protocol.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.Arrays;

import javafx.util.Pair;

@@ -38,6 +39,7 @@ public void sendMessage(RemoteMessage type) throws IOException {
}

public void sendMessage(RemoteMessage type, Object argument) throws IOException {
LOGGER.info("send arg: " + argument.toString());
out.writeObject(type);
out.writeObject(argument);
out.write('\0');
@@ -50,6 +52,13 @@ public Pair<RemoteMessage, Object> receiveMessage() throws IOException {
Object argument = in.readObject();
int endOfMessage = in.read();

LOGGER.info("recv type: " + type.toString());
if (argument instanceof String[]) {
LOGGER.info(Arrays.toString((String[]) argument));
// argument = StringUtil.join((String[]) argument, " ", 0, ((String[]) argument).length);
// argument = new String[]{(String) argument};
}

if (endOfMessage != '\0') {
throw new IOException("Message didn't end on correct end of message identifier. Got " + endOfMessage);
}