Skip to content

Commit

Permalink
Ask to save the current layout when closing shuffleboard
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCarlberg committed Nov 21, 2017
1 parent f669518 commit db3f3ef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,11 @@
/* Bring the content to all edges */
-fx-padding: 0; /* 10 0 0 10 */
}

.dialog-pane .header-panel {
-fx-background-color: -swatch-500;
}

.dialog-pane .header-panel .label {
-fx-text-fill: white;
}
21 changes: 21 additions & 0 deletions app/src/main/java/edu/wpi/first/shuffleboard/app/Shuffleboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.ButtonType;
import javafx.scene.layout.Pane;
import javafx.stage.Screen;
import javafx.stage.Stage;
Expand Down Expand Up @@ -90,6 +92,25 @@ public void start(Stage primaryStage) throws IOException {
primaryStage.setMinHeight(480);
primaryStage.setWidth(Screen.getPrimary().getVisualBounds().getWidth());
primaryStage.setHeight(Screen.getPrimary().getVisualBounds().getHeight());
primaryStage.setOnCloseRequest(closeEvent -> {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.getDialogPane().getScene().getStylesheets().setAll(mainPane.getStylesheets());
alert.getButtonTypes().setAll(ButtonType.YES, ButtonType.NO, ButtonType.CANCEL);
alert.getDialogPane().setHeaderText("Save the current layout?");
alert.showAndWait().ifPresent(bt -> {
if (bt == ButtonType.YES) {
try {
mainWindowController.save();
} catch (IOException ex) {
logger.log(Level.WARNING, "Could not save the layout", ex);
}
} else if (bt == ButtonType.CANCEL) {
// cancel the close request by consuming the event
closeEvent.consume();
}
// Don't need to check for NO because it just lets the window close normally
});
});
primaryStage.show();
Time.setStartTime(Time.now());
}
Expand Down

0 comments on commit db3f3ef

Please sign in to comment.