Inserted the VotingBoothConfiguration into every panel

For now every panel will have the configuration object when created and
will represent the questions/answers according to it.
android-scanner
Vladimir Eliezer Tokarev 2016-10-01 15:56:26 +03:00
parent c0ed5ea3fc
commit 5c2de6d009
11 changed files with 87 additions and 33 deletions

View File

@ -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<String, TwoWayNode> Build(Stage primaryStage) throws IOException {
WelcomeSplashLoader welcomeSplashLoader = new WelcomeSplashLoader(primaryStage);
static Map<String, TwoWayNode> 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);

View File

@ -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();
}

View File

@ -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;
}
}

View File

@ -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
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}