summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/elements
diff options
context:
space:
mode:
authorGravatar gegy10002019-06-16 23:49:25 +0200
committerGravatar gegy10002019-06-16 23:49:25 +0200
commite27d5967029f4f3da8889dd673ba516dcd9f3ac8 (patch)
tree71c98afad01cafdb2884da288e494e8761c2a8ff /src/main/java/cuchaz/enigma/gui/elements
parentMerge remote-tracking branch 'origin/master' into proposal-tweak (diff)
downloadenigma-fork-e27d5967029f4f3da8889dd673ba516dcd9f3ac8.tar.gz
enigma-fork-e27d5967029f4f3da8889dd673ba516dcd9f3ac8.tar.xz
enigma-fork-e27d5967029f4f3da8889dd673ba516dcd9f3ac8.zip
Plugin rework along with API rework: Enigma split from EnigmaProject; plugins now provide services configurable via a profile
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/elements')
-rw-r--r--src/main/java/cuchaz/enigma/gui/elements/MenuBar.java33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
index 98275b4..5578325 100644
--- a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
+++ b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
@@ -13,10 +13,11 @@ import java.awt.event.InputEvent;
13import java.awt.event.KeyEvent; 13import java.awt.event.KeyEvent;
14import java.io.File; 14import java.io.File;
15import java.io.IOException; 15import java.io.IOException;
16import java.net.MalformedURLException;
17import java.net.URISyntaxException; 16import java.net.URISyntaxException;
18import java.net.URL; 17import java.net.URL;
19import java.util.jar.JarFile; 18import java.nio.file.Files;
19import java.nio.file.Path;
20import java.nio.file.Paths;
20 21
21public class MenuBar extends JMenuBar { 22public class MenuBar extends JMenuBar {
22 23
@@ -43,17 +44,9 @@ public class MenuBar extends JMenuBar {
43 menu.add(item); 44 menu.add(item);
44 item.addActionListener(event -> { 45 item.addActionListener(event -> {
45 this.gui.jarFileChooser.setVisible(true); 46 this.gui.jarFileChooser.setVisible(true);
46 File file = new File(this.gui.jarFileChooser.getDirectory() + File.separator + this.gui.jarFileChooser.getFile()); 47 Path path = Paths.get(this.gui.jarFileChooser.getDirectory()).resolve(this.gui.jarFileChooser.getFile());
47 if (file.exists()) { 48 if (Files.exists(path)) {
48 // load the jar in a separate thread 49 gui.getController().openJar(path);
49 new Thread(() ->
50 {
51 try {
52 gui.getController().openJar(new JarFile(file));
53 } catch (IOException ex) {
54 throw new Error(ex);
55 }
56 }).start();
57 } 50 }
58 }); 51 });
59 } 52 }
@@ -106,7 +99,7 @@ public class MenuBar extends JMenuBar {
106 item.addActionListener(event -> { 99 item.addActionListener(event -> {
107 // TODO: Use a specific file chooser for it 100 // TODO: Use a specific file chooser for it
108 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 101 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
109 this.gui.getController().saveMappings(MappingFormat.ENIGMA_FILE, this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath()); 102 this.gui.getController().saveMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath(), MappingFormat.ENIGMA_FILE);
110 this.saveMappingsMenu.setEnabled(true); 103 this.saveMappingsMenu.setEnabled(true);
111 } 104 }
112 }); 105 });
@@ -118,7 +111,7 @@ public class MenuBar extends JMenuBar {
118 item.addActionListener(event -> { 111 item.addActionListener(event -> {
119 // TODO: Use a specific file chooser for it 112 // TODO: Use a specific file chooser for it
120 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 113 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
121 this.gui.getController().saveMappings(MappingFormat.ENIGMA_DIRECTORY, this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath()); 114 this.gui.getController().saveMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath(), MappingFormat.ENIGMA_DIRECTORY);
122 this.saveMappingsMenu.setEnabled(true); 115 this.saveMappingsMenu.setEnabled(true);
123 } 116 }
124 }); 117 });
@@ -131,7 +124,7 @@ public class MenuBar extends JMenuBar {
131 item.addActionListener(event -> { 124 item.addActionListener(event -> {
132 // TODO: Use a specific file chooser for it 125 // TODO: Use a specific file chooser for it
133 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 126 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
134 this.gui.getController().saveMappings(MappingFormat.SRG_FILE, this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath()); 127 this.gui.getController().saveMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath(), MappingFormat.SRG_FILE);
135 this.saveMappingsMenu.setEnabled(true); 128 this.saveMappingsMenu.setEnabled(true);
136 } 129 }
137 }); 130 });
@@ -162,7 +155,7 @@ public class MenuBar extends JMenuBar {
162 menu.add(item); 155 menu.add(item);
163 item.addActionListener(event -> { 156 item.addActionListener(event -> {
164 if (this.gui.exportSourceFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 157 if (this.gui.exportSourceFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
165 this.gui.getController().exportSource(this.gui.exportSourceFileChooser.getSelectedFile()); 158 this.gui.getController().exportSource(this.gui.exportSourceFileChooser.getSelectedFile().toPath());
166 } 159 }
167 }); 160 });
168 this.exportSourceMenu = item; 161 this.exportSourceMenu = item;
@@ -173,8 +166,8 @@ public class MenuBar extends JMenuBar {
173 item.addActionListener(event -> { 166 item.addActionListener(event -> {
174 this.gui.exportJarFileChooser.setVisible(true); 167 this.gui.exportJarFileChooser.setVisible(true);
175 if (this.gui.exportJarFileChooser.getFile() != null) { 168 if (this.gui.exportJarFileChooser.getFile() != null) {
176 File file = new File(this.gui.exportJarFileChooser.getDirectory() + File.separator + this.gui.exportJarFileChooser.getFile()); 169 Path path = Paths.get(this.gui.exportJarFileChooser.getDirectory(), this.gui.exportJarFileChooser.getFile());
177 this.gui.getController().exportJar(file); 170 this.gui.getController().exportJar(path);
178 } 171 }
179 }); 172 });
180 this.exportJarMenu = item; 173 this.exportJarMenu = item;
@@ -202,7 +195,7 @@ public class MenuBar extends JMenuBar {
202 search.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_MASK)); 195 search.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.SHIFT_MASK));
203 menu.add(search); 196 menu.add(search);
204 search.addActionListener(event -> { 197 search.addActionListener(event -> {
205 if (this.gui.getController().getDeobfuscator() != null) { 198 if (this.gui.getController().project != null) {
206 new SearchDialog(this.gui).show(); 199 new SearchDialog(this.gui).show();
207 } 200 }
208 }); 201 });