From 90b21ca3d1d27b73f383b7437545ea285b63cc1e Mon Sep 17 00:00:00 2001 From: localhorst Date: Wed, 5 Jun 2019 22:33:37 +0200 Subject: [PATCH] added delte context item and call for server delete --- .../controller/Controller.kt | 15 +++++++++ .../hso/texturesyncclient/model/GUIModel.kt | 6 ++++ .../model/GUIModelController.kt | 4 +++ .../view/mainView/MainViewController.kt | 33 ++++++++++++++----- 4 files changed, 50 insertions(+), 8 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 3f68745..54664a1 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/Controller.kt @@ -159,4 +159,19 @@ class RootController : Controller() { mvc.setTags(data.tags.toList().observable()) } + fun deleteTexture(data: Texture) { + +//display "confirm delete" dialog and delete texture when needed + + //if yes : + + con.deleteTexture(data) + + //TODO delete texture from ui + + mvc.removeTextureFromView(data) + + + } + } \ No newline at end of file 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 19f21ca..1e53ccb 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModel.kt @@ -22,6 +22,7 @@ class GUIModel constructor(data: Texture, img: Image) : VBox(){ private var label = Label() private var contextMenu = ContextMenu() var exportItem = MenuItem("exportiern") + var deleteItem = MenuItem("löschen") private val gmc = find(GUIModelController::class) @@ -44,7 +45,12 @@ class GUIModel constructor(data: Texture, img: Image) : VBox(){ gmc.export(data) } + deleteItem.setOnAction { + gmc.delete(data) + } + contextMenu.items.add(exportItem) + contextMenu.items.add(deleteItem) } } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt index 105b7cf..49bdcac 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/model/GUIModelController.kt @@ -11,6 +11,10 @@ class GUIModelController: Controller() { rootc.exportTexture(data) } + fun delete(data: Texture) { + rootc.deleteTexture(data) + } + fun previewSelectedAction(data: Texture) { rootc.showDetail(data) } 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 a98e54b..62779d6 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 @@ -5,6 +5,7 @@ import javafx.scene.image.Image import org.hso.texturesyncclient.model.GUIModel import tornadofx.Controller import org.hso.texturesyncclient.controller.RootController +import org.hso.texturesyncclient.model.Texture class MainViewController : Controller() { @@ -57,18 +58,34 @@ class MainViewController : Controller() { mv.spinnerSearch.isVisible = true mv.cvSearch.isDisable = true - runAsync { - previewList = rootc.search(tags) - } ui { - // when search finished - addAllElements(previewList) - mv.spinnerSearch.isVisible = false - mv.cvSearch.isDisable = false - } + runAsync { + previewList = rootc.search(tags) + } ui { + // when search finished + addAllElements(previewList) + mv.spinnerSearch.isVisible = false + mv.cvSearch.isDisable = false + } + + } fun btnImportAction() { rootc.switchMainToImport() } + + fun removeTextureFromView(data: Texture) { + + //TODO delete guimodel from view + + //var previewList = folderView.children + + //previewList.s + + + //folderView.children.remove(data) + } + + } \ No newline at end of file