mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
add PropertyComponentBooleanValue for simple settings
GitOrigin-RevId: cef053369b4a0d6ceb2bc6d834aa560a0fd6ab9e
This commit is contained in:
committed by
intellij-monorepo-bot
parent
a0760dfd74
commit
53d976c226
@@ -0,0 +1,26 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
/**
|
||||
* Value to be used as a Kotlin delegate for non-roamable application-level settings.
|
||||
*
|
||||
* Example: `var myCoolSetting by PropertyComponentBooleanValue("my.cool.setting", true)`.
|
||||
*
|
||||
* @see PropertiesComponent
|
||||
*/
|
||||
class PropertyComponentBooleanValue(
|
||||
private val name: String,
|
||||
private val defaultValue: Boolean
|
||||
) {
|
||||
|
||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): Boolean {
|
||||
return PropertiesComponent.getInstance().getBoolean(name, defaultValue)
|
||||
}
|
||||
|
||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: Boolean) {
|
||||
return PropertiesComponent.getInstance().setValue(name, value, defaultValue)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user