From 2c9a23ec8a4b167d7b1aa844fc4d6946a609f456 Mon Sep 17 00:00:00 2001 From: Seil0 Date: Fri, 7 Jun 2019 14:01:16 +0200 Subject: [PATCH] some clean up --- .../controller/NetworkController.kt | 8 ---- .../controller/net/Connection.kt | 40 ++++++++++--------- .../view/importView/ImportView.kt | 3 +- .../view/importView/ImportViewController.kt | 1 - .../view/mainView/MainViewController.kt | 1 - .../view/startupView/StartupViewController.kt | 6 +-- 6 files changed, 24 insertions(+), 35 deletions(-) delete mode 100644 client/src/main/kotlin/org/hso/texturesyncclient/controller/NetworkController.kt diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/NetworkController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/NetworkController.kt deleted file mode 100644 index f6e0d8e..0000000 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/NetworkController.kt +++ /dev/null @@ -1,8 +0,0 @@ -package org.hso.texturesyncclient.controller - -class NetworkController { - - - - -} \ No newline at end of file diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/controller/net/Connection.kt b/client/src/main/kotlin/org/hso/texturesyncclient/controller/net/Connection.kt index 9cf2ddc..72ad1b2 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/controller/net/Connection.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/controller/net/Connection.kt @@ -241,29 +241,31 @@ class Connection(val address: InetAddress, val port: Int = 10796) : Closeable { when (val pkg = Package.read(io.first)) { is JsonPackage -> { - if (pkg.content == JsonPrimitive(true)) { - // everthing is fine! - return - } else if (image != null) { - // should be { "get_texture_file": { texture_hash : }} - // we don't check, since there is no good way to handle it. + when { + pkg.content == JsonPrimitive(true) -> // everthing is fine! + return + image != null -> { + // should be { "get_texture_file": { texture_hash : }} + // we don't check, since there is no good way to handle it. - BinaryPackage(image).write(io.second) - when (val ipkg = Package.read(io.first)) { - is JsonPackage -> { - if (ipkg.content != JsonPrimitive(true)) { - // Protokoll Assertion failed - throw ConnectionUnexpectedPacketException() + BinaryPackage(image).write(io.second) + when (val ipkg = Package.read(io.first)) { + is JsonPackage -> { + if (ipkg.content != JsonPrimitive(true)) { + // Protokoll Assertion failed + throw ConnectionUnexpectedPacketException() + } } + is BinaryPackage -> throw ConnectionUnexpectedPacketException() + is ErrorPackage -> throw ConnectionErrorException(ipkg) + else -> throw RuntimeException("Unreachable") } - is BinaryPackage -> throw ConnectionUnexpectedPacketException() - is ErrorPackage -> throw ConnectionErrorException(ipkg) - else -> throw RuntimeException("Unreachable") } - } else { - ErrorPackage(404, "Texture not found!").write(io.second) - close() // gets re-opened on next request. - throw IllegalArgumentException("Image Argument was needed.") + else -> { + ErrorPackage(404, "Texture not found!").write(io.second) + close() // gets re-opened on next request. + throw IllegalArgumentException("Image Argument was needed.") + } } } is BinaryPackage -> throw ConnectionUnexpectedPacketException() diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt index 53f62cf..c41ea4b 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportView.kt @@ -3,7 +3,6 @@ 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 @@ -93,7 +92,7 @@ class ImportView : View() { tfFilePath.textProperty().addListener{ _, _, _ -> ivc.validateImport() } tfName.textProperty().addListener{ _, _, _ -> ivc.validateImport() } - cvTags.chips.addListener { change: ListChangeListener.Change? -> + cvTags.chips.onChange { ivc.validateImport() } diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt index 26acfa3..1df5ff2 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/importView/ImportViewController.kt @@ -1,6 +1,5 @@ package org.hso.texturesyncclient.view.importView -import javafx.stage.FileChooser.ExtensionFilter import org.hso.texturesyncclient.controller.RootController import tornadofx.Controller import javafx.stage.FileChooser diff --git a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt index d4bbf80..b61c3bf 100644 --- a/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt +++ b/client/src/main/kotlin/org/hso/texturesyncclient/view/mainView/MainViewController.kt @@ -26,7 +26,6 @@ class MainViewController : Controller() { } fun addAllElements(elementList: ArrayList) { - elementList.get(0).data folderView.children.addAll(elementList) } 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 0015f89..91146ba 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 @@ -2,8 +2,6 @@ package org.hso.texturesyncclient.view.startupView import org.hso.texturesyncclient.controller.RootController import org.hso.texturesyncclient.controller.SettingsController -import org.hso.texturesyncclient.view.mainView.MainView -import tornadofx.ConfigProperties import tornadofx.Controller @@ -42,7 +40,7 @@ class StartupViewController : Controller() { /** * show spinner and block textfied + button and set label */ - fun startConnectionUI() { + private fun startConnectionUI() { sv.labelStatus.text = "Verbinden ..." sv.tfServerIP.isEditable = false sv.btnConnect.isDisable = true @@ -52,7 +50,7 @@ class StartupViewController : Controller() { /** * remove spinner and unblock textfied + button and set label */ - fun endConnectionUI() { + private fun endConnectionUI() { sv.spinnerStatus.isVisible = false sv.labelStatus.text = "Verbindung zum Server einrichten" sv.tfServerIP.isEditable = true