First version of changed people module

This commit is contained in:
Mateusz Kowalczyk 2020-01-28 22:18:59 +01:00
parent ea3a08d814
commit 3f73cd902d
13 changed files with 192 additions and 5 deletions

View File

@ -0,0 +1,45 @@
package dev.mateuszkowalczyk.ffm.app.people;
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
import dev.mateuszkowalczyk.ffm.data.database.person.PersonDAO;
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
import dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PeopleContainerController;
import dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PeopleController;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import java.io.IOException;
public class PeopleWorkspace {
private static PeopleWorkspace instance = new PeopleWorkspace();
private PeopleContainerController peopleContainerController;
private PeopleWorkspace () {}
public static PeopleWorkspace getInstance() {
return instance;
}
public void setPeopleContainerController(PeopleContainerController peopleContainerController) {
this.peopleContainerController = peopleContainerController;
}
public void loadPeople() {
if (peopleContainerController != null) {
var list = PersonDAO.getInstance().getAll();
int i = 1;
for (Person person : list) {
Node node = null;
try {
node = FXMLLoader.load(ResourceLoader.getInstance().getResource("templates/workspace/elements/person_pane.fxml"));
} catch (IOException e) {
e.printStackTrace();
}
this.peopleContainerController.addPerson(node, i++);
}
}
}
}

View File

@ -2,11 +2,13 @@ package dev.mateuszkowalczyk.ffm.data.database.person;
import dev.mateuszkowalczyk.ffm.data.database.annotation.Column;
import dev.mateuszkowalczyk.ffm.data.database.annotation.PrimaryKey;
import dev.mateuszkowalczyk.ffm.data.database.annotation.Table;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.UUID;
@Table
public class Person {
@PrimaryKey
@Column(type = Column.Type.INT)

View File

@ -3,12 +3,11 @@ package dev.mateuszkowalczyk.ffm.view.workspace;
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
import dev.mateuszkowalczyk.ffm.view.workspace.elements.ElementsEnum;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.ScrollPane;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
import java.io.IOException;
import java.net.URL;
@ -37,4 +36,12 @@ public class MainPageController implements Initializable {
e.printStackTrace();
}
}
public void openImageContainer(ActionEvent actionEvent) {
this.setElement(ElementsEnum.ImagesContainer);
}
public void openPeopleModule(ActionEvent actionEvent) {
this.setElement(ElementsEnum.People);
}
}

View File

@ -1,7 +1,8 @@
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
public enum ElementsEnum {
ImagesContainer("templates/workspace/elements/image_container.fxml");
ImagesContainer("templates/workspace/elements/image_container.fxml"),
People("templates/workspace/elements/people.fxml");
private String path;

View File

@ -0,0 +1,9 @@
package dev.mateuszkowalczyk.ffm.view.workspace.elements.people;
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
public class FaceContainerController {
public FaceContainerController(Person person) {
System.out.println("read face container");
}
}

View File

@ -0,0 +1,34 @@
package dev.mateuszkowalczyk.ffm.view.workspace.elements.people;
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
import dev.mateuszkowalczyk.ffm.app.people.PeopleWorkspace;
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import java.net.URL;
import java.util.ResourceBundle;
public class PeopleContainerController implements Initializable {
private PeopleWorkspace peopleWorkspace = PeopleWorkspace.getInstance();
@FXML
public GridPane peopleContainer;
public PeopleContainerController() {
System.out.println("people container");;
}
public void addPerson(Node node, int i) {
this.peopleContainer.getChildren().add(i, node);
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
this.peopleWorkspace.setPeopleContainerController(this);
this.peopleWorkspace.loadPeople();
}
}

View File

@ -0,0 +1,38 @@
package dev.mateuszkowalczyk.ffm.view.workspace.elements.people;
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
import dev.mateuszkowalczyk.ffm.view.workspace.elements.ElementsEnum;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.layout.BorderPane;
import jdk.swing.interop.LightweightFrameWrapper;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
public class PeopleController implements Initializable {
private static String FACE_CONTAINER = "templates/workspace/elements/face_container.fxml";
private static String PEOPLE_CONTAINER = "templates/workspace/elements/people_container.fxml";
@FXML
private BorderPane mainContainer;
public PeopleController() {
System.out.println("People controller");
}
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
this.setCenterElement(PEOPLE_CONTAINER);
}
public void setCenterElement(String element) {
try {
this.mainContainer.setCenter(FXMLLoader.load(ResourceLoader.getInstance().getResource(element)));
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,7 @@
package dev.mateuszkowalczyk.ffm.view.workspace.elements.people;
public class PersonPaneController {
public PersonPaneController () {
System.out.println("Hi person");
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.FlowPane?>
<FlowPane fx:id="facesContainer" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.mateuszkowalczyk.ffm.view.workspace.elements.people.FaceContainerController" />

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane fx:id="mainContainer" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PeopleController" />

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.RowConstraints?>
<GridPane fx:id="peopleContainer" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="400.0" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/11.0.1" fx:controller="dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PeopleContainerController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.Text?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="400.0" prefHeight="200.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PersonPaneController">
<children>
<ImageView fitHeight="200.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
<Text layoutX="206.0" layoutY="58.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Person name" textAlignment="CENTER" wrappingWidth="193.13000106811523" />
<Button layoutX="273.0" layoutY="100.0" mnemonicParsing="false" text="Edit" />
</children>
</AnchorPane>

View File

@ -13,7 +13,7 @@
<left>
<VBox prefHeight="400.0" prefWidth="50.0" BorderPane.alignment="CENTER">
<children>
<Button mnemonicParsing="false" prefWidth="50.0" style="-fx-background-color: trasparent;">
<Button mnemonicParsing="false" onAction="#openImageContainer" prefWidth="50.0" style="-fx-background-color: trasparent;">
<graphic>
<ImageView fitHeight="20.0" fitWidth="20.0">
<image>
@ -25,7 +25,7 @@
</ImageView>
</graphic>
</Button>
<Button layoutX="10.0" layoutY="10.0" mnemonicParsing="false" prefWidth="50.0" style="-fx-background-color: trasparent;">
<Button layoutX="10.0" layoutY="10.0" mnemonicParsing="false" onAction="#openPeopleModule" prefWidth="50.0" style="-fx-background-color: trasparent;">
<graphic>
<ImageView fitHeight="24.0" fitWidth="24.0">
<image>