Skip to content

Commit

Permalink
Fixes bug with buttonOpenResultsClicked not opening window to corre…
Browse files Browse the repository at this point in the history
…ct location in Windows; fit and finish.
  • Loading branch information
HEdingfield committed Jun 6, 2024
1 parent 85c4e51 commit 82c25a1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
26 changes: 14 additions & 12 deletions src/main/java/network/brightspots/rcv/GuiConfigController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
15 changes: 9 additions & 6 deletions src/main/java/network/brightspots/rcv/GuiTabulateController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Check ballot counts to load>");
numberOfCandidates.setText("Number of Candidates: " + numCandidates);
numberOfCvrFiles.setText("Number of CVR Files: " + numCvrs);
numberOfBallots.setText("Number of Ballots: <Awaiting count>");
numberOfBallots.setOpacity(0.5);
filledFieldStyle = "";
unfilledFieldStyle = "-fx-border-color: red;";
Expand Down Expand Up @@ -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: <Counting...>");
numberOfBallots.setOpacity(0.5);
Service<LoadedCvrData> service = guiConfigController.parseAndCountCastVoteRecords(configPath);

watchParseCvrServiceProgress(service);
Expand Down Expand Up @@ -211,7 +213,7 @@ private <T> 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<WorkerStateEvent> originalCallback = service.getOnSucceeded();
if (originalCallback == null) {
Expand Down Expand Up @@ -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 += "/";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@
<ProgressBar fx:id="progressBar" layoutX="19.0" layoutY="429.0" prefHeight="20.0" prefWidth="563.0" progress="0.0" />
<HBox layoutX="21.0" layoutY="367.0" prefHeight="42.0" prefWidth="556.0" spacing="20.0">
<children>
<Button fx:id="loadCvrButton" defaultButton="true" disable="true" mnemonicParsing="false" onAction="#buttonloadCvrsClicked" prefHeight="42.0" prefWidth="200.0" text="Check Ballot Counts" />
<Button fx:id="loadCvrButton" defaultButton="true" disable="true"
mnemonicParsing="false" onAction="#buttonLoadCvrsClicked" prefHeight="42.0"
prefWidth="200.0" text="Check Ballot Counts"/>
<Text layoutY="21.0" strokeType="OUTSIDE" strokeWidth="0.0" text="&gt;" textAlignment="CENTER" translateY="11.0" />
<Button fx:id="tabulateButton" defaultButton="true" disable="true" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#buttonTabulateClicked" prefHeight="42.0" prefWidth="200.0" text="Tabulate" />
<Text strokeType="OUTSIDE" strokeWidth="0.0" text="&gt;" textAlignment="CENTER" translateY="11.0" />
Expand Down

0 comments on commit 82c25a1

Please sign in to comment.