move imagesContainer to own scene
This commit is contained in:
parent
b9320fc1f9
commit
ea3a08d814
@ -3,6 +3,7 @@ package dev.mateuszkowalczyk.ffm.app;
|
||||
import dev.mateuszkowalczyk.ffm.app.cache.CacheService;
|
||||
import dev.mateuszkowalczyk.ffm.data.DatabaseService;
|
||||
import dev.mateuszkowalczyk.ffm.view.workspace.MainPageController;
|
||||
import dev.mateuszkowalczyk.ffm.view.workspace.elements.ImageContainerController;
|
||||
import javafx.application.Platform;
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
@ -11,6 +12,7 @@ public class WorkspaceService {
|
||||
private DatabaseService databaseService;
|
||||
private CacheService cacheService;
|
||||
private MainPageController mainPageController;
|
||||
private ImageContainerController imagesContainerController;
|
||||
|
||||
private WorkspaceService() {
|
||||
this.cacheService = CacheService.getInstance();
|
||||
@ -29,13 +31,21 @@ public class WorkspaceService {
|
||||
this.mainPageController = mainPageController;
|
||||
}
|
||||
|
||||
public void refreshWorkspace() {
|
||||
Platform.runLater(() -> {this.getMainPageController().clearImages();});
|
||||
var t = new Thread(new WorkspaceWrapper());
|
||||
t.start();
|
||||
public void loadImages() {
|
||||
if (imagesContainerController != null) {
|
||||
Platform.runLater(() -> {this.imagesContainerController.clearImages();});
|
||||
var t = new Thread(new WorkspaceWrapper());
|
||||
t.start();
|
||||
} else {
|
||||
System.out.println("Cannot load images if imagesContainerController isn't exists");
|
||||
}
|
||||
}
|
||||
|
||||
public void addImage(ImageView element) {
|
||||
Platform.runLater(() -> this.mainPageController.addImage(element));
|
||||
Platform.runLater(() -> this.imagesContainerController.addImage(element));
|
||||
}
|
||||
|
||||
public void setImagesContainerController(ImageContainerController imageContainerController) {
|
||||
this.imagesContainerController = imageContainerController;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,10 @@ public class StageController {
|
||||
private PropertiesLoader propertiesLoader = PropertiesLoader.getInstance();
|
||||
private Stage stage;
|
||||
|
||||
public enum elements {
|
||||
|
||||
}
|
||||
|
||||
private StageController() {
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,16 @@
|
||||
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.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;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
@ -13,25 +18,23 @@ public class MainPageController implements Initializable {
|
||||
private WorkspaceService workspaceService;
|
||||
|
||||
@FXML
|
||||
private FlowPane imagesContainer;
|
||||
private ScrollPane mainContainer;
|
||||
|
||||
public MainPageController() {
|
||||
this.workspaceService = WorkspaceService.getInstance();
|
||||
this.workspaceService.setMainPageController(this);
|
||||
}
|
||||
|
||||
public void clearImages() {
|
||||
if (this.imagesContainer != null) {
|
||||
this.imagesContainer.getChildren().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void addImage(ImageView imageView) {
|
||||
this.imagesContainer.getChildren().add(imageView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
this.workspaceService.refreshWorkspace();
|
||||
this.setElement(ElementsEnum.ImagesContainer);
|
||||
}
|
||||
|
||||
public void setElement(ElementsEnum element) {
|
||||
try {
|
||||
this.mainContainer.setContent(FXMLLoader.load(ResourceLoader.getInstance().getResource(element.getPath())));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||
|
||||
public enum ElementsEnum {
|
||||
ImagesContainer("templates/workspace/elements/image_container.fxml");
|
||||
|
||||
private String path;
|
||||
|
||||
ElementsEnum(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package dev.mateuszkowalczyk.ffm.view.workspace.elements;
|
||||
|
||||
import dev.mateuszkowalczyk.ffm.app.WorkspaceService;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ImageContainerController implements Initializable {
|
||||
private WorkspaceService workspaceService = WorkspaceService.getInstance();
|
||||
|
||||
@FXML
|
||||
private FlowPane imagesContainer;
|
||||
|
||||
public ImageContainerController() { }
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
workspaceService.setImagesContainerController(this);
|
||||
workspaceService.loadImages();
|
||||
}
|
||||
|
||||
public void clearImages() {
|
||||
if (this.imagesContainer != null) {
|
||||
this.imagesContainer.getChildren().clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void addImage(ImageView imageView) {
|
||||
this.imagesContainer.getChildren().add(imageView);
|
||||
}
|
||||
}
|
BIN
src/main/resources/icons/face.png
Executable file
BIN
src/main/resources/icons/face.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 280 B |
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?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" />
|
@ -7,7 +7,6 @@
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?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">
|
||||
@ -26,6 +25,15 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button layoutX="10.0" layoutY="10.0" mnemonicParsing="false" prefWidth="50.0" style="-fx-background-color: trasparent;">
|
||||
<graphic>
|
||||
<ImageView fitHeight="24.0" fitWidth="24.0">
|
||||
<image>
|
||||
<Image url="@../../icons/face.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
<BorderPane.margin>
|
||||
<Insets top="20.0" />
|
||||
@ -33,10 +41,6 @@
|
||||
</VBox>
|
||||
</left>
|
||||
<center>
|
||||
<ScrollPane fitToWidth="true" maxWidth="1.7976931348623157E308" prefHeight="200.0" BorderPane.alignment="CENTER">
|
||||
<content>
|
||||
<FlowPane fx:id="imagesContainer" prefHeight="200.0" prefWidth="200.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
<ScrollPane fx:id="mainContainer" fitToWidth="true" maxWidth="1.7976931348623157E308" prefHeight="200.0" BorderPane.alignment="CENTER" />
|
||||
</center>
|
||||
</BorderPane>
|
||||
|
Loading…
Reference in New Issue
Block a user