Skip to content

Commit

Permalink
fix(#197): stacked dialogs can be closed correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
DropSnorz committed Jul 3, 2023
1 parent 8e57087 commit a1bc785
Showing 1 changed file with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,29 @@
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.Stack;

@Component
public class DialogManager {

@Autowired
private MainController mainController;

private JFXDialog dialog;
private Stack<JFXDialog> dialogStack = new Stack<>();

/**
* Creates a new dialog.
*
* @return
*/
public JFXDialog newDialog() {
dialog = new JFXDialog();
JFXDialog dialog = new JFXDialog();
dialog.setDialogContainer(mainController.getRootPane());
dialogStack.push(dialog);

dialog.setOnDialogClosed(e -> {
dialogStack.pop();
});

return dialog;
}
Expand Down Expand Up @@ -124,7 +131,7 @@ public JFXDialog newDialog(double width, double height, Node body, Node heading)
*/
public JFXDialog newDialog(JFXDialogLayout layout) {

newDialog();
JFXDialog dialog = newDialog();
dialog.setContent(layout);
return dialog;
}
Expand All @@ -143,6 +150,7 @@ public JFXDialog newSimpleInfoDialog(String title, String body) {
*/
public JFXDialog newSimpleInfoDialog(Node title, Node body) {
JFXDialogLayout layout = new JFXDialogLayout();
JFXDialog dialog = newDialog(layout);

layout.setHeading(title);
layout.setBody(body);
Expand All @@ -154,12 +162,12 @@ public JFXDialog newSimpleInfoDialog(Node title, Node body) {
});

layout.setActions(button);
return newDialog(layout);
return dialog;

}

public JFXDialog getDialog() {
return dialog;
return dialogStack.peek();
}

}

0 comments on commit a1bc785

Please sign in to comment.