ImportView UI finished
This commit is contained in:
parent
c26a1b80f1
commit
0c93c0fedb
@ -1,6 +1,6 @@
|
|||||||
package org.hso.texturesyncclient.app
|
package org.hso.texturesyncclient.app
|
||||||
|
|
||||||
import org.hso.texturesyncclient.controller.Controller
|
import org.hso.texturesyncclient.controller.RootController
|
||||||
import org.hso.texturesyncclient.view.importView.ImportView
|
import org.hso.texturesyncclient.view.importView.ImportView
|
||||||
import org.hso.texturesyncclient.view.mainView.MainView
|
import org.hso.texturesyncclient.view.mainView.MainView
|
||||||
import org.hso.texturesyncclient.view.startupView.StartupView
|
import org.hso.texturesyncclient.view.startupView.StartupView
|
||||||
@ -8,6 +8,6 @@ import tornadofx.App
|
|||||||
|
|
||||||
class Main: App(ImportView::class){
|
class Main: App(ImportView::class){
|
||||||
|
|
||||||
//val controller = Controller()
|
//val controller = RootController()
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package org.hso.texturesyncclient.controller
|
package org.hso.texturesyncclient.controller
|
||||||
|
|
||||||
|
import javafx.collections.ObservableList
|
||||||
import org.hso.texturesyncclient.controller.net.Connection
|
import org.hso.texturesyncclient.controller.net.Connection
|
||||||
import org.hso.texturesyncclient.model.GUIModel
|
import org.hso.texturesyncclient.model.GUIModel
|
||||||
import org.hso.texturesyncclient.model.Texture
|
import org.hso.texturesyncclient.model.Texture
|
||||||
@ -9,13 +10,14 @@ import org.hso.texturesyncclient.view.startupView.StartupViewController
|
|||||||
import tornadofx.Controller
|
import tornadofx.Controller
|
||||||
import java.net.InetAddress
|
import java.net.InetAddress
|
||||||
|
|
||||||
class Controller : Controller() {
|
class RootController : Controller() {
|
||||||
|
|
||||||
private val mvc: MainViewController by inject()
|
private val mvc: MainViewController by inject()
|
||||||
private val svc: StartupViewController by inject()
|
private val svc: StartupViewController by inject()
|
||||||
private val ivc: ImportViewController by inject()
|
private val ivc: ImportViewController by inject()
|
||||||
|
|
||||||
private val con = Connection(InetAddress.getByName("127.0.0.1"))
|
private val con = Connection(InetAddress.getByName("127.0.0.1"))
|
||||||
|
|
||||||
init {
|
init {
|
||||||
/*var data = Texture()
|
/*var data = Texture()
|
||||||
var img = con.getTexturePreview(data.textureHash)
|
var img = con.getTexturePreview(data.textureHash)
|
||||||
@ -28,4 +30,14 @@ class Controller : Controller() {
|
|||||||
mvc.addElement(test)*/
|
mvc.addElement(test)*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calculate the resolution, get today's date -> upload to server
|
||||||
|
* @param path the absolute path of the file on the client's system
|
||||||
|
* @param name the file name
|
||||||
|
* @param tags all tags for the file
|
||||||
|
*/
|
||||||
|
fun importTexture(path: String, name: String, tags: ObservableList<String>) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -3,28 +3,29 @@ package org.hso.texturesyncclient.view.importView
|
|||||||
import com.jfoenix.controls.JFXButton
|
import com.jfoenix.controls.JFXButton
|
||||||
import com.jfoenix.controls.JFXChipView
|
import com.jfoenix.controls.JFXChipView
|
||||||
import com.jfoenix.controls.JFXTextField
|
import com.jfoenix.controls.JFXTextField
|
||||||
|
import javafx.collections.ListChangeListener
|
||||||
import javafx.geometry.Pos
|
import javafx.geometry.Pos
|
||||||
import javafx.scene.layout.Background
|
import javafx.scene.layout.Background
|
||||||
import javafx.geometry.Insets
|
import javafx.geometry.Insets
|
||||||
import javafx.scene.layout.BackgroundFill
|
import javafx.scene.layout.BackgroundFill
|
||||||
import javafx.scene.layout.CornerRadii
|
import javafx.scene.layout.CornerRadii
|
||||||
import javafx.scene.paint.Paint
|
import javafx.scene.paint.Paint
|
||||||
import javafx.scene.control.Label
|
|
||||||
import javafx.scene.layout.Priority
|
import javafx.scene.layout.Priority
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
|
||||||
class ImportView : View() {
|
class ImportView : View() {
|
||||||
|
|
||||||
val labelHeading = Label("Textur hinzufügen")
|
|
||||||
val tfFilePath = JFXTextField()
|
val tfFilePath = JFXTextField()
|
||||||
val btnFileChooser = JFXButton("Datei öffnen")
|
|
||||||
val labelName = Label("Name")
|
|
||||||
val tfName = JFXTextField()
|
val tfName = JFXTextField()
|
||||||
val labelTags = Label("Tags")
|
|
||||||
val cvTags = JFXChipView<String>()
|
val cvTags = JFXChipView<String>()
|
||||||
|
val btnImport = JFXButton("Importieren")
|
||||||
|
|
||||||
private val ivc: ImportViewController by inject()
|
private val ivc: ImportViewController by inject()
|
||||||
|
|
||||||
|
init {
|
||||||
|
btnImport.isVisible = false
|
||||||
|
}
|
||||||
|
|
||||||
override val root = borderpane {
|
override val root = borderpane {
|
||||||
minWidth = 1000.0
|
minWidth = 1000.0
|
||||||
minHeight = 500.0
|
minHeight = 500.0
|
||||||
@ -34,49 +35,69 @@ class ImportView : View() {
|
|||||||
maxWidth = 350.0
|
maxWidth = 350.0
|
||||||
alignment = Pos.CENTER
|
alignment = Pos.CENTER
|
||||||
|
|
||||||
add(labelHeading)
|
label("Textur hinzufügen") {
|
||||||
|
style = "-fx-font: 20px Verdana; -fx-text-fill: #2b7bbb;"
|
||||||
|
}
|
||||||
|
|
||||||
vbox(20) {
|
vbox(20) {
|
||||||
hbox(10) {
|
hbox(10) {
|
||||||
add(tfFilePath)
|
add(tfFilePath)
|
||||||
add(btnFileChooser)
|
button("Datei öffnen") {
|
||||||
|
style = "-fx-button-type: RAISED; -fx-background-color: #3c3f41; -fx-text-fill: #2b7bbb;"
|
||||||
|
|
||||||
|
setOnAction {
|
||||||
|
ivc.btnFileChooserAction()
|
||||||
|
ivc.validateImport()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vbox(5) {
|
vbox(5) {
|
||||||
add(labelName)
|
label("Name") {
|
||||||
|
style = "-fx-font: 14px Verdana; -fx-text-fill: #2b7bbb;"
|
||||||
|
}
|
||||||
add(tfName)
|
add(tfName)
|
||||||
}
|
}
|
||||||
|
|
||||||
vbox(5) {
|
vbox(5) {
|
||||||
add(labelTags)
|
label("Tags") {
|
||||||
|
style = "-fx-font: 14px Verdana; -fx-text-fill: #2b7bbb;"
|
||||||
|
}
|
||||||
add(cvTags)
|
add(cvTags)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vbox(5) {
|
||||||
|
alignment = Pos.CENTER
|
||||||
|
add(btnImport)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
style {
|
style {
|
||||||
labelHeading.style = "-fx-font: 20px Verdana; -fx-text-fill: #2b7bbb;"
|
|
||||||
|
|
||||||
tfFilePath.style = "-fx-text-fill: #b15b2e;"
|
tfFilePath.style = "-fx-text-fill: #b15b2e;"
|
||||||
tfFilePath.promptText = "Pfad zur Datei"
|
tfFilePath.promptText = "Pfad zur Datei"
|
||||||
tfFilePath.hgrow = Priority.ALWAYS
|
tfFilePath.hgrow = Priority.ALWAYS
|
||||||
|
|
||||||
btnFileChooser.style = "-fx-button-type: RAISED; -fx-background-color: #3c3f41; -fx-text-fill: #2b7bbb;"
|
|
||||||
|
|
||||||
labelName.style = "-fx-font: 14px Verdana; -fx-text-fill: #2b7bbb;"
|
|
||||||
|
|
||||||
tfName.style = "-fx-text-fill: #b15b2e;"
|
tfName.style = "-fx-text-fill: #b15b2e;"
|
||||||
tfName.promptText = "Name eingeben"
|
tfName.promptText = "Name eingeben"
|
||||||
|
|
||||||
labelTags.style = "-fx-font: 14px Verdana; -fx-text-fill: #2b7bbb;"
|
|
||||||
|
|
||||||
cvTags.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;"
|
cvTags.style = "-fx-background-color: #3c3f41; -fx-text-inner-color: #b15b2e;"
|
||||||
//TODO change color of Chip´s
|
//TODO change color of Chip´s
|
||||||
|
|
||||||
|
btnImport.style = "-fx-button-type: RAISED; -fx-background-color: #3c3f41; -fx-text-fill: #2b7bbb;"
|
||||||
}
|
}
|
||||||
|
|
||||||
btnFileChooser.setOnAction {
|
tfFilePath.textProperty().addListener{ _, _, _ -> ivc.validateImport() }
|
||||||
ivc.btnFileChooserAction()
|
tfName.textProperty().addListener{ _, _, _ -> ivc.validateImport() }
|
||||||
|
|
||||||
|
cvTags.chips.addListener { change: ListChangeListener.Change<out String>? ->
|
||||||
|
ivc.validateImport()
|
||||||
|
}
|
||||||
|
|
||||||
|
btnImport.setOnAction {
|
||||||
|
ivc.btnImportAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,34 @@
|
|||||||
package org.hso.texturesyncclient.view.importView
|
package org.hso.texturesyncclient.view.importView
|
||||||
|
|
||||||
import javafx.stage.FileChooser.ExtensionFilter
|
import javafx.stage.FileChooser.ExtensionFilter
|
||||||
|
import org.hso.texturesyncclient.controller.RootController
|
||||||
import tornadofx.Controller
|
import tornadofx.Controller
|
||||||
import tornadofx.FileChooserMode
|
import tornadofx.FileChooserMode
|
||||||
import tornadofx.chooseFile
|
import tornadofx.chooseFile
|
||||||
|
|
||||||
class ImportViewController : Controller() {
|
class ImportViewController : Controller() {
|
||||||
|
|
||||||
|
private val iv = find(ImportView::class)
|
||||||
|
private val rootc = find(RootController::class)
|
||||||
|
|
||||||
fun btnFileChooserAction() {
|
fun btnFileChooserAction() {
|
||||||
println("btn click")
|
println("btn click")
|
||||||
|
|
||||||
var list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG")
|
val list = listOf("*.png", "*.PNG", "*.jpg", "*.JPG", "*.jpeg", "*.JPEG")
|
||||||
var filter = ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list)
|
val arrayFilter = arrayOf(ExtensionFilter("Texturen vom Bildformat: PNG oder JPG", list))
|
||||||
val arrayFilter = arrayOf(filter)
|
val file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null)
|
||||||
var file = chooseFile("Textur auswählen", arrayFilter, FileChooserMode.Single, owner = null)
|
|
||||||
|
|
||||||
println(file)
|
if (file.isNotEmpty()) {
|
||||||
|
iv.tfFilePath.text = file[0].absolutePath
|
||||||
|
iv.tfName.text = file[0].nameWithoutExtension
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun btnImportAction() {
|
||||||
|
rootc.importTexture(iv.tfFilePath.text, iv.tfName.text, iv.cvTags.chips)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun validateImport() {
|
||||||
|
iv.btnImport.isVisible = iv.tfFilePath.text.isNotEmpty() && iv.tfName.text.isNotEmpty() && iv.cvTags.chips.isNotEmpty()
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user