diff --git a/classes/production/voting-booth-gui/main/VotingBoothGUIManager.class b/classes/production/voting-booth-gui/main/VotingBoothGUIManager.class
index 31289d1..edf8cb2 100644
Binary files a/classes/production/voting-booth-gui/main/VotingBoothGUIManager.class and b/classes/production/voting-booth-gui/main/VotingBoothGUIManager.class differ
diff --git a/classes/production/voting-booth-gui/main/select_candidate_by_picture/SelectCandidateByPictureController.class b/classes/production/voting-booth-gui/main/select_candidate_by_picture/SelectCandidateByPictureController.class
index 7560494..6a409a6 100644
Binary files a/classes/production/voting-booth-gui/main/select_candidate_by_picture/SelectCandidateByPictureController.class and b/classes/production/voting-booth-gui/main/select_candidate_by_picture/SelectCandidateByPictureController.class differ
diff --git a/classes/production/voting-booth-gui/main/select_candidate_by_picture/select_candidate_by_picture.fxml b/classes/production/voting-booth-gui/main/select_candidate_by_picture/select_candidate_by_picture.fxml
index 887fd6e..6095f9b 100644
--- a/classes/production/voting-booth-gui/main/select_candidate_by_picture/select_candidate_by_picture.fxml
+++ b/classes/production/voting-booth-gui/main/select_candidate_by_picture/select_candidate_by_picture.fxml
@@ -146,7 +146,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -155,16 +164,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -175,7 +175,7 @@
-
-
+
@@ -193,7 +193,7 @@
-
+
diff --git a/voting-booth-gui/src/main/Main.java b/voting-booth-gui/src/main/Main.java
index 41a4c6e..4ea031a 100644
--- a/voting-booth-gui/src/main/Main.java
+++ b/voting-booth-gui/src/main/Main.java
@@ -16,7 +16,7 @@ public class Main extends Application {
ChainBuilder.Build(primaryStage);
primaryStage.setTitle("Meerkat Polling Station");
primaryStage.show();
- }
+}
public static void main(String[] args) throws InterruptedException {
launch(args);
diff --git a/voting-booth-gui/src/main/VotingBoothGUIManager.java b/voting-booth-gui/src/main/VotingBoothGUIManager.java
index a815387..1842c69 100644
--- a/voting-booth-gui/src/main/VotingBoothGUIManager.java
+++ b/voting-booth-gui/src/main/VotingBoothGUIManager.java
@@ -37,6 +37,19 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI
this.currentStage.show();
}
+ /**
+ * Communicates with the select * panels and passes to them the questions to ask the voter
+ * @param questions list of voting ballot questions (such as choose the racing candidate picture)
+ * @param callback is a call back to method that handles users answers
+ * @return List of voting ballot answers
+ */
+ private void askVoterForAnswers(List questions, FutureCallback> callback)
+ {
+
+ }
+
+
+
/**
* Method that activates the application and passes to start the primary stage (can be called outside this class)
* @param args array of strings to pass to the start method as argument
@@ -99,8 +112,16 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI
@Override
public void askVoterQuestions(List questions, FutureCallback> callback) {
logger.debug("Graphical user interface call to chooseChannel");
+ try {
+ askVoterForAnswers(questions, callback);
+ }
+ catch (Error e) {
+ logger.debug(String.format("Couldn't ask voter questions: ", e));
+ callback.onFailure(e);
+ }
}
+
/**
* call for the channel choice phase by registering a ChannelChoiceUICommand in the queue
* @param questions questions to determine the right voting channel for this voter
@@ -109,6 +130,7 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI
@Override
public void chooseChannel(List questions, FutureCallback> callback) {
logger.debug("Graphical user interface call to chooseChannel");
+
}
/**
@@ -120,8 +142,10 @@ public class VotingBoothGUIManager extends Application implements VotingBoothUI
logger.debug("Graphical user interface call to startNewVoterSession");
try {
this.doStartNewSession(this.currentStage);
+ callback.onSuccess(null);
} catch (IOException e) {
logger.error(String.format("Couldn't start new session of the voting process :", e));
+ callback.onFailure(e);
}
}
diff --git a/voting-booth-gui/src/main/select_candidate_by_picture/SelectCandidateByPictureController.java b/voting-booth-gui/src/main/select_candidate_by_picture/SelectCandidateByPictureController.java
index bed0e8a..74cc078 100644
--- a/voting-booth-gui/src/main/select_candidate_by_picture/SelectCandidateByPictureController.java
+++ b/voting-booth-gui/src/main/select_candidate_by_picture/SelectCandidateByPictureController.java
@@ -1,14 +1,74 @@
package main.select_candidate_by_picture;
import javafx.fxml.FXML;
+import javafx.geometry.Insets;
+import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
+import javafx.scene.layout.Background;
+import javafx.scene.layout.BackgroundFill;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.CornerRadii;
+import javafx.scene.paint.Color;
import main.TwoWayNode;
+import meerkat.protobuf.Voting;
+
+import java.awt.*;
+import java.util.List;
/**
* Created by Vladimir Eliezer Tokarev on 8/27/2016.
* SelectCandidateNameController handle the behavior of select by picture screen
*/
public class SelectCandidateByPictureController extends TwoWayNode {
+ private List questions;
+ private List answers;
+ private int QuestionId:
+
+ 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);
+ }
+
+ /**
+ * 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){
diff --git a/voting-booth-gui/src/main/select_candidate_by_picture/select_candidate_by_picture.fxml b/voting-booth-gui/src/main/select_candidate_by_picture/select_candidate_by_picture.fxml
index 887fd6e..6095f9b 100644
--- a/voting-booth-gui/src/main/select_candidate_by_picture/select_candidate_by_picture.fxml
+++ b/voting-booth-gui/src/main/select_candidate_by_picture/select_candidate_by_picture.fxml
@@ -146,7 +146,16 @@
-
+
+
+
+
+
+
+
+
+
+
@@ -155,16 +164,7 @@
-
-
-
-
-
-
-
-
-
-
+
@@ -175,7 +175,7 @@
-
+
@@ -184,7 +184,7 @@
-
+
@@ -193,7 +193,7 @@
-
+