diff options
| author | 2019-06-19 20:28:01 +0200 | |
|---|---|---|
| committer | 2019-06-19 20:28:01 +0200 | |
| commit | e9f9f8f29f2504bb750ea0af11840c1aa746b476 (patch) | |
| tree | c08d8cec3387b535141cee9bd7ffddd5bb431652 /src/main/java/cuchaz/enigma/gui/GuiController.java | |
| parent | Merge pull request #150 from Runemoro/short-inner-class-names (diff) | |
| download | enigma-fork-e9f9f8f29f2504bb750ea0af11840c1aa746b476.tar.gz enigma-fork-e9f9f8f29f2504bb750ea0af11840c1aa746b476.tar.xz enigma-fork-e9f9f8f29f2504bb750ea0af11840c1aa746b476.zip | |
Only open mappings once jar is loaded
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/GuiController.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/GuiController.java | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java index 209b5d1..092a07e 100644 --- a/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -42,6 +42,7 @@ import java.nio.file.Path; | |||
| 42 | import java.util.Collection; | 42 | import java.util.Collection; |
| 43 | import java.util.List; | 43 | import java.util.List; |
| 44 | import java.util.Optional; | 44 | import java.util.Optional; |
| 45 | import java.util.concurrent.CompletableFuture; | ||
| 45 | import java.util.concurrent.ExecutorService; | 46 | import java.util.concurrent.ExecutorService; |
| 46 | import java.util.concurrent.Executors; | 47 | import java.util.concurrent.Executors; |
| 47 | import java.util.stream.Collectors; | 48 | import java.util.stream.Collectors; |
| @@ -78,10 +79,10 @@ public class GuiController { | |||
| 78 | return project != null && project.getMapper().isDirty(); | 79 | return project != null && project.getMapper().isDirty(); |
| 79 | } | 80 | } |
| 80 | 81 | ||
| 81 | public void openJar(final Path jarPath) { | 82 | public CompletableFuture<Void> openJar(final Path jarPath) { |
| 82 | this.gui.onStartOpenJar(); | 83 | this.gui.onStartOpenJar(); |
| 83 | 84 | ||
| 84 | ProgressDialog.runOffThread(gui.getFrame(), progress -> { | 85 | return ProgressDialog.runOffThread(gui.getFrame(), progress -> { |
| 85 | project = enigma.openJar(jarPath, progress); | 86 | project = enigma.openJar(jarPath, progress); |
| 86 | 87 | ||
| 87 | indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); | 88 | indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); |
| @@ -101,12 +102,12 @@ public class GuiController { | |||
| 101 | this.gui.onCloseJar(); | 102 | this.gui.onCloseJar(); |
| 102 | } | 103 | } |
| 103 | 104 | ||
| 104 | public void openMappings(MappingFormat format, Path path) { | 105 | public CompletableFuture<Void> openMappings(MappingFormat format, Path path) { |
| 105 | if (project == null) return; | 106 | if (project == null) return CompletableFuture.completedFuture(null); |
| 106 | 107 | ||
| 107 | gui.setMappingsFile(path); | 108 | gui.setMappingsFile(path); |
| 108 | 109 | ||
| 109 | ProgressDialog.runOffThread(gui.getFrame(), progress -> { | 110 | return ProgressDialog.runOffThread(gui.getFrame(), progress -> { |
| 110 | try { | 111 | try { |
| 111 | EntryTree<EntryMapping> mappings = format.read(path, progress); | 112 | EntryTree<EntryMapping> mappings = format.read(path, progress); |
| 112 | project.setMappings(mappings); | 113 | project.setMappings(mappings); |
| @@ -122,16 +123,14 @@ public class GuiController { | |||
| 122 | }); | 123 | }); |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | public void saveMappings(Path path) { | 126 | public CompletableFuture<Void> saveMappings(Path path) { |
| 126 | if (project == null) return; | 127 | return saveMappings(path, loadedMappingFormat); |
| 127 | |||
| 128 | saveMappings(path, loadedMappingFormat); | ||
| 129 | } | 128 | } |
| 130 | 129 | ||
| 131 | public void saveMappings(Path path, MappingFormat format) { | 130 | public CompletableFuture<Void> saveMappings(Path path, MappingFormat format) { |
| 132 | if (project == null) return; | 131 | if (project == null) return CompletableFuture.completedFuture(null); |
| 133 | 132 | ||
| 134 | ProgressDialog.runOffThread(this.gui.getFrame(), progress -> { | 133 | return ProgressDialog.runOffThread(this.gui.getFrame(), progress -> { |
| 135 | EntryRemapper mapper = project.getMapper(); | 134 | EntryRemapper mapper = project.getMapper(); |
| 136 | 135 | ||
| 137 | MappingDelta<EntryMapping> delta = mapper.takeMappingDelta(); | 136 | MappingDelta<EntryMapping> delta = mapper.takeMappingDelta(); |
| @@ -158,16 +157,16 @@ public class GuiController { | |||
| 158 | refreshCurrentClass(); | 157 | refreshCurrentClass(); |
| 159 | } | 158 | } |
| 160 | 159 | ||
| 161 | public void dropMappings() { | 160 | public CompletableFuture<Void> dropMappings() { |
| 162 | if (project == null) return; | 161 | if (project == null) return CompletableFuture.completedFuture(null); |
| 163 | 162 | ||
| 164 | ProgressDialog.runOffThread(this.gui.getFrame(), progress -> project.dropMappings(progress)); | 163 | return ProgressDialog.runOffThread(this.gui.getFrame(), progress -> project.dropMappings(progress)); |
| 165 | } | 164 | } |
| 166 | 165 | ||
| 167 | public void exportSource(final Path path) { | 166 | public CompletableFuture<Void> exportSource(final Path path) { |
| 168 | if (project == null) return; | 167 | if (project == null) return CompletableFuture.completedFuture(null); |
| 169 | 168 | ||
| 170 | ProgressDialog.runOffThread(this.gui.getFrame(), progress -> { | 169 | return ProgressDialog.runOffThread(this.gui.getFrame(), progress -> { |
| 171 | EnigmaProject.JarExport jar = project.exportRemappedJar(progress); | 170 | EnigmaProject.JarExport jar = project.exportRemappedJar(progress); |
| 172 | EnigmaProject.SourceExport source = jar.decompile(progress); | 171 | EnigmaProject.SourceExport source = jar.decompile(progress); |
| 173 | 172 | ||
| @@ -175,10 +174,10 @@ public class GuiController { | |||
| 175 | }); | 174 | }); |
| 176 | } | 175 | } |
| 177 | 176 | ||
| 178 | public void exportJar(final Path path) { | 177 | public CompletableFuture<Void> exportJar(final Path path) { |
| 179 | if (project == null) return; | 178 | if (project == null) return CompletableFuture.completedFuture(null); |
| 180 | 179 | ||
| 181 | ProgressDialog.runOffThread(this.gui.getFrame(), progress -> { | 180 | return ProgressDialog.runOffThread(this.gui.getFrame(), progress -> { |
| 182 | EnigmaProject.JarExport jar = project.exportRemappedJar(progress); | 181 | EnigmaProject.JarExport jar = project.exportRemappedJar(progress); |
| 183 | jar.write(path, progress); | 182 | jar.write(path, progress); |
| 184 | }); | 183 | }); |