Note: The client architecture is broken beyond repair
This commit is contained in:
CodeSteak 2019-06-13 00:10:00 +02:00
parent 1ac13f80d5
commit bc43b33536
5 changed files with 65 additions and 32 deletions

View File

@ -246,20 +246,10 @@ class RootController : Controller() {
dialogDelete.showAndWait() dialogDelete.showAndWait()
} }
/** fun updateTexture(name: String, tags: Array<String>) {
* send a changed texture to the server val newTexture = selectedTextureModel.data.copy(
* @param chips the new tag list tags = tags,
*/ name = name
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
) )
try { try {
con.updateTexture( con.updateTexture(
@ -274,6 +264,7 @@ class RootController : Controller() {
} }
} }
/** /**
* show all available textures at start * show all available textures at start
*/ */

View File

@ -1,6 +1,8 @@
package org.hso.texturesyncclient.view.mainView package org.hso.texturesyncclient.view.mainView
import com.jfoenix.controls.JFXButton
import com.jfoenix.controls.JFXChipView import com.jfoenix.controls.JFXChipView
import com.jfoenix.controls.JFXTextField
import javafx.geometry.Insets import javafx.geometry.Insets
import javafx.geometry.Orientation import javafx.geometry.Orientation
import javafx.scene.image.Image import javafx.scene.image.Image
@ -15,15 +17,14 @@ class DetailView : View() {
val preview = Preview3D() val preview = Preview3D()
val cvTags = JFXChipView<String>() val cvTags = JFXChipView<String>()
val nameInfo = label().addClass("metadata") val nameInfo = JFXTextField().addClass("metadata")
val resolutionInfo = label().addClass("metadata") val resolutionInfo = label().addClass("metadata")
val formatInfo = label().addClass("metadata") val formatInfo = label().addClass("metadata")
val dateInfo = label().addClass("metadata") val dateInfo = label().addClass("metadata")
val submitButton = JFXButton("Ändern").addClass("btn-orange")
val metadataPanel = gridpane { val metadataPanel = gridpane {
isVisible = false
row { row {
label("Name ").addClass("metadata") label("Name ").addClass("metadata")
add(nameInfo) 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 { override val root = form {
minWidth = 250.0 minWidth = 250.0
background = Background(BackgroundFill(Paint.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY)) background = Background(BackgroundFill(Paint.valueOf("#3a3a3a"), CornerRadii.EMPTY, Insets.EMPTY))
@ -68,6 +64,17 @@ class DetailView : View() {
add(cvTags) add(cvTags)
} }
field {
add(submitButton)
}
} }
} }
init {
// set a default texture
preview.setTexture(Image("icons/TextureSync_Icon_256x256.jpeg"))
submitButton.useMaxWidth = true
}
} }

View File

@ -78,8 +78,19 @@ class MainView : View("TextureSync") {
mvc.btnImportAction() mvc.btnImportAction()
} }
// TODO: on chipview update on name update
detailView.cvTags.chips.onChange { detailView.cvTags.chips.onChange {
detailView.submitButton.isVisible = true
}
detailView.nameInfo.textProperty().onChange {
detailView.submitButton.isVisible = true
}
detailView.submitButton.setOnAction {
mvc.updateTags() mvc.updateTags()
detailView.submitButton.isVisible = false
} }
//keyboard actions //keyboard actions

View File

@ -2,10 +2,10 @@ package org.hso.texturesyncclient.view.mainView
import javafx.collections.ObservableList import javafx.collections.ObservableList
import javafx.scene.image.Image import javafx.scene.image.Image
import org.hso.texturesyncclient.model.GUIModel
import tornadofx.Controller
import org.hso.texturesyncclient.controller.RootController import org.hso.texturesyncclient.controller.RootController
import org.hso.texturesyncclient.model.GUIModel
import org.hso.texturesyncclient.model.Texture import org.hso.texturesyncclient.model.Texture
import tornadofx.Controller
class MainViewController : Controller() { class MainViewController : Controller() {
@ -53,7 +53,10 @@ class MainViewController : Controller() {
fun updateTags() { fun updateTags() {
if (lockUpdate) { //the chipView was changed by the user if (lockUpdate) { //the chipView was changed by the user
println("Tags changed") println("Tags changed")
rootc.updateTexture(cvTags.chips) rootc.updateTexture(
tags = cvTags.chips.toTypedArray(),
name = mv.detailView.nameInfo.text
)
} }
} }
@ -87,9 +90,11 @@ class MainViewController : Controller() {
fun setVisibleMetaTags(bool: Boolean) { fun setVisibleMetaTags(bool: Boolean) {
if (bool) { if (bool) {
mv.detailView.metadataPanel.isVisible = true mv.detailView.metadataPanel.isVisible = true
mv.detailView.submitButton.isVisible = false
cvTags.isVisible = true cvTags.isVisible = true
} else { } else {
mv.detailView.metadataPanel.isVisible = false mv.detailView.metadataPanel.isVisible = false
mv.detailView.submitButton.isVisible = false
cvTags.isVisible = false cvTags.isVisible = false
} }
} }

View File

@ -112,6 +112,25 @@
-fx-text-inner-color: #E0E0E0; -fx-text-inner-color: #E0E0E0;
} }
/*******************************************************************************
* *
* 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 * * DetailView *