Develope game branch #33
			
				
			
		
		
		
	| 
						 | 
					@ -7,24 +7,23 @@ public abstract class FXController {
 | 
				
			||||||
    FactoryDecorator factoryDecorator;
 | 
					    FactoryDecorator factoryDecorator;
 | 
				
			||||||
    FileIO fileIO;
 | 
					    FileIO fileIO;
 | 
				
			||||||
    Pane pane;
 | 
					    Pane pane;
 | 
				
			||||||
 | 
					    IsObserver listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public FXController(){
 | 
				
			||||||
 | 
					        listener = new IsObserver() {
 | 
				
			||||||
 | 
					            @Override
 | 
				
			||||||
 | 
					            public void update() {
 | 
				
			||||||
 | 
					                loadContent();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane){
 | 
					    public void setup(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, Pane pane){
 | 
				
			||||||
        this.tournamentDecorator = tournamentDecorator;
 | 
					        this.tournamentDecorator = tournamentDecorator;
 | 
				
			||||||
        this.fileIO = fileIO;
 | 
					        this.fileIO = fileIO;
 | 
				
			||||||
        this.factoryDecorator = factoryDecorator;
 | 
					        this.factoryDecorator = factoryDecorator;
 | 
				
			||||||
        this.pane = pane;
 | 
					        this.pane = pane;
 | 
				
			||||||
        tournamentDecorator.addListener(new IsObserver() {
 | 
					        addListener();
 | 
				
			||||||
            @Override
 | 
					 | 
				
			||||||
            public void update() {
 | 
					 | 
				
			||||||
                loadContent();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
        factoryDecorator.addListener(new IsObserver() {
 | 
					 | 
				
			||||||
            @Override
 | 
					 | 
				
			||||||
            public void update() {
 | 
					 | 
				
			||||||
                loadContent();
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        });
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public abstract void loadContent();
 | 
					    public abstract void loadContent();
 | 
				
			||||||
| 
						 | 
					@ -33,6 +32,16 @@ public abstract class FXController {
 | 
				
			||||||
        this.tournamentDecorator = tournamentDecorator;
 | 
					        this.tournamentDecorator = tournamentDecorator;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public void addListener(){
 | 
				
			||||||
 | 
					        tournamentDecorator.addListener(listener);
 | 
				
			||||||
 | 
					        factoryDecorator.addListener(listener);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected void removeListener(){
 | 
				
			||||||
 | 
					        tournamentDecorator.removeListener(listener);
 | 
				
			||||||
 | 
					        factoryDecorator.removeListener(listener);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    protected TournamentDecorator getTournamentDecorator() {
 | 
					    protected TournamentDecorator getTournamentDecorator() {
 | 
				
			||||||
        return tournamentDecorator;
 | 
					        return tournamentDecorator;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -55,6 +55,7 @@ public class GameDecorator implements IsObservable{
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public void refreshParticipants(){
 | 
					    public void refreshParticipants(){
 | 
				
			||||||
        game.refreshParticipants();
 | 
					        game.refreshParticipants();
 | 
				
			||||||
 | 
					        informListener();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public Place getPlace() {
 | 
					    public Place getPlace() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -18,6 +18,9 @@ public class GameScheduleController extends FXController {
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private Button editParticipantBtn;
 | 
					    private Button editParticipantBtn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    private Button closeTournamentBtn;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    private HBox hBoxCenter;
 | 
					    private HBox hBoxCenter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,14 +36,22 @@ public class GameScheduleController extends FXController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void openPlacesFormular(ActionEvent event) {
 | 
					    void openPlacesFormular(ActionEvent event) {
 | 
				
			||||||
 | 
					        removeListener();
 | 
				
			||||||
        getFactoryDecorator().openPlacesFormular();
 | 
					        getFactoryDecorator().openPlacesFormular();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void openParticipantFormular(ActionEvent event) {
 | 
					    void openParticipantFormular(ActionEvent event) {
 | 
				
			||||||
 | 
					        removeListener();
 | 
				
			||||||
        getFactoryDecorator().openParticipantFormular();
 | 
					        getFactoryDecorator().openParticipantFormular();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @FXML
 | 
				
			||||||
 | 
					    void closeTournament(ActionEvent event) {
 | 
				
			||||||
 | 
					        removeListener();
 | 
				
			||||||
 | 
					        getFactoryDecorator().openTournamentList();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void loadContent() {
 | 
					    public void loadContent() {
 | 
				
			||||||
        getFactoryDecorator().loadGameTree(hBoxCenter, getTournamentDecorator());
 | 
					        getFactoryDecorator().loadGameTree(hBoxCenter, getTournamentDecorator());
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -89,6 +89,7 @@ public class ParticipantFormularController extends FXController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void close(ActionEvent event) {
 | 
					    void close(ActionEvent event) {
 | 
				
			||||||
 | 
					        removeListener();
 | 
				
			||||||
        getFactoryDecorator().openScheduleView();
 | 
					        getFactoryDecorator().openScheduleView();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -68,6 +68,7 @@ public class PlacesFormularController extends FXController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void close(ActionEvent event) {
 | 
					    void close(ActionEvent event) {
 | 
				
			||||||
 | 
					        removeListener();
 | 
				
			||||||
        getFactoryDecorator().openScheduleView();
 | 
					        getFactoryDecorator().openScheduleView();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -61,6 +61,7 @@ public class TournamentListController extends FXController {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @FXML
 | 
					    @FXML
 | 
				
			||||||
    void openTournament(ActionEvent event) {
 | 
					    void openTournament(ActionEvent event) {
 | 
				
			||||||
 | 
					        removeListener();
 | 
				
			||||||
        FileIO.TournamentFile tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0);
 | 
					        FileIO.TournamentFile tournamentFile = tournamentListView.getSelectionModel().getSelectedItems().get(0);
 | 
				
			||||||
        getFactoryDecorator().openTournament(tournamentFile);
 | 
					        getFactoryDecorator().openTournament(tournamentFile);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,11 +1,10 @@
 | 
				
			||||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<?import javafx.geometry.Insets?>
 | 
					<?import javafx.geometry.*?>
 | 
				
			||||||
<?import javafx.scene.control.Button?>
 | 
					<?import javafx.scene.control.*?>
 | 
				
			||||||
<?import javafx.scene.layout.BorderPane?>
 | 
					<?import javafx.scene.layout.*?>
 | 
				
			||||||
<?import javafx.scene.layout.HBox?>
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/18" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameScheduleController">
 | 
					<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ch.zhaw.projekt2.turnierverwaltung.main.gameScheduleView.GameScheduleController">
 | 
				
			||||||
   <top>
 | 
					   <top>
 | 
				
			||||||
      <HBox alignment="TOP_RIGHT" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
 | 
					      <HBox alignment="TOP_RIGHT" prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER">
 | 
				
			||||||
         <children>
 | 
					         <children>
 | 
				
			||||||
| 
						 | 
					@ -24,6 +23,7 @@
 | 
				
			||||||
                  <Insets right="40.0" />
 | 
					                  <Insets right="40.0" />
 | 
				
			||||||
               </HBox.margin>
 | 
					               </HBox.margin>
 | 
				
			||||||
            </Button>
 | 
					            </Button>
 | 
				
			||||||
 | 
					            <Button fx:id="closeTournamentBtn" layoutX="470.0" layoutY="10.0" mnemonicParsing="false" onAction="#closeTournament" text="Close Tournament" />
 | 
				
			||||||
         </children>
 | 
					         </children>
 | 
				
			||||||
      </HBox>
 | 
					      </HBox>
 | 
				
			||||||
   </top>
 | 
					   </top>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue