removed IPv4 validation
added function for clearing the IP textfield first color style test
This commit is contained in:
		@ -12,13 +12,14 @@ import javafx.scene.layout.Background
 | 
			
		||||
import javafx.scene.layout.BackgroundFill
 | 
			
		||||
import javafx.scene.layout.CornerRadii
 | 
			
		||||
import javafx.scene.paint.Color
 | 
			
		||||
import javafx.scene.paint.Paint
 | 
			
		||||
import tornadofx.*
 | 
			
		||||
 | 
			
		||||
class StartupView : View() {
 | 
			
		||||
 | 
			
		||||
    val labelStatus = Label("Verbinden")
 | 
			
		||||
    val labelStatus = Label("Verbindung zum Server einrichten")
 | 
			
		||||
    val spinnerStatus = JFXSpinner()
 | 
			
		||||
    val labelServerIP = Label("Server-IP")
 | 
			
		||||
    val labelServerIP = Label("Server-Adresse")
 | 
			
		||||
    val tfServerIP = JFXTextField()
 | 
			
		||||
    val btnConnect = JFXButton("Manuell Verbinden")
 | 
			
		||||
 | 
			
		||||
@ -27,9 +28,10 @@ class StartupView : View() {
 | 
			
		||||
    override val root = borderpane {
 | 
			
		||||
        minWidth = 1000.0
 | 
			
		||||
        minHeight = 500.0
 | 
			
		||||
        background = Background(BackgroundFill(Paint.valueOf("#2b2b2b"), CornerRadii.EMPTY, Insets.EMPTY))
 | 
			
		||||
 | 
			
		||||
        center = vbox(50) {
 | 
			
		||||
            maxWidth = 150.0
 | 
			
		||||
            maxWidth = 350.0
 | 
			
		||||
            alignment = Pos.CENTER
 | 
			
		||||
 | 
			
		||||
            add(labelStatus)
 | 
			
		||||
@ -41,22 +43,40 @@ class StartupView : View() {
 | 
			
		||||
                add(labelServerIP)
 | 
			
		||||
                add(tfServerIP)
 | 
			
		||||
                add(btnConnect)
 | 
			
		||||
 | 
			
		||||
               // tfServerIP.style { alignment=Center} TODO
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        style {
 | 
			
		||||
            labelStatus.background = Background(BackgroundFill(Color.YELLOWGREEN, CornerRadii.EMPTY, Insets.EMPTY))
 | 
			
		||||
            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 {
 | 
			
		||||
            spinnerStatus.isVisible = true
 | 
			
		||||
            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
 | 
			
		||||
 | 
			
		||||
import tornadofx.Controller
 | 
			
		||||
import com.sun.org.apache.xalan.internal.xsltc.compiler.sym.PATTERN
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class StartupViewController : Controller() {
 | 
			
		||||
@ -10,14 +8,6 @@ class StartupViewController : Controller() {
 | 
			
		||||
    fun btnConnectAction(txt:String){
 | 
			
		||||
        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){
 | 
			
		||||
@ -25,10 +15,10 @@ class StartupViewController : Controller() {
 | 
			
		||||
        startupView.labelStatus.text =  txt
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fun validateIPv4(ip: String): Boolean {
 | 
			
		||||
        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])\$")
 | 
			
		||||
        return regex.containsMatchIn(input = ip)    // matched: true
 | 
			
		||||
    }
 | 
			
		||||
fun tfServerIPClear (){
 | 
			
		||||
    val startupView = find(StartupView::class)
 | 
			
		||||
    startupView.tfServerIP.clear()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user