mirror of
https://github.com/developersu/ns-usbloader.git
synced 2025-06-06 17:51:20 -04:00
UI refactoring
This commit is contained in:
parent
98155bc1f8
commit
ca061cd1f2
9 changed files with 263 additions and 238 deletions
src/main/java/nsusbloader
|
@ -2,15 +2,24 @@ package nsusbloader.Controllers;
|
|||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.FileChooser;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.COM.NET.NETCommunications;
|
||||
import nsusbloader.COM.USB.UsbCommunications;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.ServiceWindow;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class FrontController implements Initializable {
|
||||
|
@ -28,8 +37,17 @@ public class FrontController implements Initializable {
|
|||
@FXML
|
||||
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
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
this.resourceBundle = resourceBundle;
|
||||
specialPane.getStyleClass().add("special-pane-as-border"); // UI hacks
|
||||
|
||||
ObservableList<String> choiceProtocolList = FXCollections.observableArrayList("TinFoil", "GoldLeaf");
|
||||
|
@ -52,9 +70,9 @@ public class FrontController implements Initializable {
|
|||
}
|
||||
// Really bad disable-enable upload button function
|
||||
if (tableFilesListController.isFilesForUploadListEmpty())
|
||||
MediatorControl.getInstance().getContoller().disableUploadStopBtn(true);
|
||||
disableUploadStopBtn(true);
|
||||
else
|
||||
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false);
|
||||
disableUploadStopBtn(false);
|
||||
}); // Add listener to notify tableView controller
|
||||
tableFilesListController.setNewProtocol(choiceProtocol.getSelectionModel().getSelectedItem()); // Notify tableView controller
|
||||
|
||||
|
@ -92,6 +110,28 @@ public class FrontController implements Initializable {
|
|||
btnSwitchImage.getStyleClass().add("regionLamp");
|
||||
switchThemeBtn.setGraphic(btnSwitchImage);
|
||||
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
|
||||
|
@ -125,4 +165,171 @@ public class FrontController implements Initializable {
|
|||
String getNsIp(){
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,17 +7,11 @@ import javafx.fxml.Initializable;
|
|||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.TransferMode;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.FileChooser;
|
||||
import nsusbloader.*;
|
||||
import nsusbloader.ModelControllers.UpdatesChecker;
|
||||
import nsusbloader.COM.NET.NETCommunications;
|
||||
import nsusbloader.COM.USB.UsbCommunications;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.*;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
@ -27,26 +21,17 @@ public class NSLMainController implements Initializable {
|
|||
|
||||
@FXML
|
||||
public TextArea logArea; // Accessible from Mediator
|
||||
@FXML
|
||||
private Button selectNspBtn, selectSplitNspBtn, uploadStopBtn;
|
||||
|
||||
private Region btnUpStopImage;
|
||||
@FXML
|
||||
public ProgressBar progressBar; // Accessible from Mediator
|
||||
|
||||
@FXML
|
||||
public FrontController FrontTabController; // Accessible from Mediator | todo: incapsulate
|
||||
@FXML
|
||||
private SettingsController SettingsTabController;
|
||||
@FXML
|
||||
public FrontController FrontTabController; // Accessible from Mediator | todo: incapsulate
|
||||
|
||||
@FXML
|
||||
private SplitMergeController SplitMergeTabController;
|
||||
|
||||
private Task<Void> usbNetCommunications;
|
||||
private Thread workThread;
|
||||
|
||||
private String previouslyOpenedPath;
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle rb) {
|
||||
this.resourceBundle = rb;
|
||||
|
@ -59,27 +44,6 @@ public class NSLMainController implements Initializable {
|
|||
|
||||
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()){
|
||||
Task<List<String>> updTask = new UpdatesChecker();
|
||||
updTask.setOnSucceeded(event->{
|
||||
|
@ -112,164 +76,7 @@ public class NSLMainController implements Initializable {
|
|||
* */
|
||||
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)
|
||||
* */
|
||||
|
@ -301,13 +108,24 @@ public class NSLMainController implements Initializable {
|
|||
|
||||
event.setDropCompleted(true);
|
||||
}
|
||||
/**
|
||||
* Get 'Settings' controller
|
||||
* Used by FrontController
|
||||
* */
|
||||
public SettingsController getSettingsCtrlr(){
|
||||
return SettingsTabController;
|
||||
}
|
||||
|
||||
public FrontController getFrontCtrlr(){
|
||||
return FrontTabController;
|
||||
}
|
||||
/**
|
||||
* Save preferences before exit
|
||||
* */
|
||||
public void exit(){
|
||||
AppPreferences.getInstance().setAll(
|
||||
FrontTabController.getSelectedProtocol(),
|
||||
previouslyOpenedPath,
|
||||
FrontTabController.getRecentPath(),
|
||||
FrontTabController.getSelectedNetUsb(),
|
||||
FrontTabController.getNsIp(),
|
||||
SettingsTabController.isNsIpValidate(),
|
||||
|
|
|
@ -17,7 +17,6 @@ import nsusbloader.NSLDataTypes.EFileStatus;
|
|||
import java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
|
@ -39,7 +38,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().disableUploadStopBtn(true); // TODO: change to something better
|
||||
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(true); // TODO: change to something better
|
||||
table.refresh();
|
||||
} else if (keyEvent.getCode() == KeyCode.SPACE) {
|
||||
for (NSLRowModel item : table.getSelectionModel().getSelectedItems()) {
|
||||
|
@ -112,13 +111,13 @@ public class NSTableViewController implements Initializable {
|
|||
deleteMenuItem.setOnAction(actionEvent -> {
|
||||
rowsObsLst.remove(row.getItem());
|
||||
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();
|
||||
});
|
||||
MenuItem deleteAllMenuItem = new MenuItem(resourceBundle.getString("tab1_table_contextMenu_Btn_DeleteAll"));
|
||||
deleteAllMenuItem.setOnAction(actionEvent -> {
|
||||
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();
|
||||
});
|
||||
contextMenu.getItems().addAll(deleteMenuItem, deleteAllMenuItem);
|
||||
|
@ -163,7 +162,7 @@ public class NSTableViewController implements Initializable {
|
|||
}
|
||||
else {
|
||||
rowsObsLst.add(new NSLRowModel(file, true));
|
||||
MediatorControl.getInstance().getContoller().disableUploadStopBtn(false);
|
||||
MediatorControl.getInstance().getContoller().getFrontCtrlr().disableUploadStopBtn(false); // TODO: change to something better
|
||||
}
|
||||
table.refresh();
|
||||
}
|
||||
|
@ -183,7 +182,7 @@ public class NSTableViewController implements Initializable {
|
|||
else {
|
||||
for (File file: newFiles)
|
||||
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);
|
||||
table.refresh();
|
||||
|
|
|
@ -22,7 +22,7 @@ public class MediatorControl {
|
|||
|
||||
public synchronized void setTransferActive(boolean state) {
|
||||
isTransferActive.set(state);
|
||||
applicationController.notifyTransmissionStarted(state);
|
||||
applicationController.getFrontCtrlr().notifyTransmissionStarted(state);
|
||||
}
|
||||
public synchronized boolean getTransferActive() { return this.isTransferActive.get(); }
|
||||
}
|
||||
|
|
|
@ -12,7 +12,9 @@ import java.util.Locale;
|
|||
import java.util.ResourceBundle;
|
||||
|
||||
public class NSLMain extends Application {
|
||||
public static final String appVersion = "v1.0";
|
||||
|
||||
public static final String appVersion = "v1.1";
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception{
|
||||
FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml"));
|
||||
|
|
|
@ -182,7 +182,6 @@ public class SplitMergeTool {
|
|||
bis.close();
|
||||
}
|
||||
bos.close();
|
||||
|
||||
//=============== let's check what we have ==============
|
||||
long resultFileSize = resultFile.length();
|
||||
logPrinter.print("Total chunks size: " + cnkTotalSize, EMsgType.INFO);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue