Skip to content
Snippets Groups Projects
Commit d355e876 authored by Sverre Grønhaug Halvorsen's avatar Sverre Grønhaug Halvorsen
Browse files

Feat: Add confirmation ask when trying to add transformation that already exists

parent 36e8bd7f
No related branches found
No related tags found
2 merge requests!41final delivery,!35Resolve "Redesign GUI"
Pipeline #288399 passed
...@@ -322,16 +322,15 @@ public class MainPageController { ...@@ -322,16 +322,15 @@ public class MainPageController {
getVector2dFromStringList(maxCoords), getVector2dFromStringList(maxCoords),
getTransformListFromStringList(transform) getTransformListFromStringList(transform)
); );
if (!Files.exists(Path.of(TRANSFORMATIONS_PATH + transformationName + ".txt"))) { if (!Files.exists(Path.of(TRANSFORMATIONS_PATH + transformationName + ".txt"))
|| view.askConfirmation("Custom transformation with the same name already exists. "
+ "Do you want to overwrite it?")) {
chaosGameFileHandler chaosGameFileHandler
.writeToFile(newChaosGameDescription, .writeToFile(newChaosGameDescription,
TRANSFORMATIONS_PATH + transformationName + ".txt"); TRANSFORMATIONS_PATH + transformationName + ".txt");
customTransformations.add(transformationName); customTransformations.add(transformationName);
view.render(); view.render();
view.showAlert("Custom transformation " + transformationName + " added successfully."); view.showAlert("Custom transformation " + transformationName + " added successfully.");
} else {
throw new IllegalArgumentException("Custom transformation with the same name " +
"already exists please change it.");
} }
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment