From ed344cbd49e8e1f4e731c70199812a1945985838 Mon Sep 17 00:00:00 2001 From: Seil0 Date: Fri, 7 Jun 2019 13:48:42 +0200 Subject: [PATCH] remove deleted Elements from the FolderView, comments --- .../texturesyncclient/controller/Controller.kt | 17 +++++++++++------ .../org/hso/texturesyncclient/model/GUIModel.kt | 6 ++---- .../view/mainView/MainViewController.kt | 10 ++-------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt index 4bc6fe3..07d60d4 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt @@ -137,7 +137,7 @@ class RootController : Controller() { return previewList } - + // TODO this could be a companion object fun switchStartupToMain() { Platform.runLater { find(StartupView::class).replaceWith(MainView::class, sizeToScene = true, centerOnScreen = true) @@ -179,12 +179,20 @@ class RootController : Controller() { } } + /** + * show the detailed meta information in the DetailView + * @param data the texture as meta element + */ fun showDetail(data: Texture) { mvc.setPreview3DTexture(con.getTexturePreview(data.textureHash)) mvc.setMeta(data.name, data.resolution.toString(), "") mvc.setTags(data.tags.toList().observable()) } + /** + * remove a texture from the FolderView and the server + * @param data the texture as meta element + */ fun deleteTexture(data: Texture) { val dialogDelete = JFXOkayCancelAlert( "Löschen", @@ -192,14 +200,11 @@ class RootController : Controller() { "-fx-button-type: RAISED; -fx-background-color: #2b7bbb; -fx-text-fill: #000000;" ) dialogDelete.okayAction = EventHandler { - println("Okay") - con.deleteTexture(data) - - //TODO delete texture from ui mvc.removeTextureFromView(data) + con.deleteTexture(data) } dialogDelete.cancelAction = EventHandler { - println("Cancel") + // Do nothing } dialogDelete.showAndWait() } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt index 3a81d8f..35b7557 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt @@ -12,8 +12,6 @@ import javafx.scene.layout.BackgroundFill import javafx.scene.layout.CornerRadii import javafx.scene.layout.VBox import javafx.scene.paint.Paint -import org.hso.texturesyncclient.controller.RootController -import org.hso.texturesyncclient.view.mainView.MainViewController import tornadofx.* class GUIModel constructor(var data: Texture, img: Image) : VBox(){ @@ -21,8 +19,8 @@ class GUIModel constructor(var data: Texture, img: Image) : VBox(){ private var image = ImageView() private var label = Label() private var contextMenu = ContextMenu() - var exportItem = MenuItem("exportiern") - var deleteItem = MenuItem("löschen") + private var exportItem = MenuItem("exportiern") + private var deleteItem = MenuItem("löschen") private val gmc = find(GUIModelController::class) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt index 36d226b..d4bbf80 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt @@ -77,14 +77,8 @@ class MainViewController : Controller() { fun removeTextureFromView(data: Texture) { - - //TODO delete guimodel from view - - //var previewList = folderView.children - //previewList.stream().filter { x:GUIModel -> x.data.id == data.id }.findAny().e - - - //folderView.children.remove(data) + // stream all children nodes, filter them as GUIModel with data.id == data.id, for any found object if it's still present remove it from the folderView + folderView.children.stream().filter { x -> (x as GUIModel).data.id == data.id }.findAny().ifPresent{ x -> folderView.children.remove(x)} }