From 94adef22f3d612407ade5d207f35354e42fa9646 Mon Sep 17 00:00:00 2001 From: VladimirEliTokarev Date: Wed, 5 Oct 2016 16:48:30 +0300 Subject: [PATCH] Added the thank for auditing pannel --- .../voting/gui/managment/ChainBuilder.java | 34 +++++++++----- .../ballot_summary/VotersChoicesAdder.java | 2 +- .../cast_or_audit/CastOrAuditController.java | 8 ++++ .../cast_or_audit/CastOrAuditLoader.java | 2 +- .../PicturesAnswersUpdater.java | 3 +- .../SelectCandidateByPictureController.java | 1 - .../SelectCandidateNameController.java | 1 - .../StringsAnswersUpdater.java | 4 +- .../StraightChannelSectionController.java | 1 - .../ThankForAuditingController.java | 25 ++++++++++ .../ThankForAuditingLoader.java | 47 +++++++++++++++++++ .../main/resources/view/cast_or_audit.fxml | 2 +- .../resources/view/thank_for_auditing.fxml | 4 +- 13 files changed, 110 insertions(+), 24 deletions(-) create mode 100644 voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingController.java create mode 100644 voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingLoader.java diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java index 3175748..ba139d1 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/managment/ChainBuilder.java @@ -6,6 +6,7 @@ import meerkat.voting.gui.panels.cast_or_audit.CastOrAuditLoader; import meerkat.voting.gui.panels.select_candidate_by_picture.SelectCandidateByPictureLoader; import meerkat.voting.gui.panels.select_candidate_name.SelectCandidateNameLoader; import meerkat.voting.gui.panels.straight_channel_section.StraightChannelSectionLoader; +import meerkat.voting.gui.panels.thank_for_audditing.ThankForAuditingLoader; import meerkat.voting.gui.panels.vote_have_been_cast.VoteHaveBeenCastLoader; import meerkat.voting.gui.panels.welcome_splash.WelcomeSplashLoader; import meerkat.voting.gui.configuration.VotingBoothConfiguration; @@ -25,19 +26,19 @@ class ChainBuilder { * Creates all the twoWayNodes and connects between them * * The flow of Voting booth gui is next - * Welcome Splash screen - * \/ - * Channel selection screen - * \/ - * Select Candidate Name screen - * \/ /\ - * Select candidate by picture screen - * \/ /\ - * Ballot summary no pictures - * \/ - * Cast Or audit screen - * \/ - * thank you for screen + * Welcome Splash screen + * \/ + * Channel selection screen + * \/ + * Select Candidate Name screen + * \/ /\ + * Select candidate by picture screen + * \/ /\ + * Ballot summary no pictures + * \/ + * Cast Or audit screen + * \/ \/ + * thank for voting thank for auditing * In order to maintain this order next technique was implemented every "screen" will have the next screen * and the previous this way the flow between will be easy . * The Build method creates all the screens and connect between them @@ -74,10 +75,16 @@ class ChainBuilder { ballotSummaryController.SetPrevious(selectCandidateByPictureController); selectCandidateByPictureController.SetNext(ballotSummaryController); + ThankForAuditingLoader thankForAuditingLoader = new ThankForAuditingLoader(primaryStage, configuration); + TwoWayNode thankForAuditingController = thankForAuditingLoader.GetThankForAuditing(); + thankForAuditingController.SetVotersBallot(votersBallot); + thankForAuditingController.SetPrevious(welcomeSplashController); + CastOrAuditLoader castOrAuditLoader = new CastOrAuditLoader(primaryStage, configuration); TwoWayNode castOrAuditController = castOrAuditLoader.GetCastOrAudit(); castOrAuditController.SetVotersBallot(votersBallot); ballotSummaryController.SetNext(castOrAuditController); + castOrAuditController.SetPrevious(thankForAuditingController); VoteHaveBeenCastLoader voteHaveBeenCastLoader = new VoteHaveBeenCastLoader(primaryStage, configuration); TwoWayNode voteHaveBeenCastController = voteHaveBeenCastLoader.GetVoteHaveBeenCast(); @@ -97,6 +104,7 @@ class ChainBuilder { nameToTwoWayNodeMap.put("selectCandidateByPictureController", selectCandidateByPictureController); nameToTwoWayNodeMap.put("ballotSummaryController", ballotSummaryController); nameToTwoWayNodeMap.put("voteHaveBeenCastController", voteHaveBeenCastController); + nameToTwoWayNodeMap.put("thankForAuditing", thankForAuditingController); return nameToTwoWayNodeMap; } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java index 5916f00..05be003 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/ballot_summary/VotersChoicesAdder.java @@ -51,7 +51,7 @@ public class VotersChoicesAdder { * Remove all previous binaryDatas from the container */ private void RemoveAllAnswers() { - this.GetAnswersContainer().getChildren().removeAll(); + this.GetAnswersContainer().getChildren().remove(0, this.GetAnswersContainer().getChildren().size()); } /** diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditController.java index bd59780..202b012 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditController.java @@ -18,6 +18,14 @@ public class CastOrAuditController extends TwoWayNode { this.currentStage.show(); } + @FXML + private void GetToThankForAuditing(MouseEvent mousePressed) { + this.currentStage.close(); + this.currentStage.setScene(this.previous.GetCurrentScene()); + this.previous.UpdateNode(); + this.currentStage.show(); + } + @Override public void UpdateNode() { // Maybe one of the buttons should be disabled ? diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditLoader.java index 1bcffbf..428d55c 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/cast_or_audit/CastOrAuditLoader.java @@ -28,7 +28,7 @@ public class CastOrAuditLoader { /** * Creates welcome splash parent node and sets it to the controller - * @return TwoWayNode + * @return TwoWayNode controller.SetCurrentScene(thankForAuditing); * @throws IOException */ public TwoWayNode GetCastOrAudit() throws IOException { diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/PicturesAnswersUpdater.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/PicturesAnswersUpdater.java index 384000d..74c72a5 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/PicturesAnswersUpdater.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/PicturesAnswersUpdater.java @@ -81,9 +81,10 @@ class PicturesAnswersUpdater implements EventHandler{ * Remove all previous binaryDatas from the container */ private void RemoveAllAnswers() { - this.GetAnswersContainer().getChildren().removeAll(); + this.GetAnswersContainer().getChildren().remove(0, this.GetAnswersContainer().getChildren().size()); } + /** * Creates binaryData element which is grid pane with the binaryData and check box * diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/SelectCandidateByPictureController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/SelectCandidateByPictureController.java index d878499..abd865b 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/SelectCandidateByPictureController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_by_picture/SelectCandidateByPictureController.java @@ -45,7 +45,6 @@ public class SelectCandidateByPictureController extends TwoWayNode implements Fu @Override public void onSuccess(ByteString result) { this.votersBallot.VotersImageSelection = result; - System.out.println(this.votersBallot.Votershannel +" "+this.votersBallot.VotersNameSelection +" "+ this.votersBallot.VotersImageSelection); } @Override diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/SelectCandidateNameController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/SelectCandidateNameController.java index 7e0752e..ad78d13 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/SelectCandidateNameController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/SelectCandidateNameController.java @@ -43,7 +43,6 @@ public class SelectCandidateNameController extends TwoWayNode implements FutureC @Override public void onSuccess(String result) { this.votersBallot.VotersNameSelection = result; - System.out.println(this.votersBallot.Votershannel +" "+this.votersBallot.VotersNameSelection +" "+ this.votersBallot.VotersImageSelection); } @Override diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/StringsAnswersUpdater.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/StringsAnswersUpdater.java index 7e5c57c..f4b4cfa 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/StringsAnswersUpdater.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/select_candidate_name/StringsAnswersUpdater.java @@ -49,8 +49,8 @@ class StringsAnswersUpdater implements javafx.event.EventHandler{ /** * Remove all previous answers from the container */ - private void RemoveAllAnswers(){ - this.GetAnswersContainer().getChildren().removeAll(); + private void RemoveAllAnswers() { + this.GetAnswersContainer().getChildren().remove(0, this.GetAnswersContainer().getChildren().size() ); } /** diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java index 349a4c2..22bb1eb 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/straight_channel_section/StraightChannelSectionController.java @@ -46,7 +46,6 @@ public class StraightChannelSectionController extends TwoWayNode { */ private void UpdateVotersChoise(){ this.votersBallot.Votershannel = this.chanelValue; - System.out.println(this.votersBallot.Votershannel +" "+this.votersBallot.VotersNameSelection +" "+ this.votersBallot.VotersImageSelection); } /** diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingController.java new file mode 100644 index 0000000..52a1eea --- /dev/null +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingController.java @@ -0,0 +1,25 @@ +package meerkat.voting.gui.panels.thank_for_audditing; + +import javafx.fxml.FXML; +import javafx.scene.input.MouseEvent; +import meerkat.voting.gui.managment.TwoWayNode; + +/** + * Created by Vladimir Eliezer Tokarev on 10/5/2016. + * Representing that the vote have been given for auditing + */ +public class ThankForAuditingController extends TwoWayNode { + + @FXML + private void GetBackToStart(MouseEvent boutonPressed) { + this.currentStage.close(); + this.currentStage.setScene(this.previous.GetCurrentScene()); + this.previous.UpdateNode(); + this.currentStage.show(); + } + + @Override + public void UpdateNode() { + // Should do nothing really + } +} diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingLoader.java new file mode 100644 index 0000000..f61dde5 --- /dev/null +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/panels/thank_for_audditing/ThankForAuditingLoader.java @@ -0,0 +1,47 @@ +package meerkat.voting.gui.panels.thank_for_audditing; + +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.stage.Stage; +import meerkat.voting.gui.configuration.VotingBoothConfiguration; +import meerkat.voting.gui.managment.TwoWayNode; + +import java.io.IOException; + +/** + * Created by Vladimir Eliezer Tokarev on 10/5/2016. + * This class load the pannel that represent the thank u message + */ +public class ThankForAuditingLoader { + private static final String THANK_FOR_AUDITING_FXML_PATH = "/view/thank_for_auditing.fxml"; + + private Stage currentStage; + private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; + + public ThankForAuditingLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException + { + this.fxmlLoader = new FXMLLoader(getClass().getResource(THANK_FOR_AUDITING_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; + } + + /** + * Creates welcome splash parent node and sets it to the controller + * @return TwoWayNode + * @throws IOException + */ + public TwoWayNode GetThankForAuditing() throws IOException { + Parent thankForAuditing = fxmlLoader.load(); + ThankForAuditingController controller = fxmlLoader.getController(); + + // set the controller to be functional TwoWayNode + controller.SetCurrentScene(thankForAuditing); + controller.SetStage(currentStage); + + // set the controller to have the configuration file + controller.SetConfig(this.config); + + return controller; + } +} diff --git a/voting-booth-gui/src/main/resources/view/cast_or_audit.fxml b/voting-booth-gui/src/main/resources/view/cast_or_audit.fxml index a64f674..1777567 100644 --- a/voting-booth-gui/src/main/resources/view/cast_or_audit.fxml +++ b/voting-booth-gui/src/main/resources/view/cast_or_audit.fxml @@ -41,7 +41,7 @@ -