From 573cbda27f5c77175767a2a858f3d73b170324d5 Mon Sep 17 00:00:00 2001 From: localhorst Date: Sun, 5 May 2019 23:14:36 +0200 Subject: [PATCH] removed IPv4 validation added function for clearing the IP textfield first color style test --- .../view/startupView/StartupView.kt | 37 ++++++++++++++----- .../view/startupView/StartupViewController.kt | 18 ++------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupView.kt index 917710d..c54acb7 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupView.kt @@ -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() { } } - } \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupViewController.kt index 6a8acb4..55a67e4 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupViewController.kt @@ -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() +} }