diff --git a/pom.xml b/pom.xml
index f149371..661b622 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,11 @@
${junit.jupiter.version}
test
+
+ org.xerial
+ sqlite-jdbc
+ 3.28.0
+
diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/Main.java b/src/main/java/dev/mateuszkowalczyk/ffm/Main.java
index bf85337..6967a46 100644
--- a/src/main/java/dev/mateuszkowalczyk/ffm/Main.java
+++ b/src/main/java/dev/mateuszkowalczyk/ffm/Main.java
@@ -1,24 +1,14 @@
package dev.mateuszkowalczyk.ffm;
+import dev.mateuszkowalczyk.ffm.view.StageController;
import javafx.application.Application;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Parent;
-import javafx.scene.Scene;
import javafx.stage.Stage;
-import java.net.URL;
-
public class Main extends Application {
@Override
- public void start(Stage primaryStage) throws Exception{
- URL welcomePageUrl = getClass().getClassLoader().
- getResource("welcomePage.fxml");
-
- Parent welcomePage = FXMLLoader.load(welcomePageUrl);
- primaryStage.setTitle("Friend Face Matcher");
- primaryStage.setScene(new Scene(welcomePage));
- primaryStage.show();
+ public void start(Stage stage) throws Exception{
+ StageController.getInstance().initApp(stage);
}
diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/utils/PropertiesLoader.java b/src/main/java/dev/mateuszkowalczyk/ffm/utils/PropertiesLoader.java
new file mode 100644
index 0000000..91d41de
--- /dev/null
+++ b/src/main/java/dev/mateuszkowalczyk/ffm/utils/PropertiesLoader.java
@@ -0,0 +1,54 @@
+package dev.mateuszkowalczyk.ffm.utils;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Properties;
+
+public class PropertiesLoader {
+ public static final String CONFIG_NAME_FILE = "config.properties";
+
+ private static final PropertiesLoader instance = new PropertiesLoader();
+ private ResourceLoader resourceLoader = ResourceLoader.getInstance();
+ private Properties properties = null;
+
+ public PropertiesLoader () {}
+
+ public static PropertiesLoader getInstance() {
+ return instance;
+ }
+
+ public Properties load() {
+ this.properties = new Properties();
+ try {
+ InputStream inputStream = resourceLoader.getResourceAsStream(CONFIG_NAME_FILE);
+ this.properties.load(inputStream);
+
+ inputStream.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return this.properties;
+ }
+
+ public void save(Properties prop) {
+ try {
+ OutputStream output = new FileOutputStream(this.resourceLoader.getPath(CONFIG_NAME_FILE));
+ prop.store(output, null);
+
+ output.close();
+ System.out.println(prop);
+ } catch (IOException e){
+ e.printStackTrace();
+ }
+ }
+
+ public String get(String name) {
+ if (this.properties == null) {
+ this.load();
+ }
+
+ return this.properties.getProperty(name);
+ }
+}
diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/utils/Property.java b/src/main/java/dev/mateuszkowalczyk/ffm/utils/Property.java
new file mode 100644
index 0000000..3ddc198
--- /dev/null
+++ b/src/main/java/dev/mateuszkowalczyk/ffm/utils/Property.java
@@ -0,0 +1,5 @@
+package dev.mateuszkowalczyk.ffm.utils;
+
+public class Property {
+ public static final String PATH_TO_DIRECTORY = "pathToDirectory";
+}
diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/utils/ResourceLoader.java b/src/main/java/dev/mateuszkowalczyk/ffm/utils/ResourceLoader.java
new file mode 100644
index 0000000..60a44a5
--- /dev/null
+++ b/src/main/java/dev/mateuszkowalczyk/ffm/utils/ResourceLoader.java
@@ -0,0 +1,26 @@
+package dev.mateuszkowalczyk.ffm.utils;
+
+import java.io.InputStream;
+import java.net.URL;
+
+public class ResourceLoader {
+ private static final ResourceLoader instance = new ResourceLoader();
+
+ private ResourceLoader(){}
+
+ public URL getResource(String name) {
+ return getClass().getClassLoader().getResource(name);
+ }
+
+ public InputStream getResourceAsStream(String name) {
+ return getClass().getClassLoader().getResourceAsStream( name);
+ }
+
+ public String getPath(String name) {
+ return this.getResource(name).getPath();
+ }
+
+ public static ResourceLoader getInstance() {
+ return instance;
+ }
+}
diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java
new file mode 100644
index 0000000..291cb83
--- /dev/null
+++ b/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java
@@ -0,0 +1,40 @@
+package dev.mateuszkowalczyk.ffm.view;
+
+import dev.mateuszkowalczyk.ffm.utils.Property;
+import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader;
+import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.stage.Stage;
+
+import java.io.IOException;
+import java.net.URL;
+
+public class StageController {
+ private static final StageController instance = new StageController();
+ private ResourceLoader resourceLoader = ResourceLoader.getInstance();
+ private PropertiesLoader propertiesLoader = PropertiesLoader.getInstance();
+ private Stage stage;
+
+ private StageController() {}
+
+ public static StageController getInstance() {
+ return instance;
+ }
+
+ public void initApp(Stage stage) throws IOException {
+ this.stage = stage;
+ this.stage.setTitle("Friend Face Matcher");
+
+ URL sceneUrl = null;
+ if (this.propertiesLoader.get(Property.PATH_TO_DIRECTORY) != null) {
+ sceneUrl = this.resourceLoader.getResource("welcomePage.fxml");
+ } else {
+ sceneUrl = this.resourceLoader.getResource("welcomePage.fxml");
+ }
+ Scene scene = new Scene(FXMLLoader.load(sceneUrl));
+ this.stage.setScene(scene);
+ this.stage.show();
+ }
+
+}
diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/controller/WelcomePageController.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/controller/WelcomePageController.java
similarity index 83%
rename from src/main/java/dev/mateuszkowalczyk/ffm/controller/WelcomePageController.java
rename to src/main/java/dev/mateuszkowalczyk/ffm/view/controller/WelcomePageController.java
index bbf89e2..c36b0dc 100644
--- a/src/main/java/dev/mateuszkowalczyk/ffm/controller/WelcomePageController.java
+++ b/src/main/java/dev/mateuszkowalczyk/ffm/view/controller/WelcomePageController.java
@@ -1,4 +1,4 @@
-package dev.mateuszkowalczyk.ffm.controller;
+package dev.mateuszkowalczyk.ffm.view.controller;
import javafx.fxml.FXML;
diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/welcomePage.fxml b/src/main/resources/welcomePage.fxml
index 310c074..734ed6d 100644
--- a/src/main/resources/welcomePage.fxml
+++ b/src/main/resources/welcomePage.fxml
@@ -6,7 +6,7 @@
-
+