From 12df535ebe4e3b19fc89ff3ace8d5e6444aa9a53 Mon Sep 17 00:00:00 2001 From: Asher Date: Wed, 6 Dec 2023 18:35:56 -0900 Subject: [PATCH] Use delegated properties with recent connections From what I understand when you use BaseState you are supposed to use delegation. Something must have changed because this code used to work just as it was, but now it seems without delegation the properties are ignored and we were getting recent entries that were blank (looked like this: ``). --- .../models/RecentWorkspaceConnection.kt | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/com/coder/gateway/models/RecentWorkspaceConnection.kt b/src/main/kotlin/com/coder/gateway/models/RecentWorkspaceConnection.kt index 4194be6c..dcbae553 100644 --- a/src/main/kotlin/com/coder/gateway/models/RecentWorkspaceConnection.kt +++ b/src/main/kotlin/com/coder/gateway/models/RecentWorkspaceConnection.kt @@ -4,27 +4,51 @@ import com.intellij.openapi.components.BaseState import com.intellij.util.xmlb.annotations.Attribute class RecentWorkspaceConnection( + coderWorkspaceHostname: String? = null, + projectPath: String? = null, + lastOpened: String? = null, + ideProductCode: String? = null, + ideBuildNumber: String? = null, + downloadSource: String? = null, + idePathOnHost: String? = null, + webTerminalLink: String? = null, + configDirectory: String? = null, + name: String? = null, +) : BaseState(), Comparable { @get:Attribute - var coderWorkspaceHostname: String? = null, + var coderWorkspaceHostname by string() @get:Attribute - var projectPath: String? = null, + var projectPath by string() @get:Attribute - var lastOpened: String? = null, + var lastOpened by string() @get:Attribute - var ideProductCode: String? = null, + var ideProductCode by string() @get:Attribute - var ideBuildNumber: String? = null, + var ideBuildNumber by string() @get:Attribute - var downloadSource: String? = null, + var downloadSource by string() @get:Attribute - var idePathOnHost: String? = null, + var idePathOnHost by string() @get:Attribute - var webTerminalLink: String? = null, + var webTerminalLink by string() @get:Attribute - var configDirectory: String? = null, + var configDirectory by string() @get:Attribute - var name: String? = null, -) : BaseState(), Comparable { + var name by string() + + init { + this.coderWorkspaceHostname = coderWorkspaceHostname + this.projectPath = projectPath + this.lastOpened = lastOpened + this.ideProductCode = ideProductCode + this.ideBuildNumber = ideBuildNumber + this.downloadSource = downloadSource + this.idePathOnHost = idePathOnHost + this.webTerminalLink = webTerminalLink + this.configDirectory = configDirectory + this.name = name + } + override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false