Skip to content
Snippets Groups Projects
Commit 3bf4e9be authored by Matej Kovár's avatar Matej Kovár
Browse files

fixed saving project

parent 0aae829f
No related branches found
No related tags found
No related merge requests found
...@@ -782,6 +782,7 @@ public class ProjectPanel extends JPanel { ...@@ -782,6 +782,7 @@ public class ProjectPanel extends JPanel {
model.setRowCount(0); model.setRowCount(0);
checkFaceState(null, false); checkFaceState(null, false);
selectedRows.clear(); selectedRows.clear();
userPreferences.remove("pathToMostRecentProject");
} }
/** /**
...@@ -813,13 +814,23 @@ public class ProjectPanel extends JPanel { ...@@ -813,13 +814,23 @@ public class ProjectPanel extends JPanel {
*/ */
public void saveProject() { public void saveProject() {
JFileChooser chooser = new JFileChooser(); File file;
//chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileFilter(new FileNameExtensionFilter("json files (*.json)", "json"));
chooser.setAcceptAllFileFilterUsed(true);
chooser.showSaveDialog(null);
File file = chooser.getSelectedFile(); // If current project was saved before
String path = userPreferences.get("pathToMostRecentProject", "");
if (path != null && !path.isEmpty()) {
file = Paths.get(path).toFile();
// Project was not saved before, user chooses new path where to save project
} else {
JFileChooser chooser = new JFileChooser();
//chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileFilter(new FileNameExtensionFilter("json files (*.json)", "json"));
chooser.setAcceptAllFileFilterUsed(true);
chooser.showSaveDialog(null);
file = chooser.getSelectedFile();
}
if (file != null) { if (file != null) {
String filePath = file.getAbsolutePath(); String filePath = file.getAbsolutePath();
......
...@@ -108,7 +108,7 @@ public final class ProjectTopComp extends TopComponent { ...@@ -108,7 +108,7 @@ public final class ProjectTopComp extends TopComponent {
// Asks user whether he wants to create new project or open existing // Asks user whether he wants to create new project or open existing
projectPanel.openExistingOrNewProject(); projectPanel.openExistingOrNewProject();
// Pass this class to installer so it can call method of this class on close // Pass this class to installer so it can call method of this class on close
Installer inst = new Installer(this); Installer inst = new Installer(this);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment