From c8ca3d207c6a5da4eee983aa1616eeb0613edce7 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 Oct 2019 18:00:48 +0200 Subject: [PATCH 1/2] Fix error message related to themeloader Fixes the error message > ERROR ThemeLoader Could not watch css file for changes jrt:/org.jabref/org/jabref/gui/Base.css when starting JabRef. --- .../java/org/jabref/gui/util/ThemeLoader.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jabref/gui/util/ThemeLoader.java b/src/main/java/org/jabref/gui/util/ThemeLoader.java index 567bd939c4f..6c8d4e0225e 100644 --- a/src/main/java/org/jabref/gui/util/ThemeLoader.java +++ b/src/main/java/org/jabref/gui/util/ThemeLoader.java @@ -88,23 +88,20 @@ private void addAndWatchForChanges(Scene scene, URL cssFile, int index) { scene.getStylesheets().add(index, cssFile.toExternalForm()); try { - + // If the file is an ordinary file (i.e. not part of a java runtime bundle), we watch it for changes and turn on live reloading URI cssUri = cssFile.toURI(); - if (!cssUri.toString().contains("jar")) { + if (!cssUri.toString().contains("jrt")) { LOGGER.debug("CSS URI {}", cssUri); Path cssPath = Paths.get(cssUri).toAbsolutePath(); - // If the file is an ordinary file (i.e. not a resource part of a .jar bundle), we watch it for changes and turn on live reloading - if (!cssUri.toString().contains("jar")) { - LOGGER.info("Enabling live reloading of {}", cssPath); - fileUpdateMonitor.addListenerForFile(cssPath, () -> { - LOGGER.info("Reload css file " + cssFile); - DefaultTaskExecutor.runInJavaFXThread(() -> { - scene.getStylesheets().remove(cssFile.toExternalForm()); - scene.getStylesheets().add(index, cssFile.toExternalForm()); - }); + LOGGER.info("Enabling live reloading of {}", cssPath); + fileUpdateMonitor.addListenerForFile(cssPath, () -> { + LOGGER.info("Reload css file " + cssFile); + DefaultTaskExecutor.runInJavaFXThread(() -> { + scene.getStylesheets().remove(cssFile.toExternalForm()); + scene.getStylesheets().add(index, cssFile.toExternalForm()); }); - } + }); } } catch (IOException | URISyntaxException | UnsupportedOperationException e) { LOGGER.error("Could not watch css file for changes " + cssFile, e); From cb4752ffb6f6f0f2ca2c91e7576509d002c05bac Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sat, 12 Oct 2019 12:14:38 +0200 Subject: [PATCH 2/2] Update ThemeLoader.java --- src/main/java/org/jabref/gui/util/ThemeLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/util/ThemeLoader.java b/src/main/java/org/jabref/gui/util/ThemeLoader.java index 6c8d4e0225e..17065eb74a1 100644 --- a/src/main/java/org/jabref/gui/util/ThemeLoader.java +++ b/src/main/java/org/jabref/gui/util/ThemeLoader.java @@ -96,7 +96,7 @@ private void addAndWatchForChanges(Scene scene, URL cssFile, int index) { Path cssPath = Paths.get(cssUri).toAbsolutePath(); LOGGER.info("Enabling live reloading of {}", cssPath); fileUpdateMonitor.addListenerForFile(cssPath, () -> { - LOGGER.info("Reload css file " + cssFile); + LOGGER.info("Reload css file {}", cssFile); DefaultTaskExecutor.runInJavaFXThread(() -> { scene.getStylesheets().remove(cssFile.toExternalForm()); scene.getStylesheets().add(index, cssFile.toExternalForm());