implemented Button and Method deleteTournament in Tournament List

This commit is contained in:
schrom01 2022-05-01 11:27:54 +02:00
parent a3bd207610
commit 58b1692181
2 changed files with 23 additions and 5 deletions

View File

@ -36,6 +36,9 @@ public class TournamentListController extends FXController {
@FXML @FXML
private Button openBtn; private Button openBtn;
@FXML
private Button deleteBtn;
@FXML @FXML
private Label tournamentListTitle; private Label tournamentListTitle;
@ -82,6 +85,17 @@ public class TournamentListController extends FXController {
} //TODO handle and logging } //TODO handle and logging
} }
@FXML
void deleteTournament(ActionEvent event) {
//TODO Ask first to delete?
File tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0);
try {
getFileIO().deleteTournament(tournamentFile);
} catch (IOException e) {
e.printStackTrace(); //TODO handle and logging
}
}
@Override @Override
public void loadContent() { public void loadContent() {
tournamentListView.setItems(getFileIO().getList()); tournamentListView.setItems(getFileIO().getList());

View File

@ -22,11 +22,15 @@
<Insets /> <Insets />
</VBox.margin> </VBox.margin>
</ListView> </ListView>
<Button fx:id="openBtn" mnemonicParsing="false" onAction="#openTournament" text="Öffnen"> <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0" spacing="20.0">
<VBox.margin> <VBox.margin>
<Insets bottom="20.0" top="40.0" /> <Insets bottom="20.0" top="40.0" />
</VBox.margin> </VBox.margin>
</Button> <children>
<Button fx:id="openBtn" mnemonicParsing="false" onAction="#openTournament" text="Öffnen" />
<Button fx:id="deleteBtn" layoutX="138.0" layoutY="28.0" mnemonicParsing="false" onAction="#deleteTournament" text="Löschen" />
</children>
</HBox>
</children> </children>
<HBox.margin> <HBox.margin>
<Insets left="40.0" /> <Insets left="40.0" />