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