From 018e6291c88aa4b5f3839909eb7d85bfe1c07bd7 Mon Sep 17 00:00:00 2001 From: Denis-Cosmin NUTIU Date: Sat, 6 Apr 2024 17:31:13 +0300 Subject: [PATCH] add ErrorAlert --- .../nuculabs/imagetagger/ui/alerts/ErrorAlert.kt | 16 ++++++++++++++++ .../ui/controls/ImageTagsEntryControl.kt | 10 ++-------- 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/alerts/ErrorAlert.kt diff --git a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/alerts/ErrorAlert.kt b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/alerts/ErrorAlert.kt new file mode 100644 index 0000000..622aba3 --- /dev/null +++ b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/alerts/ErrorAlert.kt @@ -0,0 +1,16 @@ +package dev.nuculabs.imagetagger.ui.alerts + +import javafx.scene.control.Alert +import javafx.scene.control.ButtonType +import javafx.scene.layout.Region + +class ErrorAlert(var message: String, var show: Boolean = true) : Alert(AlertType.ERROR) { + init { + contentText = message + dialogPane.buttonTypes.add(ButtonType.CLOSE) + dialogPane.minHeight = Region.USE_PREF_SIZE + if (show) { + show() + } + } +} \ No newline at end of file diff --git a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt index d592993..b076536 100644 --- a/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt +++ b/img-ui/src/main/kotlin/dev/nuculabs/imagetagger/ui/controls/ImageTagsEntryControl.kt @@ -1,17 +1,14 @@ package dev.nuculabs.imagetagger.ui.controls +import dev.nuculabs.imagetagger.ui.alerts.ErrorAlert import javafx.fxml.FXML import javafx.fxml.FXMLLoader -import javafx.scene.control.Alert -import javafx.scene.control.Alert.AlertType -import javafx.scene.control.ButtonType import javafx.scene.control.Label import javafx.scene.control.TextArea import javafx.scene.image.Image import javafx.scene.image.ImageView import javafx.scene.input.MouseEvent import javafx.scene.layout.HBox -import javafx.scene.layout.Region import java.awt.Desktop import java.io.File import java.io.IOException @@ -105,10 +102,7 @@ class ImageTagsEntryControl(private val imagePath: String, predictions: List