This commit is contained in:
Dmitry Isaenko 2020-10-26 14:12:14 +03:00
parent 50e2b739a8
commit 4cb3cbb491
5 changed files with 50 additions and 24 deletions

View file

@ -61,7 +61,7 @@ public class AppPreferences {
public void setNsIp(String ip){preferences.put("NSIP", ip);} public void setNsIp(String ip){preferences.put("NSIP", ip);}
public String getNsIp(){return preferences.get("NSIP", "192.168.1.42");} public String getNsIp(){return preferences.get("NSIP", "192.168.1.42");}
public String getRecent(){ return preferences.get("RECENT", System.getProperty("user.home")); } public String getRecent(){ return FilesHelper.getRealFolder(preferences.get("RECENT", System.getProperty("user.home"))); }
public void setRecent(String path){ preferences.put("RECENT", path); } public void setRecent(String path){ preferences.put("RECENT", path); }
//------------ SETTINGS ------------------// //------------ SETTINGS ------------------//
@ -124,12 +124,12 @@ public class AppPreferences {
public int getSplitMergeType(){ return preferences.getInt("SM_TYPE", 0); } public int getSplitMergeType(){ return preferences.getInt("SM_TYPE", 0); }
public void setSplitMergeType(int value){ preferences.putInt("SM_TYPE", value); } public void setSplitMergeType(int value){ preferences.putInt("SM_TYPE", value); }
public String getSplitMergeRecent(){ return preferences.get("SM_RECENT", System.getProperty("user.home")); } public String getSplitMergeRecent(){ return FilesHelper.getRealFolder(preferences.get("SM_RECENT", System.getProperty("user.home"))); }
public void setSplitMergeRecent(String value){ preferences.put("SM_RECENT", value); } public void setSplitMergeRecent(String value){ preferences.put("SM_RECENT", value); }
// RCM // // RCM //
public String getRecentRcm(int num){ return preferences.get(String.format("RCM_%02d", num), ""); } public String getRecentRcm(int num){ return preferences.get(String.format("RCM_%02d", num), ""); }
public void setRecentRcm(int num, String value){ preferences.put(String.format("RCM_%02d", num), value); } public void setRecentRcm(int num, String value){ preferences.put(String.format("RCM_%02d", num), value); }
// NXDT // // NXDT //
public String getNXDTSaveToLocation(){ return preferences.get("nxdt_saveto", System.getProperty("user.home")); } public String getNXDTSaveToLocation(){ return FilesHelper.getRealFolder(preferences.get("nxdt_saveto", System.getProperty("user.home"))); }
public void setNXDTSaveToLocation(String value){ preferences.put("nxdt_saveto", value); } public void setNXDTSaveToLocation(String value){ preferences.put("nxdt_saveto", value); }
} }

View file

@ -32,6 +32,7 @@ import javafx.stage.FileChooser;
import nsusbloader.AppPreferences; import nsusbloader.AppPreferences;
import nsusbloader.COM.NET.NETCommunications; import nsusbloader.COM.NET.NETCommunications;
import nsusbloader.COM.USB.UsbCommunications; import nsusbloader.COM.USB.UsbCommunications;
import nsusbloader.FilesHelper;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.ModelControllers.CancellableRunnable; import nsusbloader.ModelControllers.CancellableRunnable;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
@ -193,11 +194,7 @@ public class FrontController implements Initializable {
FileChooser fileChooser = new FileChooser(); FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(resourceBundle.getString("btn_OpenFile")); fileChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
File validator = new File(previouslyOpenedPath); fileChooser.setInitialDirectory(new File(FilesHelper.getRealFolder(previouslyOpenedPath)));
if (validator.exists() && validator.isDirectory())
fileChooser.setInitialDirectory(validator);
else
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTinfoilSettings().isXciNszXczSupport()) if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTinfoilSettings().isXciNszXczSupport())
fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP/XCI/NSZ/XCZ", "*.nsp", "*.xci", "*.nsz", "*.xcz")); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP/XCI/NSZ/XCZ", "*.nsp", "*.xci", "*.nsz", "*.xcz"));
@ -223,11 +220,8 @@ public class FrontController implements Initializable {
DirectoryChooser dirChooser = new DirectoryChooser(); DirectoryChooser dirChooser = new DirectoryChooser();
dirChooser.setTitle(resourceBundle.getString("btn_OpenFile")); dirChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
File validator = new File(previouslyOpenedPath); String saveToLocation = FilesHelper.getRealFolder(previouslyOpenedPath);
if (validator.exists() && validator.isDirectory()) dirChooser.setInitialDirectory(new File(saveToLocation));
dirChooser.setInitialDirectory(validator);
else
dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));
splitFile = dirChooser.showDialog(usbNetPane.getScene().getWindow()); splitFile = dirChooser.showDialog(usbNetPane.getScene().getWindow());

View file

@ -25,6 +25,7 @@ import javafx.scene.control.Label;
import javafx.scene.layout.Region; import javafx.scene.layout.Region;
import javafx.stage.DirectoryChooser; import javafx.stage.DirectoryChooser;
import nsusbloader.AppPreferences; import nsusbloader.AppPreferences;
import nsusbloader.FilesHelper;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.ModelControllers.CancellableRunnable; import nsusbloader.ModelControllers.CancellableRunnable;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
@ -52,11 +53,8 @@ public class NxdtController implements Initializable {
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
this.rb = resourceBundle; this.rb = resourceBundle;
File saveToValidator = new File(AppPreferences.getInstance().getNXDTSaveToLocation()); String saveToLocation = AppPreferences.getInstance().getNXDTSaveToLocation();
if (saveToValidator.exists()) saveToLocationLbl.setText(saveToLocation);
saveToLocationLbl.setText(saveToValidator.getAbsolutePath());
else
saveToLocationLbl.setText(System.getProperty("user.home"));
btnDumpStopImage = new Region(); btnDumpStopImage = new Region();
btnDumpStopImage.getStyleClass().add("regionDump"); btnDumpStopImage.getStyleClass().add("regionDump");

View file

@ -20,7 +20,6 @@ package nsusbloader.Controllers;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.Initializable; import javafx.fxml.Initializable;
import javafx.scene.Node;
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;
@ -29,6 +28,7 @@ import javafx.scene.layout.VBox;
import javafx.stage.DirectoryChooser; import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser; import javafx.stage.FileChooser;
import nsusbloader.AppPreferences; import nsusbloader.AppPreferences;
import nsusbloader.FilesHelper;
import nsusbloader.MediatorControl; import nsusbloader.MediatorControl;
import nsusbloader.ModelControllers.CancellableRunnable; import nsusbloader.ModelControllers.CancellableRunnable;
import nsusbloader.NSLDataTypes.EModule; import nsusbloader.NSLDataTypes.EModule;
@ -97,10 +97,13 @@ public class SplitMergeController implements Initializable {
saveToPathLbl.setText(AppPreferences.getInstance().getSplitMergeRecent()); saveToPathLbl.setText(AppPreferences.getInstance().getSplitMergeRecent());
changeSaveToBtn.setOnAction((actionEvent -> { changeSaveToBtn.setOnAction((actionEvent -> {
DirectoryChooser dc = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
dc.setTitle(resourceBundle.getString("tabSplMrg_Btn_SelectFolder")); directoryChooser.setTitle(resourceBundle.getString("tabSplMrg_Btn_SelectFolder"));
dc.setInitialDirectory(new File(saveToPathLbl.getText()));
File saveToDir = dc.showDialog(changeSaveToBtn.getScene().getWindow()); String saveToLocation = FilesHelper.getRealFolder(saveToPathLbl.getText());
directoryChooser.setInitialDirectory(new File(saveToLocation));
File saveToDir = directoryChooser.showDialog(changeSaveToBtn.getScene().getWindow());
if (saveToDir != null) if (saveToDir != null)
saveToPathLbl.setText(saveToDir.getAbsolutePath()); saveToPathLbl.setText(saveToDir.getAbsolutePath());
})); }));
@ -227,7 +230,6 @@ public class SplitMergeController implements Initializable {
* */ * */
@FXML @FXML
private void handleDrop(DragEvent event) { private void handleDrop(DragEvent event) {
Node sourceNode = (Node) event.getSource();
File fileDrpd = event.getDragboard().getFiles().get(0); File fileDrpd = event.getDragboard().getFiles().get(0);
if (fileDrpd.isDirectory()) if (fileDrpd.isDirectory())

View file

@ -0,0 +1,32 @@
/*
Copyright 2019-2020 Dmitry Isaenko
This file is part of NS-USBloader.
NS-USBloader is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
NS-USBloader is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with NS-USBloader. If not, see <https://www.gnu.org/licenses/>.
*/
package nsusbloader;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class FilesHelper {
public static String getRealFolder(String path){
Path splitMergePath = Paths.get(path);
if (Files.notExists(splitMergePath) || Files.isRegularFile(splitMergePath))
return System.getProperty("user.home");
return path;
}
}