Resolve #79
This commit is contained in:
parent
50e2b739a8
commit
4cb3cbb491
5 changed files with 50 additions and 24 deletions
|
@ -61,7 +61,7 @@ public class AppPreferences {
|
|||
public void setNsIp(String ip){preferences.put("NSIP", ip);}
|
||||
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); }
|
||||
//------------ SETTINGS ------------------//
|
||||
|
||||
|
@ -124,12 +124,12 @@ public class AppPreferences {
|
|||
public int getSplitMergeType(){ return preferences.getInt("SM_TYPE", 0); }
|
||||
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); }
|
||||
// RCM //
|
||||
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); }
|
||||
// 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); }
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import javafx.stage.FileChooser;
|
|||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.COM.NET.NETCommunications;
|
||||
import nsusbloader.COM.USB.UsbCommunications;
|
||||
import nsusbloader.FilesHelper;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.ModelControllers.CancellableRunnable;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
|
@ -193,11 +194,7 @@ public class FrontController implements Initializable {
|
|||
FileChooser fileChooser = new FileChooser();
|
||||
fileChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
|
||||
|
||||
File validator = new File(previouslyOpenedPath);
|
||||
if (validator.exists() && validator.isDirectory())
|
||||
fileChooser.setInitialDirectory(validator);
|
||||
else
|
||||
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
||||
fileChooser.setInitialDirectory(new File(FilesHelper.getRealFolder(previouslyOpenedPath)));
|
||||
|
||||
if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTinfoilSettings().isXciNszXczSupport())
|
||||
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();
|
||||
dirChooser.setTitle(resourceBundle.getString("btn_OpenFile"));
|
||||
|
||||
File validator = new File(previouslyOpenedPath);
|
||||
if (validator.exists() && validator.isDirectory())
|
||||
dirChooser.setInitialDirectory(validator);
|
||||
else
|
||||
dirChooser.setInitialDirectory(new File(System.getProperty("user.home")));
|
||||
String saveToLocation = FilesHelper.getRealFolder(previouslyOpenedPath);
|
||||
dirChooser.setInitialDirectory(new File(saveToLocation));
|
||||
|
||||
splitFile = dirChooser.showDialog(usbNetPane.getScene().getWindow());
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import javafx.scene.control.Label;
|
|||
import javafx.scene.layout.Region;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.FilesHelper;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.ModelControllers.CancellableRunnable;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
|
@ -52,11 +53,8 @@ public class NxdtController implements Initializable {
|
|||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
this.rb = resourceBundle;
|
||||
|
||||
File saveToValidator = new File(AppPreferences.getInstance().getNXDTSaveToLocation());
|
||||
if (saveToValidator.exists())
|
||||
saveToLocationLbl.setText(saveToValidator.getAbsolutePath());
|
||||
else
|
||||
saveToLocationLbl.setText(System.getProperty("user.home"));
|
||||
String saveToLocation = AppPreferences.getInstance().getNXDTSaveToLocation();
|
||||
saveToLocationLbl.setText(saveToLocation);
|
||||
|
||||
btnDumpStopImage = new Region();
|
||||
btnDumpStopImage.getStyleClass().add("regionDump");
|
||||
|
|
|
@ -20,7 +20,6 @@ package nsusbloader.Controllers;
|
|||
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.TransferMode;
|
||||
|
@ -29,6 +28,7 @@ import javafx.scene.layout.VBox;
|
|||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.FileChooser;
|
||||
import nsusbloader.AppPreferences;
|
||||
import nsusbloader.FilesHelper;
|
||||
import nsusbloader.MediatorControl;
|
||||
import nsusbloader.ModelControllers.CancellableRunnable;
|
||||
import nsusbloader.NSLDataTypes.EModule;
|
||||
|
@ -97,10 +97,13 @@ public class SplitMergeController implements Initializable {
|
|||
saveToPathLbl.setText(AppPreferences.getInstance().getSplitMergeRecent());
|
||||
|
||||
changeSaveToBtn.setOnAction((actionEvent -> {
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
dc.setTitle(resourceBundle.getString("tabSplMrg_Btn_SelectFolder"));
|
||||
dc.setInitialDirectory(new File(saveToPathLbl.getText()));
|
||||
File saveToDir = dc.showDialog(changeSaveToBtn.getScene().getWindow());
|
||||
DirectoryChooser directoryChooser = new DirectoryChooser();
|
||||
directoryChooser.setTitle(resourceBundle.getString("tabSplMrg_Btn_SelectFolder"));
|
||||
|
||||
String saveToLocation = FilesHelper.getRealFolder(saveToPathLbl.getText());
|
||||
directoryChooser.setInitialDirectory(new File(saveToLocation));
|
||||
|
||||
File saveToDir = directoryChooser.showDialog(changeSaveToBtn.getScene().getWindow());
|
||||
if (saveToDir != null)
|
||||
saveToPathLbl.setText(saveToDir.getAbsolutePath());
|
||||
}));
|
||||
|
@ -227,7 +230,6 @@ public class SplitMergeController implements Initializable {
|
|||
* */
|
||||
@FXML
|
||||
private void handleDrop(DragEvent event) {
|
||||
Node sourceNode = (Node) event.getSource();
|
||||
File fileDrpd = event.getDragboard().getFiles().get(0);
|
||||
|
||||
if (fileDrpd.isDirectory())
|
||||
|
|
32
src/main/java/nsusbloader/FilesHelper.java
Normal file
32
src/main/java/nsusbloader/FilesHelper.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue