Migration dialog (KT-23401)
This commit is contained in:
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.config.ApiVersion
|
|||||||
import org.jetbrains.kotlin.config.LanguageVersion
|
import org.jetbrains.kotlin.config.LanguageVersion
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||||
|
import org.jetbrains.kotlin.idea.configuration.ui.MigrationNotificationDialog
|
||||||
import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID
|
import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID
|
||||||
import org.jetbrains.kotlin.idea.framework.MAVEN_SYSTEM_ID
|
import org.jetbrains.kotlin.idea.framework.MAVEN_SYSTEM_ID
|
||||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
@@ -51,7 +52,8 @@ class KotlinMigrationProjectComponent(val project: Project) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ApplicationManager.getApplication().invokeLater {
|
ApplicationManager.getApplication().invokeLater {
|
||||||
// Notify
|
val migrationNotificationDialog = MigrationNotificationDialog(project, migrationInfo)
|
||||||
|
migrationNotificationDialog.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package org.jetbrains.kotlin.idea.configuration.ui
|
||||||
|
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
import com.intellij.openapi.ui.DialogWrapper
|
||||||
|
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
|
||||||
|
import javax.swing.JComponent
|
||||||
|
|
||||||
|
internal class MigrationNotificationDialog(project: Project?, migrationInfo: MigrationInfo) : DialogWrapper(project, false) {
|
||||||
|
private val form = MigrationNotificationForm()
|
||||||
|
|
||||||
|
init {
|
||||||
|
title = "Kotlin Migration (Experimental)"
|
||||||
|
setOKButtonText("Migrate")
|
||||||
|
|
||||||
|
form.libraryInfo.isVisible = migrationInfo.oldStdlibVersion != migrationInfo.newStdlibVersion
|
||||||
|
form.libraryInfo.text = "Standard library: ${migrationInfo.oldStdlibVersion} to ${migrationInfo.newStdlibVersion}"
|
||||||
|
|
||||||
|
form.languageVersionInfo.isVisible = migrationInfo.oldLanguageVersion != migrationInfo.newLanguageVersion
|
||||||
|
form.languageVersionInfo.text = "Language version: ${migrationInfo.oldLanguageVersion} to ${migrationInfo.newLanguageVersion}"
|
||||||
|
|
||||||
|
form.apiVersionInfo.isVisible = migrationInfo.oldApiVersion != migrationInfo.newApiVersion
|
||||||
|
form.apiVersionInfo.text = "API version: ${migrationInfo.oldApiVersion} to ${migrationInfo.newApiVersion}"
|
||||||
|
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun createCenterPanel(): JComponent = form.mainPanel
|
||||||
|
|
||||||
|
private fun saveSettings() {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doOKAction() {
|
||||||
|
saveSettings()
|
||||||
|
super.doOKAction()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.idea.configuration.ui.MigrationNotificationForm">
|
||||||
|
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<xy x="20" y="20" width="593" height="233"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<vspacer id="3feff">
|
||||||
|
<constraints>
|
||||||
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
</vspacer>
|
||||||
|
<grid id="639c3" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="70410" class="javax.swing.JLabel">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Migration of Kotlin compiler settings is detected in the project:"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<grid id="73ff" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties/>
|
||||||
|
<border type="none"/>
|
||||||
|
<children>
|
||||||
|
<component id="11878" class="javax.swing.JLabel" binding="libraryInfo">
|
||||||
|
<constraints>
|
||||||
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="192" height="16"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Standard library: unchanged"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="9b963" class="javax.swing.JLabel" binding="languageVersionInfo">
|
||||||
|
<constraints>
|
||||||
|
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="192" height="16"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Language version: unchanged"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
<component id="2a47d" class="javax.swing.JLabel" binding="apiVersionInfo">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||||
|
<preferred-size width="192" height="16"/>
|
||||||
|
</grid>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="API version: unchanged"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
<component id="4d637" class="javax.swing.JCheckBox" binding="disableMigrationDetectionCheckBox" default-binding="true">
|
||||||
|
<constraints>
|
||||||
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
|
</constraints>
|
||||||
|
<properties>
|
||||||
|
<text value="Disable migration detection"/>
|
||||||
|
</properties>
|
||||||
|
</component>
|
||||||
|
</children>
|
||||||
|
</grid>
|
||||||
|
</form>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. 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.idea.configuration.ui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class MigrationNotificationForm {
|
||||||
|
public JCheckBox disableMigrationDetectionCheckBox;
|
||||||
|
public JPanel mainPanel;
|
||||||
|
public JLabel libraryInfo;
|
||||||
|
public JLabel languageVersionInfo;
|
||||||
|
public JLabel apiVersionInfo;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user