Compare commits

...

2 commits

Author SHA1 Message Date
Dmitry Isaenko
6e21c514a8 Update test, rename FrontTab to GamesTab 2020-10-27 21:33:56 +03:00
Dmitry Isaenko
eb07ab1df8 Update NXDT-related part 2020-10-27 20:53:52 +03:00
10 changed files with 64 additions and 37 deletions

View file

@ -44,7 +44,7 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ResourceBundle;
public class FrontController implements Initializable {
public class GamesController implements Initializable {
@FXML
private AnchorPane usbNetPane;
@ -353,6 +353,7 @@ public class FrontController implements Initializable {
usbNetPane.setDisable(isActive);
return;
}
selectNspBtn.setDisable(isActive);
selectSplitNspBtn.setDisable(isActive);
btnUpStopImage.getStyleClass().clear();
@ -362,17 +363,18 @@ public class FrontController implements Initializable {
uploadStopBtn.setOnAction(e-> stopBtnAction());
uploadStopBtn.setText(resourceBundle.getString("btn_Stop"));
uploadStopBtn.getStyleClass().clear();
uploadStopBtn.getStyleClass().remove("buttonUp");
uploadStopBtn.getStyleClass().add("buttonStop");
return;
}
else {
btnUpStopImage.getStyleClass().add("regionUpload");
uploadStopBtn.setOnAction(e-> uploadBtnAction());
uploadStopBtn.setText(resourceBundle.getString("btn_Upload"));
uploadStopBtn.getStyleClass().clear();
uploadStopBtn.getStyleClass().remove("buttonStop");
uploadStopBtn.getStyleClass().add("buttonUp");
}
}
/**
* Crunch. This function called from NSTableViewController
* */

View file

@ -41,7 +41,7 @@ public class NSLMainController implements Initializable {
public ProgressBar progressBar; // Accessible from Mediator
@FXML
public FrontController FrontTabController; // Accessible from Mediator | todo: incapsulate
public GamesController GamesTabController; // Accessible from Mediator | todo: incapsulate
@FXML
private SettingsController SettingsTabController;
@FXML
@ -103,8 +103,8 @@ public class NSLMainController implements Initializable {
return SettingsTabController;
}
public FrontController getFrontCtrlr(){
return FrontTabController;
public GamesController getGamesCtrlr(){
return GamesTabController;
}
public SplitMergeController getSmCtrlr(){
@ -118,7 +118,7 @@ public class NSLMainController implements Initializable {
* Save preferences before exit
* */
public void exit(){
FrontTabController.updatePreferencesOnExit();
GamesTabController.updatePreferencesOnExit();
SettingsTabController.updatePreferencesOnExit();
SplitMergeTabController.updatePreferencesOnExit(); // NOTE: This shit above should be re-written to similar pattern
RcmTabController.updatePreferencesOnExit();

View file

@ -24,12 +24,10 @@ import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.SnapshotParameters;
import javafx.scene.control.*;
import javafx.scene.control.cell.CheckBoxTableCell;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.*;
import javafx.scene.paint.Paint;
import nsusbloader.MediatorControl;
import nsusbloader.NSLDataTypes.EFileStatus;
@ -59,7 +57,7 @@ public class NSTableViewController implements Initializable {
if (keyEvent.getCode() == KeyCode.DELETE && !MediatorControl.getInstance().getTransferActive()) {
rowsObsLst.removeAll(table.getSelectionModel().getSelectedItems());
if (rowsObsLst.isEmpty())
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(true); // TODO: change to something better
MediatorControl.getInstance().getContoller().getGamesCtrlr().disableUploadStopBtn(true); // TODO: change to something better
table.refresh();
} else if (keyEvent.getCode() == KeyCode.SPACE) {
for (NSLRowModel item : table.getSelectionModel().getSelectedItems()) {
@ -177,13 +175,13 @@ public class NSTableViewController implements Initializable {
deleteMenuItem.setOnAction(actionEvent -> {
rowsObsLst.remove(row.getItem());
if (rowsObsLst.isEmpty())
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(true); // TODO: change to something better
MediatorControl.getInstance().getContoller().getGamesCtrlr().disableUploadStopBtn(true); // TODO: change to something better
table.refresh();
});
MenuItem deleteAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_DeleteAll"));
deleteAllMenuItem.setOnAction(actionEvent -> {
rowsObsLst.clear();
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(true); // TODO: change to something better
MediatorControl.getInstance().getContoller().getGamesCtrlr().disableUploadStopBtn(true); // TODO: change to something better
table.refresh();
});
contextMenu.getItems().addAll(deleteMenuItem, deleteAllMenuItem);
@ -228,7 +226,7 @@ public class NSTableViewController implements Initializable {
}
else {
rowsObsLst.add(new NSLRowModel(file, true));
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(false); // TODO: change to something better
MediatorControl.getInstance().getContoller().getGamesCtrlr().disableUploadStopBtn(false); // TODO: change to something better
}
table.refresh();
}
@ -248,7 +246,7 @@ public class NSTableViewController implements Initializable {
else {
for (File file: newFiles)
rowsObsLst.add(new NSLRowModel(file, true));
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(false); // TODO: change to something better
MediatorControl.getInstance().getContoller().getGamesCtrlr().disableUploadStopBtn(false); // TODO: change to something better
}
//rowsObsLst.get(0).setMarkForUpload(true);
table.refresh();

View file

@ -41,7 +41,7 @@ public class MediatorControl {
public synchronized void setBgThreadActive(boolean isActive, EModule appModuleType) {
isTransferActive.set(isActive);
mainCtrler.getFrontCtrlr().notifyThreadStarted(isActive, appModuleType);
mainCtrler.getGamesCtrlr().notifyThreadStarted(isActive, appModuleType);
mainCtrler.getSmCtrlr().notifySmThreadStarted(isActive, appModuleType);
mainCtrler.getRcmCtrlr().notifyThreadStarted(isActive, appModuleType);
mainCtrler.getNXDTabController().notifyThreadStarted(isActive, appModuleType);

View file

@ -26,7 +26,6 @@ import nsusbloader.Controllers.NSTableViewController;
import nsusbloader.MediatorControl;
import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EModule;
import nsusbloader.NSLDataTypes.EMsgType;
import java.util.ArrayList;
import java.util.HashMap;
@ -62,7 +61,7 @@ public class MessagesConsumer extends AnimationTimer {
this.progressBar = MediatorControl.getInstance().getContoller().progressBar;
this.statusMap = statusMap;
this.tableViewController = MediatorControl.getInstance().getContoller().FrontTabController.tableFilesListController;
this.tableViewController = MediatorControl.getInstance().getContoller().GamesTabController.tableFilesListController;
this.oneLinerStatus = oneLinerStatus;

View file

@ -35,7 +35,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
class NxdtUsbAbi1 {
private final ILogPrinter logPrinter;
@ -86,7 +85,7 @@ class NxdtUsbAbi1 {
private static final int NXDT_USB_TIMEOUT = 5000;
private HashMap<String, NxdtNspFile> nspFiles;
private NxdtNspFile nspFile;
public NxdtUsbAbi1(DeviceHandle handler,
ILogPrinter logPrinter,
@ -96,7 +95,6 @@ class NxdtUsbAbi1 {
this.handlerNS = handler;
this.logPrinter = logPrinter;
this.parent = parent;
this.nspFiles = new HashMap<>();
this.isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
if (isWindows)
@ -213,7 +211,7 @@ class NxdtUsbAbi1 {
String filename = new String(message, 0x20, fileNameLen, StandardCharsets.UTF_8);
String absoluteFilePath = getAbsoluteFilePath(filename);
File fileToDump = new File(absoluteFilePath);
NxdtNspFile nspFile = nspFiles.get(filename); // it could be null, but it's not a problem.
boolean nspTransferMode = false;
if (checkSizes(fullSize, headerSize))
@ -228,7 +226,7 @@ class NxdtUsbAbi1 {
if (headerSize > 0){ // if NSP
logPrinter.print("Receiving NSP file entry: '"+filename+"' ("+fullSize+" b)", EMsgType.INFO);
if (nspFiles.containsKey(filename)){
if (filename.equals(nspFile.getName())){
nspTransferMode = true;
}
else {
@ -265,11 +263,13 @@ class NxdtUsbAbi1 {
private boolean checkSizes(long fileSize, int headerSize) throws Exception{
if (fileSize >= headerSize){
logPrinter.print("File size should not be equal to header size for NSP files!", EMsgType.FAIL);
resetNsp();
writeUsb(USBSTATUS_MALFORMED_REQUEST);
return true;
}
if (fileSize < 0){ // It's possible to have files of zero-length, so only less is the problem
logPrinter.print("File size should not be less then zero!", EMsgType.FAIL);
resetNsp();
writeUsb(USBSTATUS_MALFORMED_REQUEST);
return true;
}
@ -294,8 +294,7 @@ class NxdtUsbAbi1 {
}
private void createNewNsp(String filename, int headerSize, long fileSize, File fileToDump) throws Exception{
try {
NxdtNspFile nsp = new NxdtNspFile(filename, headerSize, fileSize, fileToDump);
nspFiles.putIfAbsent(filename, nsp);
nspFile = new NxdtNspFile(filename, headerSize, fileSize, fileToDump);
}
catch (Exception e){
logPrinter.print(e.getMessage(), EMsgType.FAIL);
@ -334,8 +333,6 @@ class NxdtUsbAbi1 {
}
}
// @see https://bugs.openjdk.java.net/browse/JDK-8146538
private void dumpFile(File file, long size) throws Exception{
FileOutputStream fos = new FileOutputStream(file, true);
@ -404,7 +401,8 @@ class NxdtUsbAbi1 {
private void handleSendNspHeader(byte[] message) throws Exception{
final int headerSize = getLEint(message, 0x8);
NxdtNspFile nsp = nspFiles.remove( null ); // <---------------------- //TODO: PLEASE PUT FILENAME HERE
NxdtNspFile nsp = nspFile;
resetNsp();
if (nsp == null) {
writeUsb(USBSTATUS_MALFORMED_REQUEST);
@ -432,6 +430,9 @@ class NxdtUsbAbi1 {
writeUsb(USBSTATUS_SUCCESS);
}
private void resetNsp(){
this.nspFile = null;
}
/** Sending any byte array to USB device **/
private void writeUsb(byte[] message) throws Exception{

View file

@ -16,7 +16,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.SVGPath?>
<AnchorPane fx:id="usbNetPane" onDragDropped="#handleDrop" onDragOver="#handleDragOver" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.FrontController">
<AnchorPane fx:id="usbNetPane" onDragDropped="#handleDrop" onDragOver="#handleDragOver" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.GamesController">
<children>
<VBox layoutX="10.0" layoutY="10.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>

View file

@ -23,7 +23,7 @@ Steps to roll NXDT functionality back:
<tabs>
<Tab closable="false">
<content>
<fx:include fx:id="FrontTab" source="FrontTab.fxml" VBox.vgrow="ALWAYS" />
<fx:include fx:id="GamesTab" source="GamesTab.fxml" VBox.vgrow="ALWAYS" />
</content>
<graphic>
<SVGPath content="M 19.953125 -0.00390625 C 19.945025 0.86963499 19.665113 1.3200779 19.117188 1.6679688 C 18.569261 2.0158596 17.688291 2.2107818 16.572266 2.2636719 C 14.340723 2.369428 11.22952 1.9408017 8.0175781 1.7636719 L 8.015625 1.7636719 C 5.8083004 1.6301338 3.850269 1.7145428 2.421875 2.328125 C 1.7074522 2.6350131 1.1147008 3.0945958 0.765625 3.7402344 C 0.41654922 4.3858729 0.3309909 5.1840438 0.50976562 6.0957031 L 0.515625 6.1269531 L 0.52539062 6.1582031 C 0.74516874 6.8214776 1.3043008 7.2559352 1.9550781 7.46875 C 2.6058554 7.6815648 3.3739015 7.7273729 4.2304688 7.703125 C 5.9436032 7.6546292 8.0253788 7.3082908 10.042969 7.1230469 C 12.060559 6.9378029 14.005763 6.9298258 15.349609 7.4511719 C 16.693456 7.972518 17.5 8.8951351 17.5 11 L 13.023438 11 L 10.837891 11 L 1 11 C 0.156581 11 -0.10111662 11.623241 -0.10351562 12.189453 C -0.10591562 12.759114 -0.10321863 13.218366 -0.10351562 13.919922 C -0.10353762 13.969822 -0.10345962 13.990156 -0.10351562 14.042969 C -0.10332363 14.492063 -0.10337263 14.807528 -0.10351562 15.150391 C -0.10359462 15.343113 -0.10438363 15.566512 -0.10351562 15.771484 C -0.10347763 15.861874 -0.10364063 15.971437 -0.10351562 16.064453 C -0.10316562 16.324274 -0.10337563 16.550139 -0.10351562 16.880859 C -0.10353662 16.930759 -0.10345962 16.951094 -0.10351562 17.003906 C -0.10317063 17.257044 -0.10337962 17.473987 -0.10351562 17.794922 C -0.10353762 17.844822 -0.10345962 17.863203 -0.10351562 17.916016 C -0.10380362 18.172294 -0.10461563 18.463892 -0.10351562 18.732422 C -0.10363862 18.825442 -0.10347763 18.935007 -0.10351562 19.025391 C -0.10359462 19.218111 -0.10438363 19.441511 -0.10351562 19.646484 C -0.10337262 19.98934 -0.10332563 20.306746 -0.10351562 20.755859 C -0.10353662 20.805759 -0.10345962 20.826093 -0.10351562 20.878906 C -0.10321564 21.580432 -0.10591562 22.037789 -0.10351562 22.607422 C -0.10111563 23.173608 0.156706 23.796875 1 23.796875 L 10.833984 23.796875 L 13.019531 23.796875 L 22.857422 23.796875 C 23.70084 23.796875 23.958538 23.17361 23.960938 22.607422 C 23.963338 22.037788 23.960642 21.580432 23.960938 20.878906 C 23.960959 20.829006 23.96088 20.808672 23.960938 20.755859 C 23.960749 20.306747 23.960795 19.989341 23.960938 19.646484 C 23.961015 19.453769 23.961803 19.230374 23.960938 19.025391 C 23.9609 18.935011 23.961059 18.825438 23.960938 18.732422 C 23.96059 18.472592 23.960799 18.246723 23.960938 17.916016 C 23.960959 17.866116 23.96088 17.847735 23.960938 17.794922 C 23.960642 17.093366 23.963337 16.63411 23.960938 16.064453 C 23.96106 15.971433 23.960898 15.861868 23.960938 15.771484 C 23.961015 15.578768 23.961803 15.355372 23.960938 15.150391 C 23.960797 14.807528 23.960748 14.492063 23.960938 14.042969 C 23.960959 13.993069 23.96088 13.972735 23.960938 13.919922 C 23.960642 13.218366 23.963337 12.759114 23.960938 12.189453 C 23.958538 11.623242 23.700715 11 22.857422 11 L 18.5 11 C 18.5 8.6048649 17.347496 7.152482 15.710938 6.5175781 C 14.074378 5.8826742 12.017906 5.9371971 9.9511719 6.1269531 C 7.8844382 6.3167092 5.7997949 6.6578708 4.2011719 6.703125 C 3.4018604 6.7257521 2.725744 6.6699978 2.265625 6.5195312 C 1.8171096 6.3728594 1.6083191 6.1804127 1.4941406 5.859375 C 1.3628245 5.141091 1.4300216 4.6115935 1.6445312 4.2148438 C 1.8648981 3.8072608 2.2462454 3.4910124 2.8164062 3.2460938 C 3.9567281 2.7562562 5.8156963 2.6320489 7.9570312 2.7617188 L 7.9589844 2.7617188 C 11.116926 2.9357557 14.220255 3.3773586 16.619141 3.2636719 C 17.818583 3.2068289 18.856796 3.0180713 19.654297 2.5117188 C 20.451798 2.0053661 20.942623 1.130365 20.953125 0.00390625 L 19.953125 -0.00390625 z M 4.4277344 13.271484 L 7 13.271484 L 7 16 L 9.71875 16 L 9.71875 18.5625 L 7 18.5625 L 7 21.291016 L 4.4277344 21.291016 L 4.4277344 18.5625 L 1.7089844 18.5625 L 1.7089844 16 L 4.4277344 16 L 4.4277344 13.271484 z M 20 14 A 1.9161212 1.9161212 0 0 1 21.916016 15.916016 A 1.9161212 1.9161212 0 0 1 20 17.832031 A 1.9161212 1.9161212 0 0 1 18.083984 15.916016 A 1.9161212 1.9161212 0 0 1 20 14 z M 16.421875 17.667969 A 1.9168563 1.9168563 0 0 1 18.337891 19.583984 A 1.9168563 1.9168563 0 0 1 16.421875 21.5 A 1.9168563 1.9168563 0 0 1 14.505859 19.583984 A 1.9168563 1.9168563 0 0 1 16.421875 17.667969 z " />

View file

@ -0,0 +1,28 @@
package nsusbloader.com.usb;
import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.NSLDataTypes.EFileStatus;
import nsusbloader.NSLDataTypes.EMsgType;
import java.io.File;
import java.util.HashMap;
public class NoLogPrinter implements ILogPrinter {
@Override
public void print(String message, EMsgType type) { }
@Override
public void updateProgress(Double value) { }
@Override
public void update(HashMap<String, File> nspMap, EFileStatus status) { }
@Override
public void update(File file, EFileStatus status) { }
@Override
public void updateOneLinerStatus(boolean status) { }
@Override
public void close() { }
}

View file

@ -2,7 +2,6 @@ package nsusbloader.com.usb;
import nsusbloader.ModelControllers.CancellableRunnable;
import nsusbloader.ModelControllers.ILogPrinter;
import nsusbloader.ModelControllers.LogPrinterCli;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@ -81,7 +80,7 @@ class TransferModuleTest{
filesMap.put(splitFileName10, splitFile10);
filesMap.put(splitFileName11, splitFile11);
ILogPrinter printer = new LogPrinterCli();
ILogPrinter printer = new NoLogPrinter();
this.transferModule = new TransferModuleImplementation((DeviceHandle)null, filesMap, (CancellableRunnable)null, printer);
}