diff --git a/src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt b/src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt index 6b74d6af..08538680 100644 --- a/src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt +++ b/src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt @@ -17,7 +17,7 @@ import com.vk.admstorm.notifications.AdmNotification import com.vk.admstorm.services.SentryService import com.vk.admstorm.settings.AdmStormSettingsState import com.vk.admstorm.ssh.SshConnectionService -import com.vk.admstorm.utils.MyUtils.changeConfigurationProcess +import com.vk.admstorm.startup.ChangeSshBackendStartup import com.vk.admstorm.utils.MyUtils.measureTime import com.vk.admstorm.utils.ServerNameProvider import com.vk.admstorm.utils.extensions.pluginEnabled @@ -42,6 +42,9 @@ class AdmStormStartupActivity : ProjectActivity { return } + ChangeSshBackendStartup.changeConfigurationProcess(project) + checkUpdates(project) + measureTime(LOG, "patch cpp highlight") { val cppType = FileTypeChooser.getKnownFileTypeOrAssociate(".c") as AbstractFileType CppTypeHighlightPatcher.patch(cppType) @@ -53,9 +56,6 @@ class AdmStormStartupActivity : ProjectActivity { } } - changeConfigurationProcess(project) - checkUpdates(project) - // Это необходимо чтобы для бенчмарков показывались все пункты в списке // который открывается при клике на иконку рядом с классом или методом. val key = Registry.get("suggest.all.run.configurations.from.context") diff --git a/src/main/kotlin/com/vk/admstorm/startup/ChangeSshBackendStartup.kt b/src/main/kotlin/com/vk/admstorm/startup/ChangeSshBackendStartup.kt new file mode 100644 index 00000000..daa2f70b --- /dev/null +++ b/src/main/kotlin/com/vk/admstorm/startup/ChangeSshBackendStartup.kt @@ -0,0 +1,53 @@ +package com.vk.admstorm.startup + +import com.intellij.ide.util.PropertiesComponent +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.options.advanced.AdvancedSettings +import com.intellij.openapi.project.Project +import com.intellij.ssh.config.SshConnectionConfigService +import com.vk.admstorm.notifications.AdmNotification + +object ChangeSshBackendStartup { + private val LOG = logger() + + private const val SSH_NOTIFICATOR_OPTION = "sshLegacyChanges" + private const val SSH_CONFIG_BACKEND = "ssh.config.backend" + + private fun changeSshConfiguration(configValue: SshConnectionConfigService.Kind) { + AdvancedSettings.setEnum(SSH_CONFIG_BACKEND, configValue) + } + + fun changeConfigurationProcess(project: Project) { + val dntShow = PropertiesComponent.getInstance(project).getBoolean(SSH_NOTIFICATOR_OPTION) + if (dntShow) { + LOG.info("LEGACY SSH option was enabled") + return + } + + val sshSettingValue = AdvancedSettings.getEnum(SSH_CONFIG_BACKEND, SshConnectionConfigService.Kind::class.java) + if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) { + PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true) + LOG.info("LEGACY SSH option was enabled before") + return + } + + changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY) + LOG.info("LEGACY SSH has been changed") + + AdmNotification("We changed your ssh type to LEGACY") + .withActions( + AdmNotification.Action("Don`t show it again") { _, notification -> + PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true) + LOG.info("LEGACY SSH option has been set") + notification.expire() + } + ).withActions( + AdmNotification.Action("Rollback and turn off this notification") { _, notification -> + changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH) + PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true) + LOG.info("SSH option changed to OpenSSH") + notification.expire() + } + ).show(project) + } +} diff --git a/src/main/kotlin/com/vk/admstorm/utils/MyUtils.kt b/src/main/kotlin/com/vk/admstorm/utils/MyUtils.kt index cf04bf50..419fee0e 100644 --- a/src/main/kotlin/com/vk/admstorm/utils/MyUtils.kt +++ b/src/main/kotlin/com/vk/admstorm/utils/MyUtils.kt @@ -1,13 +1,10 @@ package com.vk.admstorm.utils -import com.intellij.ide.util.PropertiesComponent import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.PathManager import com.intellij.openapi.application.invokeAndWaitIfNeeded -import com.intellij.openapi.application.invokeLater import com.intellij.openapi.diagnostic.Logger import com.intellij.openapi.diagnostic.logger -import com.intellij.openapi.options.advanced.AdvancedSettings import com.intellij.openapi.progress.PerformInBackgroundOption import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.progress.ProgressManager @@ -20,8 +17,6 @@ import com.intellij.openapi.vfs.LocalFileSystem import com.intellij.openapi.vfs.VirtualFile import com.intellij.psi.PsiFile import com.intellij.psi.PsiManager -import com.intellij.ssh.config.SshConnectionConfigService -import com.vk.admstorm.notifications.AdmNotification import com.vk.admstorm.utils.extensions.toHex import org.apache.commons.io.input.ReversedLinesFileReader import java.awt.Toolkit @@ -234,47 +229,4 @@ object MyUtils { } }, delay) } - - fun changeSshConfiguration(configValue: Enum) { - AdvancedSettings.setEnum("ssh.config.backend", configValue) - } - - fun changeConfigurationProcess(project: Project) { - val sshSettingValue = - AdvancedSettings.getEnum("ssh.config.backend", SshConnectionConfigService.Kind::class.java) - if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) { - return - } - - val dntShow = PropertiesComponent.getInstance(project).getBoolean("dntShowSshLegacy") - if (dntShow) { - return - } else { - val isSshLegacy = PropertiesComponent.getInstance(project).getBoolean("isSshLegacy") - if (isSshLegacy) { - return - } - - changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY) - - AdmNotification("We changed your ssh type to LEGACY") - .withActions( - AdmNotification.Action("Don`t show it again") { _, notification -> - invokeLater { - PropertiesComponent.getInstance(project).setValue("dntShowSshLegacy", true) - notification.expire() - } - } - ).withActions( - AdmNotification.Action("Rollback and turn off this notification") { _, notification -> - invokeLater { - changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH) - PropertiesComponent.getInstance(project).setValue("dntShowSshLegacy", true) - notification.expire() - } - } - ) - .show(project) - } - } }