diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/Main.java b/src/main/java/dev/mateuszkowalczyk/ffm/Main.java index 6967a46..e547f15 100644 --- a/src/main/java/dev/mateuszkowalczyk/ffm/Main.java +++ b/src/main/java/dev/mateuszkowalczyk/ffm/Main.java @@ -1,5 +1,6 @@ package dev.mateuszkowalczyk.ffm; +import dev.mateuszkowalczyk.ffm.view.SceneEnum; import dev.mateuszkowalczyk.ffm.view.StageController; import javafx.application.Application; import javafx.stage.Stage; @@ -8,6 +9,8 @@ public class Main extends Application { @Override public void start(Stage stage) throws Exception{ + var test = SceneEnum.WelcomePage; + StageController.getInstance().initApp(stage); } diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/app/WorkspaceService.java b/src/main/java/dev/mateuszkowalczyk/ffm/app/WorkspaceService.java index b730a48..a73455c 100644 --- a/src/main/java/dev/mateuszkowalczyk/ffm/app/WorkspaceService.java +++ b/src/main/java/dev/mateuszkowalczyk/ffm/app/WorkspaceService.java @@ -3,15 +3,33 @@ package dev.mateuszkowalczyk.ffm.app; import dev.mateuszkowalczyk.ffm.data.Chooser; import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader; import dev.mateuszkowalczyk.ffm.utils.Property; +import dev.mateuszkowalczyk.ffm.view.SceneEnum; +import dev.mateuszkowalczyk.ffm.view.StageController; -import java.util.Properties; +import java.io.IOException; public class WorkspaceService { + private static final WorkspaceService instance = new WorkspaceService(); private PropertiesLoader propertiesLoader = new PropertiesLoader(); + private WorkspaceService(){} + + public static WorkspaceService getInstance() { + return instance; + } + public void setupWorkspace() { Chooser chooser = new Chooser(); String path = chooser.chooseDirectory(); this.propertiesLoader.set(Property.PATH_TO_DIRECTORY, path); + try { + StageController.getInstance().setScene(SceneEnum.MainPage); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public void refreshWorkspace() { + System.out.println("Refreshing workspace"); } } diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/view/SceneEnum.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/SceneEnum.java new file mode 100644 index 0000000..edbd1a7 --- /dev/null +++ b/src/main/java/dev/mateuszkowalczyk/ffm/view/SceneEnum.java @@ -0,0 +1,16 @@ +package dev.mateuszkowalczyk.ffm.view; + +public enum SceneEnum { + MainPage("templates/workspace/main_page.fxml"), + WelcomePage("templates/workspace/welcome_page.fxml"); + + private String path; + + SceneEnum(String path) { + this.path = path; + } + + public String getPath() { + return path; + } +} diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java index 80740e0..a59ddac 100644 --- a/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java +++ b/src/main/java/dev/mateuszkowalczyk/ffm/view/StageController.java @@ -31,15 +31,20 @@ public class StageController { this.stage = stage; this.stage.setTitle("Friend Face Matcher"); - URL sceneUrl; + if (this.propertiesLoader.get(Property.PATH_TO_DIRECTORY) != null) { - sceneUrl = this.resourceLoader.getResource("welcomePage.fxml"); + this.setScene(SceneEnum.MainPage); } else { - sceneUrl = this.resourceLoader.getResource("welcomePage.fxml"); + this.setScene(SceneEnum.WelcomePage); } - Scene scene = new Scene(FXMLLoader.load(sceneUrl)); - this.stage.setScene(scene); + this.stage.show(); } + public void setScene(SceneEnum sceneEnum) throws IOException { + URL sceneUrl = this.resourceLoader.getResource(sceneEnum.getPath()); + Scene scene = new Scene(FXMLLoader.load(sceneUrl)); + this.stage.setScene(scene); + } + } diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/view/controller/WelcomePageController.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/controller/WelcomePageController.java deleted file mode 100644 index 48faa5f..0000000 --- a/src/main/java/dev/mateuszkowalczyk/ffm/view/controller/WelcomePageController.java +++ /dev/null @@ -1,16 +0,0 @@ -package dev.mateuszkowalczyk.ffm.view.controller; - -import dev.mateuszkowalczyk.ffm.app.WorkspaceService; -import javafx.fxml.FXML; - -public class WelcomePageController { - public WelcomePageController() { - System.out.println("Controller work"); - } - - @FXML - public void startNewApp(){ - var workspaceService = new WorkspaceService(); - workspaceService.setupWorkspace(); - } -} diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/view/workspace/MainPageController.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/workspace/MainPageController.java new file mode 100644 index 0000000..ffefa11 --- /dev/null +++ b/src/main/java/dev/mateuszkowalczyk/ffm/view/workspace/MainPageController.java @@ -0,0 +1,10 @@ +package dev.mateuszkowalczyk.ffm.view.workspace; + +import dev.mateuszkowalczyk.ffm.app.WorkspaceService; + +public class MainPageController { + + public MainPageController() { + WorkspaceService.getInstance().refreshWorkspace(); + } +} diff --git a/src/main/java/dev/mateuszkowalczyk/ffm/view/workspace/WelcomePageController.java b/src/main/java/dev/mateuszkowalczyk/ffm/view/workspace/WelcomePageController.java new file mode 100644 index 0000000..5f49a26 --- /dev/null +++ b/src/main/java/dev/mateuszkowalczyk/ffm/view/workspace/WelcomePageController.java @@ -0,0 +1,13 @@ +package dev.mateuszkowalczyk.ffm.view.workspace; + +import dev.mateuszkowalczyk.ffm.app.WorkspaceService; +import javafx.fxml.FXML; + +public class WelcomePageController { + public WelcomePageController() { } + + @FXML + public void startNewApp(){ + WorkspaceService.getInstance().setupWorkspace(); + } +} diff --git a/src/main/resources/icons/dashboard.png b/src/main/resources/icons/dashboard.png new file mode 100755 index 0000000..a1476f6 Binary files /dev/null and b/src/main/resources/icons/dashboard.png differ diff --git a/src/main/resources/templates/workspace/main_page.fxml b/src/main/resources/templates/workspace/main_page.fxml new file mode 100644 index 0000000..2e3b962 --- /dev/null +++ b/src/main/resources/templates/workspace/main_page.fxml @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+
diff --git a/src/main/resources/welcomePage.fxml b/src/main/resources/templates/workspace/welcome_page.fxml similarity index 93% rename from src/main/resources/welcomePage.fxml rename to src/main/resources/templates/workspace/welcome_page.fxml index 734ed6d..c9409c3 100644 --- a/src/main/resources/welcomePage.fxml +++ b/src/main/resources/templates/workspace/welcome_page.fxml @@ -6,7 +6,7 @@ - +