removed IPv4 validation
added function for clearing the IP textfield first color style test
This commit is contained in:
parent
28085f9b87
commit
573cbda27f
@ -12,13 +12,14 @@ import javafx.scene.layout.Background
|
|||||||
import javafx.scene.layout.BackgroundFill
|
import javafx.scene.layout.BackgroundFill
|
||||||
import javafx.scene.layout.CornerRadii
|
import javafx.scene.layout.CornerRadii
|
||||||
import javafx.scene.paint.Color
|
import javafx.scene.paint.Color
|
||||||
|
import javafx.scene.paint.Paint
|
||||||
import tornadofx.*
|
import tornadofx.*
|
||||||
|
|
||||||
class StartupView : View() {
|
class StartupView : View() {
|
||||||
|
|
||||||
val labelStatus = Label("Verbinden")
|
val labelStatus = Label("Verbindung zum Server einrichten")
|
||||||
val spinnerStatus = JFXSpinner()
|
val spinnerStatus = JFXSpinner()
|
||||||
val labelServerIP = Label("Server-IP")
|
val labelServerIP = Label("Server-Adresse")
|
||||||
val tfServerIP = JFXTextField()
|
val tfServerIP = JFXTextField()
|
||||||
val btnConnect = JFXButton("Manuell Verbinden")
|
val btnConnect = JFXButton("Manuell Verbinden")
|
||||||
|
|
||||||
@ -27,9 +28,10 @@ class StartupView : View() {
|
|||||||
override val root = borderpane {
|
override val root = borderpane {
|
||||||
minWidth = 1000.0
|
minWidth = 1000.0
|
||||||
minHeight = 500.0
|
minHeight = 500.0
|
||||||
|
background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
|
||||||
|
|
||||||
center = vbox(50) {
|
center = vbox(50) {
|
||||||
maxWidth = 150.0
|
maxWidth = 350.0
|
||||||
alignment = Pos.CENTER
|
alignment = Pos.CENTER
|
||||||
|
|
||||||
add(labelStatus)
|
add(labelStatus)
|
||||||
@ -41,22 +43,40 @@ class StartupView : View() {
|
|||||||
add(labelServerIP)
|
add(labelServerIP)
|
||||||
add(tfServerIP)
|
add(tfServerIP)
|
||||||
add(btnConnect)
|
add(btnConnect)
|
||||||
|
|
||||||
// tfServerIP.style { alignment=Center} TODO
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
style {
|
style {
|
||||||
labelStatus.background = Background(BackgroundFill(Color.YELLOWGREEN, CornerRadii.EMPTY, Insets.EMPTY))
|
|
||||||
spinnerStatus.isVisible = false
|
spinnerStatus.isVisible = false
|
||||||
|
|
||||||
|
labelStatus.style {
|
||||||
|
textFill = Paint.valueOf("#2b7bbb")
|
||||||
|
fontSize = 20.px
|
||||||
|
}
|
||||||
|
|
||||||
|
labelServerIP.textFill = Paint.valueOf("#2b7bbb")
|
||||||
|
labelServerIP.style { fontSize = 15.px }
|
||||||
|
btnConnect.textFill = Paint.valueOf("#2b7bbb")
|
||||||
|
btnConnect.background =
|
||||||
|
Background(BackgroundFill(Paint.valueOf("#3c3f41"), CornerRadii.EMPTY, Insets.EMPTY))
|
||||||
|
|
||||||
|
btnConnect.style {
|
||||||
|
padding = box(20.px, 10.px)
|
||||||
|
}
|
||||||
|
|
||||||
|
tfServerIP.style {
|
||||||
|
textFill = Paint.valueOf("#b15b2e")
|
||||||
|
alignment = Pos.BASELINE_CENTER
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
btnConnect.setOnAction {
|
btnConnect.setOnAction {
|
||||||
spinnerStatus.isVisible = true
|
spinnerStatus.isVisible = true
|
||||||
svc.btnConnectAction(tfServerIP.text)
|
svc.btnConnectAction(tfServerIP.text)
|
||||||
spinnerStatus.isVisible = false
|
//spinnerStatus.isVisible = false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,5 +89,4 @@ class StartupView : View() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,6 @@
|
|||||||
package org.hso.texturesyncclient.view.startupView
|
package org.hso.texturesyncclient.view.startupView
|
||||||
|
|
||||||
import tornadofx.Controller
|
import tornadofx.Controller
|
||||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.sym.PATTERN
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class StartupViewController : Controller() {
|
class StartupViewController : Controller() {
|
||||||
@ -10,14 +8,6 @@ class StartupViewController : Controller() {
|
|||||||
fun btnConnectAction(txt:String){
|
fun btnConnectAction(txt:String){
|
||||||
println("Connect BTN: $txt")
|
println("Connect BTN: $txt")
|
||||||
|
|
||||||
if (validateIPv4(txt)){
|
|
||||||
println("valid ipv4")
|
|
||||||
//TODO connect to server ...
|
|
||||||
}else{
|
|
||||||
println("invalid ipv4")
|
|
||||||
//TODO show error
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun labelStatusSetText (txt:String){
|
fun labelStatusSetText (txt:String){
|
||||||
@ -25,10 +15,10 @@ class StartupViewController : Controller() {
|
|||||||
startupView.labelStatus.text = txt
|
startupView.labelStatus.text = txt
|
||||||
}
|
}
|
||||||
|
|
||||||
fun validateIPv4(ip: String): Boolean {
|
fun tfServerIPClear (){
|
||||||
val regex = Regex(pattern = "^(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])\$")
|
val startupView = find(StartupView::class)
|
||||||
return regex.containsMatchIn(input = ip) // matched: true
|
startupView.tfServerIP.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user