+ add proper directory selection
+ add ui elements:
  - tabs
  - scroll bar
  - grids where required
master
Ivan Olexyn 6 years ago
parent 2192703ddc
commit b1f7b33442

@ -2,10 +2,12 @@ package app;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.text.Text;
import java.awt.event.ActionEvent;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
@ -13,13 +15,14 @@ import java.nio.file.Paths;
import java.util.Map;
import app.Artifacts.MFile;
import javafx.stage.DirectoryChooser;
import javafx.stage.Window;
/***
* Controller class for JavaFX. Contains the application logic.
*/
public class Controller {
Map<Integer, MFile> doubles;
@ -45,7 +48,28 @@ public class Controller {
protected Text doubleNr;
@FXML
protected TextField dir;
protected TextField directoryField;
@FXML
protected void openDir(){
Window stage = loadDirState.getScene().getWindow();
final DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setTitle("Select Directory.");
directoryChooser.setInitialDirectory(new File(System.getProperty("user.home")));
TextArea textArea = new TextArea();
textArea.setMinHeight(70);
File dir = directoryChooser.showDialog(stage);
if (dir != null){
directoryField.setText(dir.getAbsolutePath());
}else{
//textArea.setText(null);
}
}
@FXML
@ -64,14 +88,14 @@ public class Controller {
doubleNr.setText("Number of Duplicates:");
Path path = Paths.get(dir.getText());
Path path = Paths.get(directoryField.getText());
if (!Files.isDirectory(path)) {
loadDirState.setText("ERROR.");
} else {
Map<Integer, File> pool = new Routines().loadPool(dir.getText(), "file");
Map<Integer, File> pool = new Routines().loadPool(directoryField.getText(), "file");
new Write().textPool("pool", pool);
loadDirState.setText("OK.");
fileNr.setText("Number of Files: " + pool.size());

@ -4,16 +4,22 @@ import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;
import java.io.File;
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("layout.fxml"));
Scene scene = new Scene(root, 300, 500);
Scene scene = new Scene(root, 430, 500);
primaryStage.setTitle("mucc");

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.*?>
@ -8,114 +8,133 @@
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<GridPane fx:controller="app.Controller"
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10">
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.Controller">
<children>
<ScrollPane prefHeight="442.0" prefWidth="439.0" AnchorPane.bottomAnchor="-342.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="-339.0" AnchorPane.topAnchor="0.0">
<content>
<GridPane fx:id="outerGridPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<TabPane fx:id="tabPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" GridPane.columnSpan="2" GridPane.hgrow="ALWAYS" GridPane.rowIndex="1" GridPane.vgrow="ALWAYS">
<tabs>
<Tab text="Scan Disk Image">
<content>
<GridPane>
<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>
<children>
<Label text="Not Implemented Yet." GridPane.columnSpan="2" />
</children>
</GridPane>
</content>
</Tab>
<Tab text="Retreive Sub-Files">
<content>
<GridPane>
<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>
<children>
<Label text="Not Implemented Yet." GridPane.columnSpan="2" />
</children>
</GridPane>
</content>
</Tab>
<Tab text="Delete Duplicates">
<content>
<GridPane alignment="center" hgap="10" vgap="10">
<padding>
<Insets top="25" right="25" bottom="10" left="25"/>
<Insets bottom="10" left="25" right="25" top="25" />
</padding>
<children>
<Text
text="Task"
GridPane.rowIndex="0"
GridPane.columnIndex="0"
/>
<Text text="Task" GridPane.rowIndex="1" />
<Text
text="State"
GridPane.rowIndex="0"
GridPane.columnIndex="1"
/>
<Text text="State" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Text
text="Load Directory."
GridPane.rowIndex="1"
GridPane.columnIndex="0"
/>
<Text text="Load Directory." GridPane.rowIndex="2" />
<Text fx:id="loadDirState"
GridPane.rowIndex="1"
GridPane.columnIndex="1"
/>
<Text fx:id="loadDirState" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Text
text="Calculate Md5."
GridPane.rowIndex="2"
GridPane.columnIndex="0"
/>
<Text text="Calculate Md5." GridPane.rowIndex="3" />
<Text fx:id="calcMd5State"
GridPane.rowIndex="2"
GridPane.columnIndex="1"
/>
<Text fx:id="calcMd5State" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Text
text="Sort Files."
GridPane.rowIndex="3"
GridPane.columnIndex="0"
/>
<Text text="Sort Files." GridPane.rowIndex="4" />
<Text fx:id="sortFileState"
GridPane.rowIndex="3"
GridPane.columnIndex="1"
/>
<Text fx:id="sortFileState" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Text
text="Find Duplicates."
GridPane.rowIndex="4"
GridPane.columnIndex="0"
/>
<Text text="Find Duplicates." GridPane.rowIndex="5" />
<Text fx:id="findDuplicateState"
GridPane.rowIndex="4"
GridPane.columnIndex="1"
/>
<Text fx:id="findDuplicateState" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Text
text="Delete Duplicates."
GridPane.rowIndex="5"
GridPane.columnIndex="0"
/>
<Text text="Delete Duplicates." GridPane.rowIndex="6" />
<Text fx:id="delDuplicateState"
GridPane.rowIndex="5"
GridPane.columnIndex="1"
/>
<Text fx:id="delDuplicateState" GridPane.columnIndex="1" GridPane.rowIndex="6" />
<Button onAction="#loadDir" text="Load" GridPane.columnIndex="1" GridPane.rowIndex="8" />
<TextField fx:id="dir"
text="Select Directory."
GridPane.rowIndex="6"
GridPane.columnIndex="0"
/>
<Text fx:id="fileNr" text="Number of Files:" GridPane.rowIndex="9" />
<Text fx:id="doubleNr" text="Number of Duplicates:" GridPane.rowIndex="10" />
<Button text="Load"
GridPane.rowIndex="6"
GridPane.columnIndex="1"
onAction="#loadDir"/>
<Button onAction="#deleteDuplicates" text="Delete" GridPane.columnIndex="1" GridPane.rowIndex="10" />
</children>
<columnConstraints>
<ColumnConstraints />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints />
<RowConstraints minHeight="10.0" prefHeight="30.0" />
<RowConstraints />
<RowConstraints />
<RowConstraints />
</rowConstraints>
<Text fx:id="fileNr"
text="Number of Files:"
GridPane.rowIndex="7"
GridPane.columnIndex="0"
/>
<Text fx:id="doubleNr"
text="Number of Duplicates:"
GridPane.rowIndex="8"
GridPane.columnIndex="0"
/>
<Button text="Delete"
GridPane.rowIndex="8"
GridPane.columnIndex="1"
onAction="#deleteDuplicates"/>
</GridPane>
</content>
</Tab>
</tabs>
</TabPane>
<TextField fx:id="directoryField" text="Select Directory." />
<Button onAction="#openDir" text="Open..." GridPane.columnIndex="1" />
</children>
</GridPane>
</content>
</ScrollPane>
</children>
</AnchorPane>

Loading…
Cancel
Save