v0.6 GoldLeaf v0.6.1 support

This commit is contained in:
Dmitry Isaenko 2019-08-14 05:37:58 +03:00
parent d34d522f46
commit cd73968306
20 changed files with 1076 additions and 597 deletions

View file

@ -8,6 +8,7 @@ import javafx.scene.control.*;
import javafx.scene.layout.Pane;
import javafx.scene.layout.Region;
import nsusbloader.AppPreferences;
import nsusbloader.MediatorControl;
import java.net.URL;
import java.util.ResourceBundle;
@ -49,6 +50,11 @@ public class FrontController implements Initializable {
nsIpTextField.setVisible(true);
}
}
// Really bad disable-enable upload button function
if (tableFilesListController.isFilesForUploadListEmpty())
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true);
else
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false);
}); // Add listener to notify tableView controller
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // Notify tableView controller

View file

@ -17,6 +17,7 @@ import nsusbloader.USB.UsbCommunications;
import java.io.File;
import java.net.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ResourceBundle;
@ -56,7 +57,10 @@ public class NSLMainController implements Initializable {
MediatorControl.getInstance().setController(this);
uploadStopBtn.setDisable(true);
if (FrontTabController.getSelectedProtocol().equals("TinFoil"))
uploadStopBtn.setDisable(true);
else
uploadStopBtn.setDisable(false);
selectNspBtn.setOnAction(e->{ selectFilesBtnAction(); });
uploadStopBtn.setOnAction(e->{ uploadBtnAction(); });
@ -128,23 +132,26 @@ public class NSLMainController implements Initializable {
if ((workThread == null || !workThread.isAlive())){
// Collect files
List<File> nspToUpload;
if ((nspToUpload = FrontTabController.tableFilesListController.getFilesForUpload()) == null) {
if ((nspToUpload = FrontTabController.tableFilesListController.getFilesForUpload()) == null && FrontTabController.getSelectedProtocol().equals("TinFoil")) {
logArea.setText(resourceBundle.getString("logsNoFolderFileSelected"));
return;
}
else {
logArea.setText(resourceBundle.getString("logsFilesToUploadTitle")+"\n");
for (File item: nspToUpload)
logArea.appendText(" "+item.getAbsolutePath()+"\n");
if ((nspToUpload = FrontTabController.tableFilesListController.getFilesForUpload()) != null){
logArea.setText(resourceBundle.getString("logsFilesToUploadTitle")+"\n");
for (File item: nspToUpload)
logArea.appendText(" "+item.getAbsolutePath()+"\n");
}
else {
logArea.clear();
nspToUpload = new LinkedList<>();
}
}
// If USB selected
if (FrontTabController.getSelectedProtocol().equals("GoldLeaf") ||
(
FrontTabController.getSelectedProtocol().equals("TinFoil")
&& FrontTabController.getSelectedNetUsb().equals("USB")
)
( FrontTabController.getSelectedProtocol().equals("TinFoil") && FrontTabController.getSelectedNetUsb().equals("USB") )
){
usbNetCommunications = new UsbCommunications(nspToUpload, FrontTabController.getSelectedProtocol());
usbNetCommunications = new UsbCommunications(nspToUpload, FrontTabController.getSelectedProtocol(), SettingsTabController.getNSPFileFilterForGL());
workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true);
workThread.start();
@ -217,7 +224,10 @@ public class NSLMainController implements Initializable {
* Crunch. Now you see that I'm not a programmer.. This function called from NSTableViewController
* */
public void disableUploadStopBtn(boolean disable){
uploadStopBtn.setDisable(disable);
if (FrontTabController.getSelectedProtocol().equals("TinFoil"))
uploadStopBtn.setDisable(disable);
else
uploadStopBtn.setDisable(false);
}
/**
* Drag-n-drop support (dragOver consumer)
@ -285,7 +295,8 @@ public class NSLMainController implements Initializable {
SettingsTabController.getHostPort(),
SettingsTabController.getHostExtra(),
SettingsTabController.getAutoCheckForUpdates(),
SettingsTabController.getTfXCISupport()
SettingsTabController.getTfXCISupport(),
SettingsTabController.getNSPFileFilterForGL()
);
}
}

View file

@ -25,7 +25,6 @@ import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;
import java.util.ResourceBundle;
public class NSTableViewController implements Initializable {
@ -33,8 +32,6 @@ public class NSTableViewController implements Initializable {
private TableView<NSLRowModel> table;
private ObservableList<NSLRowModel> rowsObsLst;
private String protocol;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
rowsObsLst = FXCollections.observableArrayList();
@ -55,7 +52,6 @@ public class NSTableViewController implements Initializable {
} else if (keyEvent.getCode() == KeyCode.SPACE) {
for (NSLRowModel item : table.getSelectionModel().getSelectedItems()) {
item.setMarkForUpload(!item.isMarkForUpload());
restrictSelection(item);
}
table.refresh();
}
@ -107,7 +103,6 @@ public class NSTableViewController implements Initializable {
@Override
public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue) {
model.setMarkForUpload(newValue);
restrictSelection(model);
}
});
return booleanProperty;
@ -162,7 +157,7 @@ public class NSTableViewController implements Initializable {
if (!row.isEmpty() && mouseEvent.getButton() == MouseButton.PRIMARY){
NSLRowModel thisItem = row.getItem();
thisItem.setMarkForUpload(!thisItem.isMarkForUpload());
restrictSelection(thisItem);
table.refresh();
}
mouseEvent.consume();
}
@ -174,18 +169,6 @@ public class NSTableViewController implements Initializable {
table.setItems(rowsObsLst);
table.getColumns().addAll(statusColumn, fileNameColumn, fileSizeColumn, uploadColumn);
}
/**
* See uploadColumn callback. In case of GoldLeaf we have to restrict selection
* */
private void restrictSelection(NSLRowModel modelChecked){
if (!protocol.equals("TinFoil") && rowsObsLst.size() > 1) { // Tinfoil doesn't need any restrictions. If only one file in list, also useless
for (NSLRowModel model: rowsObsLst){
if (model != modelChecked)
model.setMarkForUpload(false);
}
}
table.refresh();
}
/**
* Add files when user selected them
* */
@ -196,21 +179,15 @@ public class NSTableViewController implements Initializable {
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));
rowsObsLst.add(new NSLRowModel(file, true));
}
}
else {
for (File file: newFiles)
if (protocol.equals("TinFoil"))
rowsObsLst.add(new NSLRowModel(file, true));
else
rowsObsLst.add(new NSLRowModel(file, false));
rowsObsLst.add(new NSLRowModel(file, true));
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false);
}
rowsObsLst.get(0).setMarkForUpload(true);
//rowsObsLst.get(0).setMarkForUpload(true);
table.refresh();
}
/**
@ -237,14 +214,16 @@ public class NSTableViewController implements Initializable {
return null;
}
}
public boolean isFilesForUploadListEmpty(){
return rowsObsLst.isEmpty();
}
/**
* Update files in case something is wrong. Requested from UsbCommunications
* */
public void setFileStatus(String fileName, EFileStatus status){
for (NSLRowModel model: rowsObsLst){
if (model.getNspFileName().equals(fileName)){
if (model.getNspFileName().equals(fileName))
model.setStatus(status);
}
}
table.refresh();
}
@ -252,25 +231,10 @@ public class NSTableViewController implements Initializable {
* Called if selected different USB protocol
* */
public void setNewProtocol(String newProtocol){
protocol = newProtocol;
if (rowsObsLst.isEmpty())
return;
if (newProtocol.equals("TinFoil")){
for (NSLRowModel model: rowsObsLst)
model.setMarkForUpload(true);
}
else {
ListIterator<NSLRowModel> iterator = rowsObsLst.listIterator();
while (iterator.hasNext()){
NSLRowModel current = iterator.next();
if (current.getNspFileName().toLowerCase().endsWith("xci"))
iterator.remove();
else
current.setMarkForUpload(false);
}
if (!rowsObsLst.isEmpty())
rowsObsLst.get(0).setMarkForUpload(true);
}
if (! newProtocol.equals("TinFoil"))
rowsObsLst.removeIf(current -> current.getNspFileName().toLowerCase().endsWith("xci"));
table.refresh();
}

View file

@ -23,7 +23,8 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
public class SettingsController implements Initializable {
@FXML
private CheckBox nspFilesFilterForGLCB;
@FXML
private CheckBox validateNSHostNameCb;
@FXML
@ -64,6 +65,8 @@ public class SettingsController implements Initializable {
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
nspFilesFilterForGLCB.setSelected(AppPreferences.getInstance().getNspFileFilterGL());
validateNSHostNameCb.setSelected(AppPreferences.getInstance().getNsIpValidationNeeded());
expertSettingsVBox.setDisable(!AppPreferences.getInstance().getExpertMode());
@ -243,7 +246,7 @@ public class SettingsController implements Initializable {
});
}
public boolean getNSPFileFilterForGL(){return nspFilesFilterForGLCB.isSelected(); }
public boolean getExpertModeSelected(){ return expertModeCb.isSelected(); }
public boolean getAutoIpSelected(){ return autoDetectIpCb.isSelected(); }
public boolean getRandPortSelected(){ return randPortCb.isSelected(); }