TextInputHelper.addLengthListener(tfTeamRnk10, 50);
TextInputHelper.addLengthListener(tfTeamRnk11, 50);
TextInputHelper.addLengthListener(tfTeamRnk12, 50);
final Label title = LabelBuilder.create().text(ResourceLoader.getResource("label.title.createLeague")).style("-fx-font: NORMAL 16 Tahoma;").build();
final VBox vBoxTop = VBoxBuilder.create().children().spacing(5.0).padding(new Insets(10, 10, 10, 10)).children(title).build();
// create league button
final Button buttonCreate = ButtonBuilder.create().text(ResourceLoader.getResource("button.createLeague")).onAction(new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent event) {
// TODO validate and save data to database
final Team team1 = new Team();
team1.setStartPos(1);
team1.setName(tfTeamRnk1.getText());
}
}).prefWidth(100.0).build();
// cancel dialogue button
final Button buttonCancel = ButtonBuilder.create().text(ResourceLoader.getResource("button.cancel")).onAction(new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent event) {
final Stage stage = (Stage) parent.getScene().getWindow();
stage.close();
}
}).prefWidth(100.0).build();
final HBox hBoxButtonArea = HBoxBuilder.create().alignment(Pos.CENTER).spacing(5.0).padding(new Insets(20)).children(buttonCreate, buttonCancel).build();
final ColumnConstraints ccWidth20 = ColumnConstraintsBuilder.create().prefWidth(50.0).build();
final ColumnConstraints ccWidth180 = ColumnConstraintsBuilder.create().prefWidth(150.0).build();
// labels for team names
final Label labelTeamRnk1 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank1")).build();
final Label labelTeamRnk2 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank2")).build();
final Label labelTeamRnk3 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank3")).build();
final Label labelTeamRnk4 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank4")).build();
final Label labelTeamRnk5 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank5")).build();
final Label labelTeamRnk6 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank6")).build();
final Label labelTeamRnk7 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank7")).build();
final Label labelTeamRnk8 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank8")).build();
final Label labelTeamRnk9 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank9")).build();
final Label labelTeamRnk10 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank10")).build();
final Label labelTeamRnk11 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank11")).build();
final Label labelTeamRnk12 = LabelBuilder.create().text(ResourceLoader.getResource("label.team.rank12")).build();
final GridPane gpTeams = GridPaneBuilder.create().alignment(Pos.TOP_LEFT).hgap(5.0).vgap(5.0).columnConstraints(ccWidth20, ccWidth180).build();
gpTeams.add(labelTeamRnk1, 0, 0);
gpTeams.add(tfTeamRnk1, 1, 0);
gpTeams.add(labelTeamRnk2, 0, 1);
gpTeams.add(tfTeamRnk2, 1, 1);
gpTeams.add(labelTeamRnk3, 0, 2);
gpTeams.add(tfTeamRnk3, 1, 2);
gpTeams.add(labelTeamRnk4, 0, 3);
gpTeams.add(tfTeamRnk4, 1, 3);
gpTeams.add(labelTeamRnk5, 0, 4);
gpTeams.add(tfTeamRnk5, 1, 4);
gpTeams.add(labelTeamRnk6, 0, 5);
gpTeams.add(tfTeamRnk6, 1, 5);
gpTeams.add(labelTeamRnk7, 0, 6);
gpTeams.add(tfTeamRnk7, 1, 6);
gpTeams.add(labelTeamRnk8, 0, 7);
gpTeams.add(tfTeamRnk8, 1, 7);
gpTeams.add(labelTeamRnk9, 0, 8);
gpTeams.add(tfTeamRnk9, 1, 8);
gpTeams.add(labelTeamRnk10, 0, 9);
gpTeams.add(tfTeamRnk10, 1, 9);
gpTeams.add(labelTeamRnk11, 0, 10);
gpTeams.add(tfTeamRnk11, 1, 10);
gpTeams.add(labelTeamRnk12, 0, 11);
gpTeams.add(tfTeamRnk12, 1, 11);
final ColumnConstraints ccWidth80 = ColumnConstraintsBuilder.create().prefWidth(80.0).build();
final ColumnConstraints ccWidth120 = ColumnConstraintsBuilder.create().prefWidth(120.0).build();
final Label labelMatchday = LabelBuilder.create().text(ResourceLoader.getResource("label.firstMatchday")).build();
final TextField tfMatchday = TextFieldBuilder.create().id("idTfMatchday").build();
final GridPane gpMatchday = GridPaneBuilder.create().alignment(Pos.TOP_LEFT).hgap(5.0).vgap(5.0).columnConstraints(ccWidth80, ccWidth120).build();
gpMatchday.add(labelMatchday, 0, 0);
gpMatchday.add(tfMatchday, 1, 0);
final VBox vBoxCenter = VBoxBuilder.create().children(gpTeams, gpMatchday, hBoxButtonArea).spacing(5.0).padding(new Insets(10, 10, 10, 10)).build();
parent.setTop(vBoxTop);
parent.setCenter(vBoxCenter);
return parent;
}