Add an ability to switch between old and new J2K via settings window
Before that it was possible to do only via registry #KT-33371 fixed
This commit is contained in:
+2
-1
@@ -13,6 +13,7 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.AbstractJavaToKotlinCopyPasteConversionTest
|
||||
import org.jetbrains.kotlin.idea.conversion.copy.ConvertJavaCopyPasteProcessor
|
||||
import org.jetbrains.kotlin.j2k.J2kConverterExtension
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
@@ -35,7 +36,7 @@ abstract class AbstractPerformanceJavaToKotlinCopyPasteConversionTest(private va
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
Registry.get("kotlin.use.new.j2k").setValue(newJ2K)
|
||||
J2kConverterExtension.isNewJ2k = newJ2K
|
||||
val index = j2kIndex()
|
||||
|
||||
if (!warmedUp[index]) {
|
||||
|
||||
@@ -92,10 +92,6 @@
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<registryKey key="kotlin.use.new.j2k"
|
||||
description="Use new Java to Kotlin Converter (experimental)"
|
||||
defaultValue="true"
|
||||
restartRequired="false"/>
|
||||
<registryKey key="kotlin.mpp.editTargetPlatformEnabled"
|
||||
description="Enable manual editing of MPP target platforms"
|
||||
defaultValue="false"
|
||||
|
||||
@@ -100,10 +100,6 @@
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<registryKey key="kotlin.use.new.j2k"
|
||||
description="Use new Java to Kotlin Converter (experimental)"
|
||||
defaultValue="true"
|
||||
restartRequired="false"/>
|
||||
<registryKey key="kotlin.android.import.mpp.all.transitive"
|
||||
description="Add all transitive dependencies on MPP modules when Android project is imported"
|
||||
defaultValue="true"
|
||||
|
||||
@@ -92,10 +92,6 @@
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<registryKey key="kotlin.use.new.j2k"
|
||||
description="Use new Java to Kotlin Converter (experimental)"
|
||||
defaultValue="true"
|
||||
restartRequired="false"/>
|
||||
<registryKey key="kotlin.android.import.mpp.all.transitive"
|
||||
description="Add all transitive dependencies on MPP modules when Android project is imported"
|
||||
defaultValue="true"
|
||||
|
||||
@@ -91,10 +91,6 @@
|
||||
<j2kConverterExtension implementation="org.jetbrains.kotlin.nj2k.NewJ2kConverterExtension"/>
|
||||
</extensions>
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<registryKey key="kotlin.use.new.j2k"
|
||||
description="Use new Java to Kotlin Converter (experimental)"
|
||||
defaultValue="true"
|
||||
restartRequired="false"/>
|
||||
<registryKey key="kotlin.android.import.mpp.all.transitive"
|
||||
description="Add all transitive dependencies on MPP modules when Android project is imported"
|
||||
defaultValue="true"
|
||||
|
||||
@@ -487,7 +487,7 @@
|
||||
parentId="project.propCompiler"/>
|
||||
|
||||
<applicationConfigurable groupId="language" displayName="Kotlin" id="preferences.language.Kotlin"
|
||||
instance="org.jetbrains.kotlin.idea.configuration.KotlinUpdatesSettingsConfigurable"/>
|
||||
instance="org.jetbrains.kotlin.idea.configuration.KotlinLanguageConfiguration"/>
|
||||
|
||||
<projectConfigurable groupId="language" displayName="Kotlin Scripting" id="preferences.language.Kotlin.scripting"
|
||||
instance="org.jetbrains.kotlin.idea.script.configuration.KotlinScriptingSettingsConfigurable"
|
||||
|
||||
@@ -20,12 +20,12 @@ import com.intellij.ide.actions.ShowSettingsUtilImpl
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinUpdatesSettingsConfigurable
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinLanguageConfiguration
|
||||
|
||||
class ConfigurePluginUpdatesAction : DumbAwareAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.getData(CommonDataKeys.PROJECT)
|
||||
ShowSettingsUtilImpl.showSettingsDialog(project, KotlinUpdatesSettingsConfigurable.ID, "")
|
||||
ShowSettingsUtilImpl.showSettingsDialog(project, KotlinLanguageConfiguration.ID, "")
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -12,10 +12,11 @@ import com.intellij.openapi.updateSettings.impl.UpdateSettings
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUpdater
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.PluginUpdateStatus
|
||||
import org.jetbrains.kotlin.idea.configuration.ui.ConfigurePluginUpdatesForm
|
||||
import org.jetbrains.kotlin.idea.configuration.ui.KotlinLanguageConfigurationForm
|
||||
import org.jetbrains.kotlin.j2k.J2kConverterExtension
|
||||
import javax.swing.JComponent
|
||||
|
||||
class KotlinUpdatesSettingsConfigurable : SearchableConfigurable, Configurable.NoScroll {
|
||||
class KotlinLanguageConfiguration : SearchableConfigurable, Configurable.NoScroll {
|
||||
companion object {
|
||||
const val ID = "preferences.language.Kotlin"
|
||||
|
||||
@@ -48,7 +49,7 @@ class KotlinUpdatesSettingsConfigurable : SearchableConfigurable, Configurable.N
|
||||
}
|
||||
}
|
||||
|
||||
private val form = ConfigurePluginUpdatesForm()
|
||||
private val form = KotlinLanguageConfigurationForm()
|
||||
private var update: PluginUpdateStatus.Update? = null
|
||||
|
||||
private var savedChannel = -1
|
||||
@@ -62,10 +63,13 @@ class KotlinUpdatesSettingsConfigurable : SearchableConfigurable, Configurable.N
|
||||
|
||||
override fun getDisplayName(): String = "Kotlin"
|
||||
|
||||
override fun isModified() = false
|
||||
override fun isModified() =
|
||||
form.useNewJ2kCheckBox.isSelected != J2kConverterExtension.isNewJ2k
|
||||
|
||||
override fun apply() {
|
||||
// Selected channel is now saved automatically
|
||||
|
||||
J2kConverterExtension.isNewJ2k = form.useNewJ2kCheckBox.isSelected
|
||||
}
|
||||
|
||||
private fun setInstalledVersion(installedVersion: String?, installingStatus: String?) {
|
||||
@@ -74,6 +78,7 @@ class KotlinUpdatesSettingsConfigurable : SearchableConfigurable, Configurable.N
|
||||
}
|
||||
|
||||
override fun createComponent(): JComponent? {
|
||||
form.useNewJ2kCheckBox.isSelected = J2kConverterExtension.isNewJ2k
|
||||
form.updateCheckProgressIcon.suspend()
|
||||
form.updateCheckProgressIcon.setPaintPassiveIcon(false)
|
||||
|
||||
|
||||
+34
-13
@@ -1,6 +1,6 @@
|
||||
<?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.ConfigurePluginUpdatesForm">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="7" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="5">
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.kotlin.idea.configuration.ui.KotlinLanguageConfigurationForm">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="5">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="500" height="400"/>
|
||||
@@ -8,14 +8,9 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="42b13">
|
||||
<constraints>
|
||||
<grid row="6" 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="2505b" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -30,7 +25,7 @@
|
||||
</grid>
|
||||
<grid id="b171" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="97" height="21"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -63,7 +58,7 @@
|
||||
</grid>
|
||||
<grid id="6a5b2" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -79,7 +74,7 @@
|
||||
</grid>
|
||||
<grid id="cf404" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="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"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
@@ -109,7 +104,7 @@
|
||||
</grid>
|
||||
<grid id="e3af8" binding="pluginVersionPanel" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="0">
|
||||
<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">
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="335" height="24"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -133,7 +128,7 @@
|
||||
</grid>
|
||||
<grid id="4a454" binding="bundledCompilerVersionPanel" layout-manager="FlowLayout" hgap="5" vgap="0" flow-align="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="335" height="24"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -155,6 +150,32 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="15a75" 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="6" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<clientProperties>
|
||||
<BorderFactoryClass class="java.lang.String" value="com.intellij.ui.IdeBorderFactory$PlainSmallWithoutIndent"/>
|
||||
</clientProperties>
|
||||
<border type="etched" title="Experimental Features"/>
|
||||
<children>
|
||||
<component id="d2573" class="javax.swing.JCheckBox" binding="useNewJ2kCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Use New J2K"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="73440">
|
||||
<constraints>
|
||||
<grid row="7" 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>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
+3
-2
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.idea.util.VersioningKt;
|
||||
import javax.swing.*;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigurePluginUpdatesForm {
|
||||
public class KotlinLanguageConfigurationForm {
|
||||
public JComboBox<String> channelCombo;
|
||||
public JButton reCheckButton;
|
||||
public JPanel mainPanel;
|
||||
@@ -27,8 +27,9 @@ public class ConfigurePluginUpdatesForm {
|
||||
private JTextPane currentVersion;
|
||||
private JPanel bundledCompilerVersionPanel;
|
||||
private JTextPane compilerVersion;
|
||||
public JCheckBox useNewJ2kCheckBox;
|
||||
|
||||
public ConfigurePluginUpdatesForm() {
|
||||
public KotlinLanguageConfigurationForm() {
|
||||
showVerifierDisabledStatus();
|
||||
|
||||
String pluginVersion = KotlinPluginUtil.getPluginVersion();
|
||||
@@ -7,12 +7,13 @@ package org.jetbrains.kotlin.idea.conversion.copy
|
||||
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import org.jetbrains.kotlin.idea.AbstractCopyPasteTest
|
||||
import org.jetbrains.kotlin.j2k.J2kConverterExtension
|
||||
|
||||
abstract class AbstractJ2kCopyPasteTest : AbstractCopyPasteTest() {
|
||||
protected open fun isNewJ2K(): Boolean = false
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
Registry.get("kotlin.use.new.j2k").setValue(isNewJ2K())
|
||||
J2kConverterExtension.isNewJ2k = isNewJ2K()
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.ide.util.PropertiesComponent
|
||||
import com.intellij.openapi.extensions.AbstractExtensionPointBean
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.registry.Registry
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
|
||||
abstract class J2kConverterExtension : AbstractExtensionPointBean() {
|
||||
@@ -30,8 +30,14 @@ abstract class J2kConverterExtension : AbstractExtensionPointBean() {
|
||||
): WithProgressProcessor
|
||||
|
||||
companion object {
|
||||
val isNewJ2k
|
||||
get() = Registry.`is`("kotlin.use.new.j2k", true)
|
||||
private const val newJ2kByDefault = true
|
||||
private const val optionName = "kotlin.use.new.j2k"
|
||||
|
||||
var isNewJ2k
|
||||
get() = PropertiesComponent.getInstance().getBoolean(optionName, newJ2kByDefault)
|
||||
set(value) {
|
||||
PropertiesComponent.getInstance().setValue(optionName, value, newJ2kByDefault)
|
||||
}
|
||||
|
||||
val EP_NAME = ExtensionPointName.create<J2kConverterExtension>("org.jetbrains.kotlin.j2kConverterExtension")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user