summaryrefslogtreecommitdiff
path: root/enigma-swing
diff options
context:
space:
mode:
Diffstat (limited to 'enigma-swing')
-rw-r--r--enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java1
-rw-r--r--enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java26
-rw-r--r--enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java6
-rw-r--r--enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java11
4 files changed, 26 insertions, 18 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java
index 05146d4a..21120b8a 100644
--- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java
+++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java
@@ -147,6 +147,7 @@ public class Gui {
147 147
148 private void setupUi() { 148 private void setupUi() {
149 this.jarFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 149 this.jarFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
150 this.jarFileChooser.setMultiSelectionEnabled(true);
150 151
151 this.exportSourceFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 152 this.exportSourceFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
152 this.exportSourceFileChooser.setAcceptAllFileFilterUsed(false); 153 this.exportSourceFileChooser.setAcceptAllFileFilterUsed(false);
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java
index ad10abfc..ece11b00 100644
--- a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java
+++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java
@@ -23,6 +23,7 @@ import java.util.Objects;
23import java.util.Set; 23import java.util.Set;
24import java.util.concurrent.CompletableFuture; 24import java.util.concurrent.CompletableFuture;
25import java.util.concurrent.ExecutionException; 25import java.util.concurrent.ExecutionException;
26import java.util.stream.Collectors;
26import java.util.stream.Stream; 27import java.util.stream.Stream;
27 28
28import javax.swing.JOptionPane; 29import javax.swing.JOptionPane;
@@ -119,20 +120,27 @@ public class GuiController implements ClientPacketHandler {
119 return project != null && project.getMapper().isDirty(); 120 return project != null && project.getMapper().isDirty();
120 } 121 }
121 122
122 public CompletableFuture<Void> openJar(final Path jarPath) { 123 public CompletableFuture<Void> openJar(final List<Path> jarPaths) {
123 this.gui.onStartOpenJar(); 124 this.gui.onStartOpenJar();
124 125
125 return ProgressDialog.runOffThread(gui.getFrame(), progress -> { 126 return ProgressDialog.runOffThread(gui.getFrame(), progress -> {
126 project = enigma.openJar(jarPath, new ClasspathClassProvider(), progress); 127 project = enigma.openJars(jarPaths, new ClasspathClassProvider(), progress);
127 indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); 128 indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex());
128 chp = new ClassHandleProvider(project, UiConfig.getDecompiler().service); 129 chp = new ClassHandleProvider(project, UiConfig.getDecompiler().service);
129 SwingUtilities.invokeLater(() -> { 130 SwingUtilities.invokeLater(() -> {
130 gui.onFinishOpenJar(jarPath.getFileName().toString()); 131 gui.onFinishOpenJar(getFileNames(jarPaths));
131 refreshClasses(); 132 refreshClasses();
132 }); 133 });
133 }); 134 });
134 } 135 }
135 136
137 private static String getFileNames(List<Path> jarPaths) {
138 return jarPaths.stream()
139 .map(Path::getFileName)
140 .map(Object::toString)
141 .collect(Collectors.joining(", "));
142 }
143
136 public void closeJar() { 144 public void closeJar() {
137 this.chp.destroy(); 145 this.chp.destroy();
138 this.chp = null; 146 this.chp = null;
@@ -241,17 +249,15 @@ public class GuiController implements ClientPacketHandler {
241 } 249 }
242 250
243 public void reloadAll() { 251 public void reloadAll() {
244 Path jarPath = this.project.getJarPath(); 252 List<Path> jarPaths = this.project.getJarPaths();
245 MappingFormat loadedMappingFormat = this.loadedMappingFormat; 253 MappingFormat loadedMappingFormat = this.loadedMappingFormat;
246 Path loadedMappingPath = this.loadedMappingPath; 254 Path loadedMappingPath = this.loadedMappingPath;
247 255
248 if (jarPath != null) { 256 this.closeJar();
249 this.closeJar(); 257 CompletableFuture<Void> f = this.openJar(jarPaths);
250 CompletableFuture<Void> f = this.openJar(jarPath);
251 258
252 if (loadedMappingFormat != null && loadedMappingPath != null) { 259 if (loadedMappingFormat != null && loadedMappingPath != null) {
253 f.whenComplete((v, t) -> this.openMappings(loadedMappingFormat, loadedMappingPath)); 260 f.whenComplete((v, t) -> this.openMappings(loadedMappingFormat, loadedMappingPath));
254 }
255 } 261 }
256 } 262 }
257 263
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java
index 213a5fea..43b16cd9 100644
--- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java
+++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Main.java
@@ -38,7 +38,7 @@ public class Main {
38 public static void main(String[] args) throws IOException { 38 public static void main(String[] args) throws IOException {
39 OptionParser parser = new OptionParser(); 39 OptionParser parser = new OptionParser();
40 40
41 OptionSpec<Path> jar = parser.accepts("jar", "Jar file to open at startup").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); 41 OptionSpec<Path> jar = parser.accepts("jar", "Jar file to open at startup; if there are multiple jars, the order must be the same between all collab session members").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE);
42 42
43 OptionSpec<Path> mappings = parser.accepts("mappings", "Mappings file to open at startup").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE); 43 OptionSpec<Path> mappings = parser.accepts("mappings", "Mappings file to open at startup").withRequiredArg().withValuesConvertedBy(PathConverter.INSTANCE);
44 44
@@ -137,8 +137,8 @@ public class Main {
137 } 137 }
138 138
139 if (options.has(jar)) { 139 if (options.has(jar)) {
140 Path jarPath = options.valueOf(jar); 140 List<Path> jarPaths = options.valuesOf(jar);
141 controller.openJar(jarPath).whenComplete((v, t) -> { 141 controller.openJar(jarPaths).whenComplete((v, t) -> {
142 if (options.has(mappings)) { 142 if (options.has(mappings)) {
143 Path mappingsPath = options.valueOf(mappings); 143 Path mappingsPath = options.valueOf(mappings);
144 144
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
index d7054f78..78050bb3 100644
--- a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
+++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
@@ -7,6 +7,7 @@ import java.io.IOException;
7import java.nio.file.Files; 7import java.nio.file.Files;
8import java.nio.file.Path; 8import java.nio.file.Path;
9import java.util.Arrays; 9import java.util.Arrays;
10import java.util.List;
10import java.util.Locale; 11import java.util.Locale;
11import java.util.Map; 12import java.util.Map;
12import java.util.stream.Collectors; 13import java.util.stream.Collectors;
@@ -235,15 +236,15 @@ public class MenuBar {
235 return; 236 return;
236 } 237 }
237 238
238 File file = d.getSelectedFile(); 239 File[] files = d.getSelectedFiles();
239 240
240 // checks if the file name is not empty 241 // checks if the file name is not empty
241 if (file != null) { 242 if (files.length >= 1) {
242 Path path = file.toPath(); 243 List<Path> paths = Arrays.stream(files).map(File::toPath).toList();
243 244
244 // checks if the file name corresponds to an existing file 245 // checks if the file name corresponds to an existing file
245 if (Files.exists(path)) { 246 if (paths.stream().allMatch(Files::exists)) {
246 this.gui.getController().openJar(path); 247 this.gui.getController().openJar(paths);
247 } 248 }
248 249
249 UiConfig.setLastSelectedDir(d.getCurrentDirectory().getAbsolutePath()); 250 UiConfig.setLastSelectedDir(d.getCurrentDirectory().getAbsolutePath());