+ 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.concurrent.Task;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.text.Text; import javafx.scene.text.Text;
import java.awt.event.ActionEvent;
import java.io.File; import java.io.File;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
@ -13,13 +15,14 @@ import java.nio.file.Paths;
import java.util.Map; import java.util.Map;
import app.Artifacts.MFile; import app.Artifacts.MFile;
import javafx.stage.DirectoryChooser;
import javafx.stage.Window;
/*** /***
* Controller class for JavaFX. Contains the application logic. * Controller class for JavaFX. Contains the application logic.
*/ */
public class Controller { public class Controller {
Map<Integer, MFile> doubles; Map<Integer, MFile> doubles;
@ -45,7 +48,28 @@ public class Controller {
protected Text doubleNr; protected Text doubleNr;
@FXML @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 @FXML
@ -64,14 +88,14 @@ public class Controller {
doubleNr.setText("Number of Duplicates:"); doubleNr.setText("Number of Duplicates:");
Path path = Paths.get(dir.getText()); Path path = Paths.get(directoryField.getText());
if (!Files.isDirectory(path)) { if (!Files.isDirectory(path)) {
loadDirState.setText("ERROR."); loadDirState.setText("ERROR.");
} else { } 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); new Write().textPool("pool", pool);
loadDirState.setText("OK."); loadDirState.setText("OK.");
fileNr.setText("Number of Files: " + pool.size()); fileNr.setText("Number of Files: " + pool.size());

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.geometry.*?> <?import javafx.geometry.*?>
@ -8,114 +8,133 @@
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<AnchorPane xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.Controller">
<GridPane fx:controller="app.Controller" <children>
xmlns:fx="http://javafx.com/fxml" alignment="center" hgap="10" vgap="10"> <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> <padding>
<Insets top="25" right="25" bottom="10" left="25"/> <Insets bottom="10" left="25" right="25" top="25" />
</padding> </padding>
<children>
<Text <Text text="Task" GridPane.rowIndex="1" />
text="Task"
GridPane.rowIndex="0"
GridPane.columnIndex="0"
/>
<Text <Text text="State" GridPane.columnIndex="1" GridPane.rowIndex="1" />
text="State"
GridPane.rowIndex="0"
GridPane.columnIndex="1"
/>
<Text <Text text="Load Directory." GridPane.rowIndex="2" />
text="Load Directory."
GridPane.rowIndex="1"
GridPane.columnIndex="0"
/>
<Text fx:id="loadDirState" <Text fx:id="loadDirState" GridPane.columnIndex="1" GridPane.rowIndex="2" />
GridPane.rowIndex="1"
GridPane.columnIndex="1"
/>
<Text <Text text="Calculate Md5." GridPane.rowIndex="3" />
text="Calculate Md5."
GridPane.rowIndex="2"
GridPane.columnIndex="0"
/>
<Text fx:id="calcMd5State" <Text fx:id="calcMd5State" GridPane.columnIndex="1" GridPane.rowIndex="3" />
GridPane.rowIndex="2"
GridPane.columnIndex="1"
/>
<Text <Text text="Sort Files." GridPane.rowIndex="4" />
text="Sort Files."
GridPane.rowIndex="3"
GridPane.columnIndex="0"
/>
<Text fx:id="sortFileState" <Text fx:id="sortFileState" GridPane.columnIndex="1" GridPane.rowIndex="4" />
GridPane.rowIndex="3"
GridPane.columnIndex="1"
/>
<Text <Text text="Find Duplicates." GridPane.rowIndex="5" />
text="Find Duplicates."
GridPane.rowIndex="4"
GridPane.columnIndex="0"
/>
<Text fx:id="findDuplicateState" <Text fx:id="findDuplicateState" GridPane.columnIndex="1" GridPane.rowIndex="5" />
GridPane.rowIndex="4"
GridPane.columnIndex="1"
/>
<Text <Text text="Delete Duplicates." GridPane.rowIndex="6" />
text="Delete Duplicates."
GridPane.rowIndex="5"
GridPane.columnIndex="0"
/>
<Text fx:id="delDuplicateState" <Text fx:id="delDuplicateState" GridPane.columnIndex="1" GridPane.rowIndex="6" />
GridPane.rowIndex="5"
GridPane.columnIndex="1"
/>
<Button onAction="#loadDir" text="Load" GridPane.columnIndex="1" GridPane.rowIndex="8" />
<TextField fx:id="dir" <Text fx:id="fileNr" text="Number of Files:" GridPane.rowIndex="9" />
text="Select Directory."
GridPane.rowIndex="6"
GridPane.columnIndex="0"
/>
<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" </GridPane>
text="Number of Duplicates:" </content>
GridPane.rowIndex="8" </Tab>
GridPane.columnIndex="0" </tabs>
/> </TabPane>
<Button text="Delete"
GridPane.rowIndex="8"
GridPane.columnIndex="1"
onAction="#deleteDuplicates"/>
<TextField fx:id="directoryField" text="Select Directory." />
<Button onAction="#openDir" text="Open..." GridPane.columnIndex="1" />
</children>
</GridPane> </GridPane>
</content>
</ScrollPane>
</children>
</AnchorPane>

Loading…
Cancel
Save