UI refactoring

This commit is contained in:
Dmitry Isaenko 2020-01-24 01:08:16 +03:00
parent 98155bc1f8
commit ca061cd1f2
9 changed files with 263 additions and 238 deletions

View file

@ -8,7 +8,7 @@
<name>NS-USBloader</name> <name>NS-USBloader</name>
<artifactId>ns-usbloader</artifactId> <artifactId>ns-usbloader</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>
<url>https://github.com/developersu/ns-usbloader/</url> <url>https://github.com/developersu/ns-usbloader/</url>
<description> <description>

View file

@ -2,15 +2,24 @@ package nsusbloader.Controllers;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import nsusbloader.AppPreferences; import nsusbloader.AppPreferences;
import nsusbloader.COM.NET.NETCommunications;
import nsusbloader.COM.USB.UsbCommunications;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.ServiceWindow;
import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.LinkedList;
import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class FrontController implements Initializable { public class FrontController implements Initializable {
@ -28,8 +37,17 @@ public class FrontController implements Initializable {
@FXML @FXML
public NSTableViewController tableFilesListController; // Accessible from Mediator public NSTableViewController tableFilesListController; // Accessible from Mediator
@FXML
private Button selectNspBtn, selectSplitNspBtn, uploadStopBtn;
private String previouslyOpenedPath;
private Region btnUpStopImage;
private ResourceBundle resourceBundle;
private Task<Void> usbNetCommunications;
private Thread workThread;
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
this.resourceBundle = resourceBundle;
specialPane.getStyleClass().add("special-pane-as-border"); // UI hacks specialPane.getStyleClass().add("special-pane-as-border"); // UI hacks
ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("TinFoil", "GoldLeaf"); ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("TinFoil", "GoldLeaf");
@ -52,9 +70,9 @@ public class FrontController implements Initializable {
} }
// Really bad disable-enable upload button function // Really bad disable-enable upload button function
if (tableFilesListController.isFilesForUploadListEmpty()) if (tableFilesListController.isFilesForUploadListEmpty())
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true); disableUploadStopBtn(true);
else else
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false); disableUploadStopBtn(false);
}); // Add listener to notify tableView controller }); // Add listener to notify tableView controller
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // Notify tableView controller tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // Notify tableView controller
@ -92,6 +110,28 @@ public class FrontController implements Initializable {
btnSwitchImage.getStyleClass().add("regionLamp"); btnSwitchImage.getStyleClass().add("regionLamp");
switchThemeBtn.setGraphic(btnSwitchImage); switchThemeBtn.setGraphic(btnSwitchImage);
this.switchThemeBtn.setOnAction(e->switchTheme()); this.switchThemeBtn.setOnAction(e->switchTheme());
if (getSelectedProtocol().equals("TinFoil"))
uploadStopBtn.setDisable(true);
else
uploadStopBtn.setDisable(false);
selectNspBtn.setOnAction(e-> selectFilesBtnAction());
selectSplitNspBtn.setOnAction(e-> selectSplitBtnAction());
selectSplitNspBtn.getStyleClass().add("buttonSelect");
uploadStopBtn.setOnAction(e-> uploadBtnAction());
selectNspBtn.getStyleClass().add("buttonSelect");
this.btnUpStopImage = new Region();
btnUpStopImage.getStyleClass().add("regionUpload");
uploadStopBtn.getStyleClass().add("buttonUp");
uploadStopBtn.setGraphic(btnUpStopImage);
this.previouslyOpenedPath = AppPreferences.getInstance().getRecent();
} }
/** /**
* Changes UI theme on the go * Changes UI theme on the go
@ -125,4 +165,171 @@ public class FrontController implements Initializable {
String getNsIp(){ String getNsIp(){
return nsIpTextField.getText(); return nsIpTextField.getText();
} }
/********************************************************************************************************************/
/**
* Functionality for selecting NSP button.
* */
private void selectFilesBtnAction(){
List<File> filesList;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
File validator = new File(previouslyOpenedPath);
if (validator.exists())
fileChooser.setInitialDirectory(validator);
else
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTfXciNszXczSupport())
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP/XCI/NSZ/XCZ", "*.nsp", "*.xci", "*.nsz", "*.xcz"));
else if (getSelectedProtocol().equals("GoldLeaf") && (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL()))
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Any file", "*.*"),
new FileChooser.ExtensionFilter("NSP ROM", "*.nsp")
);
else
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP ROM", "*.nsp"));
filesList = fileChooser.showOpenMultipleDialog(specialPane.getScene().getWindow());
if (filesList != null && !filesList.isEmpty()) {
tableFilesListController.setFiles(filesList);
uploadStopBtn.setDisable(false);
previouslyOpenedPath = filesList.get(0).getParent();
}
}
/**
* Functionality for selecting Split NSP button.
* */
private void selectSplitBtnAction(){
File splitFile;
DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
File validator = new File(previouslyOpenedPath);
if (validator.exists())
dirChooser.setInitialDirectory(validator);
else
dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));
splitFile = dirChooser.showDialog(specialPane.getScene().getWindow());
if (splitFile != null && splitFile.getName().toLowerCase().endsWith(".nsp")) {
tableFilesListController.setFile(splitFile);
uploadStopBtn.setDisable(false); // Is it useful?
previouslyOpenedPath = splitFile.getParent();
}
}
/**
* It's button listener when no transmission executes
* */
private void uploadBtnAction(){
if ((workThread == null || !workThread.isAlive())){
// Collect files
List<File> nspToUpload;
if (tableFilesListController.getFilesForUpload() == null && getSelectedProtocol().equals("TinFoil")) {
MediatorControl.getInstance().getContoller().logArea.setText(resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected"));
return;
}
else {
if ((nspToUpload = tableFilesListController.getFilesForUpload()) != null){
MediatorControl.getInstance().getContoller().logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\n");
for (File item: nspToUpload)
MediatorControl.getInstance().getContoller().logArea.appendText(" "+item.getAbsolutePath()+"\n");
}
else {
MediatorControl.getInstance().getContoller().logArea.clear();
nspToUpload = new LinkedList<>();
}
}
// If USB selected
if (getSelectedProtocol().equals("GoldLeaf") ||
( getSelectedProtocol().equals("TinFoil") && getSelectedNetUsb().equals("USB") )
){
usbNetCommunications = new UsbCommunications(nspToUpload, getSelectedProtocol()+MediatorControl.getInstance().getContoller().getSettingsCtrlr().getGlOldVer(), MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL());
workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true);
workThread.start();
}
else { // NET INSTALL OVER TINFOIL
if (MediatorControl.getInstance().getContoller().getSettingsCtrlr().isNsIpValidate() && ! getNsIp().matches("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"))
if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"),resourceBundle.getString("windowBodyBadIp")))
return;
String nsIP = getNsIp();
if (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getExpertModeSelected())
usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", "");
else {
usbNetCommunications = new NETCommunications(
nspToUpload,
nsIP,
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNotServeSelected(),
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getAutoIpSelected()?"":MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostIp(),
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getRandPortSelected()?"":MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostPort(),
MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNotServeSelected()?MediatorControl.getInstance().getContoller().getSettingsCtrlr().getHostExtra():""
);
}
workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true);
workThread.start();
}
}
}
/**
* It's button listener when transmission in progress
* */
private void stopBtnAction(){
if (workThread != null && workThread.isAlive()){
usbNetCommunications.cancel(false);
}
}
/**
* This thing modify UI for reusing 'Upload to NS' button and make functionality set for "Stop transmission"
* Called from mediator
* TODO: remove shitcoding practices
* */
public void notifyTransmissionStarted(boolean isTransmissionStarted){
if (isTransmissionStarted) {
selectNspBtn.setDisable(true);
selectSplitNspBtn.setDisable(true);
uploadStopBtn.setOnAction(e-> stopBtnAction());
uploadStopBtn.setText(resourceBundle.getString("btn_Stop"));
btnUpStopImage.getStyleClass().remove("regionUpload");
btnUpStopImage.getStyleClass().add("regionStop");
uploadStopBtn.getStyleClass().remove("buttonUp");
uploadStopBtn.getStyleClass().add("buttonStop");
return;
}
selectNspBtn.setDisable(false);
selectSplitNspBtn.setDisable(false);
uploadStopBtn.setOnAction(e-> uploadBtnAction());
uploadStopBtn.setText(resourceBundle.getString("btn_Upload"));
btnUpStopImage.getStyleClass().remove("regionStop");
btnUpStopImage.getStyleClass().add("regionUpload");
uploadStopBtn.getStyleClass().remove("buttonStop");
uploadStopBtn.getStyleClass().add("buttonUp");
}
/**
* Crunch. This function called from NSTableViewController
* */
public void disableUploadStopBtn(boolean disable){
if (getSelectedProtocol().equals("TinFoil"))
uploadStopBtn.setDisable(disable);
else
uploadStopBtn.setDisable(false);
}
/**
* Get 'Recent' path
*/
public String getRecentPath(){
return previouslyOpenedPath;
}
} }

View file

@ -7,17 +7,11 @@ import javafx.fxml.Initializable;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.input.DragEvent; import javafx.scene.input.DragEvent;
import javafx.scene.input.TransferMode; import javafx.scene.input.TransferMode;
import javafx.scene.layout.Region;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import nsusbloader.*; import nsusbloader.*;
import nsusbloader.ModelControllers.UpdatesChecker; import nsusbloader.ModelControllers.UpdatesChecker;
import nsusbloader.COM.NET.NETCommunications;
import nsusbloader.COM.USB.UsbCommunications;
import java.io.File; import java.io.File;
import java.net.*; import java.net.*;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -27,26 +21,17 @@ public class NSLMainController implements Initializable {
@FXML @FXML
public TextArea logArea; // Accessible from Mediator public TextArea logArea; // Accessible from Mediator
@FXML
private Button selectNspBtn, selectSplitNspBtn, uploadStopBtn;
private Region btnUpStopImage;
@FXML @FXML
public ProgressBar progressBar; // Accessible from Mediator public ProgressBar progressBar; // Accessible from Mediator
@FXML
public FrontController FrontTabController; // Accessible from Mediator | todo: incapsulate
@FXML @FXML
private SettingsController SettingsTabController; private SettingsController SettingsTabController;
@FXML
public FrontController FrontTabController; // Accessible from Mediator | todo: incapsulate
@FXML @FXML
private SplitMergeController SplitMergeTabController; private SplitMergeController SplitMergeTabController;
private Task<Void> usbNetCommunications;
private Thread workThread;
private String previouslyOpenedPath;
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
this.resourceBundle = rb; this.resourceBundle = rb;
@ -59,27 +44,6 @@ public class NSLMainController implements Initializable {
MediatorControl.getInstance().setController(this); MediatorControl.getInstance().setController(this);
if (FrontTabController.getSelectedProtocol().equals("TinFoil"))
uploadStopBtn.setDisable(true);
else
uploadStopBtn.setDisable(false);
selectNspBtn.setOnAction(e-> selectFilesBtnAction());
selectSplitNspBtn.setOnAction(e-> selectSplitBtnAction());
selectSplitNspBtn.getStyleClass().add("buttonSelect");
uploadStopBtn.setOnAction(e-> uploadBtnAction());
selectNspBtn.getStyleClass().add("buttonSelect");
this.btnUpStopImage = new Region();
btnUpStopImage.getStyleClass().add("regionUpload");
uploadStopBtn.getStyleClass().add("buttonUp");
uploadStopBtn.setGraphic(btnUpStopImage);
this.previouslyOpenedPath = AppPreferences.getInstance().getRecent();
if (AppPreferences.getInstance().getAutoCheckUpdates()){ if (AppPreferences.getInstance().getAutoCheckUpdates()){
Task<List<String>> updTask = new UpdatesChecker(); Task<List<String>> updTask = new UpdatesChecker();
updTask.setOnSucceeded(event->{ updTask.setOnSucceeded(event->{
@ -112,164 +76,7 @@ public class NSLMainController implements Initializable {
* */ * */
public void setHostServices(HostServices hs ){ SettingsTabController.registerHostServices(hs);} public void setHostServices(HostServices hs ){ SettingsTabController.registerHostServices(hs);}
/**
* Functionality for selecting NSP button.
* */
private void selectFilesBtnAction(){
List<File> filesList;
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
File validator = new File(previouslyOpenedPath);
if (validator.exists())
fileChooser.setInitialDirectory(validator);
else
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
if (FrontTabController.getSelectedProtocol().equals("TinFoil") && SettingsTabController.getTfXciNszXczSupport())
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP/XCI/NSZ/XCZ", "*.nsp", "*.xci", "*.nsz", "*.xcz"));
else if (FrontTabController.getSelectedProtocol().equals("GoldLeaf") && (! SettingsTabController.getNSPFileFilterForGL()))
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Any file", "*.*"),
new FileChooser.ExtensionFilter("NSP ROM", "*.nsp")
);
else
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP ROM", "*.nsp"));
filesList = fileChooser.showOpenMultipleDialog(logArea.getScene().getWindow());
if (filesList != null && !filesList.isEmpty()) {
FrontTabController.tableFilesListController.setFiles(filesList);
uploadStopBtn.setDisable(false);
previouslyOpenedPath = filesList.get(0).getParent();
}
}
/**
* Functionality for selecting Split NSP button.
* */
private void selectSplitBtnAction(){
File splitFile;
DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
File validator = new File(previouslyOpenedPath);
if (validator.exists())
dirChooser.setInitialDirectory(validator);
else
dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));
splitFile = dirChooser.showDialog(logArea.getScene().getWindow());
if (splitFile != null && splitFile.getName().toLowerCase().endsWith(".nsp")) {
FrontTabController.tableFilesListController.setFile(splitFile);
uploadStopBtn.setDisable(false); // Is it useful?
previouslyOpenedPath = splitFile.getParent();
}
}
/**
* It's button listener when no transmission executes
* */
private void uploadBtnAction(){
if ((workThread == null || !workThread.isAlive())){
// Collect files
List<File> nspToUpload;
if (FrontTabController.tableFilesListController.getFilesForUpload() == null && FrontTabController.getSelectedProtocol().equals("TinFoil")) {
logArea.setText(resourceBundle.getString("tab3_Txt_NoFolderOrFileSelected"));
return;
}
else {
if ((nspToUpload = FrontTabController.tableFilesListController.getFilesForUpload()) != null){
logArea.setText(resourceBundle.getString("tab3_Txt_FilesToUploadTitle")+"\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") )
){
usbNetCommunications = new UsbCommunications(nspToUpload, FrontTabController.getSelectedProtocol()+SettingsTabController.getGlOldVer(), SettingsTabController.getNSPFileFilterForGL());
workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true);
workThread.start();
}
else { // NET INSTALL OVER TINFOIL
if (SettingsTabController.isNsIpValidate() && ! FrontTabController.getNsIp().matches("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"))
if (!ServiceWindow.getConfirmationWindow(resourceBundle.getString("windowTitleBadIp"),resourceBundle.getString("windowBodyBadIp")))
return;
String nsIP = FrontTabController.getNsIp();
if (!SettingsTabController.getExpertModeSelected())
usbNetCommunications = new NETCommunications(nspToUpload, nsIP, false, "", "", "");
else {
usbNetCommunications = new NETCommunications(
nspToUpload,
nsIP,
SettingsTabController.getNotServeSelected(),
SettingsTabController.getAutoIpSelected()?"":SettingsTabController.getHostIp(),
SettingsTabController.getRandPortSelected()?"":SettingsTabController.getHostPort(),
SettingsTabController.getNotServeSelected()?SettingsTabController.getHostExtra():""
);
}
workThread = new Thread(usbNetCommunications);
workThread.setDaemon(true);
workThread.start();
}
}
}
/**
* It's button listener when transmission in progress
* */
private void stopBtnAction(){
if (workThread != null && workThread.isAlive()){
usbNetCommunications.cancel(false);
}
}
/**
* This thing modify UI for reusing 'Upload to NS' button and make functionality set for "Stop transmission"
* Called from mediator
* */
public void notifyTransmissionStarted(boolean isTransmissionStarted){
if (isTransmissionStarted) {
selectNspBtn.setDisable(true);
selectSplitNspBtn.setDisable(true);
uploadStopBtn.setOnAction(e-> stopBtnAction());
uploadStopBtn.setText(resourceBundle.getString("btn_Stop"));
btnUpStopImage.getStyleClass().remove("regionUpload");
btnUpStopImage.getStyleClass().add("regionStop");
uploadStopBtn.getStyleClass().remove("buttonUp");
uploadStopBtn.getStyleClass().add("buttonStop");
}
else {
selectNspBtn.setDisable(false);
selectSplitNspBtn.setDisable(false);
uploadStopBtn.setOnAction(e-> uploadBtnAction());
uploadStopBtn.setText(resourceBundle.getString("btn_Upload"));
btnUpStopImage.getStyleClass().remove("regionStop");
btnUpStopImage.getStyleClass().add("regionUpload");
uploadStopBtn.getStyleClass().remove("buttonStop");
uploadStopBtn.getStyleClass().add("buttonUp");
}
}
/**
* Crunch. Now you see that I'm not a programmer.. This function called from NSTableViewController
* */
public void disableUploadStopBtn(boolean disable){
if (FrontTabController.getSelectedProtocol().equals("TinFoil"))
uploadStopBtn.setDisable(disable);
else
uploadStopBtn.setDisable(false);
}
/** /**
* Drag-n-drop support (dragOver consumer) * Drag-n-drop support (dragOver consumer)
* */ * */
@ -301,13 +108,24 @@ public class NSLMainController implements Initializable {
event.setDropCompleted(true); event.setDropCompleted(true);
} }
/**
* Get 'Settings' controller
* Used by FrontController
* */
public SettingsController getSettingsCtrlr(){
return SettingsTabController;
}
public FrontController getFrontCtrlr(){
return FrontTabController;
}
/** /**
* Save preferences before exit * Save preferences before exit
* */ * */
public void exit(){ public void exit(){
AppPreferences.getInstance().setAll( AppPreferences.getInstance().setAll(
FrontTabController.getSelectedProtocol(), FrontTabController.getSelectedProtocol(),
previouslyOpenedPath, FrontTabController.getRecentPath(),
FrontTabController.getSelectedNetUsb(), FrontTabController.getSelectedNetUsb(),
FrontTabController.getNsIp(), FrontTabController.getNsIp(),
SettingsTabController.isNsIpValidate(), SettingsTabController.isNsIpValidate(),

View file

@ -17,7 +17,6 @@ import nsusbloader.NSLDataTypes.EFileStatus;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@ -39,7 +38,7 @@ public class NSTableViewController implements Initializable {
if (keyEvent.getCode() == KeyCode.DELETE && !MediatorControl.getInstance().getTransferActive()) { 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(true); // TODO: change to something better MediatorControl.getInstance().getContoller().getFrontCtrlr().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()) {
@ -112,13 +111,13 @@ public class NSTableViewController implements Initializable {
deleteMenuItem.setOnAction(actionEvent -> { deleteMenuItem.setOnAction(actionEvent -> {
rowsObsLst.remove(row.getItem()); rowsObsLst.remove(row.getItem());
if (rowsObsLst.isEmpty()) if (rowsObsLst.isEmpty())
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true); // TODO: change to something better MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(true); // TODO: change to something better
table.refresh(); table.refresh();
}); });
MenuItem deleteAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_DeleteAll")); MenuItem deleteAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_DeleteAll"));
deleteAllMenuItem.setOnAction(actionEvent -> { deleteAllMenuItem.setOnAction(actionEvent -> {
rowsObsLst.clear(); rowsObsLst.clear();
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true); // TODO: change to something better MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(true); // TODO: change to something better
table.refresh(); table.refresh();
}); });
contextMenu.getItems().addAll(deleteMenuItem, deleteAllMenuItem); contextMenu.getItems().addAll(deleteMenuItem, deleteAllMenuItem);
@ -163,7 +162,7 @@ public class NSTableViewController implements Initializable {
} }
else { else {
rowsObsLst.add(new NSLRowModel(file, true)); rowsObsLst.add(new NSLRowModel(file, true));
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false); MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(false); // TODO: change to something better
} }
table.refresh(); table.refresh();
} }
@ -183,7 +182,7 @@ public class NSTableViewController implements Initializable {
else { else {
for (File file: newFiles) for (File file: newFiles)
rowsObsLst.add(new NSLRowModel(file, true)); rowsObsLst.add(new NSLRowModel(file, true));
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false); MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(false); // TODO: change to something better
} }
//rowsObsLst.get(0).setMarkForUpload(true); //rowsObsLst.get(0).setMarkForUpload(true);
table.refresh(); table.refresh();

View file

@ -22,7 +22,7 @@ public class MediatorControl {
public synchronized void setTransferActive(boolean state) { public synchronized void setTransferActive(boolean state) {
isTransferActive.set(state); isTransferActive.set(state);
applicationController.notifyTransmissionStarted(state); applicationController.getFrontCtrlr().notifyTransmissionStarted(state);
} }
public synchronized boolean getTransferActive() { return this.isTransferActive.get(); } public synchronized boolean getTransferActive() { return this.isTransferActive.get(); }
} }

View file

@ -12,7 +12,9 @@ import java.util.Locale;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class NSLMain extends Application { public class NSLMain extends Application {
public static final String appVersion = "v1.0";
public static final String appVersion = "v1.1";
@Override @Override
public void start(Stage primaryStage) throws Exception{ public void start(Stage primaryStage) throws Exception{
FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml"));

View file

@ -182,7 +182,6 @@ public class SplitMergeTool {
bis.close(); bis.close();
} }
bos.close(); bos.close();
//=============== let's check what we have ============== //=============== let's check what we have ==============
long resultFileSize = resultFile.length(); long resultFileSize = resultFile.length();
logPrinter.print("Total chunks size: " + cnkTotalSize, EMsgType.INFO); logPrinter.print("Total chunks size: " + cnkTotalSize, EMsgType.INFO);

View file

@ -13,6 +13,7 @@
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.RowConstraints?> <?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.SVGPath?>
<AnchorPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.FrontController"> <AnchorPane xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.FrontController">
<children> <children>
@ -45,6 +46,33 @@
</VBox.margin> </VBox.margin>
</GridPane> </GridPane>
<fx:include fx:id="tableFilesList" source="TableView.fxml" VBox.vgrow="ALWAYS" /> <fx:include fx:id="tableFilesList" source="TableView.fxml" VBox.vgrow="ALWAYS" />
<HBox alignment="TOP_CENTER" spacing="3.0" VBox.vgrow="NEVER">
<children>
<Button fx:id="selectNspBtn" contentDisplay="TOP" mnemonicParsing="false" prefHeight="60.0" text="%btn_OpenFile">
<HBox.margin>
<Insets />
</HBox.margin>
<graphic>
<SVGPath content="M 8,0 C 6.8954305,0 6,0.8954305 6,2 v 16 c 0,1.1 0.89,2 2,2 h 12 c 1.104569,0 2,-0.895431 2,-2 V 2 C 22,0.90484721 21.089844,0 20,0 Z m 2.1,1.2 h 7.8 C 18,1.20208 18,1.2002604 18,1.3 v 0.1 c 0,0.095833 0,0.097917 -0.1,0.1 H 10.1 C 10,1.5057292 10,1.5036458 10,1.4 V 1.3 C 10,1.20026 10,1.1981771 10.1,1.2 Z M 8,2 h 12 c 0.303385,0 0.5,0.2044271 0.5,0.5 v 12 C 20.5,14.789959 20.29836,15 20,15 H 8 C 7.7044271,15 7.5,14.803385 7.5,14.5 V 2.5 C 7.5,2.2083333 7.7122396,2 8,2 Z M 2,4 v 18 c 0,1.104569 0.8954305,2 2,2 H 20 V 22 H 4 V 4 Z m 8,12 h 8 l -4,3 z" fill="#289de8" />
</graphic>
</Button>
<Button fx:id="selectSplitNspBtn" contentDisplay="TOP" mnemonicParsing="false" prefHeight="60.0" text="%btn_OpenSplitFile">
<graphic>
<SVGPath content="M 2.4003906 2 C 1.0683906 2 0 3.1125 0 4.5 L 0 19.5 A 2.4 2.5 0 0 0 2.4003906 22 L 21.599609 22 A 2.4 2.5 0 0 0 24 19.5 L 24 7 C 24 5.6125 22.919609 4.5 21.599609 4.5 L 12 4.5 L 9.5996094 2 L 2.4003906 2 z M 13.193359 10.962891 C 14.113498 10.962891 14.814236 11.348741 15.296875 12.123047 C 15.779514 12.89388 16.021484 13.935113 16.021484 15.244141 C 16.021484 16.556641 15.779514 17.598741 15.296875 18.373047 C 14.814236 19.14388 14.113498 19.529297 13.193359 19.529297 C 12.276693 19.529297 11.575955 19.14388 11.089844 18.373047 C 10.607205 17.598741 10.365234 16.556641 10.365234 15.244141 C 10.365234 13.935113 10.607205 12.89388 11.089844 12.123047 C 11.575955 11.348741 12.276693 10.962891 13.193359 10.962891 z M 19.589844 10.962891 C 20.509983 10.962891 21.21072 11.348741 21.693359 12.123047 C 22.175998 12.89388 22.417969 13.935113 22.417969 15.244141 C 22.417969 16.556641 22.175998 17.598741 21.693359 18.373047 C 21.21072 19.14388 20.509983 19.529297 19.589844 19.529297 C 18.673177 19.529297 17.970486 19.14388 17.484375 18.373047 C 17.001736 17.598741 16.761719 16.556641 16.761719 15.244141 C 16.761719 13.935113 17.001736 12.89388 17.484375 12.123047 C 17.970486 11.348741 18.673177 10.962891 19.589844 10.962891 z M 13.193359 11.769531 C 12.613498 11.769531 12.173177 12.092448 11.871094 12.738281 C 11.56901 13.380642 11.417969 14.195964 11.417969 15.185547 C 11.417969 15.411241 11.423611 15.655599 11.4375 15.916016 C 11.451389 16.176432 11.511068 16.528212 11.615234 16.972656 L 14.412109 12.591797 C 14.235026 12.26888 14.042318 12.052517 13.833984 11.941406 C 13.629123 11.826823 13.415582 11.769531 13.193359 11.769531 z M 19.589844 11.769531 C 19.009983 11.769531 18.567708 12.092448 18.265625 12.738281 C 17.963542 13.380642 17.8125 14.195964 17.8125 15.185547 C 17.8125 15.411241 17.820095 15.655599 17.833984 15.916016 C 17.847873 16.176432 17.907552 16.528212 18.011719 16.972656 L 20.808594 12.591797 C 20.63151 12.26888 20.438802 12.052517 20.230469 11.941406 C 20.025608 11.826823 19.812066 11.769531 19.589844 11.769531 z M 14.761719 13.556641 L 11.984375 17.962891 C 12.133681 18.216363 12.305556 18.406684 12.5 18.535156 C 12.694444 18.660156 12.91276 18.722656 13.152344 18.722656 C 13.812066 18.722656 14.280816 18.355252 14.558594 17.619141 C 14.836372 16.879557 14.974609 16.059462 14.974609 15.160156 C 14.974609 14.604601 14.90408 14.07053 14.761719 13.556641 z M 21.15625 13.556641 L 18.380859 17.962891 C 18.530165 18.216363 18.70204 18.406684 18.896484 18.535156 C 19.090929 18.660156 19.307292 18.722656 19.546875 18.722656 C 20.206597 18.722656 20.675347 18.355252 20.953125 17.619141 C 21.230903 16.879557 21.371094 16.059462 21.371094 15.160156 C 21.371094 14.604601 21.298611 14.07053 21.15625 13.556641 z" fill="#289de8" />
</graphic></Button>
<Pane HBox.hgrow="ALWAYS" />
<Button fx:id="uploadStopBtn" contentDisplay="TOP" mnemonicParsing="false" prefHeight="60.0" text="%btn_Upload">
<HBox.margin>
<Insets />
</HBox.margin>
</Button>
</children>
<VBox.margin>
<Insets left="5.0" right="5.0" top="5.0" />
</VBox.margin>
</HBox>
</children> </children>
</VBox> </VBox>
</children> </children>

View file

@ -1,18 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?> <?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.ProgressBar?> <?import javafx.scene.control.ProgressBar?>
<?import javafx.scene.control.Tab?> <?import javafx.scene.control.Tab?>
<?import javafx.scene.control.TabPane?> <?import javafx.scene.control.TabPane?>
<?import javafx.scene.control.TextArea?> <?import javafx.scene.control.TextArea?>
<?import javafx.scene.layout.AnchorPane?> <?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?> <?import javafx.scene.layout.VBox?>
<?import javafx.scene.shape.SVGPath?> <?import javafx.scene.shape.SVGPath?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onDragDropped="#handleDrop" onDragOver="#handleDragOver" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.NSLMainController"> <AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" onDragDropped="#handleDrop" onDragOver="#handleDragOver" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="nsusbloader.Controllers.NSLMainController">
<children> <children>
<VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> <VBox AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children> <children>
@ -64,34 +61,9 @@
</TabPane> </TabPane>
<ProgressBar fx:id="progressBar" prefWidth="Infinity" progress="0.0"> <ProgressBar fx:id="progressBar" prefWidth="Infinity" progress="0.0">
<VBox.margin> <VBox.margin>
<Insets left="5.0" right="5.0" top="2.0" /> <Insets bottom="2.0" left="5.0" right="5.0" top="2.0" />
</VBox.margin> </VBox.margin>
</ProgressBar> </ProgressBar>
<HBox alignment="TOP_CENTER" spacing="3.0" VBox.vgrow="NEVER">
<children>
<Button fx:id="selectNspBtn" contentDisplay="TOP" mnemonicParsing="false" prefHeight="60.0" text="%btn_OpenFile">
<HBox.margin>
<Insets />
</HBox.margin>
<graphic>
<SVGPath content="M 8,0 C 6.8954305,0 6,0.8954305 6,2 v 16 c 0,1.1 0.89,2 2,2 h 12 c 1.104569,0 2,-0.895431 2,-2 V 2 C 22,0.90484721 21.089844,0 20,0 Z m 2.1,1.2 h 7.8 C 18,1.20208 18,1.2002604 18,1.3 v 0.1 c 0,0.095833 0,0.097917 -0.1,0.1 H 10.1 C 10,1.5057292 10,1.5036458 10,1.4 V 1.3 C 10,1.20026 10,1.1981771 10.1,1.2 Z M 8,2 h 12 c 0.303385,0 0.5,0.2044271 0.5,0.5 v 12 C 20.5,14.789959 20.29836,15 20,15 H 8 C 7.7044271,15 7.5,14.803385 7.5,14.5 V 2.5 C 7.5,2.2083333 7.7122396,2 8,2 Z M 2,4 v 18 c 0,1.104569 0.8954305,2 2,2 H 20 V 22 H 4 V 4 Z m 8,12 h 8 l -4,3 z" fill="#289de8" />
</graphic>
</Button>
<Button fx:id="selectSplitNspBtn" contentDisplay="TOP" mnemonicParsing="false" prefHeight="60.0" text="%btn_OpenSplitFile">
<graphic>
<SVGPath content="M 2.4003906 2 C 1.0683906 2 0 3.1125 0 4.5 L 0 19.5 A 2.4 2.5 0 0 0 2.4003906 22 L 21.599609 22 A 2.4 2.5 0 0 0 24 19.5 L 24 7 C 24 5.6125 22.919609 4.5 21.599609 4.5 L 12 4.5 L 9.5996094 2 L 2.4003906 2 z M 13.193359 10.962891 C 14.113498 10.962891 14.814236 11.348741 15.296875 12.123047 C 15.779514 12.89388 16.021484 13.935113 16.021484 15.244141 C 16.021484 16.556641 15.779514 17.598741 15.296875 18.373047 C 14.814236 19.14388 14.113498 19.529297 13.193359 19.529297 C 12.276693 19.529297 11.575955 19.14388 11.089844 18.373047 C 10.607205 17.598741 10.365234 16.556641 10.365234 15.244141 C 10.365234 13.935113 10.607205 12.89388 11.089844 12.123047 C 11.575955 11.348741 12.276693 10.962891 13.193359 10.962891 z M 19.589844 10.962891 C 20.509983 10.962891 21.21072 11.348741 21.693359 12.123047 C 22.175998 12.89388 22.417969 13.935113 22.417969 15.244141 C 22.417969 16.556641 22.175998 17.598741 21.693359 18.373047 C 21.21072 19.14388 20.509983 19.529297 19.589844 19.529297 C 18.673177 19.529297 17.970486 19.14388 17.484375 18.373047 C 17.001736 17.598741 16.761719 16.556641 16.761719 15.244141 C 16.761719 13.935113 17.001736 12.89388 17.484375 12.123047 C 17.970486 11.348741 18.673177 10.962891 19.589844 10.962891 z M 13.193359 11.769531 C 12.613498 11.769531 12.173177 12.092448 11.871094 12.738281 C 11.56901 13.380642 11.417969 14.195964 11.417969 15.185547 C 11.417969 15.411241 11.423611 15.655599 11.4375 15.916016 C 11.451389 16.176432 11.511068 16.528212 11.615234 16.972656 L 14.412109 12.591797 C 14.235026 12.26888 14.042318 12.052517 13.833984 11.941406 C 13.629123 11.826823 13.415582 11.769531 13.193359 11.769531 z M 19.589844 11.769531 C 19.009983 11.769531 18.567708 12.092448 18.265625 12.738281 C 17.963542 13.380642 17.8125 14.195964 17.8125 15.185547 C 17.8125 15.411241 17.820095 15.655599 17.833984 15.916016 C 17.847873 16.176432 17.907552 16.528212 18.011719 16.972656 L 20.808594 12.591797 C 20.63151 12.26888 20.438802 12.052517 20.230469 11.941406 C 20.025608 11.826823 19.812066 11.769531 19.589844 11.769531 z M 14.761719 13.556641 L 11.984375 17.962891 C 12.133681 18.216363 12.305556 18.406684 12.5 18.535156 C 12.694444 18.660156 12.91276 18.722656 13.152344 18.722656 C 13.812066 18.722656 14.280816 18.355252 14.558594 17.619141 C 14.836372 16.879557 14.974609 16.059462 14.974609 15.160156 C 14.974609 14.604601 14.90408 14.07053 14.761719 13.556641 z M 21.15625 13.556641 L 18.380859 17.962891 C 18.530165 18.216363 18.70204 18.406684 18.896484 18.535156 C 19.090929 18.660156 19.307292 18.722656 19.546875 18.722656 C 20.206597 18.722656 20.675347 18.355252 20.953125 17.619141 C 21.230903 16.879557 21.371094 16.059462 21.371094 15.160156 C 21.371094 14.604601 21.298611 14.07053 21.15625 13.556641 z" fill="#289de8" />
</graphic></Button>
<Pane HBox.hgrow="ALWAYS" />
<Button fx:id="uploadStopBtn" contentDisplay="TOP" mnemonicParsing="false" prefHeight="60.0" text="%btn_Upload">
<HBox.margin>
<Insets />
</HBox.margin>
</Button>
</children>
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="2.0" />
</VBox.margin>
</HBox>
</children> </children>
</VBox> </VBox>
</children> </children>