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

This commit is contained in:
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. 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.) 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. 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. 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) Français by [Stephane Meden (JackFromNice)](https://github.com/JackFromNice)

View file

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

View file

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