Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ jobs:
- image: circleci/openjdk:8-jdk
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
keys:
- install4j-{{ checksum "scripts/extract-install4j.sh" }}
Expand All @@ -26,6 +28,8 @@ jobs:
- restore_cache:
key: dependency-cache
- checkout
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
key: install4j-{{ checksum "scripts/extract-install4j.sh" }}
- run: scripts/extract-install4j.sh
Expand All @@ -47,6 +51,8 @@ jobs:
- restore_cache:
key: dependency-cache
- checkout
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
key: install4j-{{ checksum "scripts/extract-install4j.sh" }}
- run: scripts/extract-install4j.sh
Expand Down
32 changes: 18 additions & 14 deletions src/main/java/org/jabref/gui/util/ThemeLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
Expand Down Expand Up @@ -73,7 +73,6 @@ public ThemeLoader(FileUpdateMonitor fileUpdateMonitor, JabRefPreferences jabRef
}
}


/**
* Installs the base css file as a stylesheet in the given scene. Changes in the css file lead to a redraw of the
* scene using the new css file.
Expand All @@ -89,18 +88,23 @@ 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 a resource part of a .jar bundle), we watch it for changes and turn on live reloading
Path cssPath = Paths.get(cssFile.toURI());
if (Files.isRegularFile(cssPath)) {
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());
}
);
});

URI cssUri = cssFile.toURI();
if (!cssUri.toString().contains("jar")) {
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());
});
});
}
}
} catch (IOException | URISyntaxException e) {
LOGGER.error("Could not watch css file for changes " + cssFile, e);
Expand Down