Export the current Workspace#getAggregatedMappings() aggregated mappings to the given format. @param impl Mapping implementation to use.
(MappingImpl impl)
| 344 | * Mapping implementation to use. |
| 345 | */ |
| 346 | private void exportMap(MappingImpl impl) { |
| 347 | if (controller.getWorkspace() == null) { |
| 348 | return; |
| 349 | } |
| 350 | |
| 351 | fcSaveMap.setInitialDirectory(config().getRecentSaveMapDir()); |
| 352 | File file = fcSaveMap.showSaveDialog(null); |
| 353 | if (file != null) { |
| 354 | // TODO: Make the Mappings classes do this conversion for their respective format |
| 355 | String fullMapping = controller.getWorkspace().getAggregatedMappings().entrySet().stream() |
| 356 | .map(e -> e.getKey() + " " + e.getValue()) |
| 357 | .collect(Collectors.joining("\n")); |
| 358 | try { |
| 359 | FileUtils.write(file, fullMapping, UTF_8); |
| 360 | config().recentSaveMap = file.getAbsolutePath(); |
| 361 | } catch(IOException ex) { |
| 362 | error(ex, "Failed to save simple mapping to file: {}", file.getName()); |
| 363 | ExceptionAlert.show(ex, "Failed to save simple mapping to file: " + file.getName()); |
| 364 | } |
| 365 | |
| 366 | } |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * Load a file and apply mappings of the given type. |
no test coverage detected