mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
migrate AppletConfiguration and BndRunConfiguration to BaseState — part 5, fix CopyrightManagerTest
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 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.
|
||||
/*
|
||||
* Copyright 2000-2017 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.openapi.components
|
||||
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
@@ -66,9 +68,10 @@ abstract class BaseState : SerializationFilter, ModificationTracker {
|
||||
val getterName = (accessor as? PropertyAccessor)?.getterName
|
||||
for (property in properties) {
|
||||
if (property.name == accessor.name || property.name == getterName) {
|
||||
return property.value != property.defaultValue
|
||||
return !property.isEqualToDefault(property.defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
LOG.debug("Cannot find property by name: ${accessor.name}")
|
||||
// do not return false - maybe accessor delegates actual set to our property
|
||||
// default value in this case will be filtered by common filter (instance will be created in this case, as for non-smart state classes)
|
||||
@@ -183,6 +186,10 @@ private class NormalizedStringStoredProperty(override val defaultValue: String?)
|
||||
value = newValue
|
||||
return true
|
||||
}
|
||||
|
||||
override fun isEqualToDefault(newValue: Any?): Boolean {
|
||||
return value == newValue || (value == null && newValue != null && newValue is String && newValue.isEmpty())
|
||||
}
|
||||
}
|
||||
|
||||
private class IntStoredProperty(override val defaultValue: Int) : StoredPropertyBase<Int>() {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Copyright 2000-2017 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.
|
||||
/*
|
||||
* Copyright 2000-2017 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.openapi.components
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
@@ -12,6 +14,8 @@ internal interface StoredProperty {
|
||||
|
||||
// true if changed
|
||||
fun setValue(other: StoredProperty): Boolean
|
||||
|
||||
fun isEqualToDefault(newValue: Any?): Boolean = value == newValue
|
||||
}
|
||||
|
||||
// type must be exposed otherwise `provideDelegate` doesn't work
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Copyright 2000-2017 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.
|
||||
/*
|
||||
* Copyright 2000-2017 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.maddyhome.idea.copyright
|
||||
|
||||
import com.intellij.configurationStore.SerializableScheme
|
||||
@@ -8,6 +8,7 @@ import com.intellij.configurationStore.serializeObjectInto
|
||||
import com.intellij.openapi.components.BaseState
|
||||
import com.intellij.openapi.options.ExternalizableScheme
|
||||
import com.intellij.util.xmlb.annotations.OptionTag
|
||||
import com.intellij.util.xmlb.annotations.Transient
|
||||
import com.maddyhome.idea.copyright.pattern.EntityUtil
|
||||
import org.jdom.Element
|
||||
|
||||
@@ -18,9 +19,11 @@ val DEFAULT_COPYRIGHT_NOTICE: String = EntityUtil.encode(
|
||||
"Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. \n" +
|
||||
"Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. \n" +
|
||||
"Vestibulum commodo. Ut rhoncus gravida arcu. ")
|
||||
|
||||
class CopyrightProfile @JvmOverloads constructor(profileName: String? = null) : ExternalizableScheme, BaseState(), SerializableScheme {
|
||||
private var profileName by string()
|
||||
// ugly name to preserve compatibility
|
||||
// must be not private because otherwise binding is not created for private accessor
|
||||
@get:OptionTag("myName")
|
||||
var profileName by string()
|
||||
|
||||
var notice by string(DEFAULT_COPYRIGHT_NOTICE)
|
||||
var keyword by string(EntityUtil.encode("Copyright"))
|
||||
@@ -35,7 +38,7 @@ class CopyrightProfile @JvmOverloads constructor(profileName: String? = null) :
|
||||
}
|
||||
|
||||
// ugly name to preserve compatibility
|
||||
@OptionTag("myName")
|
||||
@Transient
|
||||
override fun getName() = profileName ?: ""
|
||||
|
||||
override fun setName(value: String) {
|
||||
|
||||
Reference in New Issue
Block a user