Copy UI classes from old project.

pull/1/head
Ivan Olexyn 5 years ago
parent e9e523f1a5
commit 61b96bff67

@ -0,0 +1,201 @@
package com.olexyn.ensync.ui;
import javafx.concurrent.Task;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.DirectoryChooser;
import javafx.stage.Window;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
/***
* Controller class for JavaFX. Contains the application logic.
*/
public class Controller {
// Delete Duplicates
// ----------------------------------------------------------------------------------------------------------------
@FXML
protected Text loadDirState;
@FXML
protected Text calcMd5State;
@FXML
protected Text sortFileState;
@FXML
protected Text findDuplicateState;
@FXML
protected Text delDuplicateState;
@FXML
protected Text fileNrCount;
@FXML
protected Text doubleNrCount;
@FXML
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")));
File dir = directoryChooser.showDialog(stage);
if (dir != null) {
directoryField.setText(dir.getAbsolutePath());
}
}
@FXML
protected void loadDuplicateDir() {
Task<Void> loadDirTask = new Task<Void>() {
@Override
public Void call() {
loadDirState.setText("__");
calcMd5State.setText("__");
sortFileState.setText("__");
findDuplicateState.setText("__");
delDuplicateState.setText("__");
fileNrCount.setText("__");
doubleNrCount.setText("__");
Path path = Paths.get(directoryField.getText());
if (!Files.isDirectory(path)) {
loadDirState.setFill(Color.RED);
loadDirState.setText("ERROR.");
} else {
loadDirState.setFill(Color.GREEN);
loadDirState.setText("OK.");
calcMd5State.setFill(Color.GREEN);
calcMd5State.setText("OK.");
sortFileState.setFill(Color.GREEN);
sortFileState.setText("OK.");
findDuplicateState.setFill(Color.GREEN);
findDuplicateState.setText("OK.");
}
return null;
}
};
new Thread(loadDirTask).start();
}
@FXML
protected void deleteDuplicates() {
Task<Void> delDuplicateTask = new Task<Void>() {
@Override
public Void call() {
delDuplicateState.setFill(Color.GREEN);
delDuplicateState.setText("OK.");
return null;
}
};
new Thread(delDuplicateTask).start();
}
@FXML
protected void loadBaseFiles() {
}
// Retrieve Sub-Files
// ----------------------------------------------------------------------------------------------------------------
@FXML
protected Text loadPdfState;
@FXML
protected Text splitPdfState;
@FXML
protected Text baseFileCount;
@FXML
protected Text subFileCount;
@FXML
protected void loadBaseDir() {
Task<Void> loadDirTask = new Task<Void>() {
@Override
public Void call() {
loadPdfState.setText("__");
splitPdfState.setText("__");
baseFileCount.setText("__");
subFileCount.setText("__");
Path path = Paths.get(directoryField.getText());
if (!Files.isDirectory(path)) {
loadPdfState.setFill(Color.RED);
loadPdfState.setText("ERROR.");
} else {
loadPdfState.setFill(Color.GREEN);
loadPdfState.setText("OK.");
}
return null;
}
};
new Thread(loadDirTask).start();
}
@FXML
protected void splitPdf() {
Task<Void> splitPdfTask = new Task<Void>() {
@Override
public Void call() {
splitPdfState.setFill(Color.GREEN);
splitPdfState.setText("OK.");
return null;
}
};
new Thread(splitPdfTask).start();
}
}

@ -0,0 +1,32 @@
package com.olexyn.ensync.ui;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class UI extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("layout.fxml"));
Scene scene = new Scene(root, 430, 500);
primaryStage.setTitle("mucc");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.text.*?>
<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 hgrow="ALWAYS" />
<ColumnConstraints />
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="40.0" minHeight="40.0" prefHeight="40.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 hgap="10.0" vgap="10.0">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
<ColumnConstraints hgrow="NEVER" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="ALWAYS" />
</rowConstraints>
<children>
<Label text="Not Implemented Yet." GridPane.columnSpan="2" GridPane.rowIndex="1" />
</children>
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0" />
</padding>
</GridPane>
</content>
</Tab>
<Tab text="Retreive Sub-Files">
<content>
<GridPane hgap="10.0" vgap="10.0">
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" />
<ColumnConstraints hgrow="NEVER" maxWidth="80.0" minWidth="80.0" prefWidth="80.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints maxHeight="20.0" minHeight="20.0" prefHeight="20.0" vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints maxHeight="20.0" minHeight="20.0" prefHeight="20.0" vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
</rowConstraints>
<children>
<Text text="Load PDF Files." GridPane.columnIndex="0" GridPane.rowIndex="1" />
<Text fx:id="loadPdfState" text="__" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Text text="Split PDF Files." GridPane.columnIndex="0" GridPane.rowIndex="2" />
<Text fx:id="splitPdfState" text="__" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Text text="Number fo Files:" GridPane.columnIndex="0" GridPane.rowIndex="4" />
<Text fx:id="baseFileCount" text="__" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Text text="Number of PDF Sub-Files:" GridPane.columnIndex="0" GridPane.rowIndex="5" />
<Text fx:id="subFileCount" text="__" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Button onAction="#loadBaseDir" text="Load" GridPane.columnIndex="0" GridPane.halignment="RIGHT" GridPane.rowIndex="7" />
<Button onAction="#splitPdf" text="Split" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<Text text="Task">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Text>
<Text text="State" GridPane.columnIndex="1">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Text>
</children>
<padding>
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
</padding>
</GridPane>
</content>
</Tab>
<Tab text="Delete Duplicates">
<content>
<GridPane alignment="center" hgap="10" vgap="10">
<padding>
<Insets bottom="25.0" left="25.0" right="25.0" top="25.0" />
</padding>
<children>
<Text text="Task">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Text>
<Text text="State" GridPane.columnIndex="1">
<font>
<Font name="System Bold" size="13.0" />
</font>
</Text>
<Text text="Load Directory." GridPane.rowIndex="1" />
<Text fx:id="loadDirState" text="__" GridPane.columnIndex="1" GridPane.rowIndex="1" />
<Text text="Calculate Md5." GridPane.rowIndex="2" />
<Text fx:id="calcMd5State" text="__" GridPane.columnIndex="1" GridPane.rowIndex="2" />
<Text text="Sort Files." GridPane.rowIndex="3" />
<Text fx:id="sortFileState" text="__" GridPane.columnIndex="1" GridPane.rowIndex="3" />
<Text text="Find Duplicates." GridPane.rowIndex="4" />
<Text fx:id="findDuplicateState" text="__" GridPane.columnIndex="1" GridPane.rowIndex="4" />
<Text text="Delete Duplicates." GridPane.rowIndex="5" />
<Text fx:id="delDuplicateState" text="__" GridPane.columnIndex="1" GridPane.rowIndex="5" />
<Button onAction="#loadDuplicateDir" text="Load" GridPane.halignment="RIGHT" GridPane.rowIndex="10" />
<Text text="Number of Files:" GridPane.rowIndex="7" />
<Text text="Number of Duplicates:" GridPane.rowIndex="8" />
<Button onAction="#deleteDuplicates" text="Delete" GridPane.columnIndex="1" GridPane.rowIndex="10" />
<Text fx:id="fileNrCount" strokeType="OUTSIDE" strokeWidth="0.0" text="__" GridPane.columnIndex="1" GridPane.rowIndex="7" />
<Text fx:id="doubleNrCount" strokeType="OUTSIDE" strokeWidth="0.0" text="__" GridPane.columnIndex="1" GridPane.rowIndex="8" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="ALWAYS" />
<ColumnConstraints hgrow="NEVER" maxWidth="80.0" minWidth="80.0" prefWidth="80.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints minHeight="20.0" prefHeight="20.0" vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints minHeight="20.0" prefHeight="20.0" vgrow="NEVER" />
<RowConstraints vgrow="NEVER" />
<RowConstraints vgrow="ALWAYS" />
</rowConstraints>
</GridPane>
</content>
</Tab>
</tabs>
</TabPane>
<TextField fx:id="directoryField" text="Select Directory.">
<GridPane.margin>
<Insets bottom="20.0" left="20.0" top="20.0" />
</GridPane.margin>
</TextField>
<Button onAction="#openDir" text="Open..." GridPane.columnIndex="1">
<GridPane.margin>
<Insets right="20.0" />
</GridPane.margin>
</Button>
</children>
</GridPane>
</content>
</ScrollPane>
</children>
</AnchorPane>
Loading…
Cancel
Save