mirror of
https://github.com/chylex/IntelliJ-Keep-Editor-Tooltips-While-Debugging.git
synced 2025-05-21 06:34:07 +02:00
Implement plugin functionality
This commit is contained in:
parent
cf6d046b70
commit
ae16f28b09
src/main
java/com/chylex/intellij/keeppopupswhiledebugging
resources/META-INF
@ -0,0 +1,24 @@
|
||||
package com.chylex.intellij.keeppopupswhiledebugging
|
||||
|
||||
import com.intellij.ide.plugins.CannotUnloadPluginException
|
||||
import com.intellij.ide.plugins.DynamicPluginListener
|
||||
import com.intellij.ide.plugins.IdeaPluginDescriptor
|
||||
|
||||
class PluginLoadListener : DynamicPluginListener {
|
||||
private companion object {
|
||||
private const val PLUGIN_ID = "com.chylex.intellij.keeppopupswhiledebugging"
|
||||
}
|
||||
|
||||
override fun pluginLoaded(pluginDescriptor: IdeaPluginDescriptor) {
|
||||
if (pluginDescriptor.pluginId.idString == PLUGIN_ID) {
|
||||
PreventHidingPopups.installListener()
|
||||
PreventHidingPopups.enablePopupsInAllProjects()
|
||||
}
|
||||
}
|
||||
|
||||
override fun beforePluginUnload(pluginDescriptor: IdeaPluginDescriptor, isUpdate: Boolean) {
|
||||
if (pluginDescriptor.pluginId.idString == PLUGIN_ID) {
|
||||
throw CannotUnloadPluginException("A restart is required to unload Keep Editor Popups While Debugging plugin.")
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.chylex.intellij.keeppopupswhiledebugging
|
||||
|
||||
import com.intellij.openapi.editor.EditorMouseHoverPopupManager
|
||||
import com.intellij.openapi.editor.impl.EditorMouseHoverPopupControl
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.ProjectManager
|
||||
import com.intellij.openapi.startup.StartupActivity
|
||||
import com.intellij.openapi.util.Key
|
||||
|
||||
class PreventHidingPopups : StartupActivity {
|
||||
override fun runActivity(project: Project) {
|
||||
installListener()
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun installListener() {
|
||||
EditorMouseHoverPopupManager.getInstance() // Installs the default listener.
|
||||
EditorMouseHoverPopupControl.getInstance()?.addListener(MouseTrackingDisabledListener)
|
||||
}
|
||||
|
||||
fun enablePopupsInAllProjects() {
|
||||
val projectManager = ProjectManager.getInstanceIfCreated() ?: return
|
||||
|
||||
for (project in projectManager.openProjects) {
|
||||
repeat(MouseTrackingDisabledKey.getDisabledCount(project)) {
|
||||
EditorMouseHoverPopupControl.enablePopups(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object MouseTrackingDisabledListener : Runnable {
|
||||
private var isReenablingPopups = false
|
||||
|
||||
override fun run() {
|
||||
if (!isReenablingPopups) {
|
||||
isReenablingPopups = true
|
||||
enablePopupsInAllProjects()
|
||||
isReenablingPopups = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object MouseTrackingDisabledKey {
|
||||
private val KEY: Key<*>?
|
||||
|
||||
init {
|
||||
EditorMouseHoverPopupControl.getInstance() // Creates the key.
|
||||
KEY = Key.findKeyByName("MOUSE_TRACKING_DISABLED_COUNT")
|
||||
}
|
||||
|
||||
@Suppress("ConvertLambdaToReference")
|
||||
fun getDisabledCount(project: Project): Int {
|
||||
return KEY?.let { project.getUserData(it) } as? Int ?: 0
|
||||
}
|
||||
}
|
||||
}
|
@ -12,4 +12,12 @@
|
||||
]]></description>
|
||||
|
||||
<depends>com.intellij.modules.platform</depends>
|
||||
|
||||
<extensions defaultExtensionNs="com.intellij">
|
||||
<postStartupActivity implementation="com.chylex.intellij.keeppopupswhiledebugging.PreventHidingPopups" />
|
||||
</extensions>
|
||||
|
||||
<applicationListeners>
|
||||
<listener class="com.chylex.intellij.keeppopupswhiledebugging.PluginLoadListener" topic="com.intellij.ide.plugins.DynamicPluginListener" />
|
||||
</applicationListeners>
|
||||
</idea-plugin>
|
||||
|
Loading…
Reference in New Issue
Block a user