Skip to content

Commit 73bf01c

Browse files
committed
fix review
1 parent a8dfb28 commit 73bf01c

File tree

3 files changed

+57
-52
lines changed

3 files changed

+57
-52
lines changed

src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import com.vk.admstorm.notifications.AdmNotification
1717
import com.vk.admstorm.services.SentryService
1818
import com.vk.admstorm.settings.AdmStormSettingsState
1919
import com.vk.admstorm.ssh.SshConnectionService
20-
import com.vk.admstorm.utils.MyUtils.changeConfigurationProcess
20+
import com.vk.admstorm.startup.ChangeSshBackendStartup
2121
import com.vk.admstorm.utils.MyUtils.measureTime
2222
import com.vk.admstorm.utils.ServerNameProvider
2323
import com.vk.admstorm.utils.extensions.pluginEnabled
@@ -42,6 +42,9 @@ class AdmStormStartupActivity : ProjectActivity {
4242
return
4343
}
4444

45+
ChangeSshBackendStartup.changeConfigurationProcess(project)
46+
checkUpdates(project)
47+
4548
measureTime(LOG, "patch cpp highlight") {
4649
val cppType = FileTypeChooser.getKnownFileTypeOrAssociate(".c") as AbstractFileType
4750
CppTypeHighlightPatcher.patch(cppType)
@@ -53,9 +56,6 @@ class AdmStormStartupActivity : ProjectActivity {
5356
}
5457
}
5558

56-
changeConfigurationProcess(project)
57-
checkUpdates(project)
58-
5959
// Это необходимо чтобы для бенчмарков показывались все пункты в списке
6060
// который открывается при клике на иконку рядом с классом или методом.
6161
val key = Registry.get("suggest.all.run.configurations.from.context")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.vk.admstorm.startup
2+
3+
import com.intellij.ide.util.PropertiesComponent
4+
import com.intellij.openapi.diagnostic.logger
5+
import com.intellij.openapi.options.advanced.AdvancedSettings
6+
import com.intellij.openapi.project.Project
7+
import com.intellij.ssh.config.SshConnectionConfigService
8+
import com.vk.admstorm.notifications.AdmNotification
9+
10+
object ChangeSshBackendStartup {
11+
private val LOG = logger<ChangeSshBackendStartup>()
12+
13+
private const val SSH_NOTIFICATOR_OPTION = "sshLegacyChanges"
14+
private const val SSH_CONFIG_BACKEND = "ssh.config.backend"
15+
16+
private fun changeSshConfiguration(configValue: SshConnectionConfigService.Kind) {
17+
AdvancedSettings.setEnum(SSH_CONFIG_BACKEND, configValue)
18+
}
19+
20+
fun changeConfigurationProcess(project: Project) {
21+
val dntShow = PropertiesComponent.getInstance(project).getBoolean(SSH_NOTIFICATOR_OPTION)
22+
if (dntShow) {
23+
LOG.info("LEGACY SSH option was enabled")
24+
return
25+
}
26+
27+
val sshSettingValue = AdvancedSettings.getEnum(SSH_CONFIG_BACKEND, SshConnectionConfigService.Kind::class.java)
28+
if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) {
29+
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
30+
LOG.info("LEGACY SSH option was enabled before")
31+
return
32+
}
33+
34+
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
35+
LOG.info("LEGACY SSH has been changed")
36+
37+
AdmNotification("We changed your ssh type to LEGACY")
38+
.withActions(
39+
AdmNotification.Action("Don`t show it again") { _, notification ->
40+
LOG.info("LEGACY SSH option has been set")
41+
notification.expire()
42+
}
43+
).withActions(
44+
AdmNotification.Action("Rollback and turn off this notification") { _, notification ->
45+
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
46+
LOG.info("SSH option changed to OpenSSH")
47+
notification.expire()
48+
}
49+
).show(project)
50+
51+
PropertiesComponent.getInstance(project).setValue(SSH_NOTIFICATOR_OPTION, true)
52+
}
53+
}

src/main/kotlin/com/vk/admstorm/utils/MyUtils.kt

-48
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package com.vk.admstorm.utils
22

3-
import com.intellij.ide.util.PropertiesComponent
43
import com.intellij.openapi.application.ApplicationManager
54
import com.intellij.openapi.application.PathManager
65
import com.intellij.openapi.application.invokeAndWaitIfNeeded
7-
import com.intellij.openapi.application.invokeLater
86
import com.intellij.openapi.diagnostic.Logger
97
import com.intellij.openapi.diagnostic.logger
10-
import com.intellij.openapi.options.advanced.AdvancedSettings
118
import com.intellij.openapi.progress.PerformInBackgroundOption
129
import com.intellij.openapi.progress.ProgressIndicator
1310
import com.intellij.openapi.progress.ProgressManager
@@ -20,8 +17,6 @@ import com.intellij.openapi.vfs.LocalFileSystem
2017
import com.intellij.openapi.vfs.VirtualFile
2118
import com.intellij.psi.PsiFile
2219
import com.intellij.psi.PsiManager
23-
import com.intellij.ssh.config.SshConnectionConfigService
24-
import com.vk.admstorm.notifications.AdmNotification
2520
import com.vk.admstorm.utils.extensions.toHex
2621
import org.apache.commons.io.input.ReversedLinesFileReader
2722
import java.awt.Toolkit
@@ -234,47 +229,4 @@ object MyUtils {
234229
}
235230
}, delay)
236231
}
237-
238-
fun changeSshConfiguration(configValue: Enum<SshConnectionConfigService.Kind>) {
239-
AdvancedSettings.setEnum("ssh.config.backend", configValue)
240-
}
241-
242-
fun changeConfigurationProcess(project: Project) {
243-
val sshSettingValue =
244-
AdvancedSettings.getEnum("ssh.config.backend", SshConnectionConfigService.Kind::class.java)
245-
if (sshSettingValue == SshConnectionConfigService.Kind.LEGACY) {
246-
return
247-
}
248-
249-
val dntShow = PropertiesComponent.getInstance(project).getBoolean("dntShowSshLegacy")
250-
if (dntShow) {
251-
return
252-
} else {
253-
val isSshLegacy = PropertiesComponent.getInstance(project).getBoolean("isSshLegacy")
254-
if (isSshLegacy) {
255-
return
256-
}
257-
258-
changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)
259-
260-
AdmNotification("We changed your ssh type to LEGACY")
261-
.withActions(
262-
AdmNotification.Action("Don`t show it again") { _, notification ->
263-
invokeLater {
264-
PropertiesComponent.getInstance(project).setValue("dntShowSshLegacy", true)
265-
notification.expire()
266-
}
267-
}
268-
).withActions(
269-
AdmNotification.Action("Rollback and turn off this notification") { _, notification ->
270-
invokeLater {
271-
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
272-
PropertiesComponent.getInstance(project).setValue("dntShowSshLegacy", true)
273-
notification.expire()
274-
}
275-
}
276-
)
277-
.show(project)
278-
}
279-
}
280232
}

0 commit comments

Comments
 (0)