alert if import failed
This commit is contained in:
parent
be11f35159
commit
89ef736954
@ -51,7 +51,7 @@ class RootController : Controller() {
|
|||||||
* @param tags all tags for the file
|
* @param tags all tags for the file
|
||||||
*/
|
*/
|
||||||
fun importTexture(path: String, name: String, tags: ObservableList<String>) {
|
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 uuid = UUID.randomUUID()
|
||||||
val format = if (File(path).extension.toLowerCase() == "png") TextureFormat.PNG else TextureFormat.JPEG
|
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 cal = Calendar.getInstance() //calendar obj with current time
|
||||||
val hash = Sha256(data)
|
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)
|
val newTexture = Texture(uuid, name, tags.toTypedArray(), format, resolution, cal, hash)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
con.uploadTexture(newTexture, data)
|
con.uploadTexture(newTexture, data)
|
||||||
println("Texture upload successful")
|
println("Texture upload successful")
|
||||||
} catch (e: Exception) {
|
} catch (e: IllegalArgumentException) {
|
||||||
println(e)
|
println(e)
|
||||||
|
alertImportHash.showAndWait()
|
||||||
|
} catch (e: Exception) {
|
||||||
|
alertImport.showAndWait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user