From 82c25a15b18353b70f0b445e7557a1cdb64e6549 Mon Sep 17 00:00:00 2001 From: HEdingfield Date: Wed, 5 Jun 2024 22:41:59 -0700 Subject: [PATCH] Fixes bug with `buttonOpenResultsClicked` not opening window to correct location in Windows; fit and finish. --- .../brightspots/rcv/GuiConfigController.java | 26 ++++++++++--------- .../rcv/GuiTabulateController.java | 15 ++++++----- .../brightspots/rcv/GuiTabulationPopup.fxml | 4 ++- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/main/java/network/brightspots/rcv/GuiConfigController.java b/src/main/java/network/brightspots/rcv/GuiConfigController.java index 3edf9a0c..e5afbc5a 100644 --- a/src/main/java/network/brightspots/rcv/GuiConfigController.java +++ b/src/main/java/network/brightspots/rcv/GuiConfigController.java @@ -513,22 +513,24 @@ public void menuItemTabulateClicked() { ContestConfig config = ContestConfig.loadContestConfig(createRawContestConfig(), FileUtils.getUserDirectory()); ValidatorService service = new ValidatorService(config); - service.setOnSucceeded(event -> { - setGuiIsBusy(false); - if (service.getValue()) { - openTabulateWindow(); - } else { - Logger.severe("Validation failed."); - } - }); + service.setOnSucceeded( + event -> { + setGuiIsBusy(false); + if (service.getValue()) { + openTabulateWindow(); + } else { + Logger.severe("Validation failed!"); + } + }); service.setOnCancelled(event -> { setGuiIsBusy(false); Logger.info("Validation canceled."); }); - service.setOnFailed(event -> { - setGuiIsBusy(false); - Logger.severe("Validation failed."); - }); + service.setOnFailed( + event -> { + setGuiIsBusy(false); + Logger.severe("Validation failed!"); + }); service.start(); } diff --git a/src/main/java/network/brightspots/rcv/GuiTabulateController.java b/src/main/java/network/brightspots/rcv/GuiTabulateController.java index 8971d896..c1563c8f 100644 --- a/src/main/java/network/brightspots/rcv/GuiTabulateController.java +++ b/src/main/java/network/brightspots/rcv/GuiTabulateController.java @@ -89,9 +89,9 @@ public class GuiTabulateController { /** Initialize the GUI with all information required for tabulation. */ public void initialize(GuiConfigController controller, int numCandidates, int numCvrs) { guiConfigController = controller; - numberOfCandidates.setText("Number of candidates: " + numCandidates); - numberOfCvrFiles.setText("Number of CVR files: " + numCvrs); - numberOfBallots.setText("Number of ballots: "); + numberOfCandidates.setText("Number of Candidates: " + numCandidates); + numberOfCvrFiles.setText("Number of CVR Files: " + numCvrs); + numberOfBallots.setText("Number of Ballots: "); numberOfBallots.setOpacity(0.5); filledFieldStyle = ""; unfilledFieldStyle = "-fx-border-color: red;"; @@ -120,10 +120,12 @@ public void nameUpdated(KeyEvent keyEvent) { * * @param actionEvent ignored */ - public void buttonloadCvrsClicked(ActionEvent actionEvent) { + public void buttonLoadCvrsClicked(ActionEvent actionEvent) { String configPath = getConfigPathOrCreateTempFile(); enableButtonsUpTo(null); + numberOfBallots.setText("Number of Ballots: "); + numberOfBallots.setOpacity(0.5); Service service = guiConfigController.parseAndCountCastVoteRecords(configPath); watchParseCvrServiceProgress(service); @@ -211,7 +213,7 @@ private void watchGenericService( Stage stage = ((Stage) window); stage.setOnCloseRequest(event -> event.consume()); - // This is a litle hacky -- we want two listeners on setOnSucceded, + // This is a little hacky -- we want two listeners on setOnSucceded, // so we enforce that this callback is added second. EventHandler originalCallback = service.getOnSucceeded(); if (originalCallback == null) { @@ -292,7 +294,8 @@ private String getConfigPathOrCreateTempFile() { ContestConfig config = ContestConfig.loadContestConfig(path); configOutputPath = config.getOutputDirectory(); - if (!configOutputPath.endsWith("/")) { + String os = System.getProperty("os.name").toLowerCase(); + if (!os.contains("win") && !configOutputPath.endsWith("/")) { configOutputPath += "/"; } diff --git a/src/main/resources/network/brightspots/rcv/GuiTabulationPopup.fxml b/src/main/resources/network/brightspots/rcv/GuiTabulationPopup.fxml index 3971f63f..76aabf3f 100644 --- a/src/main/resources/network/brightspots/rcv/GuiTabulationPopup.fxml +++ b/src/main/resources/network/brightspots/rcv/GuiTabulationPopup.fxml @@ -101,7 +101,9 @@ -