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
|
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 org.jetbrains.kotlin.tools.projectWizard.wizard.ui.Component
|
||||||
import java.awt.Graphics
|
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.PanelWithStatusText
|
||||||
import javax.swing.JPanel
|
import java.awt.BorderLayout
|
||||||
|
|
||||||
class NothingSelectedComponent : Component() {
|
class NothingSelectedComponent : Component() {
|
||||||
override val component: JPanel = object : JPanel() {
|
override val component = PanelWithStatusText(
|
||||||
override fun paint(g: Graphics?) {
|
BorderLayout(),
|
||||||
super.paint(g)
|
"Neither Module nor Sourceset is selected",
|
||||||
statusText.paint(this, g)
|
isStatusTextVisible = true
|
||||||
}
|
)
|
||||||
}
|
|
||||||
|
|
||||||
private val statusText = object : StatusText(component) {
|
|
||||||
override fun isStatusVisible() = true
|
|
||||||
|
|
||||||
init {
|
|
||||||
appendText("Neither Module nor Sourceset is selected")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+5
-4
@@ -1,18 +1,19 @@
|
|||||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting
|
||||||
|
|
||||||
import com.intellij.ui.components.panels.VerticalLayout
|
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.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.Component
|
||||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.DynamicComponent
|
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.JComponent
|
||||||
import javax.swing.JPanel
|
|
||||||
|
|
||||||
class SettingsList(
|
class SettingsList(
|
||||||
settings: List<SettingReference<*, *>>,
|
settings: List<SettingReference<*, *>>,
|
||||||
private val valuesReadingContext: ValuesReadingContext
|
private val valuesReadingContext: ValuesReadingContext
|
||||||
) : DynamicComponent(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()
|
private var settingComponents: List<Component> = emptyList()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -27,11 +28,11 @@ class SettingsList(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setSettings(settings: List<SettingReference<*, *>>) {
|
fun setSettings(settings: List<SettingReference<*, *>>) {
|
||||||
|
panel.isStatusTextVisible = settings.isEmpty()
|
||||||
panel.removeAll()
|
panel.removeAll()
|
||||||
settingComponents = settings.map { setting ->
|
settingComponents = settings.map { setting ->
|
||||||
DefaultSettingComponent.create(setting, valuesReadingContext)
|
DefaultSettingComponent.create(setting, valuesReadingContext)
|
||||||
}
|
}
|
||||||
settingComponents.forEach { setting -> setting.onInit(); panel.add(setting.component) }
|
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 {
|
buildList {
|
||||||
+ArtifactBasedLibraryDependencyIR(
|
+ArtifactBasedLibraryDependencyIR(
|
||||||
MavenArtifact(DefaultRepository.GOOGLE, "androidx.appcompat", "appcompat"),
|
MavenArtifact(DefaultRepository.GOOGLE, "androidx.appcompat", "appcompat"),
|
||||||
|
|||||||
Reference in New Issue
Block a user