diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/ChainBuilder.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/ChainBuilder.java index 30932c9..8cefdf6 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/ChainBuilder.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/ChainBuilder.java @@ -41,36 +41,36 @@ class ChainBuilder { * and the previous this way the flow between will be easy . * The Build method creates all the screens and connect between them */ - static Map Build(Stage primaryStage) throws IOException { - WelcomeSplashLoader welcomeSplashLoader = new WelcomeSplashLoader(primaryStage); + static Map Build(Stage primaryStage, VotingBoothConfiguration configuration) throws IOException { + WelcomeSplashLoader welcomeSplashLoader = new WelcomeSplashLoader(primaryStage, configuration); TwoWayNode welcomeSplashController = welcomeSplashLoader.GetWelcomeSplash(); - StraightChannelSectionLoader straightChannelSectionLoader = new StraightChannelSectionLoader(primaryStage); + StraightChannelSectionLoader straightChannelSectionLoader = new StraightChannelSectionLoader(primaryStage, configuration); TwoWayNode straightChannelSectionController = straightChannelSectionLoader.GetStraightChannelSection(); welcomeSplashController.SetNext(straightChannelSectionController); straightChannelSectionController.SetPrevious(welcomeSplashController); - SelectCandidateNameLoader selectCandidateNameLoader = new SelectCandidateNameLoader(primaryStage); + SelectCandidateNameLoader selectCandidateNameLoader = new SelectCandidateNameLoader(primaryStage, configuration); TwoWayNode selectCandidateNameController = selectCandidateNameLoader.GetSelectCandidateName(); selectCandidateNameController.SetPrevious(straightChannelSectionController); straightChannelSectionController.SetNext(selectCandidateNameController); SelectCandidateByPictureLoader selectCandidateByPictureLoader = - new SelectCandidateByPictureLoader(primaryStage); + new SelectCandidateByPictureLoader(primaryStage,configuration); TwoWayNode selectCandidateByPictureController = selectCandidateByPictureLoader.GetSelectCandidateByPicture(); selectCandidateByPictureController.SetPrevious(selectCandidateNameController); selectCandidateNameController.SetNext(selectCandidateByPictureController); - BallotSummaryLoader ballotSummaryLoader = new BallotSummaryLoader(primaryStage); + BallotSummaryLoader ballotSummaryLoader = new BallotSummaryLoader(primaryStage, configuration); TwoWayNode ballotSummaryController = ballotSummaryLoader.GetBallotSummary(); ballotSummaryController.SetPrevious(selectCandidateByPictureController); selectCandidateByPictureController.SetNext(ballotSummaryController); - CastOrAuditLoader castOrAuditLoader = new CastOrAuditLoader(primaryStage); + CastOrAuditLoader castOrAuditLoader = new CastOrAuditLoader(primaryStage, configuration); TwoWayNode castOrAuditController = castOrAuditLoader.GetCastOrAudit(); ballotSummaryController.SetNext(castOrAuditController); - VoteHaveBeenCastLoader voteHaveBeenCastLoader = new VoteHaveBeenCastLoader(primaryStage); + VoteHaveBeenCastLoader voteHaveBeenCastLoader = new VoteHaveBeenCastLoader(primaryStage, configuration); TwoWayNode voteHaveBeenCastController = voteHaveBeenCastLoader.GetVoteHaveBeenCast(); castOrAuditController.SetNext(voteHaveBeenCastController); diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/Main.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/Main.java index 7aa7551..5bd2223 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/Main.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/Main.java @@ -14,7 +14,8 @@ public class Main extends Application { @Override public void start(Stage primaryStage) throws Exception { - ChainBuilder.Build(primaryStage); + VotingBoothConfiguration config = new VotingBoothConfiguration(); + ChainBuilder.Build(primaryStage, config); primaryStage.setTitle("Meerkat Polling Station"); primaryStage.show(); } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/TwoWayNode.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/TwoWayNode.java index 897f213..ce0320a 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/TwoWayNode.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/TwoWayNode.java @@ -14,6 +14,7 @@ public abstract class TwoWayNode { protected Scene previous; protected Stage currentStage; protected Scene currentNode; + protected VotingBoothConfiguration config; /** * Sets which next TwoWayNode @@ -54,4 +55,12 @@ public abstract class TwoWayNode { public Scene GetNode() { return this.currentNode; } + + /** + * Sets the configuration for the controller + * @param config VotingBoothConfiguration object that have questions etc... + */ + public void SetConfig(VotingBoothConfiguration config) { + this.config = config; + } } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/VotingBoothConfiguration.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/VotingBoothConfiguration.java index f303307..d9a7a7f 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/VotingBoothConfiguration.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/VotingBoothConfiguration.java @@ -5,5 +5,5 @@ package meerkat.voting.gui; * This object contains all the questions and configurations needed for the voting-booth-gui work */ public class VotingBoothConfiguration { - + // will have fields that represent different question and their answers and decription tools } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryLoader.java index 928b015..9fc5edc 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryLoader.java @@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; import java.io.IOException; @@ -16,11 +17,13 @@ public class BallotSummaryLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public BallotSummaryLoader(Stage primaryStage) throws IOException + public BallotSummaryLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(BALLOT_SUMMARY_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(BALLOT_SUMMARY_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -36,6 +39,9 @@ public class BallotSummaryLoader { controller.SetParent(ballotSummary); 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/java/meerkat/voting/gui/cast_or_audit/CastOrAuditLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditLoader.java index fdab41f..689101f 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditLoader.java @@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; import java.io.IOException; @@ -16,11 +17,13 @@ public class CastOrAuditLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public CastOrAuditLoader(Stage primaryStage) throws IOException + public CastOrAuditLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(CAST_OR_AUDIT_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(CAST_OR_AUDIT_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -36,6 +39,9 @@ public class CastOrAuditLoader { controller.SetParent(castOrAudit); 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/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureLoader.java index ccac32b..1dbc40d 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureLoader.java @@ -4,6 +4,8 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; + import java.io.IOException; /** * Created by Vladimir Eliezer Tokarev on 8/27/2016. @@ -15,11 +17,13 @@ public class SelectCandidateByPictureLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public SelectCandidateByPictureLoader(Stage primaryStage) throws IOException + public SelectCandidateByPictureLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(SELECT_CANDIDATE_BY_PICTURE_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(SELECT_CANDIDATE_BY_PICTURE_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -35,6 +39,9 @@ public class SelectCandidateByPictureLoader { controller.SetParent(selectByPicture); 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/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameLoader.java index b1b30f8..09ca249 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameLoader.java @@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; import java.io.IOException; @@ -16,11 +17,13 @@ public class SelectCandidateNameLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public SelectCandidateNameLoader(Stage primaryStage) throws IOException + public SelectCandidateNameLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(SELECT_CANDIDATE_NAME_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(SELECT_CANDIDATE_NAME_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -36,6 +39,9 @@ public class SelectCandidateNameLoader { controller.SetParent(selectCandidateName); 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/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionLoader.java index c8c73d7..9a7d2a4 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionLoader.java @@ -4,6 +4,7 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; import java.io.IOException; @@ -16,11 +17,13 @@ public class StraightChannelSectionLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public StraightChannelSectionLoader(Stage primaryStage) throws IOException + public StraightChannelSectionLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(STRAIGHT_CHANNEL_LOADER_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(STRAIGHT_CHANNEL_LOADER_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -36,6 +39,9 @@ public class StraightChannelSectionLoader { controller.SetParent(straightChannelSection); 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/java/meerkat/voting/gui/vote_have_been_cast/VoteHaveBeenCastLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/vote_have_been_cast/VoteHaveBeenCastLoader.java index fa00f57..3499703 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/vote_have_been_cast/VoteHaveBeenCastLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/vote_have_been_cast/VoteHaveBeenCastLoader.java @@ -4,6 +4,8 @@ import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; +import meerkat.voting.ui.VotingBoothUI; import java.io.IOException; @@ -16,11 +18,13 @@ public class VoteHaveBeenCastLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public VoteHaveBeenCastLoader(Stage primaryStage) throws IOException + public VoteHaveBeenCastLoader(Stage primaryStage ,VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(VOTE_HAVE_BEEN_CAST_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(VOTE_HAVE_BEEN_CAST_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -36,6 +40,9 @@ public class VoteHaveBeenCastLoader { controller.SetParent(voteHaveBeenCast); 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/java/meerkat/voting/gui/welcome_splash/WelcomeSplashLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashLoader.java index ed70d90..405cf8f 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashLoader.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashLoader.java @@ -6,6 +6,7 @@ import javafx.scene.Parent; import javafx.scene.Scene; import javafx.stage.Stage; import meerkat.voting.gui.TwoWayNode; +import meerkat.voting.gui.VotingBoothConfiguration; import java.io.IOException; @@ -18,11 +19,13 @@ public class WelcomeSplashLoader { private Stage currentStage; private FXMLLoader fxmlLoader; + private VotingBoothConfiguration config; - public WelcomeSplashLoader(Stage primaryStage) throws IOException + public WelcomeSplashLoader(Stage primaryStage, VotingBoothConfiguration config) throws IOException { - fxmlLoader = new FXMLLoader(getClass().getResource(WELCOME_SPLASH_FXML_PATH)); - currentStage = primaryStage; + this.fxmlLoader = new FXMLLoader(getClass().getResource(WELCOME_SPLASH_FXML_PATH)); + this.currentStage = primaryStage; + this.config = config; } /** @@ -31,13 +34,16 @@ public class WelcomeSplashLoader { * @throws IOException */ public TwoWayNode GetWelcomeSplash() throws IOException { - Parent welcomeSplash = fxmlLoader.load(); - WelcomeSplashController controller = fxmlLoader.getController(); + Parent welcomeSplash = this.fxmlLoader.load(); + WelcomeSplashController controller = this.fxmlLoader.getController(); // set the controller to be functional TwoWayNode controller.SetParent(welcomeSplash); controller.SetStage(currentStage); + // set the controller to have the configuration file + controller.SetConfig(this.config); + return controller; } }