Compare commits
No commits in common. "main" and "testing" have entirely different histories.
Binary file not shown.
|
@ -69,7 +69,7 @@ public class Factory {
|
||||||
view.loadView(tournamentDecorator, fileIO, factoryDecorator, pane);
|
view.loadView(tournamentDecorator, fileIO, factoryDecorator, pane);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.warning("failed to load views.");
|
//TODO Handle and logging.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,6 @@ public class Factory {
|
||||||
public void showTournamentList(BorderPane pane) {
|
public void showTournamentList(BorderPane pane) {
|
||||||
tournamentDecorator.setTournament(null);
|
tournamentDecorator.setTournament(null);
|
||||||
setCenterOfBorderPane(pane, View.tournamentList);
|
setCenterOfBorderPane(pane, View.tournamentList);
|
||||||
logger.fine("showing Tournament List");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +89,6 @@ public class Factory {
|
||||||
*/
|
*/
|
||||||
public void showParticipantFormular(BorderPane pane) {
|
public void showParticipantFormular(BorderPane pane) {
|
||||||
setCenterOfBorderPane(pane, View.participantFormular);
|
setCenterOfBorderPane(pane, View.participantFormular);
|
||||||
logger.fine("showing Participant Formular");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +97,6 @@ public class Factory {
|
||||||
*/
|
*/
|
||||||
public void showPlacesFormular(BorderPane pane) {
|
public void showPlacesFormular(BorderPane pane) {
|
||||||
setCenterOfBorderPane(pane, View.placesFormular);
|
setCenterOfBorderPane(pane, View.placesFormular);
|
||||||
logger.fine("showing Places Formular");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +105,6 @@ public class Factory {
|
||||||
*/
|
*/
|
||||||
public void showGameScheduler(BorderPane pane) {
|
public void showGameScheduler(BorderPane pane) {
|
||||||
setCenterOfBorderPane(pane, View.gameScheduler);
|
setCenterOfBorderPane(pane, View.gameScheduler);
|
||||||
logger.fine("showing Game Scheduler");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +131,6 @@ public class Factory {
|
||||||
box.getChildren().add(loader.load());
|
box.getChildren().add(loader.load());
|
||||||
GameController controller = loader.getController();
|
GameController controller = loader.getController();
|
||||||
controller.setup(tournamentDecorator, fileIO, factoryDecorator, box, gameDecorator, languageConfigurator);
|
controller.setup(tournamentDecorator, fileIO, factoryDecorator, box, gameDecorator, languageConfigurator);
|
||||||
logger.fine("loaded game view");
|
|
||||||
return controller;
|
return controller;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.warning("Fatal error program can not continue after this: " + e );
|
logger.warning("Fatal error program can not continue after this: " + e );
|
||||||
|
@ -151,7 +146,6 @@ public class Factory {
|
||||||
* @param error true if it's a error message.
|
* @param error true if it's a error message.
|
||||||
*/
|
*/
|
||||||
public void printMessageToFooter(BorderPane pane, String msg, boolean error) {
|
public void printMessageToFooter(BorderPane pane, String msg, boolean error) {
|
||||||
logger.fine("message is printed to footer of window.");
|
|
||||||
VBox bottom = (VBox) pane.getBottom();
|
VBox bottom = (VBox) pane.getBottom();
|
||||||
Label label = new Label();
|
Label label = new Label();
|
||||||
VBox innerVbox;
|
VBox innerVbox;
|
||||||
|
@ -182,7 +176,6 @@ public class Factory {
|
||||||
* @param error true if the error message should be cleared.
|
* @param error true if the error message should be cleared.
|
||||||
*/
|
*/
|
||||||
public void resetFooter(BorderPane pane,boolean error) {
|
public void resetFooter(BorderPane pane,boolean error) {
|
||||||
logger.fine("messages are removed from footer of window.");
|
|
||||||
VBox bottom = (VBox) pane.getBottom();
|
VBox bottom = (VBox) pane.getBottom();
|
||||||
VBox vBox;
|
VBox vBox;
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
@ -141,20 +141,11 @@ public class FactoryDecorator implements IsObservable {
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the view of gameSchedule
|
|
||||||
*/
|
|
||||||
public void openScheduleView() {
|
public void openScheduleView() {
|
||||||
factory.showGameScheduler((BorderPane) pane);
|
factory.showGameScheduler((BorderPane) pane);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to load all game views to show.
|
|
||||||
* @param hBoxCenter the box where the games should be shown.
|
|
||||||
* @param tournamentDecorator the tournamentDecorator to communicate to tournament
|
|
||||||
* @param treeView true if the games should be arranged like a tree.
|
|
||||||
*/
|
|
||||||
public void loadGameList(HBox hBoxCenter, TournamentDecorator tournamentDecorator, boolean treeView) {
|
public void loadGameList(HBox hBoxCenter, TournamentDecorator tournamentDecorator, boolean treeView) {
|
||||||
hBoxCenter.getChildren().clear();
|
hBoxCenter.getChildren().clear();
|
||||||
|
|
||||||
|
@ -204,13 +195,6 @@ public class FactoryDecorator implements IsObservable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to draw the lines between the game views in the tree view.
|
|
||||||
* @param gameVBox the box with the games where lines should be drawn.
|
|
||||||
* @param gameBoxHeight the heigth of a single game box.
|
|
||||||
* @param lineLength the length of the horizontal lines.
|
|
||||||
* @return a box which contains the drawn lines.
|
|
||||||
*/
|
|
||||||
public VBox drawLines(VBox gameVBox, double gameBoxHeight, double lineLength) {
|
public VBox drawLines(VBox gameVBox, double gameBoxHeight, double lineLength) {
|
||||||
VBox completeLineVBox = new VBox();
|
VBox completeLineVBox = new VBox();
|
||||||
completeLineVBox.setAlignment(Pos.CENTER_LEFT);
|
completeLineVBox.setAlignment(Pos.CENTER_LEFT);
|
||||||
|
@ -244,8 +228,8 @@ public class FactoryDecorator implements IsObservable {
|
||||||
/**
|
/**
|
||||||
* Method Initializes the Game View, in order to do that a vbox is needed and the gameDecorator
|
* Method Initializes the Game View, in order to do that a vbox is needed and the gameDecorator
|
||||||
* @param vBox used for display
|
* @param vBox used for display
|
||||||
* @param gameDecorator the gameDecorator Object to communicate with game
|
* @param gameDecorator
|
||||||
* @return the controller of the loaded game view.
|
* @return
|
||||||
*/
|
*/
|
||||||
public GameController openGameView(VBox vBox, GameDecorator gameDecorator) {
|
public GameController openGameView(VBox vBox, GameDecorator gameDecorator) {
|
||||||
|
|
||||||
|
@ -272,10 +256,9 @@ public class FactoryDecorator implements IsObservable {
|
||||||
factory.resetFooter((BorderPane) pane, error);
|
factory.resetFooter((BorderPane) pane, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* getter Method of languageConfigurator
|
|
||||||
* @return the languageConfigurator object.
|
|
||||||
*/
|
|
||||||
public LanguageConfigurator getLanguageConfigurator() {
|
public LanguageConfigurator getLanguageConfigurator() {
|
||||||
return factory.getLanguageConfigurator();
|
return factory.getLanguageConfigurator();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,6 @@ import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
|
|
||||||
public class TournamentDecorator implements IsObservable{
|
public class TournamentDecorator implements IsObservable{
|
||||||
private Tournament tournament;
|
private Tournament tournament;
|
||||||
|
@ -18,84 +16,48 @@ public class TournamentDecorator implements IsObservable{
|
||||||
private ExecutorService executorService;
|
private ExecutorService executorService;
|
||||||
private FactoryDecorator factoryDecorator;
|
private FactoryDecorator factoryDecorator;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(TournamentDecorator.class.getCanonicalName());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor to initialize TournamentDecorator
|
|
||||||
* adds a listener to save the tournament every time if something is changed.
|
|
||||||
* creates a executer service to do the saving process in separate thread for better performance.
|
|
||||||
* @param fileIO
|
|
||||||
*/
|
|
||||||
public TournamentDecorator(FileIO fileIO){
|
public TournamentDecorator(FileIO fileIO){
|
||||||
logger.fine("initializing TournamentDecorator");
|
|
||||||
setFileIO(fileIO);
|
setFileIO(fileIO);
|
||||||
addListener(new IsObserver() {
|
addListener(new IsObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
if(tournament != null){
|
if(tournament != null){
|
||||||
|
|
||||||
saveTournament();
|
saveTournament();
|
||||||
logger.fine("listener to save tournament was added");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
executorService = Executors.newFixedThreadPool(1);
|
executorService = Executors.newFixedThreadPool(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter method of FactoryDecorator
|
|
||||||
* @param factoryDecorator the factory decorator to load different views.
|
|
||||||
*/
|
|
||||||
public void setFactoryDecorator(FactoryDecorator factoryDecorator) {
|
public void setFactoryDecorator(FactoryDecorator factoryDecorator) {
|
||||||
this.factoryDecorator = factoryDecorator;
|
this.factoryDecorator = factoryDecorator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Setter Method of FileIO
|
|
||||||
* @param fileIO the fileIO object to read and save to files.
|
|
||||||
*/
|
|
||||||
public void setFileIO(FileIO fileIO) {
|
public void setFileIO(FileIO fileIO) {
|
||||||
this.fileIO = fileIO;
|
this.fileIO = fileIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* setter Method of Tournament
|
|
||||||
* @param tournament the new Tournament Object which was selected by user.
|
|
||||||
*/
|
|
||||||
public void setTournament(Tournament tournament) {
|
public void setTournament(Tournament tournament) {
|
||||||
this.tournament = tournament;
|
this.tournament = tournament;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* getter Method of Tournament
|
|
||||||
* @return the actual tournament which is open.
|
|
||||||
*/
|
|
||||||
public Tournament getTournament() {
|
public Tournament getTournament() {
|
||||||
return tournament;
|
return tournament;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to add a listener in list.
|
|
||||||
* @param observer the observer object which should be informed.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(IsObserver observer) {
|
public void addListener(IsObserver observer) {
|
||||||
listener.add(observer);
|
listener.add(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to remove a listener from list.
|
|
||||||
* @param observer the object to remove.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void removeListener(IsObserver observer) {
|
public void removeListener(IsObserver observer) {
|
||||||
listener.remove(observer);
|
listener.remove(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to save the actual tournament to files.
|
|
||||||
*/
|
|
||||||
public void saveTournament(){
|
public void saveTournament(){
|
||||||
logger.fine("Saving Tournament to File.");
|
|
||||||
executorService.execute(new saveTask());
|
executorService.execute(new saveTask());
|
||||||
factoryDecorator.clearMessage(false);
|
factoryDecorator.clearMessage(false);
|
||||||
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("save");
|
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("save");
|
||||||
|
@ -103,49 +65,40 @@ public class TournamentDecorator implements IsObservable{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create a new Tournament. It checks if the name is valid, creates a new instance of Tournament and calls
|
|
||||||
* FileIO to save the new Tournament.
|
|
||||||
* @param name The name which was entered by the user.
|
|
||||||
* @param type The type of Tournament
|
|
||||||
*/
|
|
||||||
public void createTournament(String name, Tournament.Type type){
|
public void createTournament(String name, Tournament.Type type){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(fileIO.tournamentExists(name)){
|
if(fileIO.tournamentExists(name)){
|
||||||
logger.warning("a tournament with name " + name + "exists already.");
|
//TODO:Logger
|
||||||
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("tournamentExists");
|
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("tournamentExists");
|
||||||
factoryDecorator.printMessageToFooter(msg, true);
|
factoryDecorator.printMessageToFooter(msg, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Tournament tournament = new Tournament(name, type);
|
Tournament tournament = new Tournament(name, type);
|
||||||
logger.fine("new tournament instance was created.");
|
|
||||||
fileIO.saveTournament(tournament);
|
fileIO.saveTournament(tournament);
|
||||||
logger.fine("new Tournament File is saved.");
|
|
||||||
factoryDecorator.clearMessage(true);
|
factoryDecorator.clearMessage(true);
|
||||||
informListener();
|
informListener();
|
||||||
} catch (InvalidNameException e) {
|
} catch (InvalidNameException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.warning("The name which was entered is invalid.");
|
//TODO: Logger
|
||||||
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("invalidName");
|
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("invalidName");
|
||||||
factoryDecorator.printMessageToFooter(msg, true);
|
factoryDecorator.printMessageToFooter(msg, true);
|
||||||
} catch (Tournament.InvalidTypeException e) {
|
} catch (Tournament.InvalidTypeException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.warning("The selected type of tournament is not valid.");
|
//TODO: Logger
|
||||||
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("invalidMode");
|
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("invalidMode");
|
||||||
factoryDecorator.printMessageToFooter(msg, true);
|
factoryDecorator.printMessageToFooter(msg, true);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.warning("Creating a new Tournament File was failed.");
|
//TODO: Logger
|
||||||
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("IOException");
|
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("IOException");
|
||||||
factoryDecorator.printMessageToFooter(msg, true);
|
factoryDecorator.printMessageToFooter(msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to delete a Tournament File
|
|
||||||
* @param tournamentFile The File which should be deleted.
|
|
||||||
*/
|
|
||||||
public void deleteTournament(FileIO.TournamentFile tournamentFile){
|
public void deleteTournament(FileIO.TournamentFile tournamentFile){
|
||||||
try {
|
try {
|
||||||
fileIO.deleteTournament(tournamentFile);
|
fileIO.deleteTournament(tournamentFile);
|
||||||
|
@ -158,11 +111,8 @@ public class TournamentDecorator implements IsObservable{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method to create the list of games. The participants are entered in random order.
|
|
||||||
*/
|
|
||||||
public void createNewGameSchedule() {
|
public void createNewGameSchedule() {
|
||||||
logger.fine("Creating new Game Schedule");
|
//TODO: logging
|
||||||
try {
|
try {
|
||||||
tournament.createGameSchedule();
|
tournament.createGameSchedule();
|
||||||
factoryDecorator.clearMessage(true);
|
factoryDecorator.clearMessage(true);
|
||||||
|
@ -170,7 +120,6 @@ public class TournamentDecorator implements IsObservable{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("numberParticipant");
|
String msg = factoryDecorator.getLanguageConfigurator().getSelectedLanguage("numberParticipant");
|
||||||
factoryDecorator.printMessageToFooter(msg, true);
|
factoryDecorator.printMessageToFooter(msg, true);
|
||||||
logger.warning("Failed to create Game Schedule. The number of Participants is invalid.");
|
|
||||||
}
|
}
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,51 +1,29 @@
|
||||||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
|
||||||
|
|
||||||
import ch.zhaw.projekt2.turnierverwaltung.*;
|
import ch.zhaw.projekt2.turnierverwaltung.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* This Class is used by the GameController for additional functionality and holds the listeners and the Model Game
|
|
||||||
*/
|
|
||||||
public class GameDecorator implements IsObservable{
|
public class GameDecorator implements IsObservable{
|
||||||
private Game game;
|
private Game game;
|
||||||
private List<IsObserver> listener = new ArrayList<>();
|
private List<IsObserver> listener = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup the GameDecorator
|
|
||||||
*
|
|
||||||
* @param game Model for the Controller
|
|
||||||
*/
|
|
||||||
public GameDecorator (Game game) {
|
public GameDecorator (Game game) {
|
||||||
this.game = game;
|
this.game = game;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method adds a new Listener to the listener list
|
|
||||||
*
|
|
||||||
* @param observer that is being added to the Listener List
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addListener(IsObserver observer) {
|
public void addListener(IsObserver observer) {
|
||||||
listener.add(observer);
|
listener.add(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a Listener from the Listener List
|
|
||||||
*
|
|
||||||
* @param observer the Listener to be removed
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void removeListener(IsObserver observer) {
|
public void removeListener(IsObserver observer) {
|
||||||
listener.remove(observer);
|
listener.remove(observer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the Gameresult in the model
|
|
||||||
*
|
|
||||||
* @param points1 points achieved in textfield one
|
|
||||||
* @param points2 points achieved in textfield two
|
|
||||||
*/
|
|
||||||
public void saveGameResult(String points1, String points2){
|
public void saveGameResult(String points1, String points2){
|
||||||
if(points1.length() > 0){
|
if(points1.length() > 0){
|
||||||
game.setPoints1(Integer.parseInt(points1));
|
game.setPoints1(Integer.parseInt(points1));
|
||||||
|
@ -60,35 +38,19 @@ public class GameDecorator implements IsObservable{
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the Place in the Model
|
|
||||||
*
|
|
||||||
* @param place
|
|
||||||
*/
|
|
||||||
public void saveGamePlace(Place place){
|
public void saveGamePlace(Place place){
|
||||||
game.setPlace(place);
|
game.setPlace(place);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return game points from player one
|
|
||||||
*/
|
|
||||||
public String getPoints1() {
|
public String getPoints1() {
|
||||||
return String.valueOf(game.getPoints1());
|
return String.valueOf(game.getPoints1());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*@return game points from player two
|
|
||||||
*/
|
|
||||||
public String getPoints2() {
|
public String getPoints2() {
|
||||||
return String.valueOf(game.getPoints2());
|
return String.valueOf(game.getPoints2());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return returns Gameparticipant one
|
|
||||||
*/
|
|
||||||
public String getParticipantOne() {
|
public String getParticipantOne() {
|
||||||
if (game.getParticipant1() != null) {
|
if (game.getParticipant1() != null) {
|
||||||
return game.getParticipant1().toString();
|
return game.getParticipant1().toString();
|
||||||
|
@ -96,10 +58,6 @@ public class GameDecorator implements IsObservable{
|
||||||
return "1";
|
return "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return returns Gameparticipant two
|
|
||||||
*/
|
|
||||||
public String getParticipantTwo() {
|
public String getParticipantTwo() {
|
||||||
if (game.getParticipant2() != null) {
|
if (game.getParticipant2() != null) {
|
||||||
return game.getParticipant2().toString();
|
return game.getParticipant2().toString();
|
||||||
|
@ -107,25 +65,15 @@ public class GameDecorator implements IsObservable{
|
||||||
return "2";
|
return "2";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* calls method in model to refresh participant
|
|
||||||
*/
|
|
||||||
public void refreshParticipants(){
|
public void refreshParticipants(){
|
||||||
game.refreshParticipants();
|
game.refreshParticipants();
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return place
|
|
||||||
*/
|
|
||||||
public Place getPlace() {
|
public Place getPlace() {
|
||||||
return game.getPlace();
|
return game.getPlace();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method that informs all listeners of an update.
|
|
||||||
*/
|
|
||||||
public void informListener() {
|
public void informListener() {
|
||||||
for(IsObserver observer : listener) {
|
for(IsObserver observer : listener) {
|
||||||
observer.update();
|
observer.update();
|
||||||
|
|
|
@ -14,11 +14,6 @@ import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller of Participant
|
|
||||||
*/
|
|
||||||
public class ParticipantFormularController extends FXController {
|
public class ParticipantFormularController extends FXController {
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
@ -73,14 +68,8 @@ public class ParticipantFormularController extends FXController {
|
||||||
@FXML
|
@FXML
|
||||||
private Button saveBtn;
|
private Button saveBtn;
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(ParticipantFormularController.class.getCanonicalName());
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shares GUI Elements with the LanguageConfigurator
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void shareGUIElementWithLanguageConfigurator() {
|
public void shareGUIElementWithLanguageConfigurator() {
|
||||||
logger.fine("sharing GUI Elements");
|
|
||||||
getLanguageConfigurator().recieveLabel(participantListTitle);
|
getLanguageConfigurator().recieveLabel(participantListTitle);
|
||||||
getLanguageConfigurator().recieveLabel(closeBtn);
|
getLanguageConfigurator().recieveLabel(closeBtn);
|
||||||
getLanguageConfigurator().recieveLabel(deleteBtn);
|
getLanguageConfigurator().recieveLabel(deleteBtn);
|
||||||
|
@ -92,11 +81,8 @@ public class ParticipantFormularController extends FXController {
|
||||||
getLanguageConfigurator().recieveLabel(saveBtn);
|
getLanguageConfigurator().recieveLabel(saveBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the current selection
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void changedSelection(){
|
void changedSelection(MouseEvent event){
|
||||||
Player participant = (Player) participantListView.getSelectionModel().getSelectedItems().get(0);
|
Player participant = (Player) participantListView.getSelectionModel().getSelectedItems().get(0);
|
||||||
participantNameTextField.setText(participant.getName());
|
participantNameTextField.setText(participant.getName());
|
||||||
firstNameTextField.setText(participant.getFirstName());
|
firstNameTextField.setText(participant.getFirstName());
|
||||||
|
@ -104,18 +90,12 @@ public class ParticipantFormularController extends FXController {
|
||||||
birthDateTextField.setText(participant.getFormattedDateOfBirth());
|
birthDateTextField.setText(participant.getFormattedDateOfBirth());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves a new Participant and clears form
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void saveParticipant() {
|
void saveParticipant(ActionEvent event) {
|
||||||
getTournamentDecorator().savePlayer(firstNameTextField.getText(), participantNameTextField.getText(), phoneNumberTextField.getText(), birthDateTextField.getText());
|
getTournamentDecorator().savePlayer(firstNameTextField.getText(), participantNameTextField.getText(), phoneNumberTextField.getText(), birthDateTextField.getText());
|
||||||
clearFormular();
|
clearFormular();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Clears current form
|
|
||||||
*/
|
|
||||||
private void clearFormular() {
|
private void clearFormular() {
|
||||||
firstNameTextField.clear();
|
firstNameTextField.clear();
|
||||||
participantNameTextField.clear();
|
participantNameTextField.clear();
|
||||||
|
@ -123,30 +103,19 @@ public class ParticipantFormularController extends FXController {
|
||||||
birthDateTextField.clear();
|
birthDateTextField.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the selected participant.
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void delete() {
|
void delete(ActionEvent event) {
|
||||||
Participant participant = participantListView.getSelectionModel().getSelectedItems().get(0);
|
Participant participant = participantListView.getSelectionModel().getSelectedItems().get(0);
|
||||||
logger.fine("deleting participant:" + participant);
|
|
||||||
getTournamentDecorator().deleteParticipant(participant);
|
getTournamentDecorator().deleteParticipant(participant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes the participant form
|
|
||||||
*/
|
|
||||||
@FXML
|
@FXML
|
||||||
void close() {
|
void close(ActionEvent event) {
|
||||||
getFactoryDecorator().openScheduleView();
|
getFactoryDecorator().openScheduleView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the previously saved content and puts it in the list
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void loadContent() {
|
public void loadContent() {
|
||||||
logger.fine("loading and placing it into the list");
|
|
||||||
Tournament tournament = getTournamentDecorator().getTournament();
|
Tournament tournament = getTournamentDecorator().getTournament();
|
||||||
if(tournament != null){
|
if(tournament != null){
|
||||||
participantListView.setItems(tournament.getParticipants());
|
participantListView.setItems(tournament.getParticipants());
|
||||||
|
|
Loading…
Reference in New Issue