add ErrorAlert

This commit is contained in:
Denis-Cosmin NUTIU 2024-04-06 17:31:13 +03:00
parent 1f094b33c6
commit 018e6291c8
2 changed files with 18 additions and 8 deletions

View file

@ -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()
}
}
}

View file

@ -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<Str
}
} else {
logger.severe("Cannot open image $imagePath. Desktop action not supported!")
val alert =
Alert(AlertType.ERROR, "Can't open file: $imagePath\nOperation is not supported!", ButtonType.CLOSE)
alert.dialogPane.minHeight = Region.USE_PREF_SIZE
alert.show()
ErrorAlert("Can't open file: $imagePath\nOperation is not supported!")
}
}
}