diff --git a/voting-station-gui/src/polling_station_dashboard/fxml/polling_station_dashboard.fxml b/voting-station-gui/src/polling_station_dashboard/fxml/polling_station_dashboard.fxml
index 2916c59..28592af 100644
--- a/voting-station-gui/src/polling_station_dashboard/fxml/polling_station_dashboard.fxml
+++ b/voting-station-gui/src/polling_station_dashboard/fxml/polling_station_dashboard.fxml
@@ -2,7 +2,6 @@
-
@@ -38,7 +37,7 @@
-
+
diff --git a/voting-station-gui/src/polling_station_dashboard/search/SearchHandler.java b/voting-station-gui/src/polling_station_dashboard/search/SearchHandler.java
index 77b75fd..4cc4b82 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/SearchHandler.java
+++ b/voting-station-gui/src/polling_station_dashboard/search/SearchHandler.java
@@ -2,16 +2,17 @@ package polling_station_dashboard.search;
import javafx.event.Event;
import javafx.event.EventHandler;
+import javafx.scene.control.TextField;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
+import polling_station_dashboard.search.submitVoter.java.SubmitVoterLoader;
import polling_station_dashboard.search.votersFetcher.VotersFetcher;
import polling_station_dashboard.search.addVoter.java.AddVoterLoader;
import javafx.scene.control.Button;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
+import java.lang.reflect.Array;
+import java.util.*;
/**
* Created by Vladimir Eliezer Tokarev on 12/06/2016.
@@ -31,13 +32,15 @@ public class SearchHandler implements EventHandler {
private List GetFilters()
{
- return new ArrayList<>();
+ String unSeparatedFilters = ((TextField)this.currentStage.getScene().lookup("#SearchValue")).getText();
+ String[] filters = unSeparatedFilters.split(" -|\\:|\\,");
+ return Arrays.asList(filters);
}
private void AddVoterPanel() throws IOException
{
- ((Pane)currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(this.AddVoterButton);
- new AddVoterLoader(currentStage);
+ ((Pane)this.currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(this.AddVoterButton);
+ new AddVoterLoader(this.currentStage);
}
private void AddVoterAddButton() throws IOException {
@@ -52,6 +55,12 @@ public class SearchHandler implements EventHandler {
((Pane)currentStage.getScene().lookup("#AddEditPane")).getChildren().add(AddVoterButton);
}
+ private void AddSubmitVoterPanel(HashMap voter) throws IOException
+ {
+ SubmitVoterLoader submitVoterLoader = new SubmitVoterLoader(this.currentStage);
+ submitVoterLoader.GenerateVoterSubmit(voter);
+ }
+
private void VotersCheck() throws IOException {
List filters = GetFilters();
@@ -61,13 +70,9 @@ public class SearchHandler implements EventHandler {
{
AddVoterAddButton();
}
- else if(voters.get(0).get("EligibleToVote").equals("no"))
+ else if(voters.get(0).get("EligibleToVote").equals("no") || voters.get(0).get("EligibleToVote").equals("yes"))
{
- // founded the voter but he cant vote
- }
- else if(voters.get(0).get("EligibleToVote").equals("yes"))
- {
- // founded the voter and he can vote
+ AddSubmitVoterPanel(voters.get(0));
}
else
{
@@ -75,10 +80,16 @@ public class SearchHandler implements EventHandler {
}
}
+ private void CleanSearchLine()
+ {
+ ((TextField)this.currentStage.getScene().lookup("#SearchValue")).setText(" ");
+ }
+
@Override
public void handle(Event event) {
try {
VotersCheck();
+ CleanSearchLine();
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/voting-station-gui/src/polling_station_dashboard/search/addVoter/fxml/add_voter.fxml b/voting-station-gui/src/polling_station_dashboard/search/addVoter/fxml/add_voter.fxml
index 5f5b9da..fad3377 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/addVoter/fxml/add_voter.fxml
+++ b/voting-station-gui/src/polling_station_dashboard/search/addVoter/fxml/add_voter.fxml
@@ -2,12 +2,11 @@
-
-
-
+
diff --git a/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterController.java b/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterController.java
index 7b84898..7872f1d 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterController.java
+++ b/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterController.java
@@ -25,6 +25,7 @@ public class AddVoterController {
{
// when this button pressed (the cancel button) only the add voter panel is in list of children of AddEditPane
// this why removing the element at index 0 will remove this panel
+ System.out.println(((Pane)this.currentStage.getScene().lookup("#AddEditPane")).getChildren());
((Pane)this.currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(0);
}
}
diff --git a/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterLoader.java b/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterLoader.java
index 1be3b32..cdd9d2d 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterLoader.java
+++ b/voting-station-gui/src/polling_station_dashboard/search/addVoter/java/AddVoterLoader.java
@@ -13,7 +13,7 @@ import java.io.IOException;
*/
public class AddVoterLoader {
- private static final String ADD_VOTER_FXML_PATH = "../fxml/submit_voter.fxml";
+ private static final String ADD_VOTER_FXML_PATH = "../fxml/add_voter.fxml";
private Stage currentStage;
diff --git a/voting-station-gui/src/polling_station_dashboard/search/submitVoter/fxml/submit_voter.fxml b/voting-station-gui/src/polling_station_dashboard/search/submitVoter/fxml/submit_voter.fxml
index 35bb9f9..3405c92 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/submitVoter/fxml/submit_voter.fxml
+++ b/voting-station-gui/src/polling_station_dashboard/search/submitVoter/fxml/submit_voter.fxml
@@ -1,13 +1,12 @@
+
-
-
-
+
@@ -87,10 +86,13 @@
-
-
-
-
+
+
+
+
@@ -133,7 +135,7 @@
-
+
diff --git a/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterController.java b/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterController.java
index fc32190..78074e4 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterController.java
+++ b/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterController.java
@@ -1,5 +1,7 @@
package polling_station_dashboard.search.submitVoter.java;
+import javafx.fxml.FXML;
+import javafx.scene.layout.Pane;
import javafx.stage.Stage;
/**
@@ -14,4 +16,12 @@ public class SubmitVoterController {
{
this.currentStage = primaryStage;
}
+
+ @FXML
+ private void RemoveSubmitVoterPanel()
+ {
+ // when this button pressed (the cancel button) only the add voter panel is in list of children of AddEditPane
+ // this why removing the element at index 0 will remove this panel
+ ((Pane)this.currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(0);
+ }
}
diff --git a/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterLoader.java b/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterLoader.java
index 4b810d0..1adafc2 100644
--- a/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterLoader.java
+++ b/voting-station-gui/src/polling_station_dashboard/search/submitVoter/java/SubmitVoterLoader.java
@@ -2,10 +2,12 @@ package polling_station_dashboard.search.submitVoter.java;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
+import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import java.io.IOException;
+import java.util.HashMap;
/**
* Created by Vladimir Eliezer Tokarev on 18/06/2016.
@@ -16,16 +18,30 @@ public class SubmitVoterLoader {
private static final String SUBMIT_VOTER_FXML_PATH = "../fxml/submit_voter.fxml";
private Stage currentStage;
+ private FXMLLoader fxmlLoader;
+
+ private void ResetVoterParams(HashMap voter, Parent root)
+ {
+ ((Label)root.lookup("#IDNumberValue")).setText(voter.get("IDNumber"));
+ ((Label)root.lookup("#EligibleToVoteValue")).setText(voter.get("EligibleToVote"));
+ ((Label)root.lookup("#StatusValue")).setText(voter.get("Status"));
+ ((Label)root.lookup("#ChannelValue")).setText(voter.get("Channel"));
+ }
public SubmitVoterLoader (Stage primaryStage) throws IOException
{
currentStage = primaryStage;
- FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(SUBMIT_VOTER_FXML_PATH));
- Parent root = fxmlLoader.load();
- SubmitVoterController controller = fxmlLoader.getController();
+ this.fxmlLoader = new FXMLLoader(getClass().getResource(SUBMIT_VOTER_FXML_PATH));
+ }
+ public void GenerateVoterSubmit(HashMap voter) throws IOException
+ {
+ Parent root = this.fxmlLoader.load();
+ ResetVoterParams(voter, root);
+
+ SubmitVoterController controller = fxmlLoader.getController();
Pane addEditPane = (Pane)currentStage.getScene().lookup("#AddEditPane");
addEditPane.getChildren().add(root);
- controller.SetStage(primaryStage);
+ controller.SetStage(currentStage);
}
}