Skip to content

Commit 81fa90a

Browse files
committed
#32 setting dialog on top without knowledge of other stage
1 parent 624adb0 commit 81fa90a

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/main/java/de/doubleslash/keeptime/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ private void initialisePopupUI(final Stage primaryStage) throws IOException {
221221
// Give the controller access to the main app.
222222
popupViewStage.setAlwaysOnTop(true);
223223
final ViewControllerPopup viewControllerPopupController = loader.getController();
224-
viewControllerPopupController.setMainStage(primaryStage);
225224
viewControllerPopupController.setStage(popupViewStage);
226225
viewControllerPopupController.setControllerAndModel(controller, model);
227226
globalScreenListener.setViewController(viewControllerPopupController);

src/main/java/de/doubleslash/keeptime/viewpopup/ViewControllerPopup.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,18 @@ public class ViewControllerPopup {
4848

4949
@FXML
5050
private TextField searchTextField;
51+
5152
@FXML
5253
private ListView<Project> projectListView;
5354

5455
private Stage stage;
55-
private Stage mainStage;
5656

5757
private Controller controller;
5858

5959
private Model model;
6060

6161
private FilteredList<Project> filteredData;
6262

63-
public void setMainStage(final Stage mainStage) {
64-
this.mainStage = mainStage;
65-
}
66-
6763
private void changeProject(final Project item) {
6864
LOG.info("Change project to '{}'.", item.getName());
6965

@@ -74,11 +70,10 @@ private void changeProject(final Project item) {
7470
"Add a note for '" + model.activeWorkItem.get().getProject().getName() + "' before changing project?");
7571
dialog.setContentText("Note: ");
7672

77-
mainStage.setAlwaysOnTop(false);
78-
this.stage.setAlwaysOnTop(true);
73+
final Stage dialogStage = (Stage) dialog.getDialogPane().getScene().getWindow();
74+
dialogStage.setAlwaysOnTop(true);
75+
7976
final Optional<String> result = dialog.showAndWait();
80-
this.stage.setAlwaysOnTop(false);
81-
mainStage.setAlwaysOnTop(true);
8277

8378
result.ifPresent(note -> {
8479
controller.setComment(note);

0 commit comments

Comments
 (0)