Add a close button to close all pages
This commit is contained in:
@@ -66,6 +66,11 @@ public class Navigator extends StackPane {
|
|||||||
close(stack.peek());
|
close(stack.peek());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
while (stack.size() > 1)
|
||||||
|
close(stack.peek());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void close(Node from) {
|
public void close(Node from) {
|
||||||
FXUtils.checkFxUserThread();
|
FXUtils.checkFxUserThread();
|
||||||
|
|||||||
@@ -204,10 +204,12 @@ public class DecoratorController {
|
|||||||
if (navigator.getCurrentPage() instanceof DecoratorPage) {
|
if (navigator.getCurrentPage() instanceof DecoratorPage) {
|
||||||
DecoratorPage page = (DecoratorPage) navigator.getCurrentPage();
|
DecoratorPage page = (DecoratorPage) navigator.getCurrentPage();
|
||||||
|
|
||||||
page.onForceToClose();
|
if (page.canForceToClose()) {
|
||||||
} else {
|
page.onForceToClose();
|
||||||
navigator.close();
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
navigator.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void back() {
|
private void back() {
|
||||||
@@ -249,14 +251,13 @@ public class DecoratorController {
|
|||||||
|
|
||||||
if (to instanceof DecoratorPage) {
|
if (to instanceof DecoratorPage) {
|
||||||
decorator.drawerTitleProperty().bind(((DecoratorPage) to).titleProperty());
|
decorator.drawerTitleProperty().bind(((DecoratorPage) to).titleProperty());
|
||||||
decorator.canCloseProperty().set(((DecoratorPage) to).canForceToClose());
|
|
||||||
} else {
|
} else {
|
||||||
decorator.drawerTitleProperty().unbind();
|
decorator.drawerTitleProperty().unbind();
|
||||||
decorator.drawerTitleProperty().set("");
|
decorator.drawerTitleProperty().set("");
|
||||||
decorator.canCloseProperty().set(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
decorator.canBackProperty().set(navigator.canGoBack());
|
decorator.canBackProperty().set(navigator.canGoBack());
|
||||||
|
decorator.canCloseProperty().set(navigator.canGoBack());
|
||||||
|
|
||||||
if (navigator.canGoBack()) {
|
if (navigator.canGoBack()) {
|
||||||
decorator.setContentBackground(new Background(new BackgroundFill(Color.rgb(244, 244, 244, 0.5), CornerRadii.EMPTY, Insets.EMPTY)));
|
decorator.setContentBackground(new Background(new BackgroundFill(Color.rgb(244, 244, 244, 0.5), CornerRadii.EMPTY, Insets.EMPTY)));
|
||||||
|
|||||||
Reference in New Issue
Block a user