diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 7499b632df1772f84cf5702add49c21b09c729e8..942f3a230a27110a1a66c7cbfc929695518e67d9 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -2,5 +2,6 @@ <project version="4"> <component name="Encoding"> <file url="file://$PROJECT_DIR$/src/main/kotlin" charset="UTF-8" /> + <file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" /> </component> </project> \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 797acea53eb091cf5b30518802c3073f544adeed..0000000000000000000000000000000000000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="RunConfigurationProducerService"> - <option name="ignoredProducers"> - <set> - <option value="com.android.tools.idea.compose.preview.runconfiguration.ComposePreviewRunConfigurationProducer" /> - </set> - </option> - </component> -</project> \ No newline at end of file diff --git a/src/main/kotlin/ihm/td5b/controleur/ControleurSuppression.kt b/src/main/kotlin/ihm/td5b/controleur/ControleurSuppression.kt index 1009bdc638f45baa593c9f9c518133d1ea0d5e28..4a1793f084c0ccbc1d3c9b06488b49e6ad7c094f 100644 --- a/src/main/kotlin/ihm/td5b/controleur/ControleurSuppression.kt +++ b/src/main/kotlin/ihm/td5b/controleur/ControleurSuppression.kt @@ -4,15 +4,32 @@ import ihm.td5b.Bibliotheque import ihm.td5b.MainVue import javafx.event.ActionEvent import javafx.event.EventHandler - +import javafx.scene.control.Alert +import javafx.scene.control.ButtonType class ControleurSuppression(vue: MainVue, modele: Bibliotheque): EventHandler<ActionEvent> { - //TODO - override fun handle(event: ActionEvent) { + private val vue: MainVue + private val modele: Bibliotheque + + init { + this.vue = vue + this.modele = modele + } - //TODO + private fun supprimer(){ + modele.suppressionLivre() + vue.updateLivres(modele.livres, modele.courant) + vue.panneauDroit.update(modele.courant, modele.donneLivre()) + vue.updateLivres(modele.livres, ControleurDetailLivre(vue, modele), 0) + } + + override fun handle(event: ActionEvent) { + val alert = Alert(Alert.AlertType.CONFIRMATION) + alert.title = "Boîte de dialogue de confirmation" + alert.headerText = "Voulez-vous vraiment supprimer ce livre ?" + alert.showAndWait().filter{i -> i == ButtonType.OK}.ifPresent { supprimer() } } }