alert if import failed

This commit is contained in:
Hendrik Schutter 2019-06-08 14:20:48 +02:00
parent be11f35159
commit 89ef736954

View File

@ -51,7 +51,7 @@ class RootController : Controller() {
* @param tags all tags for the file
*/
fun importTexture(path: String, name: String, tags: ObservableList<String>) {
val data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
var data = Files.readAllBytes(File(path).toPath()) // this is the image as byte array
val uuid = UUID.randomUUID()
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
@ -60,15 +60,33 @@ class RootController : Controller() {
val cal = Calendar.getInstance() //calendar obj with current time
val hash = Sha256(data)
//Todo free image
val alertImportHash = JFXInfoAlert(
"Upload fehlgeschlagen",
"Die Textur wurde nicht fehlerfrei übertragen",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
val alertImport = JFXInfoAlert(
"Upload fehlgeschlagen",
"Mögliche Ursachen:" +
"\n- Textur existiert bereits" +
"\n- Server nicht bereit",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)
data = null //Free image
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
try {
con.uploadTexture(newTexture, data)
println("Texture upload successful")
} catch (e: Exception) {
} catch (e: IllegalArgumentException) {
println(e)
alertImportHash.showAndWait()
} catch (e: Exception) {
alertImport.showAndWait()
}
}
@ -180,8 +198,8 @@ class RootController : Controller() {
val alertExport = JFXInfoAlert(
"Exporterien fehlgeschlagen",
"Mögliche Ursachen:" +
"\n-Datei existiert bereits" +
"\n-Ordner nicht beschreibbar",
"\n- Datei existiert bereits" +
"\n- Ordner nicht beschreibbar",
"-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;"
)