Added the submit voter logic to PSD
Now all the search flow works, if the users dont find any users hi is given the option to add one, if it found then the submit voter panel is open.voting-station-gui
parent
f813c11edd
commit
36e1f6ea20
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
<!-- Created By Vladimir Eliezer Tokarev !-->
|
<!-- Created By Vladimir Eliezer Tokarev !-->
|
||||||
|
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.*?>
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
@ -38,7 +37,7 @@
|
||||||
</ImageView>
|
</ImageView>
|
||||||
</left>
|
</left>
|
||||||
<center>
|
<center>
|
||||||
<TextField prefHeight="56.0" prefWidth="536.0" BorderPane.alignment="CENTER" />
|
<TextField fx:id="SearchValue" prefHeight="56.0" prefWidth="536.0" BorderPane.alignment="CENTER" text="IDNumber: 123123123, FilterName2: value2 ..." />
|
||||||
</center>
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -2,16 +2,17 @@ package polling_station_dashboard.search;
|
||||||
|
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import polling_station_dashboard.search.submitVoter.java.SubmitVoterLoader;
|
||||||
import polling_station_dashboard.search.votersFetcher.VotersFetcher;
|
import polling_station_dashboard.search.votersFetcher.VotersFetcher;
|
||||||
import polling_station_dashboard.search.addVoter.java.AddVoterLoader;
|
import polling_station_dashboard.search.addVoter.java.AddVoterLoader;
|
||||||
|
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.lang.reflect.Array;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Vladimir Eliezer Tokarev on 12/06/2016.
|
* Created by Vladimir Eliezer Tokarev on 12/06/2016.
|
||||||
|
@ -31,13 +32,15 @@ public class SearchHandler implements EventHandler {
|
||||||
|
|
||||||
private List<String> GetFilters()
|
private List<String> 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
|
private void AddVoterPanel() throws IOException
|
||||||
{
|
{
|
||||||
((Pane)currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(this.AddVoterButton);
|
((Pane)this.currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(this.AddVoterButton);
|
||||||
new AddVoterLoader(currentStage);
|
new AddVoterLoader(this.currentStage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddVoterAddButton() throws IOException {
|
private void AddVoterAddButton() throws IOException {
|
||||||
|
@ -52,6 +55,12 @@ public class SearchHandler implements EventHandler {
|
||||||
((Pane)currentStage.getScene().lookup("#AddEditPane")).getChildren().add(AddVoterButton);
|
((Pane)currentStage.getScene().lookup("#AddEditPane")).getChildren().add(AddVoterButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AddSubmitVoterPanel(HashMap<String, String> voter) throws IOException
|
||||||
|
{
|
||||||
|
SubmitVoterLoader submitVoterLoader = new SubmitVoterLoader(this.currentStage);
|
||||||
|
submitVoterLoader.GenerateVoterSubmit(voter);
|
||||||
|
}
|
||||||
|
|
||||||
private void VotersCheck() throws IOException {
|
private void VotersCheck() throws IOException {
|
||||||
List<String> filters = GetFilters();
|
List<String> filters = GetFilters();
|
||||||
|
|
||||||
|
@ -61,13 +70,9 @@ public class SearchHandler implements EventHandler {
|
||||||
{
|
{
|
||||||
AddVoterAddButton();
|
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
|
AddSubmitVoterPanel(voters.get(0));
|
||||||
}
|
|
||||||
else if(voters.get(0).get("EligibleToVote").equals("yes"))
|
|
||||||
{
|
|
||||||
// founded the voter and he can vote
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -75,10 +80,16 @@ public class SearchHandler implements EventHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CleanSearchLine()
|
||||||
|
{
|
||||||
|
((TextField)this.currentStage.getScene().lookup("#SearchValue")).setText(" ");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle(Event event) {
|
public void handle(Event event) {
|
||||||
try {
|
try {
|
||||||
VotersCheck();
|
VotersCheck();
|
||||||
|
CleanSearchLine();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
|
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.*?>
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="753.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.search.addVoter.java.AddVoterController">
|
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="753.0"
|
||||||
|
xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.search.addVoter.java.AddVoterController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints />
|
<ColumnConstraints />
|
||||||
<ColumnConstraints />
|
<ColumnConstraints />
|
||||||
|
|
|
@ -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
|
// 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
|
// 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);
|
((Pane)this.currentStage.getScene().lookup("#AddEditPane")).getChildren().remove(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public class AddVoterLoader {
|
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;
|
private Stage currentStage;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import java.lang.*?>
|
||||||
<?import javafx.scene.image.*?>
|
<?import javafx.scene.image.*?>
|
||||||
<?import javafx.geometry.*?>
|
<?import javafx.geometry.*?>
|
||||||
<?import javafx.scene.text.*?>
|
|
||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import java.lang.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
|
|
||||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="753.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.search.addVoter.java.AddVoterController">
|
<GridPane fx:id="SubmitVoterPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="753.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="polling_station_dashboard.search.submitVoter.java.SubmitVoterController">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints />
|
<ColumnConstraints />
|
||||||
<ColumnConstraints />
|
<ColumnConstraints />
|
||||||
|
@ -87,10 +86,13 @@
|
||||||
</Label>
|
</Label>
|
||||||
</center>
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
<Label prefHeight="29.0" prefWidth="107.0" text="234234234" GridPane.columnIndex="1" />
|
<Label fx:id="IDNumberValue" prefHeight="29.0" prefWidth="107.0" text="234234234" GridPane.columnIndex="1" />
|
||||||
<Label prefHeight="23.0" prefWidth="107.0" text="YES" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
<Label fx:id="EligibleToVoteValue" prefHeight="23.0" prefWidth="107.0" text="YES" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||||
<Label prefHeight="38.0" prefWidth="107.0" text="Has Not Voted" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
<padding>
|
||||||
<Label prefHeight="60.0" prefWidth="107.0" text="IDC Maths" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
<Insets left="3.0" />
|
||||||
|
</padding></Label>
|
||||||
|
<Label fx:id="StatusValue" prefHeight="38.0" prefWidth="107.0" text="Has Not Voted" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||||
|
<Label fx:id="ChannelValue" prefHeight="60.0" prefWidth="107.0" text="IDC Maths" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||||
</children>
|
</children>
|
||||||
</GridPane>
|
</GridPane>
|
||||||
</children>
|
</children>
|
||||||
|
@ -133,7 +135,7 @@
|
||||||
<children>
|
<children>
|
||||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
||||||
<center>
|
<center>
|
||||||
<Button mnemonicParsing="false" onMousePressed="#RemoveAddVoterPanel" text="Cancel" BorderPane.alignment="CENTER" />
|
<Button mnemonicParsing="false" onMousePressed="#RemoveSubmitVoterPanel" text="Cancel" BorderPane.alignment="CENTER" />
|
||||||
</center>
|
</center>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
|
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1">
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package polling_station_dashboard.search.submitVoter.java;
|
package polling_station_dashboard.search.submitVoter.java;
|
||||||
|
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,4 +16,12 @@ public class SubmitVoterController {
|
||||||
{
|
{
|
||||||
this.currentStage = primaryStage;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@ package polling_station_dashboard.search.submitVoter.java;
|
||||||
|
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Parent;
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Vladimir Eliezer Tokarev on 18/06/2016.
|
* 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 static final String SUBMIT_VOTER_FXML_PATH = "../fxml/submit_voter.fxml";
|
||||||
|
|
||||||
private Stage currentStage;
|
private Stage currentStage;
|
||||||
|
private FXMLLoader fxmlLoader;
|
||||||
|
|
||||||
|
private void ResetVoterParams(HashMap<String, String> 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
|
public SubmitVoterLoader (Stage primaryStage) throws IOException
|
||||||
{
|
{
|
||||||
currentStage = primaryStage;
|
currentStage = primaryStage;
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(SUBMIT_VOTER_FXML_PATH));
|
this.fxmlLoader = new FXMLLoader(getClass().getResource(SUBMIT_VOTER_FXML_PATH));
|
||||||
Parent root = fxmlLoader.load();
|
}
|
||||||
SubmitVoterController controller = fxmlLoader.getController();
|
|
||||||
|
|
||||||
|
public void GenerateVoterSubmit(HashMap<String, String> voter) throws IOException
|
||||||
|
{
|
||||||
|
Parent root = this.fxmlLoader.load();
|
||||||
|
ResetVoterParams(voter, root);
|
||||||
|
|
||||||
|
SubmitVoterController controller = fxmlLoader.getController();
|
||||||
Pane addEditPane = (Pane)currentStage.getScene().lookup("#AddEditPane");
|
Pane addEditPane = (Pane)currentStage.getScene().lookup("#AddEditPane");
|
||||||
addEditPane.getChildren().add(root);
|
addEditPane.getChildren().add(root);
|
||||||
controller.SetStage(primaryStage);
|
controller.SetStage(currentStage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue