From 9beb43cf054f91db036a172020b14f64572cd611 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 3 Oct 2020 17:10:30 +0200 Subject: [PATCH 1/6] Fix could not connect to LO on Mac OSX Refactor --- CHANGELOG.md | 1 + .../gui/openoffice/OpenOfficePanel.java | 7 ++++- .../openoffice/OpenOfficeFileSearch.java | 26 ++++++++++--------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ef2a053543..249f474662e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907). - We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog [#6934](https://github.com/JabRef/jabref/issues/6934) - We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906) +- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX ### Removed diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 41adef02303..921ff24d050 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -48,6 +48,7 @@ import org.jabref.logic.openoffice.OpenOfficePreferences; import org.jabref.logic.openoffice.StyleLoader; import org.jabref.logic.openoffice.UndefinedParagraphFormatException; +import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; import org.jabref.model.database.BibDatabase; import org.jabref.model.database.BibDatabaseContext; @@ -430,9 +431,13 @@ private List findOpenOfficeJars(Path configurationPath) throws IOException throw new IOException("(Not all) required Open Office Jars were found inside installation path. Searched for " + OpenOfficePreferences.OO_JARS + " in " + configurationPath); } - List jarURLs = new ArrayList<>(OpenOfficePreferences.OO_JARS.size()); + List jarURLs = new ArrayList<>(OpenOfficePreferences.OO_JARS.size() + 1); for (Optional jarPath : filePaths) { jarURLs.add((jarPath.get().toUri().toURL())); + // For Mac OSX we need to add the "Contents/MacOS", because otherwise we cannot connect to LO + if (OS.OS_X) { + jarURLs.add(configurationPath.resolve("Contents/MacOS/").toUri().toURL()); + } } return jarURLs; } diff --git a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java index e9369087c4a..b17ceea34b1 100644 --- a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java +++ b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java @@ -1,13 +1,17 @@ package org.jabref.logic.openoffice; -import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; +import java.util.function.BiPredicate; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; @@ -33,19 +37,17 @@ public static List detectInstallations() { } private static List findOpenOfficeDirectories(List programDirectories) { - List result = new ArrayList<>(); - for (Path programDir : programDirectories) { - File[] subDirs = programDir.toFile().listFiles(File::isDirectory); - if (subDirs != null) { - for (File dir : subDirs) { - if (dir.getPath().toLowerCase(Locale.ROOT).contains("openoffice") || dir.getPath().toLowerCase(Locale.ROOT).contains("libreoffice")) { - result.add(dir.toPath()); - } - } + BiPredicate filePredicate = (path, attr) -> attr.isDirectory() && (path.toString().toLowerCase(Locale.ROOT).contains("openoffice") + || path.toString().toLowerCase(Locale.ROOT).contains("libreoffice")); + + return programDirectories.stream().flatMap(dirs -> { + try { + return Files.find(dirs, 1, filePredicate); + } catch (IOException e) { + return Stream.empty(); } - } - return result; + }).collect(Collectors.toList()); } private static List findWindowsOpenOfficeDirs() { From 539b827eda7dcc6b228929ad81e2762e02d79624 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 3 Oct 2020 17:18:21 +0200 Subject: [PATCH 2/6] add link to pr --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 249f474662e..9c40190b158 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,9 +42,9 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed the failure to Copy citation key and link. [#5835](https://github.com/JabRef/jabref/issues/5835) - We fixed an issue where the sort order of the entry table was reset after a restart of JabRef. [#6898](https://github.com/JabRef/jabref/pull/6898) - We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907). -- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog [#6934](https://github.com/JabRef/jabref/issues/6934) -- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906) -- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX +- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog [#6934](https://github.com/JabRef/jabref/issues/6934). +- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906). +- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX [#6970](https://github.com/JabRef/jabref/pull/6970). ### Removed From b997075024e6839ecc96613bfcdcc73033487537 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 3 Oct 2020 22:46:06 +0200 Subject: [PATCH 3/6] Update CHANGELOG.md Co-authored-by: Oliver Kopp --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c40190b158..cf174752688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed the failure to Copy citation key and link. [#5835](https://github.com/JabRef/jabref/issues/5835) - We fixed an issue where the sort order of the entry table was reset after a restart of JabRef. [#6898](https://github.com/JabRef/jabref/pull/6898) - We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907). -- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog [#6934](https://github.com/JabRef/jabref/issues/6934). +- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog. [#6934](https://github.com/JabRef/jabref/issues/6934) - We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906). - We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX [#6970](https://github.com/JabRef/jabref/pull/6970). From d5e4f747f64012fc6eb569b9600bb39777b69533 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 3 Oct 2020 22:46:14 +0200 Subject: [PATCH 4/6] Update CHANGELOG.md Co-authored-by: Oliver Kopp --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf174752688..ca28dd060a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907). - We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog. [#6934](https://github.com/JabRef/jabref/issues/6934) - We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906). -- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX [#6970](https://github.com/JabRef/jabref/pull/6970). +- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX. [#6970](https://github.com/JabRef/jabref/pull/6970) ### Removed From 237cff7b16c22490f4cb4ae310ff7decf6200fc0 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 3 Oct 2020 22:52:00 +0200 Subject: [PATCH 5/6] add Logger for exception --- .../org/jabref/logic/openoffice/OpenOfficeFileSearch.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java index b17ceea34b1..309096b08cf 100644 --- a/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java +++ b/src/main/java/org/jabref/logic/openoffice/OpenOfficeFileSearch.java @@ -16,7 +16,12 @@ import org.jabref.logic.util.OS; import org.jabref.logic.util.io.FileUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class OpenOfficeFileSearch { + private static final Logger LOGGER = LoggerFactory.getLogger(OpenOfficeFileSearch.class); + /** * Detects existing installation of OpenOffice and LibreOffice. * @@ -45,6 +50,7 @@ private static List findOpenOfficeDirectories(List programDirectorie try { return Files.find(dirs, 1, filePredicate); } catch (IOException e) { + LOGGER.error("Problem searching for openoffice/libreoffice install directory", e); return Stream.empty(); } }).collect(Collectors.toList()); From 3856405b48f89d859f223cbf5b3c303567e19f72 Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 3 Oct 2020 22:56:37 +0200 Subject: [PATCH 6/6] fix changelog dot --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0d982bf750..44012b3400e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where the sort order of the entry table was reset after a restart of JabRef. [#6898](https://github.com/JabRef/jabref/pull/6898) - We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907). - We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog. [#6934](https://github.com/JabRef/jabref/issues/6934) -- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906). +- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog. [6906](https://github.com/JabRef/jabref/issues/6906) - We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX. [#6970](https://github.com/JabRef/jabref/pull/6970) - We fixed an issue with the python script used by browser plugins that failed to locate JabRef if not installed in its default location. [#6963](https://github.com/JabRef/jabref/pull/6963/files)