diff --git a/owlplug-client/pom.xml b/owlplug-client/pom.xml index 2f68ad38..b8e427a4 100644 --- a/owlplug-client/pom.xml +++ b/owlplug-client/pom.xml @@ -143,6 +143,13 @@ org.jfxtras jmetro 11.6.16 + + + + org.openjfx + javafx-base + + diff --git a/owlplug-client/src/main/java/com/owlplug/core/controllers/DirectoryInfoController.java b/owlplug-client/src/main/java/com/owlplug/core/controllers/DirectoryInfoController.java index ca32fea4..85b90b53 100644 --- a/owlplug-client/src/main/java/com/owlplug/core/controllers/DirectoryInfoController.java +++ b/owlplug-client/src/main/java/com/owlplug/core/controllers/DirectoryInfoController.java @@ -33,6 +33,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; @@ -41,6 +42,10 @@ import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.ListView; +import javafx.scene.control.Tab; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.TextField; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; import javafx.scene.text.Text; @@ -56,9 +61,9 @@ public class DirectoryInfoController extends BaseController { private FileStatDAO fileStatDAO; @FXML - private Label directoryPathLabel; + private Label directoryNameLabel; @FXML - private Label directoryMetricsLabel; + private TextField directoryPathTextField; @FXML private ListView pluginDirectoryListView; @FXML @@ -67,7 +72,18 @@ public class DirectoryInfoController extends BaseController { private Button deleteDirectoryButton; @FXML private VBox pieChartContainer; - + @FXML + private Tab directoryMetricsTab; + @FXML + private Tab directoryPluginsTab; + @FXML + private Tab directoryFilesTab; + @FXML + private TableView directoryFilesTableView; + @FXML + private TableColumn fileNameColumn; + @FXML + private TableColumn fileSizeColumn; private PieChart pieChart; private PluginDirectory pluginDirectory; @@ -132,12 +148,22 @@ protected void layoutChartChildren(double top, double left, double contentWidth, pieChartContainer.getChildren().add(pieChart); VBox.setVgrow(pieChart, Priority.ALWAYS); + fileNameColumn.setCellValueFactory(cellData -> + new SimpleStringProperty(cellData.getValue().getName())); + + fileSizeColumn.setCellValueFactory(cellData -> + new SimpleStringProperty( + FileUtils.humanReadableByteCount( + cellData.getValue().getLength(), true))); + } public void setPluginDirectory(PluginDirectory pluginDirectory) { this.pluginDirectory = pluginDirectory; - directoryPathLabel.setText(pluginDirectory.getPath()); + directoryPathTextField.setText(pluginDirectory.getPath()); + directoryNameLabel.setText(pluginDirectory.getName()); pluginDirectoryListView.getItems().setAll(pluginDirectory.getPluginList()); + directoryMetricsTab.setText("0 KB"); String path = pluginDirectory.getPath(); @@ -145,22 +171,22 @@ public void setPluginDirectory(PluginDirectory pluginDirectory) { path = path.substring(0, path.length() - 1); } - List directoryMetrics = new ArrayList<>(); Optional directoryStat = fileStatDAO.findByPath(path); - directoryStat.ifPresent(fileStat -> directoryMetrics.add( + directoryStat.ifPresent(fileStat -> directoryMetricsTab.setText( FileUtils.humanReadableByteCount(fileStat.getLength(), true))); - directoryMetrics.add(pluginDirectory.getPluginList().size() + " plugin(s)"); + + directoryPluginsTab.setText("Plugins (" + pluginDirectory.getPluginList().size() + ")"); List fileStats = fileStatDAO.findByParentPathOrderByLengthDesc(path); - if (fileStats.size() > 0) { - directoryMetrics.add(fileStats.size() + " file(s)"); - } + directoryFilesTab.setText("Files (" + fileStats.size() + ")"); + + ObservableList obsStats = FXCollections.observableArrayList(); + obsStats.addAll(fileStats); + directoryFilesTableView.setItems(obsStats); pieChart.setData(createStatChartBuckets(fileStats)); pieChart.layout(); - directoryMetricsLabel.setText(String.join(" | ", directoryMetrics)); - } private ObservableList createStatChartBuckets(List fileStats) { diff --git a/owlplug-client/src/main/java/com/owlplug/core/model/FileStat.java b/owlplug-client/src/main/java/com/owlplug/core/model/FileStat.java index 12a0428c..3079517a 100644 --- a/owlplug-client/src/main/java/com/owlplug/core/model/FileStat.java +++ b/owlplug-client/src/main/java/com/owlplug/core/model/FileStat.java @@ -23,13 +23,17 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToMany; +import jakarta.persistence.Table; import java.util.HashSet; import java.util.Set; @Entity +@Table(indexes = { @Index(name = "IDX_FILESTAT_ID", columnList = "id"), + @Index(name = "IDX_FILESTAT_PARENT_PATH", columnList = "parentPath") }) public class FileStat { @Id diff --git a/owlplug-client/src/main/resources/fxml/DirectoryInfoView.fxml b/owlplug-client/src/main/resources/fxml/DirectoryInfoView.fxml index e8804e21..2fe6c005 100644 --- a/owlplug-client/src/main/resources/fxml/DirectoryInfoView.fxml +++ b/owlplug-client/src/main/resources/fxml/DirectoryInfoView.fxml @@ -6,63 +6,83 @@ - + - + - - + - - - - - - - - - - + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +