Skip to content

Commit

Permalink
Add submodule pull to circle ci and fix theme loading css (#4443)
Browse files Browse the repository at this point in the history
* Add submodule pull to circle ci

* align again

* fix submodule checkout according to doc

* add null check for theme loading paths get

* fix theme loading css errors
  • Loading branch information
Siedlerchr authored Nov 1, 2018
1 parent 32b580d commit 11ddb8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
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

0 comments on commit 11ddb8c

Please sign in to comment.