diff options
| author | Pinapelz <yukais@pinapelz.com> | 2024-10-02 13:42:08 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2024-10-02 13:42:08 -0700 |
| commit | eeab121612d5bb8bb02d383ae9cfd12b3a9febe0 (patch) | |
| tree | 66af77963a8e9d56941680ec7fd64cc8e5df4b17 /src/main/java/DownloadConfigPane.java | |
| parent | 110ad8f7746aca49a91fe4048e2b0f4329944a74 (diff) | |
add button to change output dir w/ filechooser, remove blacklist feature, change config files to use json
Diffstat (limited to 'src/main/java/DownloadConfigPane.java')
| -rw-r--r-- | src/main/java/DownloadConfigPane.java | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/src/main/java/DownloadConfigPane.java b/src/main/java/DownloadConfigPane.java index 7206d7e..8de09bb 100644 --- a/src/main/java/DownloadConfigPane.java +++ b/src/main/java/DownloadConfigPane.java @@ -167,35 +167,34 @@ public class DownloadConfigPane extends JFrame{ } private void saveConfigToFile() throws IOException { - if(loadedPath == null){ - File selectedDirectory = selectDirectoryFileChooser(); - if (selectedDirectory == null){ + if (loadedPath == null) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setDialogTitle("Specify a file to save"); + int userSelection = fileChooser.showSaveDialog(this); + if (userSelection == JFileChooser.APPROVE_OPTION) { + File fileToSave = fileChooser.getSelectedFile(); + loadedPath = fileToSave.getAbsolutePath(); + if (!loadedPath.endsWith(".txt")) { + loadedPath += ".txt"; + } + } else { return; } - loadedPath = selectedDirectory.getAbsolutePath() + "/download_config.txt"; } + File saveFile = new File(loadedPath); FileWriter writer = new FileWriter(saveFile); - if(!saveFile.exists()){ - System.out.println("File does not exist"); - return; - } for (int i = 0; i < outputTable.getRowCount(); i++) { String url = (String) outputTable.getValueAt(i, 0); String from = (String) outputTable.getValueAt(i, 1); String to = (String) outputTable.getValueAt(i, 2); String line = ""; - if (from.equals("00:00:00") && to.equals("00:00:00")){ + if (from.equals("00:00:00") && to.equals("00:00:00")) { line = url; - } - else{ + } else { line = url + "," + from + "-" + to; } - try{ - writer.write(line + System.lineSeparator()); - } - catch (Exception ignored){ - } + writer.write(line + System.lineSeparator()); System.out.println(line); } writer.close(); |
