Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7dea7919c5 | ||
|
|
55517a531e | ||
|
|
a6f14b94bd | ||
|
|
d3472017bb | ||
|
|
bdb34fde31 |
@@ -8,6 +8,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class TournamentDecorator implements IsObservable{
|
||||
private Tournament tournament;
|
||||
@@ -175,6 +176,11 @@ public class TournamentDecorator implements IsObservable{
|
||||
}
|
||||
}
|
||||
|
||||
public void closeApplication() throws InterruptedException {
|
||||
executorService.shutdown();
|
||||
executorService.awaitTermination(2000, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private class saveTask implements Runnable {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,28 +5,31 @@ import ch.zhaw.projekt2.turnierverwaltung.FactoryDecorator;
|
||||
import ch.zhaw.projekt2.turnierverwaltung.FileIO;
|
||||
import ch.zhaw.projekt2.turnierverwaltung.TournamentDecorator;
|
||||
import javafx.application.Application;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.WindowEvent;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class MainWindow extends Application {
|
||||
private FileIO fileIO = new FileIO(System.getProperty("user.dir") + System.getProperty("file.separator") + "tournierverwaltung_angrynerds");
|
||||
private FactoryDecorator factoryDecorator;
|
||||
private TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO);
|
||||
private Factory factory = new Factory(fileIO, tournamentDecorator); //TODO make it private!
|
||||
private Factory factory = new Factory(fileIO, tournamentDecorator);
|
||||
private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName());
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
|
||||
BorderPane pane = factory.loadMainWindow();
|
||||
factoryDecorator = new FactoryDecorator(fileIO, factory, pane);
|
||||
factory.loadAllViews(factoryDecorator, pane);
|
||||
tournamentDecorator.setFactoryDecorator(factoryDecorator);
|
||||
factoryDecorator.openTournamentList();
|
||||
|
||||
|
||||
Scene scene = new Scene(pane);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setMaximized(true);
|
||||
@@ -35,5 +38,13 @@ public class MainWindow extends Application {
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
try {
|
||||
super.stop();
|
||||
tournamentDecorator.closeApplication();
|
||||
} catch (Exception e) {
|
||||
logger.warning("Exception while closing application");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main;
|
||||
|
||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
||||
import javafx.application.Platform;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class MainWindowController extends FXController {
|
||||
|
||||
@FXML
|
||||
void closeApplication(ActionEvent event) {
|
||||
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.ButtonBar;
|
||||
import javafx.scene.control.ButtonType;
|
||||
|
||||
public class AlertNewSchedule extends Alert {
|
||||
private ButtonType yesButton = new ButtonType("Ja", ButtonBar.ButtonData.YES);
|
||||
private ButtonType noButton = new ButtonType("Nein", ButtonBar.ButtonData.NO);
|
||||
private boolean result;
|
||||
|
||||
public AlertNewSchedule() {
|
||||
super(AlertType.WARNING);
|
||||
setTitle("Neu erstellen");
|
||||
setHeaderText("Spielplan neu erstellen?");
|
||||
setContentText("Sind Sie sicher, dass Sie den Spielplan neu erstellen moechten?\nAlle Spielfortschritte gehen daraufhin verloren!");
|
||||
getButtonTypes().setAll(yesButton,noButton);
|
||||
}
|
||||
|
||||
public boolean showAndGetResult() {
|
||||
showAndWait().ifPresent(input -> {
|
||||
result = input == yesButton;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+8
-2
@@ -1,7 +1,6 @@
|
||||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||
|
||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
|
||||
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Button;
|
||||
@@ -30,7 +29,14 @@ public class GameScheduleController extends FXController {
|
||||
|
||||
@FXML
|
||||
void createNewSchedule(ActionEvent event) {
|
||||
getTournamentDecorator().createNewGameSchedule();
|
||||
if (getTournamentDecorator().getTournament().getGameList().size() > 0) {
|
||||
AlertNewSchedule alert = new AlertNewSchedule();
|
||||
if (alert.showAndGetResult()) {
|
||||
getTournamentDecorator().createNewGameSchedule();
|
||||
}
|
||||
} else {
|
||||
getTournamentDecorator().createNewGameSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
||||
+1
-3
@@ -21,9 +21,7 @@ public class AlertDelete extends Alert {
|
||||
public boolean showAndGetResult() {
|
||||
result = false;
|
||||
showAndWait().ifPresent(type -> {
|
||||
if (type == yesButton) {
|
||||
result = true;
|
||||
}
|
||||
result = type == yesButton;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user