Skip to content

Commit

Permalink
[kotlin] KTIJ-21424 Simplify new project wizard of Kotlin Multiplatform
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 4188e038db61bebb66afb9e10cf1e283d80470dd
  • Loading branch information
jreznot authored and intellij-monorepo-bot committed Mar 26, 2022
1 parent 0b19116 commit 7608e31
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 100 deletions.

Large diffs are not rendered by default.

Expand Up @@ -26,7 +26,6 @@ module.kind.mpp.module=MPP Module
module.kind.target=Target

plugin.buildsystem.setting.type=Build system
plugin.buildsystem.setting.type.tooltip=The build tool that will be used for managing dependencies, testing, packaging, automating the build process, and so on
plugin.buildsystem.setting.type.error.wrong.project.kind={0} project cannot be generated using {1}

plugin.kotlin.downloading.kotlin.versions=Downloading list of Kotlin versions
Expand Down Expand Up @@ -54,7 +53,7 @@ plugin.structure.setting.artifact.id=Artifact ID
plugin.structure.setting.artifact.id.tooltip=The unique name of the primary artifact for this project \u2013 not applicable for the IntelliJ build system
plugin.structure.setting.version=Version
plugin.structure.setting.version.tooltip=The version of the primary artifact generated by the project \u2013 not applicable for the IntelliJ build system
plugin.templates.setting.template=Project Template
plugin.templates.setting.template=Project template
plugin.templates.setting.template.tooltip=Defines the initial project structure. Depending on your purpose, select one of the following templates:

plugin.android.setting.sdk=Android SDK
Expand Down
@@ -1,7 +1,7 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem


import com.intellij.openapi.util.text.StringUtil
import kotlinx.collections.immutable.toImmutableList
import org.jetbrains.annotations.Nls
import org.jetbrains.annotations.NonNls
Expand Down Expand Up @@ -59,14 +59,12 @@ abstract class BuildSystemPlugin(context: Context) : Plugin(context) {
ValidationResult.ValidationError(
KotlinNewProjectWizardBundle.message(
"plugin.buildsystem.setting.type.error.wrong.project.kind",
projectKind.shortName.capitalize(),
StringUtil.capitalize(projectKind.shortName),
buildSystemType.fullText
)
)
}
}

tooltipText = KotlinNewProjectWizardBundle.message("plugin.buildsystem.setting.type.tooltip")
}

val buildSystemData by property<List<BuildSystemData>>(emptyList())
Expand Down Expand Up @@ -195,7 +193,7 @@ enum class BuildSystemType(

companion object {
val ALL_GRADLE = setOf(GradleKotlinDsl, GradleGroovyDsl)
val ALL_BY_PRIORITY = setOf(GradleKotlinDsl, GradleGroovyDsl, Maven, Jps)
val ALL_BY_PRIORITY = setOf(GradleKotlinDsl, GradleGroovyDsl)
}
}

Expand Down Expand Up @@ -228,7 +226,6 @@ fun BuildSystemType.getDefaultPluginRepositories(): List<DefaultRepository> = wh
BuildSystemType.Jps -> emptyList()
}


val Reader.buildSystemType: BuildSystemType
get() = BuildSystemPlugin.type.settingValue

Expand Up @@ -67,19 +67,14 @@ abstract class ProjectTemplate : DisplayableSettingItem {
}
}


companion object {
val ALL = listOf(
ConsoleApplicationProjectTemplateWithSample,
FullStackWebApplicationProjectTemplate,
MultiplatformLibraryProjectTemplate,
NativeApplicationProjectTemplate,
FrontendApplicationProjectTemplate,
ReactApplicationProjectTemplate,
FullStackWebApplicationProjectTemplate,
NodeJsApplicationProjectTemplate,
ComposeDesktopApplicationProjectTemplate,
ComposeMultiplatformApplicationProjectTemplate,
ComposeWebApplicationProjectTemplate
NodeJsApplicationProjectTemplate
)

fun byId(id: String): ProjectTemplate? = ALL.firstOrNull {
Expand Down
Expand Up @@ -3,13 +3,9 @@ generator.title=Kotlin Multiplatform
error.nothing.selected=Select module to configure
error.generation=Project Generation Error

additional.buildsystem.settings.project.jdk=Project JDK
additional.buildsystem.settings.project.jdk.tooltip=The Java Development Kit (JDK) that will be used in the project (version 1.8 or later is recommended) <ul><li>If the JDK is installed on your computer but not defined in the IDE, select Add JDK and specify the path to the JDK home directory (for example, /Library/Java/JavaVirtualMachines/jdk-12.0.1.jdk).</li><li> If you don't have the necessary JDK on your machine, select Download JDK. In the next dialog, specify the JDK vendor, version, and change the installation path if required.</li></ul>
additional.buildsystem.settings.project.jdk=JDK
additional.buildsystem.settings.artifact.coordinates=Artifact Coordinates

feedback.link.tooltip.text=<html><body>If anything is missing or seems confusing in the Kotlin New Project wizard, please create an issue\
\ or feature request in the <a href="{0}">Kotlin issue tracker</a>.</body></html>
module.dependencies.module.dependencies=Module dependencies
module.dependencies.module.dependencies.tooltip=Modules the current application depends on
module.dependencies.add.module.dependency=Add Module Dependency
Expand Down
@@ -1,15 +1,11 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.firstStep

import com.intellij.icons.AllIcons
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.ex.ActionButtonLook
import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.actionSystem.impl.ActionButtonWithText
import com.intellij.openapi.project.DumbAware
import icons.OpenapiIcons
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.extensions.gradle.KotlinGradleFacade
import org.jetbrains.kotlin.tools.projectWizard.core.Context
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ValidationResult
import org.jetbrains.kotlin.tools.projectWizard.core.entity.isSpecificError
Expand All @@ -27,7 +23,6 @@ import java.awt.Dimension
import java.awt.Insets
import javax.swing.JComponent


class BuildSystemTypeSettingComponent(
context: Context
) : SettingComponent<BuildSystemType, DropDownSettingType<BuildSystemType>>(
Expand Down Expand Up @@ -64,7 +59,7 @@ class BuildSystemTypeSettingComponent(

private inner class BuildSystemTypeAction(
val buildSystemType: BuildSystemType
) : ToggleAction(buildSystemType.text, null, buildSystemType.icon), DumbAware {
) : ToggleAction(buildSystemType.text, null, null), DumbAware {
override fun isSelected(e: AnActionEvent): Boolean = value == buildSystemType

override fun setSelected(e: AnActionEvent, state: Boolean) {
Expand Down Expand Up @@ -125,12 +120,4 @@ class BuildSystemTypeSettingComponent(
private const val LEFT_RIGHT_PADDING = 6
private const val TOP_BOTTOM_PADDING = 2
}
}

private val BuildSystemType.icon
get() = when (this) {
BuildSystemType.GradleKotlinDsl -> KotlinIcons.GRADLE_SCRIPT
BuildSystemType.GradleGroovyDsl -> KotlinGradleFacade.instance?.gradleIcon ?: KotlinIcons.GRADLE_SCRIPT
BuildSystemType.Maven -> OpenapiIcons.RepositoryLibraryLogo
BuildSystemType.Jps -> AllIcons.Nodes.Module
}
}
Expand Up @@ -12,8 +12,11 @@ import com.intellij.openapi.roots.ui.configuration.JdkComboBox
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel
import com.intellij.openapi.util.Condition
import com.intellij.openapi.util.NlsContexts
import com.intellij.ui.IdeBorderFactory
import com.intellij.ui.TitledSeparator
import com.intellij.ui.layout.*
import com.intellij.ui.dsl.builder.*
import com.intellij.ui.dsl.gridLayout.HorizontalAlign
import com.intellij.util.ui.JBInsets
import com.intellij.util.ui.JBUI
import com.intellij.util.ui.components.BorderLayoutPanel
import org.jetbrains.kotlin.idea.projectWizard.WizardStatsService
Expand Down Expand Up @@ -70,26 +73,29 @@ class ProjectSettingsComponent(ideWizard: IdeWizard) : DynamicComponent(ideWizar
),
context,
stretchY = true,
useBigYGap = true
useBigYGap = true,
xPadding = 0,
yPadding = 0
).asSubComponent()

override val component: JComponent by lazy(LazyThreadSafetyMode.NONE) {
panel {
row {
nameAndLocationComponent.component(growX)
cell(nameAndLocationComponent.component)
.horizontalAlign(HorizontalAlign.FILL)
.resizableColumn()

bottomGap(BottomGap.SMALL)
}

row {
buildSystemAdditionalSettingsComponent.component(growX)
}.largeGapAfter()
row {
comment(
KotlinNewProjectWizardUIBundle.message(
"feedback.link.tooltip.text",
"https://youtrack.jetbrains.com/newIssue?project=KTIJ&Type=Feature&Subsystems=IDE.Wizards"
), 100
).constraints(pushY).withLargeLeftGap()
cell(buildSystemAdditionalSettingsComponent.component)
.horizontalAlign(HorizontalAlign.FILL)
.resizableColumn()

bottomGap(BottomGap.SMALL)
}
}.addBorder(JBUI.Borders.emptyRight(UIConstants.PADDING))
}.addBorder(IdeBorderFactory.createEmptyBorder(JBInsets(20, 20, 20, 20)))
}

override fun onValueUpdated(reference: SettingReference<*, *>?) {
Expand Down Expand Up @@ -209,7 +215,6 @@ private class JdkComponent(ideWizard: IdeWizard) : TitledComponent(ideWizard.con
}

override val title: String = KotlinNewProjectWizardUIBundle.message("additional.buildsystem.settings.project.jdk")
override val tooltipText: String = KotlinNewProjectWizardUIBundle.message("additional.buildsystem.settings.project.jdk.tooltip")
override val component: JComponent = jdkComboBox
}

Expand Down
Expand Up @@ -67,7 +67,6 @@ class ProjectTemplateSettingComponent(
addToBottom(templateDescriptionComponent.component.addBorder(JBUI.Borders.empty(/*top*/8,/*left*/ 3, 0, 0)))
}


private fun applySelectedTemplate() = modify {
value?.let(::applyProjectTemplate)
}
Expand All @@ -76,10 +75,7 @@ class ProjectTemplateSettingComponent(
super.onValueUpdated(reference)
if (reference == ProjectTemplatesPlugin.template.reference) {
applySelectedTemplate()
value?.let { template ->
list.setSelectedValue(template, true)
templateDescriptionComponent.setTemplate(template)
}
updateHint()
}
}

Expand All @@ -89,6 +85,14 @@ class ProjectTemplateSettingComponent(
list.selectedIndex = 0
value = setting.type.values.firstOrNull()
applySelectedTemplate()
updateHint()
}
}

private fun updateHint() {
value?.let { template ->
list.setSelectedValue(template, true)
templateDescriptionComponent.setTemplate(template)
}
}
}
Expand Down
Expand Up @@ -16,6 +16,8 @@ open class TitledComponentsList(
private val stretchY: Boolean = false,
private val globalMaxWidth: Int? = null,
useBigYGap: Boolean = false,
var xPadding: Int = xPanelPadding,
var yPadding: Int = yPanelPadding
) : DynamicComponent(context) {
private val ui = BorderLayoutPanel()

Expand Down Expand Up @@ -80,7 +82,7 @@ open class TitledComponentsList(
componentsWithLabels.forEach { (_, tooltipConst, component, _, _, componentMaxWidth) ->
val maxWidth = componentMaxWidth ?: globalMaxWidth
if (maxWidth == null) {
component[SpringLayout.EAST] = layout.getConstraint(SpringLayout.EAST, this) - xPanelPadding.asSpring()
component[SpringLayout.EAST] = layout.getConstraint(SpringLayout.EAST, this) - xPadding.asSpring()
} else {
component.width = maxWidth.asSpring()
}
Expand All @@ -93,7 +95,7 @@ open class TitledComponentsList(

for (data in componentsWithLabels) {
val (label, tooltip, component) = data
label.x = xPanelPadding.asSpring()
label.x = xPadding.asSpring()
tooltip?.x = label[SpringLayout.EAST] + xGap
component.x = maxLabelWidth + 2 * xGap
if (tooltipWidth != null)
Expand All @@ -105,9 +107,9 @@ open class TitledComponentsList(
tooltip?.y = label.y
component.y = constraint
} else {
label.y = data.centerConstraint() + yPanelPadding
label.y = data.centerConstraint() + yPadding
tooltip?.y = label.y
component.y = yPanelPadding.asSpring()
component.y = yPadding.asSpring()
}

lastLabel = label
Expand Down

0 comments on commit 7608e31

Please sign in to comment.