MCPcopy Create free account
hub / github.com/FabricMC/Matcher / saveMatches

Method saveMatches

src/main/java/matcher/gui/menu/FileMenu.java:350–375  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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}

Callers 1

initMethod · 0.95

Calls 6

requestFileMethod · 0.95
writeMethod · 0.95
getSceneMethod · 0.80
showAlertMethod · 0.80
getMatcherMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected