From c410fc6693f594283f17a183b62ebf5a5b74344b Mon Sep 17 00:00:00 2001 From: VladimirEliTokarev Date: Sun, 2 Oct 2016 19:11:34 +0300 Subject: [PATCH] Added the changes of two way node to number of clases --- .../java/meerkat/voting/gui/TwoWayNode.java | 10 ++-- .../BallotSummaryController.java | 11 +++- .../ballot_summary/BallotSummaryLoader.java | 2 +- .../cast_or_audit/CastOrAuditController.java | 8 ++- .../gui/cast_or_audit/CastOrAuditLoader.java | 2 +- .../SelectCandidateByPictureController.java | 57 +++---------------- .../SelectCandidateByPictureLoader.java | 2 +- .../SelectCandidateNameController.java | 6 +- .../StraightChannelSectionController.java | 3 +- .../WelcomeSplashController.java | 3 +- 10 files changed, 41 insertions(+), 63 deletions(-) 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 16cbcc2..9a0fd4e 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 @@ -10,8 +10,8 @@ import javafx.stage.Stage; */ public abstract class TwoWayNode { - protected Scene next; - protected Scene previous; + protected TwoWayNode next; + protected TwoWayNode previous; protected Stage currentStage; protected Scene currentScene; protected VotingBoothConfiguration config; @@ -21,7 +21,7 @@ public abstract class TwoWayNode { * @param nextObject the next TwoWayNode to which the flow will eventual arrive */ void SetNext(TwoWayNode nextObject) { - this.next = nextObject.GetCurrentScene(); + this.next = nextObject; } /** @@ -29,7 +29,7 @@ public abstract class TwoWayNode { * @param previousObject the object that is one twoWayNode before current object */ void SetPrevious(TwoWayNode previousObject) { - this.previous = previousObject.GetCurrentScene(); + this.previous = previousObject; } /** @@ -52,7 +52,7 @@ public abstract class TwoWayNode { * GetCurrentScene return the paren node that represents current object * @return Paren object */ - private Scene GetCurrentScene() { + public Scene GetCurrentScene() { return this.currentScene; } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryController.java index 9c46379..dfe56c5 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/ballot_summary/BallotSummaryController.java @@ -12,14 +12,21 @@ public class BallotSummaryController extends TwoWayNode { @FXML private void GetToSelectByPicture(MouseEvent mousePressed){ this.currentStage.close(); - this.currentStage.setScene(this.previous); + this.next.UpdateNode(); + this.currentStage.setScene(this.next.GetCurrentScene()); this.currentStage.show(); } @FXML private void GetToCastOrAudit(MouseEvent mousePressed){ this.currentStage.close(); - this.currentStage.setScene(this.next); + this.previous.UpdateNode(); + this.currentStage.setScene(this.previous.GetCurrentScene()); this.currentStage.show(); } + + @Override + public void UpdateNode() { + // Nothing relevant to do + } } 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 9fc5edc..ef8ac28 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 @@ -36,7 +36,7 @@ public class BallotSummaryLoader { BallotSummaryController controller = fxmlLoader.getController(); // set the controller to be functional TwoWayNode - controller.SetParent(ballotSummary); + controller.SetCurrentScene(ballotSummary); controller.SetStage(currentStage); // set the controller to have the configuration file diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditController.java index 8a8c9d9..6fdc68c 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditController.java @@ -13,7 +13,13 @@ public class CastOrAuditController extends TwoWayNode { @FXML private void GetToVoteHaveBeenCast(MouseEvent mousePressed) { this.currentStage.close(); - this.currentStage.setScene(this.next); + this.next.UpdateNode(); + this.currentStage.setScene(this.next.GetCurrentScene()); 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/cast_or_audit/CastOrAuditLoader.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/cast_or_audit/CastOrAuditLoader.java index 689101f..d3adc8c 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 @@ -36,7 +36,7 @@ public class CastOrAuditLoader { CastOrAuditController controller = fxmlLoader.getController(); // set the controller to be functional TwoWayNode - controller.SetParent(castOrAudit); + controller.SetCurrentScene(castOrAudit); controller.SetStage(currentStage); // set the controller to have the configuration file diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureController.java index 5aa1d3e..6cdd809 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_by_picture/SelectCandidateByPictureController.java @@ -22,64 +22,25 @@ public class SelectCandidateByPictureController extends TwoWayNode { private List questions; private List answers; - public void SetQuestions(List questions) throws InterruptedException { - this.questions = questions; - this.GetAnswers(); - } - - - public List GetAnswers() throws InterruptedException { - return null; - } - - @FXML - private void submitTheSelection(MouseEvent mousePressed){ - BorderPane b = (BorderPane) mousePressed.getSource(); - int id = Integer.parseInt(b.getId().split("_")[1]); - unColorAllOthers(id); - b.setBackground(new Background(new BackgroundFill(Color.RED, CornerRadii.EMPTY, Insets.EMPTY))); - - - } - - private List getAnswers(String id){ - String name = getCandidateName(id); - return null; - } - - /** - * Gets the name of the candidate - * @param id - * @return - */ - private String getCandidateName(String id){ - return ((Label)this.currentStage.getScene().lookup("#name"+id)).getText(); - } - - /** - * Uncolors all the not selected picttures of candidates - * @param id the id of the selected candidate - */ - private void unColorAllOthers(int id){ - for (int i = 0 ; i < 3 ; i++ ){ - BorderPane b = (BorderPane)currentStage.getScene().lookup("#picture_"+i); - if (i != id) { - b.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY))); - } - } - } @FXML private void GetToSelectByName(MouseEvent mousePressed){ this.currentStage.close(); - this.currentStage.setScene(this.previous); + this.next.UpdateNode(); + this.currentStage.setScene(this.next.GetCurrentScene()); this.currentStage.show(); } @FXML private void GetToBallotSummary(MouseEvent mousePressed){ this.currentStage.close(); - this.currentStage.setScene(this.next); + this.previous.UpdateNode(); + this.currentStage.setScene(this.previous.GetCurrentScene()); this.currentStage.show(); } + + @Override + public void UpdateNode() { + // Update the visual representations of the voters options + } } 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 1dbc40d..cdbb4a7 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 @@ -36,7 +36,7 @@ public class SelectCandidateByPictureLoader { meerkat.voting.gui.select_candidate_by_picture.SelectCandidateByPictureController controller = fxmlLoader.getController(); // set the controller to be functional TwoWayNode - controller.SetParent(selectByPicture); + controller.SetCurrentScene(selectByPicture); controller.SetStage(currentStage); // set the controller to have the configuration file diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameController.java index b14ad77..5e3adbd 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/select_candidate_name/SelectCandidateNameController.java @@ -13,14 +13,16 @@ public class SelectCandidateNameController extends TwoWayNode { @FXML private void GetToSelectChannel(MouseEvent mousePressed){ this.currentStage.close(); - this.currentStage.setScene(this.previous); + this.next.UpdateNode(); + this.currentStage.setScene(this.next.GetCurrentScene()); this.currentStage.show(); } @FXML private void SelectCandidateByName(MouseEvent mousePressed) { this.currentStage.close(); - this.currentStage.setScene(this.next); + this.previous.UpdateNode(); + this.currentStage.setScene(this.previous.GetCurrentScene()); this.currentStage.show(); } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java index 62ccfcd..56d405c 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/straight_channel_section/StraightChannelSectionController.java @@ -16,7 +16,8 @@ public class StraightChannelSectionController extends TwoWayNode { @FXML private void ProceedToNameSelection(MouseEvent boutonPressed) { this.currentStage.close(); - this.currentStage.setScene(this.next); + this.next.UpdateNode(); + this.currentStage.setScene(this.next.GetCurrentScene()); this.currentStage.show(); } diff --git a/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashController.java b/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashController.java index 8e572d1..995e5fb 100644 --- a/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashController.java +++ b/voting-booth-gui/src/main/java/meerkat/voting/gui/welcome_splash/WelcomeSplashController.java @@ -14,7 +14,8 @@ public class WelcomeSplashController extends TwoWayNode { @FXML private void StartVotingProcess(MouseEvent mousePressed) { this.currentStage.close(); - this.currentStage.setScene(this.next); + this.next.UpdateNode(); + this.currentStage.setScene(this.next.GetCurrentScene()); this.currentStage.show(); }