Skip to content

Commit

Permalink
Merge pull request #466 from dlsc-software-consulting-gmbh/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dlemmermann authored Sep 6, 2023
2 parents 0254088 + 8f86438 commit dcd167b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
18 changes: 11 additions & 7 deletions app/src/main/java/com/dlsc/jfxcentral2/app/pages/RefreshPage.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,20 +22,14 @@
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;

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("/"));
}
};

Expand All @@ -43,10 +38,16 @@ public class RefreshPage extends PageBase {
private Node updateView;
private Node setupView;

private SessionManager sessionManager;

public RefreshPage(ObjectProperty<Size> size) {
super(size, Mode.DARK);
}

public SessionManager getSessionManager() {
return sessionManager;
}

@Override
public String title() {
return "JFXCentral Refresh";
Expand All @@ -68,6 +69,7 @@ public boolean fullscreen() {

@Override
public Node content() {
sessionManager = sessionManager();
Platform.runLater(() -> {
RepositoryManager.repositoryUpdatedProperty().addListener(weakInvalidationListener);
invalidationListener.invalidated(null);
Expand Down Expand Up @@ -192,13 +194,15 @@ public void update(int completed) {

@Override
public void endTask() {
DataRepository2.getInstance().reload();
}

@Override
public boolean isCancelled() {
return false;
}
}));

thread.setName("Repository Thread");
thread.setDaemon(true);
thread.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit dcd167b

Please sign in to comment.