Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2023-11-21 12:24:28 -05:00
commit 4f8c920cce
16 changed files with 270 additions and 30 deletions

View file

@ -137,15 +137,22 @@ class SelectProjectPanel extends AbstractWizardJPanel {
directoryField = new JTextField(25);
directoryField.setName("Project Directory");
String lastDirSelected = Preferences.getProperty(Preferences.LAST_NEW_PROJECT_DIRECTORY);
if (lastDirSelected != null) {
directoryField.setText(lastDirSelected);
File projectDirectory = null;
String projectDirPath = Preferences.getProperty(Preferences.LAST_NEW_PROJECT_DIRECTORY);
if (projectDirPath != null) {
// if it exists, use last directory where project was created
projectDirectory = new File(projectDirPath);
if (!projectDirectory.isDirectory()) {
projectDirectory = null;
}
}
else {
File projectDirectory = new File(GenericRunInfo.getProjectsDirPath());
directoryField.setText(projectDirectory.getAbsolutePath());
if (projectDirectory == null) {
// otherwise, use last project directory or default
projectDirectory = new File(GenericRunInfo.getProjectsDirPath());
}
directoryField.setCaretPosition(directoryField.getText().length() - 1);
projectDirPath = projectDirectory.getAbsolutePath();
directoryField.setText(projectDirPath);
directoryField.setCaretPosition(projectDirPath.length() - 1);
JLabel projectNameLabel = new GDLabel("Project Name:", SwingConstants.RIGHT);
projectNameField = new JTextField(25);
projectNameField.setName("Project Name");

View file

@ -423,7 +423,10 @@ class ToolActionManager implements ToolChestChangeListener {
String importDir = Preferences.getProperty(Preferences.LAST_TOOL_IMPORT_DIRECTORY);
if (importDir != null) {
fileChooser.setCurrentDirectory(new File(importDir));
File dir = new File(importDir);
if (dir.isDirectory()) {
fileChooser.setCurrentDirectory(dir);
}
}
fileChooser.rescanCurrentDirectory();

View file

@ -125,8 +125,8 @@ public class ProjectLocator {
scanIndex = 4;
}
checkInvalidChar("path", path, scanIndex);
if (!path.endsWith(File.separator)) {
path += File.separator;
if (!path.endsWith("/")) {
path += "/";
}
return path;
}

View file

@ -394,7 +394,10 @@ public class SaveToolConfigDialog extends DialogComponentProvider implements Lis
new ExtensionFileFilter(new String[] { "gif", "jpg", "bmp", "png" }, "Image Files"));
String iconDir = Preferences.getProperty(LAST_ICON_DIRECTORY);
if (iconDir != null) {
chooser.setCurrentDirectory(new File(iconDir));
File dir = new File(iconDir);
if (dir.isDirectory()) {
chooser.setCurrentDirectory(dir);
}
}
File file = chooser.getSelectedFile();
chooser.dispose();

View file

@ -145,7 +145,10 @@ class ToolServicesImpl implements ToolServices {
String exportDir = Preferences.getProperty(Preferences.LAST_TOOL_EXPORT_DIRECTORY);
if (exportDir != null) {
newFileChooser.setCurrentDirectory(new File(exportDir));
File dir = new File(exportDir);
if (dir.isDirectory()) {
newFileChooser.setCurrentDirectory(dir);
}
}
newFileChooser.setTitle("Export Tool");