Wizard: minor, not to use reading context directly in some places

This commit is contained in:
Ilya Kirillov
2020-02-20 20:09:10 +03:00
parent 8259bf749d
commit 4c62f64396
7 changed files with 12 additions and 10 deletions
@@ -5,7 +5,7 @@ import java.awt.BorderLayout
import javax.swing.JComponent
abstract class SubStep(
val readingContext: ReadingContext
readingContext: ReadingContext
) : DynamicComponent(readingContext) {
protected abstract fun buildContent(): JComponent
@@ -57,7 +57,7 @@ class TemplatesSubStep(readingContext: ReadingContext) :
}
read {
allModules().forEach { module ->
module.apply { initDefaultValuesForSettings(readingContext.context) }
module.apply { initDefaultValuesForSettings() }
}
}
}
@@ -70,8 +70,9 @@ class TemplatesSubStep(readingContext: ReadingContext) :
module.subModules.forEach(::addModule)
}
readingContext.context.settingContext[KotlinPlugin::modules.reference]
?.forEach(::addModule)
read {
KotlinPlugin::modules.reference.notRequiredSettingValue
}?.forEach(::addModule)
return modules
}
@@ -1,5 +1,6 @@
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep
import org.jetbrains.kotlin.idea.debugger.readAction
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
import org.jetbrains.kotlin.tools.projectWizard.core.ReadingContext
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
@@ -63,7 +64,7 @@ class ModuleSettingsSubStep(
uiEditorUsagesStats: UiEditorUsageStats
) : SubStep(wizard.valuesReadingContext) {
private val sourcesetSettingsComponent = SourcesetSettingsComponent(wizard.valuesReadingContext).asSubComponent()
private val moduleSettingsComponent = ModuleSettingsComponent(readingContext, uiEditorUsagesStats).asSubComponent()
private val moduleSettingsComponent = ModuleSettingsComponent(wizard.valuesReadingContext, uiEditorUsagesStats).asSubComponent()
private val nothingSelectedComponent = NothingSelectedComponent().asSubComponent()
private val panel = panel {
@@ -84,7 +84,7 @@ class TemplatesComponent(
}
class ChooseTemplateComponent(
private val readingContext: ReadingContext,
readingContext: ReadingContext,
private val onTemplateChosen: (Template) -> Unit
) : DynamicComponent(readingContext) {
private enum class State(val text: String) {
@@ -105,7 +105,7 @@ class ChooseTemplateComponent(
}
private val allTemplates
get() = with(readingContext) {
get() = read {
TemplatesPlugin::templates.propertyValue
}
@@ -65,7 +65,7 @@ class TargetsModel(
fun add(module: Module) {
uiEditorUsagesStats.modulesCreated++
with(readingContext) {
module.apply { initDefaultValuesForSettings(context) }
module.apply { initDefaultValuesForSettings() }
}
addToTheTree(module, modifyValue = true, parent = tree.selectedNode ?: root)
}
@@ -8,7 +8,7 @@ import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.FocusableComponent
abstract class SettingComponent<V : Any, T: SettingType<V>>(
val reference: SettingReference<V, T>,
val readingContext: ReadingContext
private val readingContext: ReadingContext
) : DynamicComponent(readingContext), Displayable, FocusableComponent {
var value: V?
get() = reference.value
@@ -86,7 +86,7 @@ class Module(
else -> "Module"
}
fun ReadingContext.initDefaultValuesForSettings(context: Context) {
fun ReadingContext.initDefaultValuesForSettings() {
configurator.safeAs<ModuleConfiguratorWithSettings>()?.initDefaultValuesFor(this@Module, context)
template?.apply { initDefaultValuesFor(this@Module, context) }
}