Commit 48f70109 authored by Olav Dagestad Eikrem's avatar Olav Dagestad Eikrem
Browse files

Task 3, Factory added for fxml files

parent 49f9e580
package mappe.del2.factory;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import mappe.del2.GUI.controllers.DeleteConfirmationController;
import mappe.del2.GUI.controllers.NewPatientDetails;
import java.io.IOException;
public class DeleteConfirmation implements GuiWindow{
private FXMLLoader loader;
@Override
public Scene loadScene() throws IOException {
this.loader = new FXMLLoader();
this.loader.setLocation(getClass().getResource("/DeleteConfirmation.fxml"));
AnchorPane root = loader.load();
Scene scene = new Scene(root);
return scene;
}
public DeleteConfirmationController getController() throws IOException {
if (this.loader != null) {
return this.loader.getController();
}
loadScene();
return this.loader.getController();
}
}
package mappe.del2.factory;
import javafx.scene.Scene;
import java.io.IOException;
public interface GuiWindow {
Scene loadScene() throws IOException;
}
package mappe.del2.factory;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import java.io.IOException;
public class InformationDialog implements GuiWindow{
@Override
public Scene loadScene() throws IOException {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/InformationDialog.fxml"));
AnchorPane root = loader.load();
Scene scene = new Scene(root);
return scene; }
}
package mappe.del2.factory;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import mappe.del2.GUI.controllers.NewPatientDetails;
import java.io.IOException;
public class NewPatientDialog implements GuiWindow{
private FXMLLoader loader;
@Override
public Scene loadScene() throws IOException {
this.loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/NewPatientDetails.fxml"));
AnchorPane root = loader.load();
Scene scene = new Scene(root);
return scene;
}
public NewPatientDetails getController() throws IOException {
if (this.loader != null) {
return this.loader.getController();
}
loadScene();
return this.loader.getController();
}
}
package mappe.del2.factory;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.control.TableView;
import javafx.scene.layout.AnchorPane;
import mappe.del2.hospital.Pasient;
import mappe.del2.persistence.CSVManager;
import java.io.IOException;
public class PatientRegister implements GuiWindow{
@Override
public Scene loadScene() throws IOException {
CSVManager csvManager = new CSVManager();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/PatientRegister.fxml"));
AnchorPane root = loader.load();
Scene scene = new Scene(root);
return scene;
}
}
package mappe.del2.factory;
import mappe.del2.hospital.Pasient;
public class SceneFactory {
public GuiWindow getScene(String sceneType){
if (sceneType == null){
return null;
}else if (sceneType.equalsIgnoreCase("patientRegister")){
return new PatientRegister();
}else if (sceneType.equalsIgnoreCase("deleteConfirmation")){
return new DeleteConfirmation();
}else if (sceneType.equalsIgnoreCase("informationDialog")){
return new InformationDialog();
}else if (sceneType.equalsIgnoreCase("newPatient")){
return new NewPatientDialog();
}
return null;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment