diff --git a/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java b/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java index fd8b7af8..218b02df 100644 --- a/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java +++ b/app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java @@ -1,5 +1,6 @@ package com.dlsc.jfxcentral2.app.pages; +import com.dlsc.jfxcentral.data.DataRepository2; import com.dlsc.jfxcentral2.app.RepositoryManager; import com.dlsc.jfxcentral2.components.CustomImageView; import com.dlsc.jfxcentral2.components.Mode; @@ -21,7 +22,6 @@ import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; -import one.jpro.routing.LinkUtil; import one.jpro.routing.sessionmanager.SessionManager; import org.eclipse.jgit.lib.ProgressMonitor; @@ -29,12 +29,7 @@ public class RefreshPage extends PageBase { private final InvalidationListener invalidationListener = it -> { if (RepositoryManager.isRepositoryUpdated()) { - Platform.runLater(() -> { - SessionManager sessionManager = LinkUtil.getSessionManager(realContent()); - if (sessionManager != null) { - sessionManager.gotoURL("/"); - } - }); + Platform.runLater(() -> getSessionManager().gotoURL("/")); } }; @@ -43,10 +38,16 @@ public class RefreshPage extends PageBase { private Node updateView; private Node setupView; + private SessionManager sessionManager; + public RefreshPage(ObjectProperty size) { super(size, Mode.DARK); } + public SessionManager getSessionManager() { + return sessionManager; + } + @Override public String title() { return "JFXCentral Refresh"; @@ -68,6 +69,7 @@ public boolean fullscreen() { @Override public Node content() { + sessionManager = sessionManager(); Platform.runLater(() -> { RepositoryManager.repositoryUpdatedProperty().addListener(weakInvalidationListener); invalidationListener.invalidated(null); @@ -192,6 +194,7 @@ public void update(int completed) { @Override public void endTask() { + DataRepository2.getInstance().reload(); } @Override @@ -199,6 +202,7 @@ public boolean isCancelled() { return false; } })); + thread.setName("Repository Thread"); thread.setDaemon(true); thread.start(); diff --git a/sampler/src/main/java/com/dlsc/jfxcentral2/demo/components/HelloTermsAndConditionsView.java b/sampler/src/main/java/com/dlsc/jfxcentral2/demo/components/HelloTermsAndConditionsView.java index 43a1b388..17bcaf8a 100644 --- a/sampler/src/main/java/com/dlsc/jfxcentral2/demo/components/HelloTermsAndConditionsView.java +++ b/sampler/src/main/java/com/dlsc/jfxcentral2/demo/components/HelloTermsAndConditionsView.java @@ -15,14 +15,17 @@ import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Objects; public class HelloTermsAndConditionsView extends JFXCentralSampleBase { + private CustomMarkdownTabPane largeTabPane; private CustomMarkdownTabPane mediumTabPane; private CustomMarkdownTabPane smallTabPane; private final String termsText = readStrFromFile("/com/dlsc/jfxcentral2/demo/components/text/TermsAndConditions.txt"); private final String privacyText = readStrFromFile("/com/dlsc/jfxcentral2/demo/components/text/PrivacyPolicy.txt"); private final String cookieText = readStrFromFile("/com/dlsc/jfxcentral2/demo/components/text/CookiePolicy.txt"); + @Override protected Region createControl() { largeTabPane = createTabPane(Size.LARGE,2); @@ -50,7 +53,7 @@ private CustomMarkdownTabPane createTabPane(Size size, int selectedIndex) { private String readStrFromFile(String filePath) { String text = ""; try { - URI uri = getClass().getResource(filePath).toURI(); + URI uri = Objects.requireNonNull(getClass().getResource(filePath)).toURI(); text = Files.readString(Path.of(uri)); } catch (Exception e) { e.printStackTrace();