|
@ -13,7 +13,7 @@ import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class to load the views from FXML Files and switch between the views.
|
||||||
*/
|
*/
|
||||||
public class Factory {
|
public class Factory {
|
||||||
private TournamentDecorator tournamentDecorator;
|
private TournamentDecorator tournamentDecorator;
|
||||||
|
@ -21,16 +21,29 @@ public class Factory {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger(Factory.class.getCanonicalName());
|
private static final Logger logger = Logger.getLogger(Factory.class.getCanonicalName());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contructor to create Factory instance.
|
||||||
|
* @param fileIO the fileIO instance which saves and reads the tournament from files.
|
||||||
|
* @param tournamentDecorator the touramanetDecorator class to access the tournament.
|
||||||
|
*/
|
||||||
public Factory(FileIO fileIO, TournamentDecorator tournamentDecorator) {
|
public Factory(FileIO fileIO, TournamentDecorator tournamentDecorator) {
|
||||||
this.fileIO = fileIO;
|
this.fileIO = fileIO;
|
||||||
this.tournamentDecorator = tournamentDecorator;
|
this.tournamentDecorator = tournamentDecorator;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter Method of tournament
|
||||||
|
* @param tournament the new tournament Object.
|
||||||
|
*/
|
||||||
public void setTournament(Tournament tournament) {
|
public void setTournament(Tournament tournament) {
|
||||||
this.tournamentDecorator.setTournament(tournament);
|
this.tournamentDecorator.setTournament(tournament);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to load the main Window (without the content in the center)
|
||||||
|
* @return the boarder Pane which is loaded.
|
||||||
|
*/
|
||||||
public BorderPane loadMainWindow() {
|
public BorderPane loadMainWindow() {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("mainWindow.fxml"));
|
||||||
try {
|
try {
|
||||||
|
@ -42,6 +55,11 @@ public class Factory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class which loads all views of Enum View
|
||||||
|
* @param factoryDecorator the FactoryDecorator which is used to setup the controller.
|
||||||
|
* @param pane the pane where the loaded view will be visible
|
||||||
|
*/
|
||||||
public void loadAllViews(FactoryDecorator factoryDecorator, BorderPane pane){
|
public void loadAllViews(FactoryDecorator factoryDecorator, BorderPane pane){
|
||||||
for(View view : View.values()){
|
for(View view : View.values()){
|
||||||
try {
|
try {
|
||||||
|
@ -53,32 +71,57 @@ public class Factory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showTournamentList(BorderPane pane, FactoryDecorator factoryDecorator) {
|
/**
|
||||||
|
* Method to show the view TournamentList
|
||||||
|
* @param pane the Pane where the View will be visible
|
||||||
|
*/
|
||||||
|
public void showTournamentList(BorderPane pane) {
|
||||||
tournamentDecorator.setTournament(null);
|
tournamentDecorator.setTournament(null);
|
||||||
setCenterOfBorderPane(pane, View.tournamentList);
|
setCenterOfBorderPane(pane, View.tournamentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Can be used to Open new Scene in same Stage.
|
/**
|
||||||
//This way possible to later give object to Controller
|
* Method to show the view ParticipantFormular
|
||||||
public void showParticipantFormular(BorderPane pane, FactoryDecorator factoryDecorator) {
|
* @param pane the Pane where the View will be visible
|
||||||
|
*/
|
||||||
|
public void showParticipantFormular(BorderPane pane) {
|
||||||
setCenterOfBorderPane(pane, View.participantFormular);
|
setCenterOfBorderPane(pane, View.participantFormular);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPlacesFormular(BorderPane pane, FactoryDecorator factoryDecorator) {
|
/**
|
||||||
|
* Method to show the view PlacesFormular
|
||||||
|
* @param pane the Pane where the View will be visible
|
||||||
|
*/
|
||||||
|
public void showPlacesFormular(BorderPane pane) {
|
||||||
setCenterOfBorderPane(pane, View.placesFormular);
|
setCenterOfBorderPane(pane, View.placesFormular);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showGameScheduler(BorderPane pane, FactoryDecorator factoryDecorator) {
|
/**
|
||||||
|
* Method to show the view GameScheduler
|
||||||
|
* @param pane the Pane where the View will be visible
|
||||||
|
*/
|
||||||
|
public void showGameScheduler(BorderPane pane) {
|
||||||
setCenterOfBorderPane(pane, View.gameScheduler);
|
setCenterOfBorderPane(pane, View.gameScheduler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to change the view in the center of the boarder pane in the mainWindow
|
||||||
|
* @param pane the Pane where the View will be visible
|
||||||
|
* @param view the view which should be visible
|
||||||
|
*/
|
||||||
private void setCenterOfBorderPane(BorderPane pane, View view) {
|
private void setCenterOfBorderPane(BorderPane pane, View view) {
|
||||||
FXController controller = null;
|
FXController controller = null;
|
||||||
pane.setCenter(view.getPane());
|
pane.setCenter(view.getPane());
|
||||||
resetFooter(pane, true);
|
resetFooter(pane, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to load a Game View
|
||||||
|
* @param box the box where the game view should be added.
|
||||||
|
* @param gameDecorator the gameDecorator instance of the game.
|
||||||
|
* @param factoryDecorator the factoryDecorator instance.
|
||||||
|
* @return the controller of the GameView
|
||||||
|
*/
|
||||||
public GameController loadGameView(VBox box, GameDecorator gameDecorator, FactoryDecorator factoryDecorator) {
|
public GameController loadGameView(VBox box, GameDecorator gameDecorator, FactoryDecorator factoryDecorator) {
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource("gameScheduleView/Game.fxml"));
|
||||||
|
@ -93,6 +136,12 @@ public class Factory {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to print information for the user to the footer of mainwindow.
|
||||||
|
* @param pane the pane where the footer should be shown.
|
||||||
|
* @param msg the text to show.
|
||||||
|
* @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) {
|
||||||
VBox bottom = (VBox) pane.getBottom();
|
VBox bottom = (VBox) pane.getBottom();
|
||||||
Label label = new Label();
|
Label label = new Label();
|
||||||
|
@ -121,9 +170,9 @@ public class Factory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Method to remove the messages in the footer.
|
||||||
* @param pane
|
* @param pane the pane were the footer should be reseted
|
||||||
* @param error
|
* @param error true if the error message should be cleared.
|
||||||
*/
|
*/
|
||||||
public void resetFooter(BorderPane pane,boolean error) {
|
public void resetFooter(BorderPane pane,boolean error) {
|
||||||
VBox bottom = (VBox) pane.getBottom();
|
VBox bottom = (VBox) pane.getBottom();
|
||||||
|
@ -138,7 +187,7 @@ public class Factory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enum for keeping the different fxml form views
|
* Enum of all views which can be set to the center of the mainwindow.
|
||||||
*/
|
*/
|
||||||
public enum View {
|
public enum View {
|
||||||
tournamentList("tournamentList/tournamentList.fxml"),
|
tournamentList("tournamentList/tournamentList.fxml"),
|
||||||
|
@ -149,6 +198,10 @@ public class Factory {
|
||||||
private String fxmlFileName;
|
private String fxmlFileName;
|
||||||
private Pane pane;
|
private Pane pane;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor of View
|
||||||
|
* @param fxmlFileName The name of the FXML File to load.
|
||||||
|
*/
|
||||||
private View(String fxmlFileName) {
|
private View(String fxmlFileName) {
|
||||||
this.fxmlFileName = fxmlFileName;
|
this.fxmlFileName = fxmlFileName;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +210,14 @@ public class Factory {
|
||||||
return pane;
|
return pane;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to laod the view
|
||||||
|
* @param tournamentDecorator the tournamentDecorator object which will be passed to the controller.
|
||||||
|
* @param fileIO the fileIO object which will be passed to the controller.
|
||||||
|
* @param factoryDecorator the factoryDecorator object which will be passed to the controller.
|
||||||
|
* @param borderPane the borderPane object which will be passed to the controller.
|
||||||
|
* @throws IOException if the fxml file is not found or can not be loaded correctly.
|
||||||
|
*/
|
||||||
public void loadView(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, BorderPane borderPane) throws IOException {
|
public void loadView(TournamentDecorator tournamentDecorator, FileIO fileIO, FactoryDecorator factoryDecorator, BorderPane borderPane) throws IOException {
|
||||||
FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFileName));
|
FXMLLoader loader = new FXMLLoader(getClass().getResource(fxmlFileName));
|
||||||
this.pane = loader.load();
|
this.pane = loader.load();
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class FactoryDecorator implements IsObservable {
|
||||||
*/
|
*/
|
||||||
public void openTournamentList() {
|
public void openTournamentList() {
|
||||||
logger.fine("Showing TournamentList view");
|
logger.fine("Showing TournamentList view");
|
||||||
factory.showTournamentList((BorderPane) pane, this);
|
factory.showTournamentList((BorderPane) pane);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class FactoryDecorator implements IsObservable {
|
||||||
*/
|
*/
|
||||||
public void openParticipantForm() {
|
public void openParticipantForm() {
|
||||||
logger.fine("Showing participant form view");
|
logger.fine("Showing participant form view");
|
||||||
factory.showParticipantFormular((BorderPane) pane, this);
|
factory.showParticipantFormular((BorderPane) pane);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,12 +134,12 @@ public class FactoryDecorator implements IsObservable {
|
||||||
*/
|
*/
|
||||||
public void openPlacesForm() {
|
public void openPlacesForm() {
|
||||||
logger.fine("Showing places form view");
|
logger.fine("Showing places form view");
|
||||||
factory.showPlacesFormular((BorderPane) pane, this);
|
factory.showPlacesFormular((BorderPane) pane);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void openScheduleView() {
|
public void openScheduleView() {
|
||||||
factory.showGameScheduler((BorderPane) pane, this);
|
factory.showGameScheduler((BorderPane) pane);
|
||||||
informListener();
|
informListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue