implemented functionality to activate treeview

This commit is contained in:
schrom01 2022-05-11 16:21:38 +02:00
parent b51a585167
commit 7f723fd763
4 changed files with 37 additions and 20 deletions

View File

@ -77,7 +77,7 @@ public class FactoryDecorator implements IsObservable{
informListener();
}
public void loadGameTree(HBox hBoxCenter, TournamentDecorator tournamentDecorator) {
public void loadGameList(HBox hBoxCenter, TournamentDecorator tournamentDecorator, boolean treeView) {
hBoxCenter.getChildren().clear();
List<List<Game>> gameList = tournamentDecorator.getTournament().getGameList();
@ -88,8 +88,12 @@ public class FactoryDecorator implements IsObservable{
for (int i = 0; i < gameList.size(); i++) {
List<GameDecorator> newGameDecorators = new ArrayList<>();
VBox vBox = new VBox();
vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(gameBoxHeight * spacingFactor);
if(treeView){
vBox.setAlignment(Pos.CENTER);
vBox.setSpacing(gameBoxHeight * spacingFactor);
} else {
vBox.setAlignment(Pos.TOP_CENTER);
}
spacingFactor = spacingFactor * 2 + 1;
for (int j = 0; j < gameList.get(i).size(); j++) {
GameDecorator gameDecorator = new GameDecorator(gameList.get(i).get(j));

View File

@ -5,6 +5,7 @@ import ch.zhaw.projekt2.turnierverwaltung.Tournament;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.layout.HBox;
public class GameScheduleController extends FXController {
@ -24,6 +25,9 @@ public class GameScheduleController extends FXController {
@FXML
private HBox hBoxCenter;
@FXML
private CheckBox treeView;
@FXML
void createNewSchedule(ActionEvent event) {
try {
@ -52,9 +56,14 @@ public class GameScheduleController extends FXController {
getFactoryDecorator().openTournamentList();
}
@FXML
void changeView(ActionEvent event) {
loadContent();
}
@Override
public void loadContent() {
getFactoryDecorator().loadGameTree(hBoxCenter, getTournamentDecorator());
getFactoryDecorator().loadGameList(hBoxCenter, getTournamentDecorator(), treeView.isSelected());
}
}

View File

@ -1,35 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ChoiceBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.VBox?>
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="150.0" style="-fx-border-color: black; -fx-border-insets: 2; -fx-border-width: 3;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameController">
<VBox alignment="CENTER" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="90.0" prefWidth="450.0" style="-fx-border-color: black; -fx-border-insets: 2; -fx-border-width: 3;" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameController">
<children>
<VBox fx:id="mainVBox" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="150.0">
<VBox fx:id="mainVBox" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="90.0">
<children>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Label fx:id="participantNameOne" text="Participant One">
<Label fx:id="participantNameOne" style="-fx-font-weight: bold;" text="Participant One">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</Label>
<TextField fx:id="pointsTeamOne" prefHeight="25.0" prefWidth="50.0" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
<children>
<Label fx:id="participantNameTwo" text="Participant Two">
<TextField fx:id="pointsTeamOne" alignment="CENTER" onKeyTyped="#saveGameResult" prefHeight="25.0" prefWidth="50.0">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</TextField>
<Label text=":">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</Label>
<TextField fx:id="pointsTeamTwo" alignment="CENTER" onKeyTyped="#saveGameResult" prefHeight="25.0" prefWidth="50.0">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</TextField>
<Label fx:id="participantNameTwo" style="-fx-font-weight: bold;" text="Participant Two">
<HBox.margin>
<Insets right="20.0" />
</HBox.margin>
</Label>
<TextField fx:id="pointsTeamTwo" prefHeight="25.0" prefWidth="50.0" />
</children>
</HBox>
<HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
@ -45,11 +53,6 @@
<Insets top="10.0" />
</VBox.margin>
</HBox>
<Button mnemonicParsing="false" onAction="#saveGamerResult" text="Speichern">
<VBox.margin>
<Insets bottom="10.0" top="10.0" />
</VBox.margin>
</Button>
</children>
</VBox>
</children>

View File

@ -8,6 +8,7 @@
<top>
<HBox alignment="TOP_RIGHT" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
<children>
<CheckBox fx:id="treeView" mnemonicParsing="false" onAction="#changeView" selected="true" text="Baumansicht" />
<Button fx:id="createScheduleBtn" mnemonicParsing="false" onAction="#createNewSchedule" text="Create New Game Schedule">
<HBox.margin>
<Insets right="20.0" />