forked from MasterFlomaster1/JFXCrypto
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileHashPageController.java
More file actions
93 lines (74 loc) · 2.27 KB
/
Copy pathFileHashPageController.java
File metadata and controls
93 lines (74 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package GUI.Controllers;
import GUI.Main.GUI;
import Hash.CurrentHash;
import Utils.PathCutter;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.TextArea;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.DragEvent;
import javafx.scene.input.TransferMode;
import javafx.scene.text.Text;
import javafx.stage.FileChooser;
import java.io.File;
import java.util.List;
public class FileHashPageController {
public ImageView menuImage;
@FXML
public Button browseInFile;
@FXML
public Text fileInPath;
@FXML
public Text dragNDropText;
@FXML
public TextArea hashSumText;
private boolean fileInReady = false;
private File in;
public void browseInButtonAction() {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Select file");
in = fileChooser.showOpenDialog(browseInFile.getScene().getWindow());
//debug here
if (in==null) {
fileInReady = false;
return;
}
hideDragDropText();
fileInPath.setText(PathCutter.cutPath(in.getPath()));
fileInReady = true;
}
public void handleDragOver(DragEvent event) {
if (event.getDragboard().hasFiles()) {
event.acceptTransferModes(TransferMode.ANY);
}
}
public void handleDragDropped(DragEvent event) {
List<File> files = event.getDragboard().getFiles();
in = files.get(0);
hideDragDropText();
fileInPath.setText(PathCutter.cutPath(in.getPath()));
fileInReady = true;
}
public void hashButtonAction() {
if (fileInReady) {
hashSumText.setText(CurrentHash.fileHashSum(in));
}
}
private void hideDragDropText() {
dragNDropText.setVisible(false);
}
private void enableDragDropText() {
dragNDropText.setDisable(true);
}
public void menuButtonPressed() {
menuImage.setImage(new javafx.scene.image.Image("/menu2.png"));
GUI.menuButtonPressed();
}
public void menuButtonRelease() {
menuImage.setImage(new javafx.scene.image.Image("/menu1.png"));
}
public void mouseEntered() {
menuImage.setImage(new Image("/menu2.png"));
}
}