Skip to content

Commit

Permalink
Fix error message related to themeloader (#5429)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tobiasdiez committed Oct 12, 2019
1 parent 77431ea commit b6c2663
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/main/java/org/jabref/gui/util/ThemeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit b6c2663

Please sign in to comment.