diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt index 3c48450..a7171b8 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/RootController.kt @@ -246,20 +246,10 @@ class RootController : Controller() { dialogDelete.showAndWait() } - /** - * send a changed texture to the server - * @param chips the new tag list - */ - fun updateTexture(chips: ObservableList<String>) { - val uuid = UUID.randomUUID() - val newTexture = Texture( - uuid, - selectedTextureModel.data.name, - chips.toTypedArray(), - selectedTextureModel.data.format, - selectedTextureModel.data.resolution, - selectedTextureModel.data.addedOn, - selectedTextureModel.data.textureHash + fun updateTexture(name: String, tags: Array<String>) { + val newTexture = selectedTextureModel.data.copy( + tags = tags, + name = name ) try { con.updateTexture( @@ -274,6 +264,7 @@ class RootController : Controller() { } } + /** * show all available textures at start */ diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/DetailView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/DetailView.kt index aa7520b..e18458f 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/DetailView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/DetailView.kt @@ -1,6 +1,8 @@ package org.hso.texturesyncclient.view.mainView +import com.jfoenix.controls.JFXButton import com.jfoenix.controls.JFXChipView +import com.jfoenix.controls.JFXTextField import javafx.geometry.Insets import javafx.geometry.Orientation import javafx.scene.image.Image @@ -15,15 +17,14 @@ class DetailView : View() { val preview = Preview3D() val cvTags = JFXChipView<String>() - val nameInfo = label().addClass("metadata") + val nameInfo = JFXTextField().addClass("metadata") val resolutionInfo = label().addClass("metadata") val formatInfo = label().addClass("metadata") val dateInfo = label().addClass("metadata") + val submitButton = JFXButton("Ändern").addClass("btn-orange") + val metadataPanel = gridpane { - - isVisible = false - row { label("Name ").addClass("metadata") add(nameInfo) @@ -42,11 +43,6 @@ class DetailView : View() { } } - init { - // set a default texture - preview.setTexture(Image("icons/TextureSync_Icon_256x256.jpeg")) - } - override val root = form { minWidth = 250.0 background = Background(BackgroundFill(Paint.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY)) @@ -68,6 +64,17 @@ class DetailView : View() { add(cvTags) } + field { + add(submitButton) + } + } } + + init { + // set a default texture + preview.setTexture(Image("icons/TextureSync_Icon_256x256.jpeg")) + submitButton.useMaxWidth = true + + } } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt index 1199b8c..a2ac6d3 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainView.kt @@ -78,8 +78,19 @@ class MainView : View("TextureSync") { mvc.btnImportAction() } + // TODO: on chipview update on name update + detailView.cvTags.chips.onChange { + detailView.submitButton.isVisible = true + } + + detailView.nameInfo.textProperty().onChange { + detailView.submitButton.isVisible = true + } + + detailView.submitButton.setOnAction { mvc.updateTags() + detailView.submitButton.isVisible = false } //keyboard actions 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 f1ecafc..4e203cb 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 @@ -2,10 +2,10 @@ package org.hso.texturesyncclient.view.mainView import javafx.collections.ObservableList 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.GUIModel import org.hso.texturesyncclient.model.Texture +import tornadofx.Controller class MainViewController : Controller() { @@ -31,7 +31,7 @@ class MainViewController : Controller() { } fun setMeta(name: String, res: String, format: String, date: String) { - with( mv.detailView) { + with(mv.detailView) { nameInfo.text = name formatInfo.text = format resolutionInfo.text = date @@ -46,14 +46,17 @@ class MainViewController : Controller() { lockUpdate = true //allow update with onChange } - fun getTags(): ObservableList<String>{ + fun getTags(): ObservableList<String> { return cvTags.chips } fun updateTags() { if (lockUpdate) { //the chipView was changed by the user println("Tags changed") - rootc.updateTexture(cvTags.chips) + rootc.updateTexture( + tags = cvTags.chips.toTypedArray(), + name = mv.detailView.nameInfo.text + ) } } @@ -84,12 +87,14 @@ class MainViewController : Controller() { .ifPresent { x -> folderView.children.remove(x) } } - fun setVisibleMetaTags(bool: Boolean){ - if(bool){ + fun setVisibleMetaTags(bool: Boolean) { + if (bool) { mv.detailView.metadataPanel.isVisible = true + mv.detailView.submitButton.isVisible = false cvTags.isVisible = true - }else{ + } else { mv.detailView.metadataPanel.isVisible = false + mv.detailView.submitButton.isVisible = false cvTags.isVisible = false } } diff --git a/client/src/main/resources/css/Styles.css b/client/src/main/resources/css/Styles.css index 15caef6..6760e57 100644 --- a/client/src/main/resources/css/Styles.css +++ b/client/src/main/resources/css/Styles.css @@ -114,7 +114,26 @@ /******************************************************************************* * * - * DetailView * + * Buttons * + * * + ******************************************************************************/ + +.btn-blue { + -fx-button-type: RAISED; + -fx-background-color: #3c3f41; + -fx-text-fill: #2b7bbb; + -fx-padding: 10; +} + +.btn-orange { + -fx-button-type: RAISED; + -fx-background-color: #b15b2e; + -fx-text-fill: #3c3f41; +} + +/******************************************************************************* + * * + * DetailView * * * ******************************************************************************/