■ ■ ■ ■ ■ ■
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
| skipped 43 lines |
44 | 44 | | import javax.swing.Box; |
45 | 45 | | import javax.swing.ImageIcon; |
46 | 46 | | import javax.swing.JCheckBoxMenuItem; |
| 47 | + | import javax.swing.JFileChooser; |
47 | 48 | | import javax.swing.JFrame; |
48 | 49 | | import javax.swing.JMenu; |
49 | 50 | | import javax.swing.JMenuBar; |
| skipped 35 lines |
85 | 86 | | import jadx.api.ResourceFile; |
86 | 87 | | import jadx.api.plugins.utils.CommonFileUtils; |
87 | 88 | | import jadx.core.Jadx; |
88 | | - | import jadx.core.dex.nodes.RootNode; |
89 | 89 | | import jadx.core.utils.ListUtils; |
90 | 90 | | import jadx.core.utils.StringUtils; |
91 | 91 | | import jadx.core.utils.files.FileUtils; |
| skipped 270 lines |
362 | 362 | | } |
363 | 363 | | |
364 | 364 | | private void exportMappings(MappingFormat mappingFormat) { |
365 | | - | RootNode rootNode = wrapper.getDecompiler().getRoot(); |
366 | | - | |
367 | | - | Thread exportThread = new Thread(() -> { |
368 | | - | new MappingExporter(rootNode).exportMappings( |
369 | | - | Paths.get(project.getProjectPath().getParent().toString(), |
370 | | - | "mappings" + (mappingFormat.hasSingleFile() ? "." + mappingFormat.fileExt : "")), |
371 | | - | project.getCodeData(), mappingFormat); |
372 | | - | }); |
373 | | - | |
374 | | - | backgroundExecutor.execute(NLS.str("progress.export_mappings"), exportThread); |
375 | | - | update(); |
| 365 | + | FileDialog fileDialog = new FileDialog(this, FileDialog.OpenMode.CUSTOM_SAVE); |
| 366 | + | fileDialog.setTitle(NLS.str("file.export_mappings_as")); |
| 367 | + | Path workingDir = project.getWorkingDir(); |
| 368 | + | Path baseDir = workingDir != null ? workingDir : settings.getLastSaveFilePath(); |
| 369 | + | if (mappingFormat.hasSingleFile()) { |
| 370 | + | fileDialog.setSelectedFile(baseDir.resolve("mappings." + mappingFormat.fileExt)); |
| 371 | + | fileDialog.setFileExtList(Collections.singletonList(mappingFormat.fileExt)); |
| 372 | + | fileDialog.setSelectionMode(JFileChooser.FILES_ONLY); |
| 373 | + | } else { |
| 374 | + | fileDialog.setCurrentDir(baseDir); |
| 375 | + | fileDialog.setSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
| 376 | + | } |
| 377 | + | List<Path> paths = fileDialog.show(); |
| 378 | + | if (paths.size() != 1) { |
| 379 | + | return; |
| 380 | + | } |
| 381 | + | Path savePath = paths.get(0); |
| 382 | + | LOG.info("Export mappings to: {}", savePath.toAbsolutePath()); |
| 383 | + | backgroundExecutor.execute(NLS.str("progress.export_mappings"), |
| 384 | + | () -> new MappingExporter(wrapper.getDecompiler().getRoot()) |
| 385 | + | .exportMappings(savePath, project.getCodeData(), mappingFormat), |
| 386 | + | s -> update()); |
376 | 387 | | } |
377 | 388 | | |
378 | 389 | | void open(List<Path> paths) { |
| skipped 1194 lines |