mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-05-14 07:04:50 -04:00
v0.2 bug fixes
This commit is contained in:
parent
42782929f9
commit
d3b25d57b1
6 changed files with 33 additions and 12 deletions
|
@ -42,6 +42,7 @@ public class NSLMainController implements Initializable {
|
|||
@FXML
|
||||
public NSTableViewController tableFilesListController; // Accessible from Mediator
|
||||
|
||||
private UsbCommunications usbCommunications;
|
||||
private Thread usbThread;
|
||||
|
||||
private String previouslyOpenedPath;
|
||||
|
@ -74,7 +75,7 @@ public class NSLMainController implements Initializable {
|
|||
|
||||
ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("TinFoil", "GoldLeaf");
|
||||
choiceProtocol.setItems(choiceProtocolList);
|
||||
choiceProtocol.getSelectionModel().select(0); // TODO: shared settings
|
||||
choiceProtocol.getSelectionModel().select(AppPreferences.getInstance().getProtocol()); // TODO: shared settings
|
||||
choiceProtocol.setOnAction(e->tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem())); // Add listener to notify tableView controller
|
||||
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // Notify tableView controller
|
||||
|
||||
|
@ -99,6 +100,7 @@ public class NSLMainController implements Initializable {
|
|||
switchThemeBtn.getScene().getStylesheets().remove("/res/app_light.css");
|
||||
switchThemeBtn.getScene().getStylesheets().add("/res/app_dark.css");
|
||||
}
|
||||
AppPreferences.getInstance().setTheme(switchThemeBtn.getScene().getStylesheets().get(0));
|
||||
}
|
||||
/**
|
||||
* Functionality for selecting NSP button.
|
||||
|
@ -142,8 +144,9 @@ public class NSLMainController implements Initializable {
|
|||
for (File item: nspToUpload)
|
||||
logArea.appendText(" "+item.getAbsolutePath()+"\n");
|
||||
}
|
||||
UsbCommunications usbCommunications = new UsbCommunications(nspToUpload, choiceProtocol.getSelectionModel().getSelectedItem());
|
||||
usbCommunications = new UsbCommunications(nspToUpload, choiceProtocol.getSelectionModel().getSelectedItem());
|
||||
usbThread = new Thread(usbCommunications);
|
||||
usbThread.setDaemon(true);
|
||||
usbThread.start();
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +155,7 @@ public class NSLMainController implements Initializable {
|
|||
* */
|
||||
private void stopBtnAction(){
|
||||
if (usbThread != null && usbThread.isAlive()){
|
||||
usbThread.interrupt();
|
||||
usbCommunications.cancel(false);
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -189,7 +192,7 @@ public class NSLMainController implements Initializable {
|
|||
* Save preferences before exit
|
||||
* */
|
||||
public void exit(){
|
||||
AppPreferences.getInstance().setTheme(switchThemeBtn.getScene().getStylesheets().get(0));
|
||||
AppPreferences.getInstance().setProtocol(choiceProtocol.getSelectionModel().getSelectedItem());
|
||||
AppPreferences.getInstance().setRecent(previouslyOpenedPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ public class NSLRowModel {
|
|||
case FAILED:
|
||||
this.status = "Failed";
|
||||
break;
|
||||
case UNKNOWN:
|
||||
this.status = "...";
|
||||
break;
|
||||
case INCORRECT_FILE_FAILED:
|
||||
this.status = "Failed: Incorrect file";
|
||||
markForUpload = false;
|
||||
|
|
|
@ -125,7 +125,7 @@ public class NSTableViewController implements Initializable {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* Return files ready for upload. Requested from NSLMainController only
|
||||
* Return files ready for upload. Requested from NSLMainController only -> uploadBtnAction() //TODO: set undefined
|
||||
* @return null if no files marked for upload
|
||||
* List<File> if there are files
|
||||
* */
|
||||
|
@ -135,11 +135,15 @@ public class NSTableViewController implements Initializable {
|
|||
return null;
|
||||
else {
|
||||
for (NSLRowModel model: rowsObsLst){
|
||||
if (model.isMarkForUpload())
|
||||
if (model.isMarkForUpload()){
|
||||
files.add(model.getNspFile());
|
||||
model.setStatus(EFileStatus.UNKNOWN);
|
||||
}
|
||||
}
|
||||
if (!files.isEmpty())
|
||||
if (!files.isEmpty()) {
|
||||
table.refresh();
|
||||
return files;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue