Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save File Path #562

Merged
merged 7 commits into from
Jun 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update ProofEditorPanel.java
hi

Update ProofEditorPanel.java
  • Loading branch information
04vmatsibekker committed Jun 23, 2023
commit 886ea3dd6e3a4b03c26857ec6cfa4d9648f832bf
11 changes: 11 additions & 0 deletions src/main/java/edu/rpi/legup/app/LegupPreferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 8,8 @@ public class LegupPreferences {

private static LegupPreferences instance;

private static String SAVED_PATH = "";

private static final Preferences preferences = Preferences.userNodeForPackage(LegupPreferences.class);

private static final Map<String, String> preferencesMap = new HashMap<>();
Expand Down Expand Up @@ -104,4 106,13 @@ public boolean getUserPrefAsBool(String key) {
}
}
}


public String getSavedPath() {
return SAVED_PATH;
}

public void setSavedPath(String path) {
SAVED_PATH = path;
}
}
7 changes: 6 additions & 1 deletion src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 380,9 @@ public Object[] promptPuzzle() {

LegupPreferences preferences = LegupPreferences.getInstance();
String preferredDirectory = preferences.getUserPref(LegupPreferences.WORK_DIRECTORY);
if (preferences.getSavedPath() != "") {
preferredDirectory = preferences.getSavedPath();
}

File preferredDirectoryFile = new File(preferredDirectory);
JFileChooser fileBrowser = new JFileChooser(preferredDirectoryFile);
Expand All @@ -388,7 391,7 @@ public Object[] promptPuzzle() {

fileBrowser.showOpenDialog(this);
fileBrowser.setVisible(true);
fileBrowser.setCurrentDirectory(new File(LegupPreferences.WORK_DIRECTORY));
fileBrowser.setCurrentDirectory(new File(preferredDirectory));
fileBrowser.setDialogTitle("Select Proof File");
fileBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileBrowser.setAcceptAllFileFilterUsed(false);
Expand All @@ -398,6 401,8 @@ public Object[] promptPuzzle() {

if (puzzlePath != null) {
fileName = puzzlePath.getAbsolutePath();
String lastDirectoryPath = fileName.substring(0, fileName.lastIndexOf(File.separator));
preferences.setSavedPath(lastDirectoryPath);
puzzleFile = puzzlePath;
}
else {
Expand Down