TextureSync/client/src/main/kotlin/org/hso/texturesyncclient/view/startupView/StartupViewController.kt

67 lines
1.7 KiB
Kotlin
Raw Normal View History

package org.hso.texturesyncclient.view.startupView
2019-06-04 16:05:47 +02:00
import org.hso.texturesyncclient.controller.RootController
2019-06-07 09:52:09 +02:00
import org.hso.texturesyncclient.controller.SettingsController
2019-06-04 18:20:09 +02:00
import org.hso.texturesyncclient.view.mainView.MainView
2019-06-07 09:52:09 +02:00
import tornadofx.ConfigProperties
import tornadofx.Controller
2019-05-01 22:57:03 +02:00
class StartupViewController : Controller() {
2019-04-30 18:50:41 +02:00
2019-06-04 16:05:47 +02:00
private val sv = find(StartupView::class)
private val rootc = find(RootController::class)
2019-06-07 09:52:09 +02:00
init {
println("init StartupViewController")
SettingsController.init()
startConnectionUI()
runAsync {
rootc.initConnection(" ")
} ui {
// reset for later use
endConnectionUI()
}
}
fun setServerAddress(address: String) {
2019-06-05 16:05:10 +02:00
sv.tfServerIP.text = address
sv.tfServerIP.isFocusTraversable = false
}
2019-06-04 16:05:47 +02:00
fun btnConnectAction(name: String) {
2019-06-07 09:52:09 +02:00
startConnectionUI()
2019-06-04 18:20:09 +02:00
runAsync {
2019-06-04 16:05:47 +02:00
rootc.initConnection(name)
} ui {
// reset for later use
2019-06-07 09:52:09 +02:00
endConnectionUI()
2019-06-04 16:05:47 +02:00
}
}
2019-05-01 22:57:03 +02:00
2019-06-07 09:52:09 +02:00
/**
* show spinner and block textfied + button and set label
*/
fun startConnectionUI() {
sv.labelStatus.text = "Verbinden ..."
sv.tfServerIP.isEditable = false
sv.btnConnect.isDisable = true
sv.spinnerStatus.isVisible = true
}
/**
* remove spinner and unblock textfied + button and set label
*/
fun endConnectionUI() {
sv.spinnerStatus.isVisible = false
sv.labelStatus.text = "Verbindung zum Server einrichten"
sv.tfServerIP.isEditable = true
sv.btnConnect.isDisable = false
sv.tfServerIP.clear()
}
2019-05-01 22:57:03 +02:00
}