diff options
| author | 2020-04-04 17:59:41 +0200 | |
|---|---|---|
| committer | 2020-04-04 11:59:41 -0400 | |
| commit | 54a23336a06e43bfb2c19c7cdead5594f06edd16 (patch) | |
| tree | 1bbee080c828e8c77aedc6e4fab555ae7b632a3a /src/main | |
| parent | Fix division by zero (#189) (diff) | |
| download | enigma-54a23336a06e43bfb2c19c7cdead5594f06edd16.tar.gz enigma-54a23336a06e43bfb2c19c7cdead5594f06edd16.tar.xz enigma-54a23336a06e43bfb2c19c7cdead5594f06edd16.zip | |
Added export functionality to CrashDialog.java (#208)
* Added export functionality to CrashDialog.java
* Update french crash.export translation
Co-Authored-By: Yanis48 <doublecraft.official@gmail.com>
Co-authored-by: Yanis48 <doublecraft.official@gmail.com>
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java | 24 | ||||
| -rw-r--r-- | src/main/resources/lang/en_us.json | 1 | ||||
| -rw-r--r-- | src/main/resources/lang/fr_fr.json | 1 |
3 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java index 7e66ecde..3921b513 100644 --- a/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java +++ b/src/main/java/cuchaz/enigma/gui/dialog/CrashDialog.java | |||
| @@ -19,6 +19,9 @@ import javax.swing.*; | |||
| 19 | import java.awt.*; | 19 | import java.awt.*; |
| 20 | import java.io.PrintWriter; | 20 | import java.io.PrintWriter; |
| 21 | import java.io.StringWriter; | 21 | import java.io.StringWriter; |
| 22 | import java.io.FileWriter; | ||
| 23 | import java.io.File; | ||
| 24 | import java.io.IOException; | ||
| 22 | 25 | ||
| 23 | public class CrashDialog { | 26 | public class CrashDialog { |
| 24 | 27 | ||
| @@ -44,9 +47,24 @@ public class CrashDialog { | |||
| 44 | 47 | ||
| 45 | // buttons panel | 48 | // buttons panel |
| 46 | JPanel buttonsPanel = new JPanel(); | 49 | JPanel buttonsPanel = new JPanel(); |
| 47 | FlowLayout buttonsLayout = new FlowLayout(); | 50 | buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS)); |
| 48 | buttonsLayout.setAlignment(FlowLayout.RIGHT); | 51 | JButton exportButton = new JButton(I18n.translate("crash.export")); |
| 49 | buttonsPanel.setLayout(buttonsLayout); | 52 | exportButton.addActionListener(event -> { |
| 53 | JFileChooser chooser = new JFileChooser(); | ||
| 54 | chooser.setSelectedFile(new File("enigma_crash.log")); | ||
| 55 | if (chooser.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { | ||
| 56 | try { | ||
| 57 | File file = chooser.getSelectedFile(); | ||
| 58 | FileWriter writer = new FileWriter(file); | ||
| 59 | writer.write(instance.text.getText()); | ||
| 60 | writer.close(); | ||
| 61 | } catch (IOException ex) { | ||
| 62 | ex.printStackTrace(); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | }); | ||
| 66 | buttonsPanel.add(exportButton); | ||
| 67 | buttonsPanel.add(Box.createHorizontalGlue()); | ||
| 50 | buttonsPanel.add(Utils.unboldLabel(new JLabel(I18n.translate("crash.exit.warning")))); | 68 | buttonsPanel.add(Utils.unboldLabel(new JLabel(I18n.translate("crash.exit.warning")))); |
| 51 | JButton ignoreButton = new JButton(I18n.translate("crash.ignore")); | 69 | JButton ignoreButton = new JButton(I18n.translate("crash.ignore")); |
| 52 | ignoreButton.addActionListener(event -> { | 70 | ignoreButton.addActionListener(event -> { |
diff --git a/src/main/resources/lang/en_us.json b/src/main/resources/lang/en_us.json index dbba1983..9c114bb9 100644 --- a/src/main/resources/lang/en_us.json +++ b/src/main/resources/lang/en_us.json | |||
| @@ -111,6 +111,7 @@ | |||
| 111 | 111 | ||
| 112 | "crash.title": "%s - Crash Report", | 112 | "crash.title": "%s - Crash Report", |
| 113 | "crash.summary": "%s has crashed! =(", | 113 | "crash.summary": "%s has crashed! =(", |
| 114 | "crash.export": "Export", | ||
| 114 | "crash.ignore": "Ignore", | 115 | "crash.ignore": "Ignore", |
| 115 | "crash.exit": "Exit", | 116 | "crash.exit": "Exit", |
| 116 | "crash.exit.warning": "If you choose exit, you will lose any unsaved work." | 117 | "crash.exit.warning": "If you choose exit, you will lose any unsaved work." |
diff --git a/src/main/resources/lang/fr_fr.json b/src/main/resources/lang/fr_fr.json index 5c4c514f..cbd56d0b 100644 --- a/src/main/resources/lang/fr_fr.json +++ b/src/main/resources/lang/fr_fr.json | |||
| @@ -110,6 +110,7 @@ | |||
| 110 | 110 | ||
| 111 | "crash.title": "%s - Rapport de plantage", | 111 | "crash.title": "%s - Rapport de plantage", |
| 112 | "crash.summary": "%s a planté ! =(", | 112 | "crash.summary": "%s a planté ! =(", |
| 113 | "crash.export": "Exporter", | ||
| 113 | "crash.ignore": "Ignorer", | 114 | "crash.ignore": "Ignorer", |
| 114 | "crash.exit": "Quitter", | 115 | "crash.exit": "Quitter", |
| 115 | "crash.exit.warning": "Si vous choisissez Quitter, vous perdrez tout travail non sauvegardé." | 116 | "crash.exit.warning": "Si vous choisissez Quitter, vous perdrez tout travail non sauvegardé." |