Wizard: Show message when module has no configurable settings
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui
|
||||
|
||||
import com.intellij.util.ui.StatusText
|
||||
import java.awt.Graphics
|
||||
import java.awt.LayoutManager
|
||||
import javax.swing.JPanel
|
||||
|
||||
class PanelWithStatusText(
|
||||
layout: LayoutManager,
|
||||
private val statusText: String,
|
||||
var isStatusTextVisible: Boolean = false
|
||||
) : JPanel(layout) {
|
||||
|
||||
override fun paint(g: Graphics?) {
|
||||
super.paint(g)
|
||||
statusTextComponent.paint(this, g)
|
||||
}
|
||||
|
||||
private val statusTextComponent = object : StatusText(this) {
|
||||
override fun isStatusVisible(): Boolean = isStatusTextVisible
|
||||
|
||||
init {
|
||||
appendText(statusText)
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-17
@@ -1,23 +1,13 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep
|
||||
|
||||
import com.intellij.util.ui.StatusText
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.Component
|
||||
import java.awt.Graphics
|
||||
import javax.swing.JPanel
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.PanelWithStatusText
|
||||
import java.awt.BorderLayout
|
||||
|
||||
class NothingSelectedComponent : Component() {
|
||||
override val component: JPanel = object : JPanel() {
|
||||
override fun paint(g: Graphics?) {
|
||||
super.paint(g)
|
||||
statusText.paint(this, g)
|
||||
}
|
||||
}
|
||||
|
||||
private val statusText = object : StatusText(component) {
|
||||
override fun isStatusVisible() = true
|
||||
|
||||
init {
|
||||
appendText("Neither Module nor Sourceset is selected")
|
||||
}
|
||||
}
|
||||
override val component = PanelWithStatusText(
|
||||
BorderLayout(),
|
||||
"Neither Module nor Sourceset is selected",
|
||||
isStatusTextVisible = true
|
||||
)
|
||||
}
|
||||
+5
-4
@@ -1,18 +1,19 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
||||
|
||||
import com.intellij.ui.components.panels.VerticalLayout
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ValuesReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.SettingReference
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.Component
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.DynamicComponent
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.PanelWithStatusText
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
|
||||
class SettingsList(
|
||||
settings: List<SettingReference<*, *>>,
|
||||
private val valuesReadingContext: ValuesReadingContext
|
||||
) : DynamicComponent(valuesReadingContext) {
|
||||
private val panel = JPanel(VerticalLayout(5))
|
||||
private val panel = PanelWithStatusText(VerticalLayout(5), "This module has no settings to configure")
|
||||
|
||||
private var settingComponents: List<Component> = emptyList()
|
||||
|
||||
init {
|
||||
@@ -27,11 +28,11 @@ class SettingsList(
|
||||
}
|
||||
|
||||
fun setSettings(settings: List<SettingReference<*, *>>) {
|
||||
panel.isStatusTextVisible = settings.isEmpty()
|
||||
panel.removeAll()
|
||||
settingComponents = settings.map { setting ->
|
||||
DefaultSettingComponent.create(setting, valuesReadingContext)
|
||||
}
|
||||
settingComponents.forEach { setting -> setting.onInit(); panel.add(setting.component) }
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -92,7 +92,7 @@ object AndroidSinglePlatformModuleConfigurator : ModuleConfiguratorWithSettings(
|
||||
)
|
||||
}
|
||||
|
||||
override fun createModuleIRs(configurationData: ModuleConfigurationData, module: Module): List<BuildSystemIR> =
|
||||
override fun ValuesReadingContext.createModuleIRs(configurationData: ModuleConfigurationData, module: Module): List<BuildSystemIR> =
|
||||
buildList {
|
||||
+ArtifactBasedLibraryDependencyIR(
|
||||
MavenArtifact(DefaultRepository.GOOGLE, "androidx.appcompat", "appcompat"),
|
||||
|
||||
Reference in New Issue
Block a user