Skip to content

Commit

Permalink
proof editor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkxu committed Apr 16, 2024
1 parent 54e50c8 commit c423e9e
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions src/main/java/edu/rpi/legup/ui/PuzzleEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -551,39 +551,35 @@ private String savePuzzle() {
}
}

if (fileDialog == null) {
fileDialog = new FileDialog(this.frame);
LegupPreferences preferences = LegupPreferences.getInstance();
File preferredDirectory =
new File(preferences.getUserPref(LegupPreferences.WORK_DIRECTORY));
if (preferences.getSavedPath() != "") {
preferredDirectory = new File(preferences.getSavedPath());
}
folderBrowser = new JFileChooser(preferredDirectory);

fileDialog.setMode(FileDialog.SAVE);
fileDialog.setTitle("Save Proof");
String curFileName = GameBoardFacade.getInstance().getCurFileName();
if (curFileName == null) {
fileDialog.setDirectory(
LegupPreferences.getInstance().getUserPref(LegupPreferences.WORK_DIRECTORY));
} else {
File curFile = new File(curFileName);
fileDialog.setDirectory(curFile.getParent());
}
fileDialog.setVisible(true);
folderBrowser.showSaveDialog(this);
folderBrowser.setVisible(true);
folderBrowser.setCurrentDirectory(new File(LegupPreferences.WORK_DIRECTORY));
folderBrowser.setDialogTitle("Select Directory");
folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
folderBrowser.setAcceptAllFileFilterUsed(false);

String fileName = null;
if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) {
fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile();
}
String path = folderBrowser.getSelectedFile().getAbsolutePath();

if (fileName != null) {
if (path != null) {
try {
PuzzleExporter exporter = puzzle.getExporter();
if (exporter == null) {
throw new ExportFileException("Puzzle exporter null");
}
exporter.exportPuzzle(fileName);
exporter.exportPuzzle(path);
} catch (ExportFileException e) {
e.printStackTrace();
}
}
return fileName;
return path;
}

public DynamicView getDynamicBoardView() {
Expand Down

0 comments on commit c423e9e

Please sign in to comment.