diff --git a/pom.xml b/pom.xml index 8c7be89..b1d4388 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.andrewlalis javafx-scene-router - 1.1.1 + 1.2.0 JavaFX Scene Router A library that provides a router implementation for JavaFX, for browser-like navigation between pages. https://github.com/andrewlalis/javafx-scene-router diff --git a/src/main/java/com/andrewlalis/javafx_scene_router/SceneRouter.java b/src/main/java/com/andrewlalis/javafx_scene_router/SceneRouter.java index 5852f9a..fd4a2d8 100644 --- a/src/main/java/com/andrewlalis/javafx_scene_router/SceneRouter.java +++ b/src/main/java/com/andrewlalis/javafx_scene_router/SceneRouter.java @@ -1,6 +1,9 @@ package com.andrewlalis.javafx_scene_router; import javafx.application.Platform; +import javafx.beans.property.ListProperty; +import javafx.beans.property.SimpleListProperty; +import javafx.collections.ObservableList; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.layout.Pane; @@ -34,6 +37,7 @@ public class SceneRouter { private final Pane viewPane = new Pane(); private final Map routeMap = new HashMap<>(); private final RouteHistory history = new RouteHistory(); + private final ListProperty breadCrumbs = new SimpleListProperty<>(); /** * Constructs the router. @@ -139,14 +143,29 @@ public class SceneRouter { return viewPane; } + /** + * Gets an observable list of {@link BreadCrumb} that is updated each time + * the router's navigation history is updated. + * @return The list of breadcrumbs. + */ + public ObservableList getBreadCrumbs() { + return breadCrumbs; + } + private Parent getMappedNode(String route) { Parent node = routeMap.get(route); if (node == null) throw new IllegalArgumentException("Route " + route + " is not mapped to any node."); return node; } + /** + * Internal method to actually set this router's view pane to a particular + * node. This is called any time a route changes. + * @param node The node to set. + */ private void setCurrentNode(Parent node) { viewPane.getChildren().setAll(node); + breadCrumbs.setAll(history.getBreadCrumbs()); } private Parent loadNode(URL resource, Consumer controllerCustomizer) {