Add main page
This commit is contained in:
parent
49c7465f07
commit
1067221cfe
@ -1,5 +1,6 @@
|
|||||||
package dev.mateuszkowalczyk.ffm;
|
package dev.mateuszkowalczyk.ffm;
|
||||||
|
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.SceneEnum;
|
||||||
import dev.mateuszkowalczyk.ffm.view.StageController;
|
import dev.mateuszkowalczyk.ffm.view.StageController;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
@ -8,6 +9,8 @@ public class Main extends Application {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage stage) throws Exception{
|
public void start(Stage stage) throws Exception{
|
||||||
|
var test = SceneEnum.WelcomePage;
|
||||||
|
|
||||||
StageController.getInstance().initApp(stage);
|
StageController.getInstance().initApp(stage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,15 +3,33 @@ package dev.mateuszkowalczyk.ffm.app;
|
|||||||
import dev.mateuszkowalczyk.ffm.data.Chooser;
|
import dev.mateuszkowalczyk.ffm.data.Chooser;
|
||||||
import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader;
|
import dev.mateuszkowalczyk.ffm.utils.PropertiesLoader;
|
||||||
import dev.mateuszkowalczyk.ffm.utils.Property;
|
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 {
|
public class WorkspaceService {
|
||||||
|
private static final WorkspaceService instance = new WorkspaceService();
|
||||||
private PropertiesLoader propertiesLoader = new PropertiesLoader();
|
private PropertiesLoader propertiesLoader = new PropertiesLoader();
|
||||||
|
|
||||||
|
private WorkspaceService(){}
|
||||||
|
|
||||||
|
public static WorkspaceService getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
public void setupWorkspace() {
|
public void setupWorkspace() {
|
||||||
Chooser chooser = new Chooser();
|
Chooser chooser = new Chooser();
|
||||||
String path = chooser.chooseDirectory();
|
String path = chooser.chooseDirectory();
|
||||||
this.propertiesLoader.set(Property.PATH_TO_DIRECTORY, path);
|
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");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
src/main/java/dev/mateuszkowalczyk/ffm/view/SceneEnum.java
Normal file
16
src/main/java/dev/mateuszkowalczyk/ffm/view/SceneEnum.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -31,15 +31,20 @@ public class StageController {
|
|||||||
this.stage = stage;
|
this.stage = stage;
|
||||||
this.stage.setTitle("Friend Face Matcher");
|
this.stage.setTitle("Friend Face Matcher");
|
||||||
|
|
||||||
URL sceneUrl;
|
|
||||||
if (this.propertiesLoader.get(Property.PATH_TO_DIRECTORY) != null) {
|
if (this.propertiesLoader.get(Property.PATH_TO_DIRECTORY) != null) {
|
||||||
sceneUrl = this.resourceLoader.getResource("welcomePage.fxml");
|
this.setScene(SceneEnum.MainPage);
|
||||||
} else {
|
} 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();
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,10 @@
|
|||||||
|
package dev.mateuszkowalczyk.ffm.view.workspace;
|
||||||
|
|
||||||
|
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
||||||
|
|
||||||
|
public class MainPageController {
|
||||||
|
|
||||||
|
public MainPageController() {
|
||||||
|
WorkspaceService.getInstance().refreshWorkspace();
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
BIN
src/main/resources/icons/dashboard.png
Executable file
BIN
src/main/resources/icons/dashboard.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 139 B |
42
src/main/resources/templates/workspace/main_page.fxml
Normal file
42
src/main/resources/templates/workspace/main_page.fxml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.geometry.Rectangle2D?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ScrollPane?>
|
||||||
|
<?import javafx.scene.image.Image?>
|
||||||
|
<?import javafx.scene.image.ImageView?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
|
|
||||||
|
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.mateuszkowalczyk.ffm.view.workspace.MainPageController">
|
||||||
|
<left>
|
||||||
|
<VBox prefHeight="400.0" prefWidth="50.0" BorderPane.alignment="CENTER">
|
||||||
|
<children>
|
||||||
|
<Button mnemonicParsing="false" prefWidth="50.0" style="-fx-background-color: trasparent;">
|
||||||
|
<graphic>
|
||||||
|
<ImageView fitHeight="20.0" fitWidth="20.0">
|
||||||
|
<image>
|
||||||
|
<Image url="@../../icons/dashboard.png" />
|
||||||
|
</image>
|
||||||
|
<viewport>
|
||||||
|
<Rectangle2D />
|
||||||
|
</viewport>
|
||||||
|
</ImageView>
|
||||||
|
</graphic>
|
||||||
|
</Button>
|
||||||
|
</children>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets top="20.0" />
|
||||||
|
</BorderPane.margin>
|
||||||
|
</VBox>
|
||||||
|
</left>
|
||||||
|
<center>
|
||||||
|
<ScrollPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
|
<content>
|
||||||
|
<VBox prefWidth="200.0" />
|
||||||
|
</content>
|
||||||
|
</ScrollPane>
|
||||||
|
</center>
|
||||||
|
</BorderPane>
|
@ -6,7 +6,7 @@
|
|||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.mateuszkowalczyk.ffm.view.controller.WelcomePageController">
|
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.mateuszkowalczyk.ffm.view.workspace.WelcomePageController">
|
||||||
<children>
|
<children>
|
||||||
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
<AnchorPane maxHeight="-1.0" maxWidth="-1.0" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
|
||||||
<children>
|
<children>
|
Loading…
Reference in New Issue
Block a user