Adding files logic for the button has been changed to "add whatever you want to the table without cleanup"

master
Dmitry Isaenko 2019-03-16 02:43:14 +03:00
parent 4da62b4c07
commit d41401c85e
3 changed files with 34 additions and 54 deletions

View File

@ -69,11 +69,11 @@ If you use different MacOS (not Mojave) - check release section for another JAR
Table 'Status' = 'Uploaded' does not means that file installed. It means that it has been sent to NS without any issues! That's what this app about.
Handling successful/failed installation is a purpose of the other side application (TinFoil/GoldLeaf). (And they don't provide any feedback interfaces so I can't detect success/failure.)
## Translators! Traducteurs! Traductores! Übersetzer! Թարգմանիչներ!
## Translators! Traductores! Übersetzer! Թարգմանիչներ!
If you want to see this app translated to your language, go grab [this file](https://github.com/developersu/ns-usbloader/blob/master/src/main/resources/locale.properties) and translate it.
Upload somewhere (pastebin? google drive? whatever else). [Create new issue](https://github.com/developersu/ns-usbloader/issues) and post a link. I'll grab it and add.
### Thanks for great work done by to our translater~~s team~~!
### Thanks for great work done by our translater~~s team~~!
Français by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice)

View File

@ -128,10 +128,6 @@ public class NSLMainController implements Initializable {
uploadStopBtn.setDisable(false);
previouslyOpenedPath = filesList.get(0).getParent();
}
else{
tableFilesListController.setFiles(null);
uploadStopBtn.setDisable(true);
}
}
/**
* It's button listener when no transmission executes
@ -194,8 +190,8 @@ public class NSLMainController implements Initializable {
/**
* Crunch. Now you see that I'm not a programmer.. This function called from NSTableViewController
* */
public void disableUploadStopBtn(){
uploadStopBtn.setDisable(true);
public void disableUploadStopBtn(boolean disable){
uploadStopBtn.setDisable(disable);
}
/**
* Drag-n-drop support (dragOver consumer)
@ -210,6 +206,10 @@ public class NSLMainController implements Initializable {
* */
@FXML
private void handleDrop(DragEvent event){
if (MediatorControl.getInstance().getTransferActive()) {
event.setDropCompleted(true);
return;
}
List<File> filesDropped = new ArrayList<>();
try {
for (File fileOrDir : event.getDragboard().getFiles()) {
@ -224,20 +224,8 @@ public class NSLMainController implements Initializable {
catch (SecurityException se){
se.printStackTrace();
}
if (!filesDropped.isEmpty()) {
List<File> filesAlreadyInTable;
if ((filesAlreadyInTable = tableFilesListController.getFiles()) != null) {
filesDropped.removeAll(filesAlreadyInTable); // Get what we already have and add new file(s)
if (!filesDropped.isEmpty()) {
filesDropped.addAll(filesAlreadyInTable);
tableFilesListController.setFiles(filesDropped);
}
}
else {
tableFilesListController.setFiles(filesDropped);
uploadStopBtn.setDisable(false);
}
}
if (!filesDropped.isEmpty())
tableFilesListController.setFiles(filesDropped);
event.setDropCompleted(true);
}

View File

@ -46,10 +46,10 @@ public class NSTableViewController implements Initializable {
@Override
public void handle(KeyEvent keyEvent) {
if (!rowsObsLst.isEmpty()) {
if (keyEvent.getCode() == KeyCode.DELETE) {
if (keyEvent.getCode() == KeyCode.DELETE && !MediatorControl.getInstance().getTransferActive()) {
rowsObsLst.removeAll(table.getSelectionModel().getSelectedItems());
if (rowsObsLst.isEmpty())
MediatorControl.getInstance().getContoller().disableUploadStopBtn(); // TODO: change to something better
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true); // TODO: change to something better
table.refresh();
} else if (keyEvent.getCode() == KeyCode.SPACE) {
for (NSLRowModel item : table.getSelectionModel().getSelectedItems()) {
@ -132,7 +132,7 @@ public class NSTableViewController implements Initializable {
public void handle(ActionEvent actionEvent) {
rowsObsLst.remove(row.getItem());
if (rowsObsLst.isEmpty())
MediatorControl.getInstance().getContoller().disableUploadStopBtn(); // TODO: change to something better
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true); // TODO: change to something better
table.refresh();
}
});
@ -141,7 +141,7 @@ public class NSTableViewController implements Initializable {
@Override
public void handle(ActionEvent actionEvent) {
rowsObsLst.clear();
MediatorControl.getInstance().getContoller().disableUploadStopBtn(); // TODO: change to something better
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true); // TODO: change to something better
table.refresh();
}
});
@ -188,37 +188,29 @@ public class NSTableViewController implements Initializable {
/**
* Add files when user selected them
* */
public void setFiles(List<File> files){
rowsObsLst.clear(); // TODO: consider table refresh
if (files == null)
return;
if (protocol.equals("TinFoil")){
for (File nspFile: files){
rowsObsLst.add(new NSLRowModel(nspFile, true));
}
public void setFiles(List<File> newFiles){
if (!rowsObsLst.isEmpty()){
List<String> filesAlreayInList = new ArrayList<>();
for (NSLRowModel model : rowsObsLst)
filesAlreayInList.add(model.getNspFileName());
for (File file: newFiles)
if (!filesAlreayInList.contains(file.getName())) {
if (protocol.equals("TinFoil"))
rowsObsLst.add(new NSLRowModel(file, true));
else
rowsObsLst.add(new NSLRowModel(file, false));
}
}
else {
rowsObsLst.clear();
for (File nspFile: files){
rowsObsLst.add(new NSLRowModel(nspFile, false));
}
rowsObsLst.get(0).setMarkForUpload(true);
for (File file: newFiles)
if (protocol.equals("TinFoil"))
rowsObsLst.add(new NSLRowModel(file, true));
else
rowsObsLst.add(new NSLRowModel(file, false));
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false);
}
}
/**
* Return all files no matter how they're marked
* */
public List<File> getFiles(){
List<File> files = new ArrayList<>();
if (rowsObsLst.isEmpty())
return null;
else
for (NSLRowModel model: rowsObsLst)
files.add(model.getNspFile());
if (!files.isEmpty())
return files;
else
return null;
rowsObsLst.get(0).setMarkForUpload(true);
table.refresh();
}
/**
* Return files ready for upload. Requested from NSLMainController only -> uploadBtnAction() //TODO: set undefined