Verified Commit 3db4ff47 authored by Konstantin Kopper's avatar Konstantin Kopper
Browse files

Various minor improvements

parent 0cd05490
Pipeline #29042 passed with stages
in 18 minutes and 30 seconds
......@@ -8,6 +8,7 @@ import io.ktor.client.features.json.JsonFeature
import io.ktor.client.features.json.serializer.KotlinxSerializer
import io.ktor.client.request.accept
import io.ktor.client.request.get
import io.ktor.client.request.parameter
import io.ktor.client.request.post
import io.ktor.client.statement.HttpStatement
import io.ktor.http.ContentType
......@@ -62,6 +63,8 @@ object PseuCoShare : FileSharer {
@Throws(PseuCoShareException::class)
override suspend fun uploadFile(file: PseuCoComFile): URI = shareFile(file, true)
private val jsonAllowingStructuredMapKeys = Json { allowStructuredMapKeys = true }
/**
* Uploads [file] to the [pseuCo.com](https://pseuco.com) sharing API.
*
......@@ -92,7 +95,7 @@ object PseuCoShare : FileSharer {
return try {
URI(
Json { allowStructuredMapKeys = true }.parseToJsonElement(
jsonAllowingStructuredMapKeys.parseToJsonElement(
c.content.toInputStream().reader().use { it.readText() }).jsonObject["url"]!!.jsonPrimitive.content
)
} catch (e: SerializationException) {
......@@ -119,7 +122,7 @@ object PseuCoShare : FileSharer {
host = "pseuco.com"
port = protocol.defaultPort
path("api", "paste", "get")
parameters["id"] = id
parameter("id", id)
}
accept(ContentType.Application.Json.withCharset(Charsets.UTF_8))
}.execute()
......
......@@ -52,6 +52,7 @@ internal open class PseucoAlert(alertType: Alert.AlertType) : Alert(alertType) {
* @author Konstantin Kopper
* @since 2.0.0
*/
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
private val STYLESHEET = PseucoAlert::class.java.getResource("/fxGui/css/alert.css").toExternalForm()
}
}
......@@ -2,11 +2,10 @@ package fxGui.debugger.channels
import javafx.scene.control.Label
internal class ChannelElement(private val element: String, private val type: ChannelType) : Label(element) {
@Suppress("RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
internal class ChannelElement(element: String, type: ChannelType) : Label(element) {
internal constructor(element: Int, type: ChannelType) : this(element.toString(), type)
internal constructor(element: Boolean, type: ChannelType) : this(element.toString(), type)
internal constructor(element: Any, type: ChannelType) : this(element.toString(), type)
init {
stylesheets += this::class.java.getResource("/fxGui/css/general.css").toExternalForm()
......
......@@ -7,7 +7,8 @@ import javafx.scene.layout.AnchorPane
import javafx.scene.layout.HBox
import java.util.concurrent.BlockingQueue
internal class ChannelPane<T>(internal val queue: BlockingQueue<T>, internal val type: ChannelType) : AnchorPane() {
internal class ChannelPane<T : Any>(internal val queue: BlockingQueue<T>, internal val type: ChannelType) :
AnchorPane() {
/**
* The label indicating the capacity of this channel.
......@@ -64,9 +65,10 @@ internal class ChannelPane<T>(internal val queue: BlockingQueue<T>, internal val
internal fun update() {
elements.children.clear()
queue.takeIf { it.isNotEmpty() }?.forEach { elements.children += ChannelElement(it.toString(), this.type) }
?: { elements.children += ChannelElement("Channel is empty!", ChannelType.NONE) }()
queue.takeIf { it.isNotEmpty() }?.forEach { elements.children += ChannelElement(it, this.type) }
?: run { elements.children += ChannelElement("Channel is empty!", ChannelType.NONE) }
channelPane.style = if (queue.remainingCapacity() == 0) "-fx-border-width: 3px; -fx-border-color: indianred;" else ""
channelPane.style =
if (queue.remainingCapacity() == 0) "-fx-border-width: 3px; -fx-border-color: indianred;" else ""
}
}
......@@ -56,7 +56,7 @@ object AboutProperties : Properties() {
init {
try {
load(this::class.java.getResourceAsStream("/about.properties"))
this::class.java.getResourceAsStream("/about.properties").use { load(it) }
} catch (e: IOException) {
System.err.println("Could not read properties. Using some default values.")
if (Main.DEBUG)
......
......@@ -38,7 +38,7 @@ object BuildProperties : Properties() {
init {
try {
load(this::class.java.getResourceAsStream("/build.properties"))
this::class.java.getResourceAsStream("/build.properties").use { load(it) }
} catch (e: IOException) {
System.err.println("Reading build properties failed.")
if (Main.DEBUG)
......
......@@ -32,6 +32,7 @@ object ZipUtilities {
val buffer = ByteArray(1024)
@Suppress("NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS")
val inputStream = ZipInputStream(ZipUtilities::class.java.getResourceAsStream(name))
try {
......
......@@ -22,6 +22,7 @@ import io.ktor.routing.post
import io.ktor.routing.routing
import io.ktor.server.engine.embeddedServer
import io.ktor.server.netty.Netty
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.awt.Desktop
import java.net.URI
......@@ -117,7 +118,7 @@ object CompanionWebApp {
Config.file.deleteOnExit()
launch {
// Wait for response to be sent and kill IDE afterwards.
Thread.sleep(250)
delay(250)
exitProcess(0)
}
call.respond(HttpStatusCode.OK, "Success. Please close this tab and restart the IDE.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment