add showing face and delete face
This commit is contained in:
parent
811bfc0f91
commit
8a747a5982
@ -0,0 +1,4 @@
|
|||||||
|
package dev.mateuszkowalczyk.ffm.app.exception;
|
||||||
|
|
||||||
|
public class NotFoundException extends Exception {
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package dev.mateuszkowalczyk.ffm.app.face;
|
||||||
|
|
||||||
|
import dev.mateuszkowalczyk.ffm.app.exception.NotFoundException;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.face.Face;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.face.FaceDAO;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
||||||
|
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.FaceContainerController;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.FacePaneController;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FaceWorkspace {
|
||||||
|
private static FaceWorkspace instance = new FaceWorkspace();
|
||||||
|
|
||||||
|
public static FaceWorkspace getInstance() {
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFacesForPerson(MainPageController mainPageController, FaceContainerController faceContainerController, Person person) throws NotFoundException {
|
||||||
|
List<Face> faceList = FaceDAO.getInstance().getAllForPerson(person);
|
||||||
|
var resourceLoader = ResourceLoader.getInstance();
|
||||||
|
|
||||||
|
if (faceList.size() == 0) {
|
||||||
|
throw new NotFoundException();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Face face : faceList) {
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader();
|
||||||
|
fxmlLoader.setLocation(resourceLoader.getResource("templates/workspace/elements/face_pane.fxml"));
|
||||||
|
fxmlLoader.setController(new FacePaneController(mainPageController, faceContainerController, face));
|
||||||
|
|
||||||
|
try {
|
||||||
|
faceContainerController.addFacePane(fxmlLoader.load());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,18 +3,16 @@ package dev.mateuszkowalczyk.ffm.app.people;
|
|||||||
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.person.PersonDAO;
|
import dev.mateuszkowalczyk.ffm.data.database.person.PersonDAO;
|
||||||
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
|
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
|
||||||
import dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PeopleContainerController;
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
import dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PeopleController;
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.PeopleContainerController;
|
||||||
import dev.mateuszkowalczyk.ffm.view.workspace.elements.people.PersonPaneController;
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.PersonPaneController;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.Button;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PeopleWorkspace {
|
public class PeopleWorkspace {
|
||||||
private static PeopleWorkspace instance = new PeopleWorkspace();
|
private static PeopleWorkspace instance = new PeopleWorkspace();
|
||||||
private PeopleContainerController peopleContainerController;
|
|
||||||
|
|
||||||
private PeopleWorkspace () {}
|
private PeopleWorkspace () {}
|
||||||
|
|
||||||
@ -23,30 +21,32 @@ public class PeopleWorkspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setPeopleContainerController(PeopleContainerController peopleContainerController) {
|
public void loadPeople(MainPageController mainPageController, PeopleContainerController peopleContainerController) {
|
||||||
this.peopleContainerController = peopleContainerController;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void loadPeople() {
|
|
||||||
if (peopleContainerController != null) {
|
if (peopleContainerController != null) {
|
||||||
var list = PersonDAO.getInstance().getAll();
|
var list = PersonDAO.getInstance().getAll(true);
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
|
Node node = null;
|
||||||
for (Person person : list) {
|
for (Person person : list) {
|
||||||
Node node = null;
|
node = null;
|
||||||
try {
|
try {
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader();
|
FXMLLoader fxmlLoader = new FXMLLoader();
|
||||||
fxmlLoader.setController(new PersonPaneController(person));
|
var controller = new PersonPaneController(mainPageController, person);
|
||||||
|
fxmlLoader.setController(controller);
|
||||||
fxmlLoader.setLocation((ResourceLoader.getInstance().getResource("templates/workspace/elements/person_pane.fxml")));
|
fxmlLoader.setLocation((ResourceLoader.getInstance().getResource("templates/workspace/elements/person_pane.fxml")));
|
||||||
// node = FXMLLoader.load);
|
// node = FXMLLoader.load);
|
||||||
|
|
||||||
node = fxmlLoader.load();
|
node = fxmlLoader.load();
|
||||||
|
if(!controller.valid()) {
|
||||||
|
PersonDAO.getInstance().delete(person);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// node = new Button();
|
// node = new Button();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.peopleContainerController.addPerson(node, i++);
|
peopleContainerController.addPerson(node, i++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,23 @@ public class FaceDAO implements Dao<Face> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Face face) {
|
public void delete(Face face) {
|
||||||
|
String sql = "DELETE FROM face where id = ?";
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
||||||
|
preparedStatement.setLong(1, face.getId());
|
||||||
|
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
|
||||||
|
this.getAll(true);
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face getFirstFace(Person person) {
|
public Face getFirstFace(Person person) {
|
||||||
String sql = "SELECT * FROM face WHERE face.personId = :personId LIMIT 1";
|
String sql = "SELECT * FROM face WHERE face.personId = ? LIMIT 1";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
||||||
@ -118,4 +130,27 @@ public class FaceDAO implements Dao<Face> {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Face> getAllForPerson(Person person) {
|
||||||
|
List<Face> personFaceList = new ArrayList<>();
|
||||||
|
|
||||||
|
String sql = "SELECT * FROM face WHERE personId = ?";
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
||||||
|
preparedStatement.setLong(1, person.getId());
|
||||||
|
|
||||||
|
ResultSet resultSet = preparedStatement.executeQuery();
|
||||||
|
|
||||||
|
while (resultSet.next()) {
|
||||||
|
Face face = new Face(resultSet);
|
||||||
|
personFaceList.add(face);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return personFaceList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ public class PersonDAO implements Dao<Person> {
|
|||||||
@Override
|
@Override
|
||||||
public List<Person> getAll(boolean refresh) {
|
public List<Person> getAll(boolean refresh) {
|
||||||
if (this.personList.size() == 0 || refresh) {
|
if (this.personList.size() == 0 || refresh) {
|
||||||
|
this.personList.clear();
|
||||||
String sql = "SELECT * FROM persons";
|
String sql = "SELECT * FROM persons";
|
||||||
try {
|
try {
|
||||||
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
||||||
@ -86,6 +87,16 @@ public class PersonDAO implements Dao<Person> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Person person) {
|
public void delete(Person person) {
|
||||||
|
String sql = "DELETE FROM persons WHERE id = ?";
|
||||||
|
|
||||||
|
try {
|
||||||
|
PreparedStatement preparedStatement = this.databaseService.getConnection().prepareStatement(sql);
|
||||||
|
preparedStatement.setLong(1, person.getId());
|
||||||
|
|
||||||
|
preparedStatement.executeUpdate();
|
||||||
|
this.getAll(true);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
package dev.mateuszkowalczyk.ffm.view.workspace;
|
package dev.mateuszkowalczyk.ffm.view.workspace;
|
||||||
|
|
||||||
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
||||||
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
|
import dev.mateuszkowalczyk.ffm.utils.ResourceLoader;
|
||||||
import dev.mateuszkowalczyk.ffm.view.workspace.elements.ElementsEnum;
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.ElementsEnum;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.FaceContainerController;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.ImageContainerController;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.elements.PeopleContainerController;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
@ -18,6 +22,7 @@ public class MainPageController implements Initializable {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ScrollPane mainContainer;
|
private ScrollPane mainContainer;
|
||||||
|
private Person selectedPerson;
|
||||||
|
|
||||||
public MainPageController() {
|
public MainPageController() {
|
||||||
this.workspaceService = WorkspaceService.getInstance();
|
this.workspaceService = WorkspaceService.getInstance();
|
||||||
@ -31,7 +36,22 @@ public class MainPageController implements Initializable {
|
|||||||
|
|
||||||
public void setElement(ElementsEnum element) {
|
public void setElement(ElementsEnum element) {
|
||||||
try {
|
try {
|
||||||
this.mainContainer.setContent(FXMLLoader.load(ResourceLoader.getInstance().getResource(element.getPath())));
|
Object controller = null;
|
||||||
|
FXMLLoader fxmlLoader = new FXMLLoader();
|
||||||
|
switch (element) {
|
||||||
|
case ImagesContainer:
|
||||||
|
controller = new ImageContainerController(this);
|
||||||
|
break;
|
||||||
|
case PeopleContainer:
|
||||||
|
controller = new PeopleContainerController(this);
|
||||||
|
break;
|
||||||
|
case PersonFaceContainer:
|
||||||
|
controller = new FaceContainerController(this, this.selectedPerson);
|
||||||
|
}
|
||||||
|
fxmlLoader.setLocation(ResourceLoader.getInstance().getResource(element.getPath()));
|
||||||
|
fxmlLoader.setController(controller);
|
||||||
|
|
||||||
|
this.mainContainer.setContent(fxmlLoader.load());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -42,6 +62,11 @@ public class MainPageController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void openPeopleModule(ActionEvent actionEvent) {
|
public void openPeopleModule(ActionEvent actionEvent) {
|
||||||
this.setElement(ElementsEnum.People);
|
this.setElement(ElementsEnum.PeopleContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openFacesSelectedPerson(Person person) {
|
||||||
|
this.selectedPerson = person;
|
||||||
|
this.setElement(ElementsEnum.PersonFaceContainer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,8 @@ package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
|||||||
|
|
||||||
public enum ElementsEnum {
|
public enum ElementsEnum {
|
||||||
ImagesContainer("templates/workspace/elements/image_container.fxml"),
|
ImagesContainer("templates/workspace/elements/image_container.fxml"),
|
||||||
People("templates/workspace/elements/people.fxml");
|
PeopleContainer("templates/workspace/elements/people_container.fxml"),
|
||||||
|
PersonFaceContainer("templates/workspace/elements/face_container.fxml");
|
||||||
|
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
|
@ -0,0 +1,48 @@
|
|||||||
|
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||||
|
|
||||||
|
import dev.mateuszkowalczyk.ffm.app.exception.NotFoundException;
|
||||||
|
import dev.mateuszkowalczyk.ffm.app.face.FaceWorkspace;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.face.FaceDAO;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.person.PersonDAO;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.layout.FlowPane;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class FaceContainerController implements Initializable {
|
||||||
|
private MainPageController mainPageController;
|
||||||
|
private Person person;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private FlowPane facesContainer;
|
||||||
|
|
||||||
|
public FaceContainerController(MainPageController mainPageController, Person person) {
|
||||||
|
this.mainPageController = mainPageController;
|
||||||
|
this.person = person;
|
||||||
|
System.out.println("read face container");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addFacePane(Node node) {
|
||||||
|
this.facesContainer.getChildren().add(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
|
this.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refresh() {
|
||||||
|
this.facesContainer.getChildren().clear();
|
||||||
|
try {
|
||||||
|
FaceWorkspace.getInstance().loadFacesForPerson(mainPageController, this, person);
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
PersonDAO.getInstance().delete(person);
|
||||||
|
this.mainPageController.setElement(ElementsEnum.PeopleContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||||
|
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.face.Face;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.face.FaceDAO;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
|
import javafx.event.Event;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.Initializable;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
public class FacePaneController implements Initializable {
|
||||||
|
private MainPageController mainPageController;
|
||||||
|
private FaceContainerController faceContainerController;
|
||||||
|
private Face face;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private ImageView faceImage;
|
||||||
|
|
||||||
|
public FacePaneController(MainPageController mainPageController, FaceContainerController faceContainerController, Face face) {
|
||||||
|
|
||||||
|
this.mainPageController = mainPageController;
|
||||||
|
this.faceContainerController = faceContainerController;
|
||||||
|
this.face = face;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeThis(Event event) {
|
||||||
|
FaceDAO.getInstance().delete(this.face);
|
||||||
|
this.faceContainerController.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
|
this.loadFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadFace() {
|
||||||
|
Image image = new Image("file:" + this.face.getPath());
|
||||||
|
this.faceImage.setImage(image);
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||||
|
|
||||||
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
||||||
|
import dev.mateuszkowalczyk.ffm.data.database.photo.PhotoDAO;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
|
import javafx.event.Event;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
@ -15,7 +18,7 @@ public class ImageContainerController implements Initializable {
|
|||||||
@FXML
|
@FXML
|
||||||
private FlowPane imagesContainer;
|
private FlowPane imagesContainer;
|
||||||
|
|
||||||
public ImageContainerController() { }
|
public ImageContainerController(MainPageController mainPageController) { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
@ -29,6 +32,11 @@ public class ImageContainerController implements Initializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void forceRefresh(Event event) {
|
||||||
|
PhotoDAO.getInstance().getAll(true);
|
||||||
|
this.workspaceService.loadImages();
|
||||||
|
}
|
||||||
|
|
||||||
public void addImage(ImageView imageView) {
|
public void addImage(ImageView imageView) {
|
||||||
this.imagesContainer.getChildren().add(imageView);
|
this.imagesContainer.getChildren().add(imageView);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package dev.mateuszkowalczyk.ffm.view.workspace.elements.people;
|
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||||
|
|
||||||
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
||||||
import dev.mateuszkowalczyk.ffm.app.people.PeopleWorkspace;
|
import dev.mateuszkowalczyk.ffm.app.people.PeopleWorkspace;
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
||||||
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
@ -13,13 +14,15 @@ import java.net.URL;
|
|||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class PeopleContainerController implements Initializable {
|
public class PeopleContainerController implements Initializable {
|
||||||
|
private final MainPageController mainPageController;
|
||||||
private PeopleWorkspace peopleWorkspace = PeopleWorkspace.getInstance();
|
private PeopleWorkspace peopleWorkspace = PeopleWorkspace.getInstance();
|
||||||
private Integer numberOfAdded = 0;
|
private Integer numberOfAdded = 0;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public GridPane peopleContainer;
|
public GridPane peopleContainer;
|
||||||
|
|
||||||
public PeopleContainerController() {
|
public PeopleContainerController(MainPageController mainPageController) {
|
||||||
|
this.mainPageController = mainPageController;
|
||||||
System.out.println("people container");;
|
System.out.println("people container");;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +41,6 @@ public class PeopleContainerController implements Initializable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||||
this.peopleWorkspace.setPeopleContainerController(this);
|
this.peopleWorkspace.loadPeople(mainPageController, this);
|
||||||
this.peopleWorkspace.loadPeople();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package dev.mateuszkowalczyk.ffm.view.workspace.elements.people;
|
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||||
|
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.face.Face;
|
import dev.mateuszkowalczyk.ffm.data.database.face.Face;
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.face.FaceDAO;
|
import dev.mateuszkowalczyk.ffm.data.database.face.FaceDAO;
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
import dev.mateuszkowalczyk.ffm.data.database.person.Person;
|
||||||
import dev.mateuszkowalczyk.ffm.data.database.person.PersonDAO;
|
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
@ -11,30 +11,30 @@ import javafx.scene.image.Image;
|
|||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class PersonPaneController implements Initializable {
|
public class PersonPaneController implements Initializable {
|
||||||
private FaceDAO faceDAO = FaceDAO.getInstance();
|
private FaceDAO faceDAO = FaceDAO.getInstance();
|
||||||
|
private MainPageController mainPageController;
|
||||||
private Person person;
|
private Person person;
|
||||||
@FXML
|
@FXML
|
||||||
private Text personName;
|
private Text personName;
|
||||||
@FXML
|
@FXML
|
||||||
private ImageView faceImage;
|
private ImageView faceImage;
|
||||||
|
private boolean valid = true;
|
||||||
|
|
||||||
public PersonPaneController () {
|
public PersonPaneController () {
|
||||||
System.out.println("Hi person");
|
System.out.println("Hi person");
|
||||||
}
|
}
|
||||||
|
|
||||||
public PersonPaneController(Person person) {
|
public PersonPaneController(MainPageController mainPageController, Person person) {
|
||||||
|
this.mainPageController = mainPageController;
|
||||||
this.person = person;
|
this.person = person;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void editPerson(ActionEvent actionEvent) {
|
public void editPerson(ActionEvent actionEvent) {
|
||||||
|
this.mainPageController.openFacesSelectedPerson(this.person);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,7 +42,11 @@ public class PersonPaneController implements Initializable {
|
|||||||
this.personName.setText(person.getName());
|
this.personName.setText(person.getName());
|
||||||
var face = this.faceDAO.getFirstFace(person);
|
var face = this.faceDAO.getFirstFace(person);
|
||||||
|
|
||||||
this.setFace(face);
|
if (face == null) {
|
||||||
|
this.valid = false;
|
||||||
|
} else {
|
||||||
|
this.setFace(face);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFace(Face face) {
|
private void setFace(Face face) {
|
||||||
@ -51,4 +55,8 @@ public class PersonPaneController implements Initializable {
|
|||||||
|
|
||||||
this.faceImage.setImage(image);
|
this.faceImage.setImage(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean valid() {
|
||||||
|
return this.valid;
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,9 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,4 +3,4 @@
|
|||||||
<?import javafx.scene.layout.FlowPane?>
|
<?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" />
|
<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" />
|
||||||
|
@ -0,0 +1,18 @@
|
|||||||
|
<?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.layout.Pane?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<Pane layoutX="27.0" layoutY="25.0" prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: grey;">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="faceImage" fitHeight="200.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
</children>
|
||||||
|
</Pane>
|
||||||
|
<Button layoutX="309.0" layoutY="197.0" mnemonicParsing="false" onAction="#removeThis" text="This is not a face" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
@ -0,0 +1,18 @@
|
|||||||
|
<?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.layout.Pane?>
|
||||||
|
|
||||||
|
|
||||||
|
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="250.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<children>
|
||||||
|
<Pane layoutX="27.0" layoutY="25.0" prefHeight="200.0" prefWidth="200.0" style="-fx-border-color: grey;">
|
||||||
|
<children>
|
||||||
|
<ImageView fx:id="faceImage" fitHeight="200.0" fitWidth="200.0" pickOnBounds="true" preserveRatio="true" />
|
||||||
|
</children>
|
||||||
|
</Pane>
|
||||||
|
<Button layoutX="309.0" layoutY="197.0" mnemonicParsing="false" onAction="#removeThis" text="This is not a face" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
@ -1,6 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.ToolBar?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
<?import javafx.scene.layout.FlowPane?>
|
<?import javafx.scene.layout.FlowPane?>
|
||||||
|
|
||||||
|
|
||||||
<FlowPane fx:id="imagesContainer" 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.ImageContainerController" />
|
<BorderPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
|
<center>
|
||||||
|
<FlowPane fx:id="imagesContainer" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" />
|
||||||
|
</center>
|
||||||
|
<top>
|
||||||
|
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
|
<items>
|
||||||
|
<Button mnemonicParsing="false" onAction="#forceRefresh" text="Refresh" />
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</top>
|
||||||
|
</BorderPane>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<?import javafx.scene.layout.GridPane?>
|
<?import javafx.scene.layout.GridPane?>
|
||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
|
||||||
<GridPane fx:id="peopleContainer" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="1000.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.PeopleContainerController">
|
<GridPane fx:id="peopleContainer" maxHeight="-Infinity" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="1000.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" >
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user