From b9613ed693c6d8bed6e8be065931b2c42e24714a Mon Sep 17 00:00:00 2001 From: Laura Radaelli Date: Tue, 27 Jun 2017 14:19:30 +0300 Subject: [PATCH] added summary screen after voting --- .../ChannelChoiceController.java | 20 ++- .../gui/controllersFX/VotingController.java | 68 +++++++++- .../main/resources/views/channel_choice.fxml | 5 +- .../src/main/resources/views/voting.fxml | 8 +- .../main/resources/views/welcome_screen.fxml | 122 ++++-------------- 5 files changed, 106 insertions(+), 117 deletions(-) diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/ChannelChoiceController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/ChannelChoiceController.java index bea9cf1..2cb8b66 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/ChannelChoiceController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/ChannelChoiceController.java @@ -31,8 +31,8 @@ public class ChannelChoiceController { String questionText; @FXML ToggleGroup answerGroup; - @FXML private Text question; - @FXML private Text warningMsg; +// @FXML private Text question; +// @FXML private Text warningMsg; @FXML private Pane questionPane; @FXML @@ -72,13 +72,17 @@ public class ChannelChoiceController { private void showCodeSelection() { questionText = "Here we show code pad."; - question.setText(questionText); + questionPane.getChildren().clear(); + Text txt = new Text(); + questionPane.getChildren().add(txt); + txt.setText(questionText); +// question.setText(questionText); } private void showQuestion() { Voting.BallotQuestion ballotQuestion = questions.get(index); questionText = "Please answer this question before voting:"; - question.setText(questionText); +// question.setText(questionText); answerGroup.getToggles().clear(); VBox vbox = VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup); questionPane.getChildren().clear(); @@ -87,8 +91,10 @@ public class ChannelChoiceController { private void showError() { questionText = "There was an error reading the channel, please go back to polling station."; - question.setText(questionText); - +// question.setText(questionText); + questionPane.getChildren().clear(); + Text txt = new Text(); + questionPane.getChildren().add(txt); } @FXML @@ -97,6 +103,8 @@ public class ChannelChoiceController { String s = answerGroup.getSelectedToggle().getUserData().toString(); answers.add(UIUtils.translateStringAnswerToProtoBufMessageAnswer(s)); } else { + Text warningMsg = new Text(); + questionPane.getChildren().add(0,warningMsg); warningMsg.setText("(Please give an answer to continue)"); } if (answers.size()!=0) { diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/VotingController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/VotingController.java index 917f670..42fd8d4 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/VotingController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/controllersFX/VotingController.java @@ -1,11 +1,21 @@ package meerkat.voting.gui.controllersFX; import javafx.fxml.FXML; +import javafx.geometry.HPos; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.Separator; import javafx.scene.control.ToggleGroup; +import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; import javafx.scene.text.Text; +import javafx.scene.text.TextAlignment; import meerkat.protobuf.Voting; +import meerkat.voting.VotingBooth; import meerkat.voting.controller.callbacks.VoterCancelThrowable; import meerkat.voting.gui.ui.UIUtils; import meerkat.voting.gui.ui.uicommands.RaceVotingUICommand; @@ -31,10 +41,10 @@ public class VotingController { RaceVotingUICommand command = (RaceVotingUICommand) VistaNavigator.getCurrentCommand(); @FXML ToggleGroup answerGroup; - @FXML private Text question; @FXML private Text currentPage; @FXML private Text totalPage; - @FXML private Pane questionPane; + @FXML private ScrollPane questionPane; + @FXML private Button nextButton; @FXML public void initialize() { @@ -56,11 +66,18 @@ public class VotingController { answers.add(UIUtils.translateStringAnswerToProtoBufMessageAnswer(s)); index++; } + if (nextButton.getText().equals("Confirm")) { + index++; + } if (index < questions.size()) { showQuestion(); } else { - //return answers to main threads - nextPane(); + if (index == questions.size()) { + showSummary(); + } else { + //return answers to main threads + nextPane(); + } } } @@ -70,10 +87,49 @@ public class VotingController { currentPage.setText("Page "+(index+1)); answerGroup.getToggles().clear(); VBox vbox = VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup); - questionPane.getChildren().clear(); - questionPane.getChildren().addAll(vbox); + nextButton.setText("Next"); + questionPane.setContent(vbox); + questionPane.setFitToHeight(true); + //questionPane.getChildren().clear(); +// questionPane.getChildren().addAll(vbox); } + private void showSummary() { +// Voting.BallotQuestion ballotQuestion = questions.get(index); + currentPage.setText("Page "+(index+1)); + answerGroup.getToggles().clear(); + VBox vbox = new VBox();//VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup); + vbox.setPrefWidth(questionPane.getPrefWidth()-30); + /*Set title of summary*/ + Text title = new Text("Almost done!"); + title.setFont(Font.font("System", FontWeight.BOLD, 24)); + vbox.getChildren().add(title); + /*Set subtitle of summary*/ + Text subtitle = new Text("Review your selections. If you are satisfied, press confirm."); + subtitle.setFont(Font.font("System", FontWeight.BOLD, 18)); + subtitle.setStyle("-fx-margin: 0 0 70 0;"); + vbox.getChildren().add(subtitle); + /*Create summery*/ + for (int i=0; i - - - - - - - - - - - - - - - - - - - - - - - -
- -
-
- - - - - - - - - - -
- -
-
- - - - -
-
-
-
- -
-
-
+ - +