- Fixed things GUIn the Engine class
- changed from Swing GUI to JavaFX GUI - added release 0.3
This commit is contained in:
parent
c14054b170
commit
bf24ecdab0
5 changed files with 158 additions and 171 deletions
BIN
releases/GetYourFilesOutThere 0.3.jar
Normal file
BIN
releases/GetYourFilesOutThere 0.3.jar
Normal file
Binary file not shown.
|
|
@ -12,7 +12,7 @@ public class Engine {
|
||||||
private SettingsFilter filter;
|
private SettingsFilter filter;
|
||||||
|
|
||||||
public Engine() {
|
public Engine() {
|
||||||
|
filter = new SettingsFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,7 +27,7 @@ public class Engine {
|
||||||
String parentDir = dir.getCanonicalFile().getParent();
|
String parentDir = dir.getCanonicalFile().getParent();
|
||||||
|
|
||||||
File[] files;
|
File[] files;
|
||||||
if(filter.extensions.size() == 1 && filter.extensions.get(0).equals(""))
|
if(filter.extensions.size() == 0)
|
||||||
files = dir.listFiles();
|
files = dir.listFiles();
|
||||||
else
|
else
|
||||||
files = dir.listFiles(filter);
|
files = dir.listFiles(filter);
|
||||||
|
|
@ -45,9 +45,10 @@ public class Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setExtensionSettings(String extensionString) {
|
protected void setExtensionSettings(String extensionString) {
|
||||||
String[] extensions = extensionString.split(",");
|
if(extensionString.equals("")) {
|
||||||
if (extensions.length == 0)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
String[] extensions = extensionString.split(",");
|
||||||
for(String extension:extensions) {
|
for(String extension:extensions) {
|
||||||
filter.extensions.add(extension.trim());
|
filter.extensions.add(extension.trim());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
58
src/eu/seelenoede/getyourfilesoutthere/GUI.fxml
Normal file
58
src/eu/seelenoede/getyourfilesoutthere/GUI.fxml
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.geometry.Insets?>
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.BorderPane?>
|
||||||
|
<?import javafx.scene.layout.ColumnConstraints?>
|
||||||
|
<?import javafx.scene.layout.GridPane?>
|
||||||
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
|
|
||||||
|
|
||||||
|
<BorderPane fx:controller="eu.seelenoede.getyourfilesoutthere.Main" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/8.0.171">
|
||||||
|
<center>
|
||||||
|
<Label fx:id="lblDone" text="Done" visible="false" BorderPane.alignment="CENTER">
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets bottom="5.0" />
|
||||||
|
</BorderPane.margin>
|
||||||
|
</Label>
|
||||||
|
</center>
|
||||||
|
<bottom>
|
||||||
|
<Button mnemonicParsing="false" onAction="#handleStartButtonAction" text="Start" BorderPane.alignment="CENTER" />
|
||||||
|
</bottom>
|
||||||
|
<top>
|
||||||
|
<GridPane BorderPane.alignment="CENTER">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" />
|
||||||
|
<ColumnConstraints hgrow="SOMETIMES" />
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<TextField fx:id="textField_dirs" editable="false" GridPane.columnIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets />
|
||||||
|
</GridPane.margin>
|
||||||
|
</TextField>
|
||||||
|
<Label text="Path: " />
|
||||||
|
<Button alignment="CENTER" contentDisplay="CENTER" mnemonicParsing="false" onAction="#handleBrowseButtonAction" text="Browse" GridPane.columnIndex="2">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets left="5.0" right="5.0" />
|
||||||
|
</GridPane.margin>
|
||||||
|
</Button>
|
||||||
|
<Label text="Extensions: " GridPane.rowIndex="1" />
|
||||||
|
<TextField fx:id="textField_extensions" GridPane.columnIndex="1" GridPane.rowIndex="1" text=""/>
|
||||||
|
</children>
|
||||||
|
<BorderPane.margin>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||||
|
</BorderPane.margin>
|
||||||
|
</GridPane>
|
||||||
|
</top>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||||
|
</padding>
|
||||||
|
</BorderPane>
|
||||||
95
src/eu/seelenoede/getyourfilesoutthere/Main.java
Normal file
95
src/eu/seelenoede/getyourfilesoutthere/Main.java
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
package eu.seelenoede.getyourfilesoutthere;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class Main extends Application {
|
||||||
|
|
||||||
|
private boolean alreadyRunning;
|
||||||
|
private File[] dirs;
|
||||||
|
private Engine engine;
|
||||||
|
|
||||||
|
@FXML Label lblDone;
|
||||||
|
@FXML TextField textField_dirs;
|
||||||
|
@FXML TextField textField_extensions;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void initialize() {
|
||||||
|
engine = new Engine();
|
||||||
|
alreadyRunning = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(Stage primaryStage) throws IOException {
|
||||||
|
Parent root = FXMLLoader.load(getClass().getResource("GUI.fxml"));
|
||||||
|
|
||||||
|
Scene scene = new Scene(root);
|
||||||
|
primaryStage.setTitle("Get Your Files Out There");
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
launch(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void handleBrowseButtonAction(ActionEvent event) {
|
||||||
|
selectDirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private void handleStartButtonAction(ActionEvent event) {
|
||||||
|
Thread noBlock = new Thread() {
|
||||||
|
public void run() {
|
||||||
|
engine.setExtensionSettings(textField_extensions.getText());
|
||||||
|
resetElements();
|
||||||
|
engine.extractFiles(dirs);
|
||||||
|
alreadyRunning = false;
|
||||||
|
lblDone.setVisible(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if ((!alreadyRunning) & (dirs!=null)) {
|
||||||
|
noBlock.start();
|
||||||
|
alreadyRunning = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void resetElements() {
|
||||||
|
lblDone.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectDirs() {
|
||||||
|
if(alreadyRunning){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JFileChooser chooser = new JFileChooser();
|
||||||
|
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||||
|
chooser.setMultiSelectionEnabled(true);
|
||||||
|
int val = chooser.showOpenDialog(null);
|
||||||
|
|
||||||
|
if (val == JFileChooser.APPROVE_OPTION) {
|
||||||
|
dirs = chooser.getSelectedFiles();
|
||||||
|
String selectedDirs = "";
|
||||||
|
for (File dir:dirs)
|
||||||
|
{
|
||||||
|
selectedDirs = selectedDirs + "\"" + dir.getAbsolutePath() + "\"; ";
|
||||||
|
}
|
||||||
|
textField_dirs.setText(selectedDirs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
package eu.seelenoede.getyourfilesoutthere;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.Color;
|
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
|
|
||||||
public class MainForm {
|
|
||||||
|
|
||||||
private JFrame frmGetYourFiles;
|
|
||||||
private JTextField textField;
|
|
||||||
private JTextField textField_extensions;
|
|
||||||
private JButton btnBrowse;
|
|
||||||
private JButton btnStart;
|
|
||||||
private JLabel lblDone;
|
|
||||||
|
|
||||||
private boolean alreadyRunning;
|
|
||||||
private File[] dirs;
|
|
||||||
private Engine engine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Launch the application.
|
|
||||||
*/
|
|
||||||
public static void main(String[] args) {
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
MainForm window = new MainForm();
|
|
||||||
window.frmGetYourFiles.setVisible(true);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the application.
|
|
||||||
*/
|
|
||||||
public MainForm() {
|
|
||||||
engine = new Engine();
|
|
||||||
initialize();
|
|
||||||
initActions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the contents of the frame.
|
|
||||||
*/
|
|
||||||
private void initialize() {
|
|
||||||
alreadyRunning = false;
|
|
||||||
frmGetYourFiles = new JFrame("Get Your Files Out There");
|
|
||||||
frmGetYourFiles.setTitle("Get Your Files Out There");
|
|
||||||
frmGetYourFiles.getContentPane().setBackground(Color.LIGHT_GRAY);
|
|
||||||
frmGetYourFiles.setResizable(false);
|
|
||||||
frmGetYourFiles.setBackground(Color.WHITE);
|
|
||||||
frmGetYourFiles.setBounds(100, 100, 489, 150);
|
|
||||||
frmGetYourFiles.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frmGetYourFiles.setLocationRelativeTo(null);
|
|
||||||
frmGetYourFiles.getContentPane().setLayout(new BorderLayout(0, 0));
|
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
frmGetYourFiles.getContentPane().add(panel, BorderLayout.NORTH);
|
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
|
||||||
|
|
||||||
JPanel panel_path = new JPanel();
|
|
||||||
panel.add(panel_path);
|
|
||||||
panel_path.setBackground(Color.WHITE);
|
|
||||||
|
|
||||||
JLabel lblPath = new JLabel("Path: ");
|
|
||||||
panel_path.add(lblPath);
|
|
||||||
|
|
||||||
textField = new JTextField();
|
|
||||||
textField.setEditable(false);
|
|
||||||
panel_path.add(textField);
|
|
||||||
textField.setColumns(30);
|
|
||||||
|
|
||||||
btnBrowse = new JButton("Browse");
|
|
||||||
btnBrowse.setBackground(Color.LIGHT_GRAY);
|
|
||||||
panel_path.add(btnBrowse);
|
|
||||||
|
|
||||||
JPanel panel_settings = new JPanel();
|
|
||||||
panel_settings.setBackground(Color.WHITE);
|
|
||||||
panel.add(panel_settings);
|
|
||||||
panel_settings.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
|
||||||
|
|
||||||
JLabel lblSettings = new JLabel("Extensions: ");
|
|
||||||
panel_settings.add(lblSettings);
|
|
||||||
|
|
||||||
textField_extensions = new JTextField();
|
|
||||||
panel_settings.add(textField_extensions);
|
|
||||||
textField_extensions.setColumns(35);
|
|
||||||
|
|
||||||
btnStart = new JButton("Start");
|
|
||||||
frmGetYourFiles.getContentPane().add(btnStart, BorderLayout.SOUTH);
|
|
||||||
btnStart.setSelected(true);
|
|
||||||
btnStart.setBackground(Color.LIGHT_GRAY);
|
|
||||||
|
|
||||||
frmGetYourFiles.getRootPane().setDefaultButton(btnStart);
|
|
||||||
|
|
||||||
JPanel panel_progress = new JPanel();
|
|
||||||
panel_progress.setBackground(Color.WHITE);
|
|
||||||
frmGetYourFiles.getContentPane().add(panel_progress, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
lblDone = new JLabel("");
|
|
||||||
panel_progress.add(lblDone);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initActions() {
|
|
||||||
btnBrowse.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if(alreadyRunning){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JFileChooser chooser = new JFileChooser();
|
|
||||||
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
||||||
chooser.setMultiSelectionEnabled(true);
|
|
||||||
int val = chooser.showOpenDialog(null);
|
|
||||||
|
|
||||||
if (val == JFileChooser.APPROVE_OPTION) {
|
|
||||||
dirs = chooser.getSelectedFiles();
|
|
||||||
String selectedDirs = "";
|
|
||||||
for (File dir:dirs)
|
|
||||||
{
|
|
||||||
selectedDirs = selectedDirs + "\"" + dir.getAbsolutePath() + "\"; ";
|
|
||||||
}
|
|
||||||
textField.setText(selectedDirs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
btnStart.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
|
||||||
Thread noBlock = new Thread() {
|
|
||||||
public void run() {
|
|
||||||
engine.setExtensionSettings(textField_extensions.getText());
|
|
||||||
resetElements();
|
|
||||||
engine.extractFiles(dirs);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if ((!alreadyRunning) & (dirs!=null)) {
|
|
||||||
noBlock.start();
|
|
||||||
alreadyRunning = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetElements() {
|
|
||||||
lblDone.setText("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue