Createing the object that will update the new strings answers
parent
fe5a4d7be1
commit
4e071c83ce
|
@ -29,8 +29,8 @@ public class SelectCandidateNameController extends TwoWayNode {
|
||||||
* Updates the voter options according to the VotingBoothConfiguration
|
* Updates the voter options according to the VotingBoothConfiguration
|
||||||
*/
|
*/
|
||||||
private void UpdateVoterOptions(){
|
private void UpdateVoterOptions(){
|
||||||
|
StringsAnswersUpdater updater = new StringsAnswersUpdater(this.currentStage);
|
||||||
|
updater.AddAnswers(this.config.NameSelectionQuestion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package meerkat.voting.gui.select_candidate_name;
|
||||||
|
|
||||||
|
import com.google.protobuf.ByteString;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import meerkat.protobuf.BallotQuestionUIElementOuterClass;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Vladimir Eliezer Tokarev on 10/2/2016.
|
||||||
|
* This object gets the current stage and appends to the container of the names
|
||||||
|
* the different names that there are in the config object
|
||||||
|
*/
|
||||||
|
public class StringsAnswersUpdater {
|
||||||
|
private Stage currentStage;
|
||||||
|
private int rowAmount;
|
||||||
|
|
||||||
|
public StringsAnswersUpdater(Stage primaryStage) {
|
||||||
|
this.currentStage = primaryStage;
|
||||||
|
this.rowAmount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GridPane GetAnswersContainer(){
|
||||||
|
return (GridPane) this.currentStage.getScene().lookup("#AnswersScrollPane");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddAnswer(String answer){
|
||||||
|
GridPane container = this.GetAnswersContainer();
|
||||||
|
|
||||||
|
Label label = new Label();
|
||||||
|
label.setText(answer);
|
||||||
|
container.addRow(0);
|
||||||
|
|
||||||
|
this.rowAmount++;
|
||||||
|
container.add(label, 0, this.rowAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveAllAnswers(){
|
||||||
|
GridPane gridPane = this.GetAnswersContainer();
|
||||||
|
gridPane.getChildren().removeAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddAnswers(BallotQuestionUIElementOuterClass.BallotQuestionUIElement question) {
|
||||||
|
this.RemoveAllAnswers();
|
||||||
|
for (ByteString bytesAnswer : question.getAnswers().getAnswers().getAnswersList()){
|
||||||
|
this.AddAnswer(bytesAnswer.toString());
|
||||||
|
}
|
||||||
|
this.currentStage.show();
|
||||||
|
}
|
||||||
|
}
|
|
@ -85,7 +85,7 @@
|
||||||
<children>
|
<children>
|
||||||
<BorderPane layoutY="18.0" prefHeight="182.0" prefWidth="587.0">
|
<BorderPane layoutY="18.0" prefHeight="182.0" prefWidth="587.0">
|
||||||
<bottom>
|
<bottom>
|
||||||
<GridPane prefHeight="159.0" prefWidth="596.0" BorderPane.alignment="CENTER">
|
<GridPane fx:id="#AnswersScrollPane" prefHeight="159.0" prefWidth="596.0" BorderPane.alignment="CENTER">
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="143.0" minWidth="10.0" prefWidth="66.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="143.0" minWidth="10.0" prefWidth="66.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" maxWidth="462.0" minWidth="10.0" prefWidth="452.0" />
|
<ColumnConstraints hgrow="SOMETIMES" maxWidth="462.0" minWidth="10.0" prefWidth="452.0" />
|
||||||
|
|
Loading…
Reference in New Issue