added summary screen after voting
parent
19a7d5731c
commit
b9613ed693
|
@ -31,8 +31,8 @@ public class ChannelChoiceController {
|
|||
String questionText;
|
||||
|
||||
@FXML ToggleGroup answerGroup;
|
||||
@FXML private Text question;
|
||||
@FXML private Text warningMsg;
|
||||
// @FXML private Text question;
|
||||
// @FXML private Text warningMsg;
|
||||
@FXML private Pane questionPane;
|
||||
|
||||
@FXML
|
||||
|
@ -72,13 +72,17 @@ public class ChannelChoiceController {
|
|||
|
||||
private void showCodeSelection() {
|
||||
questionText = "Here we show code pad.";
|
||||
question.setText(questionText);
|
||||
questionPane.getChildren().clear();
|
||||
Text txt = new Text();
|
||||
questionPane.getChildren().add(txt);
|
||||
txt.setText(questionText);
|
||||
// question.setText(questionText);
|
||||
}
|
||||
|
||||
private void showQuestion() {
|
||||
Voting.BallotQuestion ballotQuestion = questions.get(index);
|
||||
questionText = "Please answer this question before voting:";
|
||||
question.setText(questionText);
|
||||
// question.setText(questionText);
|
||||
answerGroup.getToggles().clear();
|
||||
VBox vbox = VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup);
|
||||
questionPane.getChildren().clear();
|
||||
|
@ -87,8 +91,10 @@ public class ChannelChoiceController {
|
|||
|
||||
private void showError() {
|
||||
questionText = "There was an error reading the channel, please go back to polling station.";
|
||||
question.setText(questionText);
|
||||
|
||||
// question.setText(questionText);
|
||||
questionPane.getChildren().clear();
|
||||
Text txt = new Text();
|
||||
questionPane.getChildren().add(txt);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
@ -97,6 +103,8 @@ public class ChannelChoiceController {
|
|||
String s = answerGroup.getSelectedToggle().getUserData().toString();
|
||||
answers.add(UIUtils.translateStringAnswerToProtoBufMessageAnswer(s));
|
||||
} else {
|
||||
Text warningMsg = new Text();
|
||||
questionPane.getChildren().add(0,warningMsg);
|
||||
warningMsg.setText("(Please give an answer to continue)");
|
||||
}
|
||||
if (answers.size()!=0) {
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
package meerkat.voting.gui.controllersFX;
|
||||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Separator;
|
||||
import javafx.scene.control.ToggleGroup;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
import meerkat.protobuf.Voting;
|
||||
import meerkat.voting.VotingBooth;
|
||||
import meerkat.voting.controller.callbacks.VoterCancelThrowable;
|
||||
import meerkat.voting.gui.ui.UIUtils;
|
||||
import meerkat.voting.gui.ui.uicommands.RaceVotingUICommand;
|
||||
|
@ -31,10 +41,10 @@ public class VotingController {
|
|||
RaceVotingUICommand command = (RaceVotingUICommand) VistaNavigator.getCurrentCommand();
|
||||
|
||||
@FXML ToggleGroup answerGroup;
|
||||
@FXML private Text question;
|
||||
@FXML private Text currentPage;
|
||||
@FXML private Text totalPage;
|
||||
@FXML private Pane questionPane;
|
||||
@FXML private ScrollPane questionPane;
|
||||
@FXML private Button nextButton;
|
||||
|
||||
@FXML
|
||||
public void initialize() {
|
||||
|
@ -56,11 +66,18 @@ public class VotingController {
|
|||
answers.add(UIUtils.translateStringAnswerToProtoBufMessageAnswer(s));
|
||||
index++;
|
||||
}
|
||||
if (nextButton.getText().equals("Confirm")) {
|
||||
index++;
|
||||
}
|
||||
if (index < questions.size()) {
|
||||
showQuestion();
|
||||
} else {
|
||||
//return answers to main threads
|
||||
nextPane();
|
||||
if (index == questions.size()) {
|
||||
showSummary();
|
||||
} else {
|
||||
//return answers to main threads
|
||||
nextPane();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,10 +87,49 @@ public class VotingController {
|
|||
currentPage.setText("Page "+(index+1));
|
||||
answerGroup.getToggles().clear();
|
||||
VBox vbox = VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup);
|
||||
questionPane.getChildren().clear();
|
||||
questionPane.getChildren().addAll(vbox);
|
||||
nextButton.setText("Next");
|
||||
questionPane.setContent(vbox);
|
||||
questionPane.setFitToHeight(true);
|
||||
//questionPane.getChildren().clear();
|
||||
// questionPane.getChildren().addAll(vbox);
|
||||
}
|
||||
|
||||
private void showSummary() {
|
||||
// Voting.BallotQuestion ballotQuestion = questions.get(index);
|
||||
currentPage.setText("Page "+(index+1));
|
||||
answerGroup.getToggles().clear();
|
||||
VBox vbox = new VBox();//VistaNavigator.uiThread.showQuestionInFX(ballotQuestion, answerGroup);
|
||||
vbox.setPrefWidth(questionPane.getPrefWidth()-30);
|
||||
/*Set title of summary*/
|
||||
Text title = new Text("Almost done!");
|
||||
title.setFont(Font.font("System", FontWeight.BOLD, 24));
|
||||
vbox.getChildren().add(title);
|
||||
/*Set subtitle of summary*/
|
||||
Text subtitle = new Text("Review your selections. If you are satisfied, press confirm.");
|
||||
subtitle.setFont(Font.font("System", FontWeight.BOLD, 18));
|
||||
subtitle.setStyle("-fx-margin: 0 0 70 0;");
|
||||
vbox.getChildren().add(subtitle);
|
||||
/*Create summery*/
|
||||
for (int i=0; i<questions.size(); i++) {
|
||||
String qst = UIUtils.bytesToString(questions.get(i).getQuestion().getData());
|
||||
int a_i = (int) answers.get(i).getAnswer(0);
|
||||
String ans = UIUtils.bytesToString(questions.get(i).getAnswer(a_i-1).getData());
|
||||
Text qst_txt = new Text((i+1)+". "+qst);
|
||||
Text ans_txt = new Text(ans);
|
||||
Separator sep = new Separator();
|
||||
sep.setMaxWidth(vbox.getPrefWidth());
|
||||
vbox.getChildren().add(sep);
|
||||
vbox.getChildren().add(qst_txt);
|
||||
vbox.getChildren().add(ans_txt);
|
||||
}
|
||||
vbox.setAlignment(Pos.CENTER);
|
||||
nextButton.setText("Confirm");
|
||||
questionPane.setContent(vbox);
|
||||
questionPane.setFitToHeight(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
private void goBack() throws VoterCancelThrowable{
|
||||
if (index == 0) {
|
||||
|
|
|
@ -2,13 +2,10 @@
|
|||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.ChannelChoiceController">
|
||||
<children>
|
||||
<Button layoutX="469.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#nextPane" prefHeight="39.0" prefWidth="109.0" text="Next" />
|
||||
<Text fx:id="question" layoutX="84.0" layoutY="89.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Channel selection:" wrappingWidth="431.3046875" />
|
||||
<Pane fx:id="questionPane" layoutX="84.0" layoutY="97.0" prefHeight="234.0" prefWidth="422.0" />
|
||||
<Text fx:id="warningMsg" fill="#ee0909" layoutX="82.0" layoutY="64.0" strokeType="OUTSIDE" strokeWidth="0.0" wrappingWidth="431.3046875" />
|
||||
<Pane fx:id="questionPane" layoutX="1.0" layoutY="-1.0" prefHeight="326.0" prefWidth="600.0" />
|
||||
</children>
|
||||
</Pane>
|
||||
|
|
|
@ -2,15 +2,14 @@
|
|||
|
||||
<?import javafx.scene.Group?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.VotingController">
|
||||
<children>
|
||||
<Button layoutX="469.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#nextQuestion" text="Next" />
|
||||
<Text fx:id="question" layoutX="84.0" layoutY="89.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Click 'Next' to see the first question." wrappingWidth="431.3046875" />
|
||||
<Pane fx:id="questionPane" layoutX="84.0" layoutY="97.0" prefHeight="234.0" prefWidth="422.0" />
|
||||
<Button layoutX="84.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#goBack" text="Back" />
|
||||
<Button fx:id="nextButton" layoutX="469.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#nextQuestion" text="Next" />
|
||||
<Button layoutX="74.0" layoutY="343.0" mnemonicParsing="false" onMousePressed="#goBack" text="Back" />
|
||||
<Group layoutX="220.0" layoutY="369.0">
|
||||
<children>
|
||||
<Text fx:id="currentPage" layoutX="-16.0" strokeType="OUTSIDE" strokeWidth="0.0" text="XXX" textAlignment="RIGHT" wrappingWidth="112.30468860268593" />
|
||||
|
@ -18,5 +17,6 @@
|
|||
<Text fx:id="totalPage" layoutX="109.0" strokeType="OUTSIDE" strokeWidth="0.0" text="YYY" wrappingWidth="46.30468860268593" />
|
||||
</children>
|
||||
</Group>
|
||||
<ScrollPane fx:id="questionPane" layoutY="1.0" prefHeight="322.0" prefWidth="600.0" />
|
||||
</children>
|
||||
</Pane>
|
||||
|
|
|
@ -1,104 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.WelcomeScreenController">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints />
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints />
|
||||
<RowConstraints maxHeight="129.0" minHeight="10.0" prefHeight="47.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="222.0" minHeight="10.0" prefHeight="201.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="170.0" minHeight="10.0" prefHeight="129.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<Pane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1" fx:controller="meerkat.voting.gui.controllersFX.WelcomeScreenController">
|
||||
<children>
|
||||
<GridPane GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="185.0" minWidth="10.0" prefWidth="185.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="334.0" minWidth="10.0" prefWidth="258.0" />
|
||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="194.0" minWidth="10.0" prefWidth="124.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<VBox alignment="CENTER" prefHeight="400.0" prefWidth="600.0">
|
||||
<children>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
||||
<center>
|
||||
<Label text="Organization Logo" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="2">
|
||||
<center>
|
||||
<Label text="Date" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
<Text fx:id="electionName" strokeType="OUTSIDE" strokeWidth="0.0" text="Name of the Election" textAlignment="CENTER" wrappingWidth="343.205078125">
|
||||
<font>
|
||||
<Font name="System Bold" size="24.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Text fx:id="electionLocation" layoutX="138.0" layoutY="191.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Location" textAlignment="CENTER" wrappingWidth="343.205078125">
|
||||
<VBox.margin>
|
||||
<Insets bottom="70.0" />
|
||||
</VBox.margin>
|
||||
</Text>
|
||||
<Button mnemonicParsing="false" onMousePressed="#nextPane" prefHeight="51.0" prefWidth="214.0" text="Start Here">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Button>
|
||||
</children>
|
||||
</GridPane>
|
||||
<GridPane GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="74.0" minHeight="10.0" prefHeight="74.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="123.0" minHeight="10.0" prefHeight="93.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="59.0" minHeight="10.0" prefHeight="29.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
</GridPane>
|
||||
<GridPane GridPane.columnIndex="1" GridPane.rowIndex="2">
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints maxHeight="75.0" minHeight="10.0" prefHeight="75.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="107.0" minHeight="10.0" prefHeight="107.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints maxHeight="56.0" minHeight="10.0" prefHeight="27.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1">
|
||||
<center>
|
||||
<Button mnemonicParsing="false" onMousePressed="#nextPane" prefHeight="50.0" prefWidth="170.0" text="Start Here" BorderPane.alignment="CENTER">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Button>
|
||||
</center>
|
||||
</BorderPane>
|
||||
<GridPane>
|
||||
<columnConstraints>
|
||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0">
|
||||
<center>
|
||||
<Label text="This is the name of the Election" BorderPane.alignment="CENTER">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</center>
|
||||
</BorderPane>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.rowIndex="1">
|
||||
<top>
|
||||
<Label text="Location | Precinct" BorderPane.alignment="CENTER" />
|
||||
</top>
|
||||
</BorderPane>
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
</GridPane>
|
||||
<BorderPane prefHeight="200.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.rowIndex="3">
|
||||
<center>
|
||||
<Label fx:id="ErrorPanel" maxHeight="30.0" maxWidth="500.0" minHeight="30.0" minWidth="500.0" prefHeight="30.0" prefWidth="500.0" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
</VBox>
|
||||
</children>
|
||||
</GridPane>
|
||||
</Pane>
|
||||
|
|
Loading…
Reference in New Issue