Skip to content

Commit 0d396f1

Browse files
committed
impl: direct access to observable properties
- without the need to go through a "field accessor" - fixes some NPE when reading the url
1 parent fb68191 commit 0d396f1

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

src/main/kotlin/com/coder/gateway/views/CoderPage.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,6 @@ abstract class CoderPage(
6161
notifier?.accept(ex) ?: errorBuffer.add(ex)
6262
}
6363

64-
/**
65-
* Get the value for a field.
66-
*
67-
* TODO@JB: Is this really meant to be used with casting? I kind of expected
68-
* to be able to do `myField.value`.
69-
*/
70-
fun get(field: UiField): Any? {
71-
//return stateAccessor?.get(field)
72-
// TODO - check this later
73-
return null
74-
}
75-
7664
/**
7765
* Immediately notify any pending errors and store for later errors.
7866
*/

src/main/kotlin/com/coder/gateway/views/CoderSettingsPage.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ class CoderSettingsPage(private val settings: CoderSettingsService) : CoderPage(
4848

4949
override fun getActionButtons(): MutableList<RunnableActionDescription> = mutableListOf(
5050
Action("Save", closesPage = true) {
51-
settings.binarySource = get(binarySourceField) as String
52-
settings.binaryDirectory = get(binaryDirectoryField) as String
53-
settings.dataDirectory = get(dataDirectoryField) as String
54-
settings.enableDownloads = get(enableDownloadsField) as Boolean
55-
settings.enableBinaryDirectoryFallback = get(enableBinaryDirectoryFallbackField) as Boolean
56-
settings.headerCommand = get(headerCommandField) as String
57-
settings.tlsCertPath = get(tlsCertPathField) as String
58-
settings.tlsKeyPath = get(tlsKeyPathField) as String
59-
settings.tlsCAPath = get(tlsCAPathField) as String
60-
settings.tlsAlternateHostname = get(tlsAlternateHostnameField) as String
61-
settings.disableAutostart = get(disableAutostartField) as Boolean
51+
settings.binarySource = binarySourceField.text.value
52+
settings.binaryDirectory = binaryDirectoryField.text.value
53+
settings.dataDirectory = dataDirectoryField.text.value
54+
settings.enableDownloads = enableDownloadsField.checked.value
55+
settings.enableBinaryDirectoryFallback = enableBinaryDirectoryFallbackField.checked.value
56+
settings.headerCommand = headerCommandField.text.value
57+
settings.tlsCertPath = tlsCertPathField.text.value
58+
settings.tlsKeyPath = tlsKeyPathField.text.value
59+
settings.tlsCAPath = tlsCAPathField.text.value
60+
settings.tlsAlternateHostname = tlsAlternateHostnameField.text.value
61+
settings.disableAutostart = disableAutostartField.checked.value
6262
},
6363
)
6464
}

src/main/kotlin/com/coder/gateway/views/SignInPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class SignInPage(
4545
* Call onSignIn with the URL, or error if blank.
4646
*/
4747
private fun submit() {
48-
val urlRaw = get(urlField) as String
48+
val urlRaw = urlField.text.value
4949
// Ensure the URL can be parsed.
5050
try {
5151
if (urlRaw.isBlank()) {

src/main/kotlin/com/coder/gateway/views/TokenPage.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ package com.coder.gateway.views
33
import com.coder.gateway.settings.Source
44
import com.coder.gateway.util.withPath
55
import com.jetbrains.toolbox.api.ui.actions.RunnableActionDescription
6-
import com.jetbrains.toolbox.api.ui.components.*
6+
import com.jetbrains.toolbox.api.ui.components.LabelField
7+
import com.jetbrains.toolbox.api.ui.components.LinkField
8+
import com.jetbrains.toolbox.api.ui.components.TextField
9+
import com.jetbrains.toolbox.api.ui.components.TextType
10+
import com.jetbrains.toolbox.api.ui.components.UiField
711
import java.net.URL
812

913
/**
@@ -42,7 +46,7 @@ class TokenPage(
4246
* Buttons displayed at the bottom of the page.
4347
*/
4448
override fun getActionButtons(): MutableList<RunnableActionDescription> = mutableListOf(
45-
Action("Connect", closesPage = false) { submit(get(tokenField) as String) },
49+
Action("Connect", closesPage = false) { submit(tokenField.text.value) },
4650
)
4751

4852
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy