()
| 348 | } |
| 349 | |
| 350 | private void saveMatches() { |
| 351 | SelectedFile res = Gui.requestFile("Save matches file", gui.getScene().getWindow(), Arrays.asList(new FileChooser.ExtensionFilter("Matches", "*.match")), false); |
| 352 | if (res == null) return; |
| 353 | |
| 354 | Path path = res.path; |
| 355 | |
| 356 | if (!path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".match")) { |
| 357 | path = path.resolveSibling(path.getFileName().toString()+".match"); |
| 358 | } |
| 359 | |
| 360 | try { |
| 361 | if (Files.isDirectory(path)) { |
| 362 | gui.showAlert(AlertType.ERROR, "Save error", "Invalid file selection", "The selected file is a directory."); |
| 363 | } else if (Files.exists(path)) { |
| 364 | Files.deleteIfExists(path); |
| 365 | } |
| 366 | |
| 367 | if (!MatchesIo.write(gui.getMatcher(), path)) { |
| 368 | gui.showAlert(AlertType.WARNING, "Matches save warning", "No matches to save", "There are currently no matched classes, so saving was aborted."); |
| 369 | } |
| 370 | } catch (IOException e) { |
| 371 | // TODO Auto-generated catch block |
| 372 | e.printStackTrace(); |
| 373 | return; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | private final Gui gui; |
| 378 | } |
no test coverage detected