Skip to content

Commit

Permalink
save as for proof editor
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkxu committed Apr 16, 2024
1 parent 6bd9a39 commit 54e50c8
Showing 1 changed file with 11 additions and 49 deletions.
60 changes: 11 additions & 49 deletions src/main/java/edu/rpi/legup/ui/ProofEditorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -580,9 +580,7 @@ private void saveProofAs() {
if (puzzle == null) {
return;
}

//===================================


LegupPreferences preferences = LegupPreferences.getInstance();
File preferredDirectory =
new File(preferences.getUserPref(LegupPreferences.WORK_DIRECTORY));
Expand All @@ -598,55 +596,19 @@ private void saveProofAs() {
folderBrowser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
folderBrowser.setAcceptAllFileFilterUsed(false);

File folder = folderBrowser.getSelectedFile();
String path = folderBrowser.getSelectedFile().getAbsolutePath();

// Write csv file (Path,File-Name,Puzzle-Type,Score,Solved?)
File resultFile = new File(folder.getAbsolutePath() + File.separator + "result.csv");
try (BufferedWriter writer = new BufferedWriter(new FileWriter(resultFile))) {
writer.append("Name,File Name,Puzzle Type,Score,Solved?\n");

// Go through student folders
for (final File folderEntry :
Objects.requireNonNull(folder.listFiles(File::isDirectory))) {
// Write path
String path = folderEntry.getName();
traverseDir(folderEntry, writer, path);
if (path != null) {
try {
PuzzleExporter exporter = puzzle.getExporter();
if (exporter == null) {
throw new ExportFileException("Puzzle exporter null");
}
exporter.exportPuzzle(path);
} catch (ExportFileException e) {
e.printStackTrace();
}
} catch (IOException ex) {
LOGGER.error(ex.getMessage());
}


//==========================================

// fileDialog.setMode(FileDialog.SAVE);
// fileDialog.setTitle("Save As");
// 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);
//
// String fileName = null;
// if (fileDialog.getDirectory() != null && fileDialog.getFile() != null) {
// fileName = fileDialog.getDirectory() + File.separator + fileDialog.getFile();
// }
//
// if (fileName != null) {
// try {
// PuzzleExporter exporter = puzzle.getExporter();
// if (exporter == null) {
// throw new ExportFileException("Puzzle exporter null");
// }
// exporter.exportPuzzle(fileName);
// } catch (ExportFileException e) {
// e.printStackTrace();
// }
// }
}

// Hyperlink for help button; links to wiki page for tutorials
Expand Down

0 comments on commit 54e50c8

Please sign in to comment.