summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/elements
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/elements')
-rw-r--r--src/main/java/cuchaz/enigma/gui/elements/MenuBar.java21
1 files changed, 4 insertions, 17 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
index 14ad53d..d7be1a9 100644
--- a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
+++ b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
@@ -5,7 +5,6 @@ import cuchaz.enigma.config.Themes;
5import cuchaz.enigma.gui.Gui; 5import cuchaz.enigma.gui.Gui;
6import cuchaz.enigma.gui.dialog.AboutDialog; 6import cuchaz.enigma.gui.dialog.AboutDialog;
7import cuchaz.enigma.gui.dialog.SearchDialog; 7import cuchaz.enigma.gui.dialog.SearchDialog;
8import cuchaz.enigma.throwables.MappingParseException;
9import cuchaz.enigma.translation.mapping.serde.MappingFormat; 8import cuchaz.enigma.translation.mapping.serde.MappingFormat;
10 9
11import javax.swing.*; 10import javax.swing.*;
@@ -68,15 +67,9 @@ public class MenuBar extends JMenuBar {
68 openMenu.add(item); 67 openMenu.add(item);
69 item.addActionListener(event -> { 68 item.addActionListener(event -> {
70 if (this.gui.enigmaMappingsFileChooser.showOpenDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 69 if (this.gui.enigmaMappingsFileChooser.showOpenDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
71 try { 70 File selectedFile = this.gui.enigmaMappingsFileChooser.getSelectedFile();
72 File selectedFile = this.gui.enigmaMappingsFileChooser.getSelectedFile(); 71 MappingFormat format = selectedFile.isDirectory() ? MappingFormat.ENIGMA_DIRECTORY : MappingFormat.ENIGMA_FILE;
73 MappingFormat format = selectedFile.isDirectory() ? MappingFormat.ENIGMA_DIRECTORY : MappingFormat.ENIGMA_FILE; 72 this.gui.getController().openMappings(format, selectedFile.toPath());
74 this.gui.getController().openMappings(format, selectedFile.toPath());
75 } catch (IOException ex) {
76 throw new Error(ex);
77 } catch (MappingParseException ex) {
78 JOptionPane.showMessageDialog(this.gui.getFrame(), ex.getMessage());
79 }
80 } 73 }
81 }); 74 });
82 this.openEnigmaMappingsMenu = item; 75 this.openEnigmaMappingsMenu = item;
@@ -87,13 +80,7 @@ public class MenuBar extends JMenuBar {
87 this.gui.tinyMappingsFileChooser.setVisible(true); 80 this.gui.tinyMappingsFileChooser.setVisible(true);
88 File file = new File(this.gui.tinyMappingsFileChooser.getDirectory() + File.separator + this.gui.tinyMappingsFileChooser.getFile()); 81 File file = new File(this.gui.tinyMappingsFileChooser.getDirectory() + File.separator + this.gui.tinyMappingsFileChooser.getFile());
89 if (file.exists()) { 82 if (file.exists()) {
90 try { 83 this.gui.getController().openMappings(MappingFormat.TINY_FILE, file.toPath());
91 this.gui.getController().openMappings(MappingFormat.TINY_FILE, file.toPath());
92 } catch (IOException ex) {
93 throw new Error(ex);
94 } catch (MappingParseException ex) {
95 JOptionPane.showMessageDialog(this.gui.getFrame(), ex.getMessage());
96 }
97 } 84 }
98 }); 85 });
99 this.openTinyMappingsMenu = item; 86 this.openTinyMappingsMenu = item;