summaryrefslogtreecommitdiff
path: root/src/main/kotlin/me/kyren223/trident/data
diff options
context:
space:
mode:
authorKyren223 <ulmliad223@gmail.com>2024-05-14 19:10:19 +0300
committerKyren223 <ulmliad223@gmail.com>2024-05-14 19:10:19 +0300
commitf18b83288869613c2119ed3c51fd1b94c6a313ef (patch)
tree2df6cb7bce7123580adf4e3be55d5ae67d0e0f77 /src/main/kotlin/me/kyren223/trident/data
parent0f2e71ba3e40ba5994fa723b2d4e3792a6b5165b (diff)
Version 2.1.2
Reverted back to the old settings panel due to the new one not saving properly after a restart.
Diffstat (limited to 'src/main/kotlin/me/kyren223/trident/data')
-rw-r--r--src/main/kotlin/me/kyren223/trident/data/Settings.kt25
-rw-r--r--src/main/kotlin/me/kyren223/trident/data/SettingsData.kt18
2 files changed, 24 insertions, 19 deletions
diff --git a/src/main/kotlin/me/kyren223/trident/data/Settings.kt b/src/main/kotlin/me/kyren223/trident/data/Settings.kt
index a1a400b..e97737c 100644
--- a/src/main/kotlin/me/kyren223/trident/data/Settings.kt
+++ b/src/main/kotlin/me/kyren223/trident/data/Settings.kt
@@ -2,20 +2,12 @@ package me.kyren223.trident.data
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
+import com.intellij.util.xmlb.XmlSerializerUtil
// Copyright 2000-2022 JetBrains s.r.o. and other contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
@Service
@State(name = "me.kyren223.trident.data.SettingsState", storages = [Storage("SdkSettingsPlugin.xml")])
-class Settings : SimplePersistentStateComponent<SettingsState>(SettingsState()) {
- companion object {
- private val instance: Settings
- get() = ApplicationManager.getApplication().getService(Settings::class.java)
- val state: SettingsState
- get() = instance.state
- }
-}
-
-class SettingsState : BaseState() {
+class SettingsState : PersistentStateComponent<SettingsState?> {
var width = 800
var height = 400
var fontSize = 20
@@ -25,4 +17,17 @@ class SettingsState : BaseState() {
var recursiveMapping = false
var rememberLine = false
var indexCycling = false
+
+ override fun getState(): SettingsState {
+ return this
+ }
+
+ override fun loadState(state: SettingsState) {
+ XmlSerializerUtil.copyBean(state, this)
+ }
+
+ companion object {
+ val instance: SettingsState
+ get() = ApplicationManager.getApplication().getService(SettingsState::class.java)
+ }
}
diff --git a/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt b/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
index b4c48f7..26cb1d1 100644
--- a/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
+++ b/src/main/kotlin/me/kyren223/trident/data/SettingsData.kt
@@ -17,20 +17,20 @@ class SettingsData {
val panel: JPanel
- private val width = JBIntSpinner(Settings.state.width, minValue, maxValue, step)
- private val height = JBIntSpinner(Settings.state.height, minValue, maxValue, step)
- private val fontSize = JBIntSpinner(Settings.state.fontSize, minValue, maxValue, step)
+ private val width = JBIntSpinner(SettingsState.instance.width, minValue, maxValue, step)
+ private val height = JBIntSpinner(SettingsState.instance.height, minValue, maxValue, step)
+ private val fontSize = JBIntSpinner(SettingsState.instance.fontSize, minValue, maxValue, step)
- private val enterToSelect = JBCheckBox(null, Settings.state.enterToSelect)
- private val rememberLine = JBCheckBox(null, Settings.state.rememberLine)
+ private val enterToSelect = JBCheckBox(null, SettingsState.instance.enterToSelect)
+ private val rememberLine = JBCheckBox(null, SettingsState.instance.rememberLine)
private val automaticMapping = ComboBox(AutomaticMapping.entries.toTypedArray())
private val automaticReplacing = ComboBox(AutomaticReplacing.entries.toTypedArray())
- private val recursiveMapping = JBCheckBox(null, Settings.state.recursiveMapping)
- private val indexCycling = JBCheckBox(null, Settings.state.indexCycling)
+ private val recursiveMapping = JBCheckBox(null, SettingsState.instance.recursiveMapping)
+ private val indexCycling = JBCheckBox(null, SettingsState.instance.indexCycling)
init {
- automaticMapping.selectedItem = Settings.state.automaticMapping
- automaticReplacing.selectedItem = Settings.state.automaticReplacing
+ automaticMapping.selectedItem = SettingsState.instance.automaticMapping
+ automaticReplacing.selectedItem = SettingsState.instance.automaticReplacing
panel = FormBuilder.createFormBuilder()
.addComponent(JBLabel("Popup settings").withFont(JBFont.h4()))