Add drag-n-drop for Split'n'merge tab. Fix minor issues.
This commit is contained in:
parent
8eb05bb1b5
commit
2e0d583963
5 changed files with 60 additions and 31 deletions
|
@ -292,7 +292,7 @@ public class FrontController implements Initializable {
|
|||
* */
|
||||
@FXML
|
||||
private void handleDragOver(DragEvent event){
|
||||
if (event.getDragboard().hasFiles())
|
||||
if (event.getDragboard().hasFiles() && ! MediatorControl.getInstance().getTransferActive())
|
||||
event.acceptTransferModes(TransferMode.ANY);
|
||||
event.consume();
|
||||
}
|
||||
|
@ -301,10 +301,6 @@ public class FrontController implements Initializable {
|
|||
* */
|
||||
@FXML
|
||||
private void handleDrop(DragEvent event){
|
||||
if (MediatorControl.getInstance().getTransferActive()) {
|
||||
event.setDropCompleted(true);
|
||||
return;
|
||||
}
|
||||
List<File> filesDropped = event.getDragboard().getFiles();
|
||||
|
||||
if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTfXciNszXczSupport())
|
||||
|
|
|
@ -231,7 +231,10 @@ public class RcmController implements Initializable {
|
|||
);
|
||||
|
||||
File payloadFile = fileChooser.showOpenDialog(payloadFPathLbl1.getScene().getWindow());
|
||||
if (payloadFile != null) {
|
||||
|
||||
if (payloadFile == null)
|
||||
return;
|
||||
|
||||
final String fullFileName = payloadFile.getAbsolutePath();
|
||||
final Node btn = (Node)event.getSource();
|
||||
|
||||
|
@ -252,7 +255,6 @@ public class RcmController implements Initializable {
|
|||
setPayloadFile(5, fullFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@FXML
|
||||
private void bntResetPayloader(ActionEvent event){
|
||||
final Node btn = (Node)event.getSource();
|
||||
|
|
|
@ -3,7 +3,10 @@ package nsusbloader.Controllers;
|
|||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.TransferMode;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
|
@ -101,7 +104,6 @@ public class SplitMergeController implements Initializable {
|
|||
if (fileFile == null)
|
||||
return;
|
||||
fileFolderActualPathLbl.setText(fileFile.getAbsolutePath());
|
||||
convertBtn.setDisable(false);
|
||||
}
|
||||
else{
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
|
@ -120,14 +122,14 @@ public class SplitMergeController implements Initializable {
|
|||
if (folderFile == null)
|
||||
return;
|
||||
fileFolderActualPathLbl.setText(folderFile.getAbsolutePath());
|
||||
convertBtn.setDisable(false);
|
||||
}
|
||||
convertBtn.setDisable(false);
|
||||
});
|
||||
|
||||
convertBtn.setOnAction(actionEvent -> setConvertBtnAction());
|
||||
}
|
||||
|
||||
public void notifySmThreadStarted(boolean isStart, EModule type){
|
||||
public void notifySmThreadStarted(boolean isStart, EModule type){ // todo: refactor: remove everything, place to separate container and just disable.
|
||||
if (! type.equals(EModule.SPLIT_MERGE_TOOL)){
|
||||
smToolPane.setDisable(isStart);
|
||||
return;
|
||||
|
@ -176,7 +178,10 @@ public class SplitMergeController implements Initializable {
|
|||
private void setConvertBtnAction(){
|
||||
statusLbl.setText("");
|
||||
if (MediatorControl.getInstance().getTransferActive()) {
|
||||
ServiceWindow.getErrorNotification(resourceBundle.getString("windowTitleError"), resourceBundle.getString("windowBodyPleaseFinishTransfersFirst"));
|
||||
ServiceWindow.getErrorNotification(
|
||||
resourceBundle.getString("windowTitleError"),
|
||||
resourceBundle.getString("windowBodyPleaseFinishTransfersFirst")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -195,6 +200,32 @@ public class SplitMergeController implements Initializable {
|
|||
smThread.setDaemon(true);
|
||||
smThread.start();
|
||||
}
|
||||
/**
|
||||
* Drag-n-drop support (dragOver consumer)
|
||||
* */
|
||||
@FXML
|
||||
private void handleDragOver(DragEvent event){
|
||||
if (event.getDragboard().hasFiles() && ! MediatorControl.getInstance().getTransferActive())
|
||||
event.acceptTransferModes(TransferMode.ANY);
|
||||
event.consume();
|
||||
}
|
||||
/**
|
||||
* Drag-n-drop support (drop consumer)
|
||||
* */
|
||||
@FXML
|
||||
private void handleDrop(DragEvent event) {
|
||||
Node sourceNode = (Node) event.getSource();
|
||||
File fileDrpd = event.getDragboard().getFiles().get(0);
|
||||
|
||||
if (fileDrpd.isDirectory())
|
||||
mergeRad.fire();
|
||||
else
|
||||
splitRad.fire();
|
||||
fileFolderActualPathLbl.setText(fileDrpd.getAbsolutePath());
|
||||
convertBtn.setDisable(false);
|
||||
event.setDropCompleted(true);
|
||||
event.consume();
|
||||
}
|
||||
/**
|
||||
* Save application settings on exit
|
||||
* */
|
||||
|
|
|
@ -183,7 +183,7 @@ class MergeTask extends Task<Boolean> {
|
|||
|
||||
File[] chunkFiles = folder.listFiles((file, s) -> s.matches("^[0-9][0-9]$"));
|
||||
|
||||
if (chunkFiles == null){
|
||||
if (chunkFiles == null || chunkFiles.length == 0){
|
||||
logPrinter.print("Selected folder doesn't have any chunks. Nothing to do here.", EMsgType.FAIL);
|
||||
logPrinter.close();
|
||||
return false;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox fx:id="smToolPane" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.SplitMergeController">
|
||||
<VBox fx:id="smToolPane" onDragDropped="#handleDrop" onDragOver="#handleDragOver" spacing="20.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.SplitMergeController">
|
||||
<VBox spacing="15.0">
|
||||
<children>
|
||||
<Pane minHeight="-Infinity" prefHeight="10.0" style="-fx-background-color: linear-gradient(from 41px 34px to 50px 50px, reflect, #00c8fc 40%, transparent 45%);" />
|
||||
|
|
Loading…
Reference in a new issue