Create Language Change
This commit is contained in:
		
							parent
							
								
									f575bb94d3
								
							
						
					
					
						commit
						c4f0a5335d
					
				| 
						 | 
					@ -8,8 +8,9 @@ public abstract class FXController {
 | 
				
			||||||
    FileIO fileIO;
 | 
					    FileIO fileIO;
 | 
				
			||||||
    Pane pane;
 | 
					    Pane pane;
 | 
				
			||||||
    IsObserver listener;
 | 
					    IsObserver listener;
 | 
				
			||||||
 | 
					    LanguageConfigurator languageConfigurator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public FXController(){
 | 
					    public FXController() {
 | 
				
			||||||
        listener = new IsObserver() {
 | 
					        listener = new IsObserver() {
 | 
				
			||||||
            @Override
 | 
					            @Override
 | 
				
			||||||
            public void update() {
 | 
					            public void update() {
 | 
				
			||||||
| 
						 | 
					@ -18,21 +19,30 @@ public abstract class FXController {
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane){
 | 
					    public void setup(LanguageConfigurator languageConfigurator) {
 | 
				
			||||||
 | 
					        this.languageConfigurator = languageConfigurator;
 | 
				
			||||||
 | 
					        shareGUIElementWithLanguageConfigurator();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane, LanguageConfigurator languageConfigurator) {
 | 
				
			||||||
        this.tournamentDecorator = tournamentDecorator;
 | 
					        this.tournamentDecorator = tournamentDecorator;
 | 
				
			||||||
        this.fileIO = fileIO;
 | 
					        this.fileIO = fileIO;
 | 
				
			||||||
        this.factoryDecorator = factoryDecorator;
 | 
					        this.factoryDecorator = factoryDecorator;
 | 
				
			||||||
        this.pane = pane;
 | 
					        this.pane = pane;
 | 
				
			||||||
 | 
					        this.languageConfigurator = languageConfigurator;
 | 
				
			||||||
 | 
					        shareGUIElementWithLanguageConfigurator();
 | 
				
			||||||
        addListener();
 | 
					        addListener();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public abstract void shareGUIElementWithLanguageConfigurator();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public abstract void loadContent();
 | 
					    public abstract void loadContent();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected void setTournamentDecorator(TournamentDecorator tournamentDecorator) {
 | 
					    protected void setTournamentDecorator(TournamentDecorator tournamentDecorator) {
 | 
				
			||||||
        this.tournamentDecorator = tournamentDecorator;
 | 
					        this.tournamentDecorator = tournamentDecorator;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void addListener(){
 | 
					    public void addListener() {
 | 
				
			||||||
        tournamentDecorator.addListener(listener);
 | 
					        tournamentDecorator.addListener(listener);
 | 
				
			||||||
        factoryDecorator.addListener(listener);
 | 
					        factoryDecorator.addListener(listener);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					@ -64,4 +74,8 @@ public abstract class FXController {
 | 
				
			||||||
    protected Pane getPane() {
 | 
					    protected Pane getPane() {
 | 
				
			||||||
        return pane;
 | 
					        return pane;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected LanguageConfigurator getLanguageConfigurator() {
 | 
				
			||||||
 | 
					        return languageConfigurator;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,11 +14,12 @@ import java.io.IOException;
 | 
				
			||||||
public class Factory {
 | 
					public class Factory {
 | 
				
			||||||
    private TournamentDecorator tournamentDecorator;
 | 
					    private TournamentDecorator tournamentDecorator;
 | 
				
			||||||
    private FileIO fileIO;
 | 
					    private FileIO fileIO;
 | 
				
			||||||
 | 
					    private static LanguageConfigurator languageConfigurator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Factory(FileIO fileIO, TournamentDecorator tournamentDecorator) {
 | 
					    public Factory(FileIO fileIO, TournamentDecorator tournamentDecorator, LanguageConfigurator languageConfigurator) {
 | 
				
			||||||
        this.fileIO = fileIO;
 | 
					        this.fileIO = fileIO;
 | 
				
			||||||
        this.tournamentDecorator = tournamentDecorator;
 | 
					        this.tournamentDecorator = tournamentDecorator;
 | 
				
			||||||
 | 
					        this.languageConfigurator = languageConfigurator;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public TournamentDecorator getTournamentDecorator() {
 | 
					    public TournamentDecorator getTournamentDecorator() {
 | 
				
			||||||
| 
						 | 
					@ -30,9 +31,12 @@ public class Factory {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public BorderPane loadMainWindow() {
 | 
					    public BorderPane loadMainWindow() {
 | 
				
			||||||
        FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
 | 
					        FXMLLoader loader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
 | 
				
			||||||
        try {
 | 
					        try {
 | 
				
			||||||
            return loader.load();
 | 
					            BorderPane pane = loader.load();
 | 
				
			||||||
 | 
					            FXController controller = loader.getController();
 | 
				
			||||||
 | 
					            controller.setup(languageConfigurator);
 | 
				
			||||||
 | 
					            return pane;
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
            //TODO handle and logging
 | 
					            //TODO handle and logging
 | 
				
			||||||
| 
						 | 
					@ -82,7 +86,7 @@ public class Factory {
 | 
				
			||||||
            FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
 | 
					            FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
 | 
				
			||||||
            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);
 | 
					            controller.setup(tournamentDecorator, fileIO, factoryDecorator, box, gameDecorator, languageConfigurator);
 | 
				
			||||||
            return controller;
 | 
					            return controller;
 | 
				
			||||||
        } catch (IOException e) {
 | 
					        } catch (IOException e) {
 | 
				
			||||||
            e.printStackTrace();
 | 
					            e.printStackTrace();
 | 
				
			||||||
| 
						 | 
					@ -151,7 +155,7 @@ public class Factory {
 | 
				
			||||||
            FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFileName));
 | 
					            FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFileName));
 | 
				
			||||||
            this.pane = loader.load();
 | 
					            this.pane = loader.load();
 | 
				
			||||||
            FXController controller = loader.getController();
 | 
					            FXController controller = loader.getController();
 | 
				
			||||||
            controller.setup(tournamentDecorator, fileIO, factoryDecorator, borderPane);
 | 
					            controller.setup(tournamentDecorator, fileIO, factoryDecorator, borderPane, languageConfigurator);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -0,0 +1,144 @@
 | 
				
			||||||
 | 
					package ch.zhaw.projekt2.turnierverwaltung;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import javafx.scene.control.Labeled;
 | 
				
			||||||
 | 
					import javafx.scene.control.MenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class LanguageConfigurator {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private Language selectedLanguage;
 | 
				
			||||||
 | 
					    private Map<String,String> germanDictionary;
 | 
				
			||||||
 | 
					    private Map<String,String> englishDictionary;
 | 
				
			||||||
 | 
					    private List<Labeled> labelList;
 | 
				
			||||||
 | 
					    private List<MenuItem> menuItemList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public LanguageConfigurator() {
 | 
				
			||||||
 | 
					        selectedLanguage = Language.GERMAN;
 | 
				
			||||||
 | 
					        labelList = new ArrayList<>();
 | 
				
			||||||
 | 
					        menuItemList = new ArrayList<>();
 | 
				
			||||||
 | 
					        germanDictionary = new HashMap<>();
 | 
				
			||||||
 | 
					        englishDictionary = new HashMap<>();
 | 
				
			||||||
 | 
					        setUpDictionaries();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private void setUpDictionaries() {
 | 
				
			||||||
 | 
					        //Main
 | 
				
			||||||
 | 
					        germanDictionary.put("menuItemLanguage","Sprache");
 | 
				
			||||||
 | 
					        englishDictionary.put("menuItemLanguage","Language");
 | 
				
			||||||
 | 
					        germanDictionary.put("closeBtn","Beenden");
 | 
				
			||||||
 | 
					        englishDictionary.put("closeBtn","Close");
 | 
				
			||||||
 | 
					        germanDictionary.put("mainTitle","Turnier Manager");
 | 
				
			||||||
 | 
					        englishDictionary.put("mainTitle","Tournament Manager");
 | 
				
			||||||
 | 
					        //Tournamentlist
 | 
				
			||||||
 | 
					        germanDictionary.put("tournamentListTitle","Bestehende Turniere");
 | 
				
			||||||
 | 
					        englishDictionary.put("tournamentListTitle","Existing tournaments");
 | 
				
			||||||
 | 
					        germanDictionary.put("openBtn","Öffnen");
 | 
				
			||||||
 | 
					        englishDictionary.put("openBtn","Open");
 | 
				
			||||||
 | 
					        germanDictionary.put("deleteBtn","Löschen");
 | 
				
			||||||
 | 
					        englishDictionary.put("deleteBtn","Delete");
 | 
				
			||||||
 | 
					        germanDictionary.put("newTournamentFormularTitle","Neues Turnier erstellen");
 | 
				
			||||||
 | 
					        englishDictionary.put("newTournamentFormularTitle","Create new tournament");
 | 
				
			||||||
 | 
					        germanDictionary.put("tournamentNameLabel","Turnier Name:");
 | 
				
			||||||
 | 
					        englishDictionary.put("tournamentNameLabel","Tournament Name:");
 | 
				
			||||||
 | 
					        germanDictionary.put("tournamentModLabel","Turnier Modus");
 | 
				
			||||||
 | 
					        englishDictionary.put("tournamentModLabel","Tournament Mode");
 | 
				
			||||||
 | 
					        germanDictionary.put("createBtn","Erstellen");
 | 
				
			||||||
 | 
					        englishDictionary.put("createBtn","Create");
 | 
				
			||||||
 | 
					        //PlaceList
 | 
				
			||||||
 | 
					        germanDictionary.put("placeListTitle","Hinzugefügt");
 | 
				
			||||||
 | 
					        englishDictionary.put("placeListTitle","Added");
 | 
				
			||||||
 | 
					        germanDictionary.put("saveBtn","Speichern");
 | 
				
			||||||
 | 
					        englishDictionary.put("saveBtn","Save");
 | 
				
			||||||
 | 
					        germanDictionary.put("newplaceFormularTitle","Ort ändern/erstellen");
 | 
				
			||||||
 | 
					        englishDictionary.put("newplaceFormularTitle","Location change/create");
 | 
				
			||||||
 | 
					        //GameSchedule
 | 
				
			||||||
 | 
					        germanDictionary.put("treeView","Baumansicht");
 | 
				
			||||||
 | 
					        englishDictionary.put("treeView","Treeview");
 | 
				
			||||||
 | 
					        germanDictionary.put("createScheduleBtn","Spielplan erstellen");
 | 
				
			||||||
 | 
					        englishDictionary.put("createScheduleBtn","Create game schedule");
 | 
				
			||||||
 | 
					        germanDictionary.put("editParticipantBtn","Teilnehmer bearbeiten");
 | 
				
			||||||
 | 
					        englishDictionary.put("editParticipantBtn","Edit Participants");
 | 
				
			||||||
 | 
					        germanDictionary.put("editLocBtn","Orte bearbeiten");
 | 
				
			||||||
 | 
					        englishDictionary.put("editLocBtn","Edit Locations");
 | 
				
			||||||
 | 
					        germanDictionary.put("closeTournamentBtn","Turnier schliessen");
 | 
				
			||||||
 | 
					        englishDictionary.put("closeTournamentBtn","Close tournament");
 | 
				
			||||||
 | 
					        //ParticipantFormular
 | 
				
			||||||
 | 
					        germanDictionary.put("participantListTitle","Hinzugefügt");
 | 
				
			||||||
 | 
					        englishDictionary.put("participantListTitle","Added");
 | 
				
			||||||
 | 
					        germanDictionary.put("newParticipantFormularTitle","Teilnehmer ändern/erstellen");
 | 
				
			||||||
 | 
					        englishDictionary.put("newParticipantFormularTitle","Participant change/create");
 | 
				
			||||||
 | 
					        germanDictionary.put("participantNameLabel","Name:");
 | 
				
			||||||
 | 
					        englishDictionary.put("participantNameLabel","Name:");
 | 
				
			||||||
 | 
					        germanDictionary.put("firstNameLabel","Vorname:");
 | 
				
			||||||
 | 
					        englishDictionary.put("firstNameLabel","First Name:");
 | 
				
			||||||
 | 
					        germanDictionary.put("phoneNumberLabel","Telefon:");
 | 
				
			||||||
 | 
					        englishDictionary.put("phoneNumberLabel","Phone:");
 | 
				
			||||||
 | 
					        germanDictionary.put("birthDateLabel","Geb. Datum:");
 | 
				
			||||||
 | 
					        englishDictionary.put("birthDateLabel","Birthday:");
 | 
				
			||||||
 | 
					        //Game
 | 
				
			||||||
 | 
					        germanDictionary.put("locationLabel","Ort:");
 | 
				
			||||||
 | 
					        englishDictionary.put("locationLabel","Location:");
 | 
				
			||||||
 | 
					        germanDictionary.put("participantNameOne","Teilnehmer A");
 | 
				
			||||||
 | 
					        englishDictionary.put("participantNameOne","Participant One");
 | 
				
			||||||
 | 
					        germanDictionary.put("participantNameTwo","Teilnehmer B");
 | 
				
			||||||
 | 
					        englishDictionary.put("participantNameTwo","Participant Two");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void translateGUI() {
 | 
				
			||||||
 | 
					        String word = "";
 | 
				
			||||||
 | 
					        for (Labeled label : labelList) {
 | 
				
			||||||
 | 
					            switch (selectedLanguage) {
 | 
				
			||||||
 | 
					                case GERMAN -> {
 | 
				
			||||||
 | 
					                    word = germanDictionary.get(label.getId());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                case ENGLISH -> {
 | 
				
			||||||
 | 
					                    word = englishDictionary.get(label.getId());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(word != null) {
 | 
				
			||||||
 | 
					                label.setText(word);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                //TODO LOG
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for (MenuItem item : menuItemList) {
 | 
				
			||||||
 | 
					            switch (selectedLanguage) {
 | 
				
			||||||
 | 
					                case GERMAN -> {
 | 
				
			||||||
 | 
					                    word = germanDictionary.get(item.getId());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                case ENGLISH -> {
 | 
				
			||||||
 | 
					                    word = englishDictionary.get(item.getId());
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if(word != null) {
 | 
				
			||||||
 | 
					                item.setText(word);
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                //TODO LOG
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void recieveLabel(Labeled label) {
 | 
				
			||||||
 | 
					        if (label != null) {
 | 
				
			||||||
 | 
					            labelList.add(label);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void recieveMenuItem(MenuItem item) {
 | 
				
			||||||
 | 
					        menuItemList.add(item);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void changeLanguage(Language language) {
 | 
				
			||||||
 | 
					        this.selectedLanguage = language;
 | 
				
			||||||
 | 
					        translateGUI();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public enum Language {
 | 
				
			||||||
 | 
					        ENGLISH,GERMAN
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,9 +1,6 @@
 | 
				
			||||||
package ch.zhaw.projekt2.turnierverwaltung.main;
 | 
					package ch.zhaw.projekt2.turnierverwaltung.main;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.Factory;
 | 
					import ch.zhaw.projekt2.turnierverwaltung.*;
 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.FactoryDecorator;
 | 
					 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.FileIO;
 | 
					 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.TournamentDecorator;
 | 
					 | 
				
			||||||
import javafx.application.Application;
 | 
					import javafx.application.Application;
 | 
				
			||||||
import javafx.event.EventHandler;
 | 
					import javafx.event.EventHandler;
 | 
				
			||||||
import javafx.fxml.FXMLLoader;
 | 
					import javafx.fxml.FXMLLoader;
 | 
				
			||||||
| 
						 | 
					@ -19,7 +16,8 @@ public class MainWindow extends Application {
 | 
				
			||||||
    private FileIO fileIO = new FileIO(System.getProperty("user.dir") + System.getProperty("file.separator") + "tournierverwaltung_angrynerds");
 | 
					    private FileIO fileIO = new FileIO(System.getProperty("user.dir") + System.getProperty("file.separator") + "tournierverwaltung_angrynerds");
 | 
				
			||||||
    private FactoryDecorator factoryDecorator;
 | 
					    private FactoryDecorator factoryDecorator;
 | 
				
			||||||
    private TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO);
 | 
					    private TournamentDecorator tournamentDecorator = new TournamentDecorator(fileIO);
 | 
				
			||||||
    private Factory factory = new Factory(fileIO, tournamentDecorator);
 | 
					    private LanguageConfigurator languageConfigurator = new LanguageConfigurator();
 | 
				
			||||||
 | 
					    private Factory factory = new Factory(fileIO, tournamentDecorator, languageConfigurator);
 | 
				
			||||||
    private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName());
 | 
					    private static final Logger logger = Logger.getLogger(FileIO.class.getCanonicalName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
| 
						 | 
					@ -29,6 +27,7 @@ public class MainWindow extends Application {
 | 
				
			||||||
        factory.loadAllViews(factoryDecorator, pane);
 | 
					        factory.loadAllViews(factoryDecorator, pane);
 | 
				
			||||||
        tournamentDecorator.setFactoryDecorator(factoryDecorator);
 | 
					        tournamentDecorator.setFactoryDecorator(factoryDecorator);
 | 
				
			||||||
        factoryDecorator.openTournamentList();
 | 
					        factoryDecorator.openTournamentList();
 | 
				
			||||||
 | 
					        languageConfigurator.translateGUI();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Scene scene = new Scene(pane);
 | 
					        Scene scene = new Scene(pane);
 | 
				
			||||||
        primaryStage.setScene(scene);
 | 
					        primaryStage.setScene(scene);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,15 +1,33 @@
 | 
				
			||||||
package ch.zhaw.projekt2.turnierverwaltung.main;
 | 
					package ch.zhaw.projekt2.turnierverwaltung.main;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
 | 
					import ch.zhaw.projekt2.turnierverwaltung.FXController;
 | 
				
			||||||
 | 
					import ch.zhaw.projekt2.turnierverwaltung.LanguageConfigurator;
 | 
				
			||||||
import javafx.application.Platform;
 | 
					import javafx.application.Platform;
 | 
				
			||||||
import javafx.event.ActionEvent;
 | 
					import javafx.event.ActionEvent;
 | 
				
			||||||
import javafx.fxml.FXML;
 | 
					import javafx.fxml.FXML;
 | 
				
			||||||
 | 
					import javafx.scene.control.Label;
 | 
				
			||||||
 | 
					import javafx.scene.control.Menu;
 | 
				
			||||||
 | 
					import javafx.scene.control.MenuItem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class MainWindowController extends FXController {
 | 
					public class MainWindowController extends FXController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void changeLangToGerman(ActionEvent event) {
 | 
					    private MenuItem closeBtn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    private Label mainTitle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    private Menu menuItemLanguage;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    void changeLangToGerman(ActionEvent event) {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().changeLanguage(LanguageConfigurator.Language.GERMAN);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    void changeLangToEnglish(ActionEvent event) {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().changeLanguage(LanguageConfigurator.Language.ENGLISH);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
| 
						 | 
					@ -17,6 +35,15 @@ public class MainWindowController extends FXController {
 | 
				
			||||||
        Platform.exit();
 | 
					        Platform.exit();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void shareGUIElementWithLanguageConfigurator() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(mainTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveMenuItem(closeBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveMenuItem(menuItemLanguage);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void loadContent() {
 | 
					    public void loadContent() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,6 +32,16 @@ public class GameController extends FXController{
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private TextField pointsTeamTwo;
 | 
					    private TextField pointsTeamTwo;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    private Label locationLabel;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void shareGUIElementWithLanguageConfigurator() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(participantNameOne);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(participantNameTwo);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(locationLabel);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void saveGameResult(Event event) {
 | 
					    void saveGameResult(Event event) {
 | 
				
			||||||
        gameDecorator.saveGameResult(pointsTeamOne.getText(), pointsTeamTwo.getText());
 | 
					        gameDecorator.saveGameResult(pointsTeamOne.getText(), pointsTeamTwo.getText());
 | 
				
			||||||
| 
						 | 
					@ -48,6 +58,7 @@ public class GameController extends FXController{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void loadContent() {
 | 
					    public void loadContent() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().translateGUI();
 | 
				
			||||||
        participantNameOne.setText(gameDecorator.getParticipantOne());
 | 
					        participantNameOne.setText(gameDecorator.getParticipantOne());
 | 
				
			||||||
        participantNameTwo.setText(gameDecorator.getParticipantTwo());
 | 
					        participantNameTwo.setText(gameDecorator.getParticipantTwo());
 | 
				
			||||||
        pointsTeamOne.setText(String.valueOf(gameDecorator.getPoints1()));
 | 
					        pointsTeamOne.setText(String.valueOf(gameDecorator.getPoints1()));
 | 
				
			||||||
| 
						 | 
					@ -71,9 +82,10 @@ public class GameController extends FXController{
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane, GameDecorator gameDecorator) {
 | 
					    public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane, GameDecorator gameDecorator,LanguageConfigurator languageConfigurator) {
 | 
				
			||||||
        setTournamentDecorator(tournamentDecorator);
 | 
					        setTournamentDecorator(tournamentDecorator);
 | 
				
			||||||
        this.gameDecorator = gameDecorator;
 | 
					        this.gameDecorator = gameDecorator;
 | 
				
			||||||
 | 
					        setup(languageConfigurator);
 | 
				
			||||||
        placesChoiceBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends Place> observable, Place oldValue, Place newValue) -> saveGamePlace(newValue == null ? oldValue : newValue));
 | 
					        placesChoiceBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends Place> observable, Place oldValue, Place newValue) -> saveGamePlace(newValue == null ? oldValue : newValue));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,11 @@
 | 
				
			||||||
package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
 | 
					package ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.FXController;
 | 
					import ch.zhaw.projekt2.turnierverwaltung.FXController;
 | 
				
			||||||
import ch.zhaw.projekt2.turnierverwaltung.Tournament;
 | 
					 | 
				
			||||||
import javafx.event.ActionEvent;
 | 
					import javafx.event.ActionEvent;
 | 
				
			||||||
import javafx.fxml.FXML;
 | 
					import javafx.fxml.FXML;
 | 
				
			||||||
import javafx.scene.control.Button;
 | 
					import javafx.scene.control.Button;
 | 
				
			||||||
import javafx.scene.control.CheckBox;
 | 
					import javafx.scene.control.CheckBox;
 | 
				
			||||||
 | 
					import javafx.scene.control.Labeled;
 | 
				
			||||||
import javafx.scene.layout.HBox;
 | 
					import javafx.scene.layout.HBox;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GameScheduleController extends FXController {
 | 
					public class GameScheduleController extends FXController {
 | 
				
			||||||
| 
						 | 
					@ -28,6 +28,15 @@ public class GameScheduleController extends FXController {
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private CheckBox treeView;
 | 
					    private CheckBox treeView;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void shareGUIElementWithLanguageConfigurator() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(treeView);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(createScheduleBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(editParticipantBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(editLocBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(closeTournamentBtn);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void createNewSchedule(ActionEvent event) {
 | 
					    void createNewSchedule(ActionEvent event) {
 | 
				
			||||||
        getTournamentDecorator().createNewGameSchedule();
 | 
					        getTournamentDecorator().createNewGameSchedule();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,6 +68,19 @@ public class ParticipantFormularController extends FXController {
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private Button saveBtn;
 | 
					    private Button saveBtn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void shareGUIElementWithLanguageConfigurator() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(participantListTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(closeBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(deleteBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(newParticipantFormularTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(participantNameLabel);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(firstNameLabel);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(phoneNumberLabel);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(birthDateLabel);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(saveBtn);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void changedSelection(MouseEvent event){
 | 
					    void changedSelection(MouseEvent event){
 | 
				
			||||||
        Player participant = (Player) participantListView.getSelectionModel().getSelectedItems().get(0);
 | 
					        Player participant = (Player) participantListView.getSelectionModel().getSelectedItems().get(0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,6 +50,18 @@ public class PlacesFormularController extends FXController {
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private Button saveBtn;
 | 
					    private Button saveBtn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void shareGUIElementWithLanguageConfigurator() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(placeListTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(newPlaceFormularTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(placeNameLabel);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(closeBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(deleteBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(saveBtn);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void changedSelection(MouseEvent event){
 | 
					    void changedSelection(MouseEvent event){
 | 
				
			||||||
        Place place = placeListView.getSelectionModel().getSelectedItems().get(0);
 | 
					        Place place = placeListView.getSelectionModel().getSelectedItems().get(0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,8 +25,6 @@ public class TournamentListController extends FXController {
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private Button createBtn;
 | 
					    private Button createBtn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					 | 
				
			||||||
    private GridPane grid;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private ChoiceBox<Tournament.Type> modusChoiceBox;
 | 
					    private ChoiceBox<Tournament.Type> modusChoiceBox;
 | 
				
			||||||
| 
						 | 
					@ -55,6 +53,17 @@ public class TournamentListController extends FXController {
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private TextField tournamentNameField;
 | 
					    private TextField tournamentNameField;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void shareGUIElementWithLanguageConfigurator() {
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(createBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(newTournamentFormularTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(openBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(deleteBtn);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(tournamentListTitle);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(tournamentModLabel);
 | 
				
			||||||
 | 
					        getLanguageConfigurator().recieveLabel(tournamentNameLabel);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void createTournament(ActionEvent event) {
 | 
					    void createTournament(ActionEvent event) {
 | 
				
			||||||
        getTournamentDecorator().createTournament(tournamentNameField.getText(), modusChoiceBox.getValue());
 | 
					        getTournamentDecorator().createTournament(tournamentNameField.getText(), modusChoiceBox.getValue());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -16,17 +16,18 @@
 | 
				
			||||||
               <menus>
 | 
					               <menus>
 | 
				
			||||||
                  <Menu mnemonicParsing="false" text="Start">
 | 
					                  <Menu mnemonicParsing="false" text="Start">
 | 
				
			||||||
                     <items>
 | 
					                     <items>
 | 
				
			||||||
                        <Menu mnemonicParsing="false" text="Sprache">
 | 
					                        <Menu fx:id="menuItemLanguage" mnemonicParsing="false" text="Sprache">
 | 
				
			||||||
                           <items>
 | 
					                           <items>
 | 
				
			||||||
                              <MenuItem mnemonicParsing="false" onAction="#changeLangToGerman" text="Deutsch" />
 | 
					                              <MenuItem mnemonicParsing="false" onAction="#changeLangToGerman" text="Deutsch" />
 | 
				
			||||||
 | 
					                              <MenuItem mnemonicParsing="false" onAction="#changeLangToEnglish" text="English" />
 | 
				
			||||||
                           </items>
 | 
					                           </items>
 | 
				
			||||||
                        </Menu>
 | 
					                        </Menu>
 | 
				
			||||||
                        <MenuItem mnemonicParsing="false" onAction="#closeApplication" text="Close" />
 | 
					                        <MenuItem fx:id="closeBtn" mnemonicParsing="false" onAction="#closeApplication" text="Close" />
 | 
				
			||||||
                     </items>
 | 
					                     </items>
 | 
				
			||||||
                  </Menu>
 | 
					                  </Menu>
 | 
				
			||||||
               </menus>
 | 
					               </menus>
 | 
				
			||||||
            </MenuBar>
 | 
					            </MenuBar>
 | 
				
			||||||
            <Label text="Turnier Manager">
 | 
					            <Label fx:id="mainTitle" text="Turnier Manager">
 | 
				
			||||||
               <font>
 | 
					               <font>
 | 
				
			||||||
                  <Font name="System Bold" size="40.0" />
 | 
					                  <Font name="System Bold" size="40.0" />
 | 
				
			||||||
               </font>
 | 
					               </font>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@
 | 
				
			||||||
            </HBox>
 | 
					            </HBox>
 | 
				
			||||||
            <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
 | 
					            <HBox alignment="CENTER" prefHeight="100.0" prefWidth="200.0">
 | 
				
			||||||
               <children>
 | 
					               <children>
 | 
				
			||||||
                  <Label text="Ort">
 | 
					                  <Label fx:id="locationLabel" text="Ort">
 | 
				
			||||||
                     <HBox.margin>
 | 
					                     <HBox.margin>
 | 
				
			||||||
                        <Insets right="20.0" />
 | 
					                        <Insets right="20.0" />
 | 
				
			||||||
                     </HBox.margin>
 | 
					                     </HBox.margin>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,7 +18,7 @@
 | 
				
			||||||
   <top>
 | 
					   <top>
 | 
				
			||||||
      <HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
 | 
					      <HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
 | 
				
			||||||
         <children>
 | 
					         <children>
 | 
				
			||||||
            <CheckBox fx:id="treeView" mnemonicParsing="false" onAction="#changeView" selected="true" text="Baumansicht">
 | 
					            <CheckBox fx:id="treeView" minWidth="100.0" mnemonicParsing="false" onAction="#changeView" selected="true" text="Baumansicht" textOverrun="WORD_ELLIPSIS" wrapText="true">
 | 
				
			||||||
               <HBox.margin>
 | 
					               <HBox.margin>
 | 
				
			||||||
                  <Insets left="20.0" right="20.0" />
 | 
					                  <Insets left="20.0" right="20.0" />
 | 
				
			||||||
               </HBox.margin>
 | 
					               </HBox.margin>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue