From b6c266377ae157f0c922eda418c2c8a367c68fb2 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sat, 12 Oct 2019 12:14:49 +0200 Subject: [PATCH] Fix error message related to themeloader (#5429) * 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. * Update ThemeLoader.java --- .../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..17065eb74a1 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);