[lang-impl] DocumentationPopupUI: add "Open Automatically During Completion" action
authorTagir Valeev <Tagir.Valeev@jetbrains.com>
Mon, 18 Oct 2021 09:27:52 +0000 (16:27 +0700)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 18 Oct 2021 10:10:17 +0000 (10:10 +0000)
The same action was added before to older DocumentationComponent, see 81a29d8b0c740a

GitOrigin-RevId: 29282fcffeee615c0b9bb42e98fd6f0b60d64f9b

platform/lang-impl/src/com/intellij/lang/documentation/ide/ui/DocumentationPopupUI.kt

index 6db16e77d62d3525221cc613efb95feab257a46f..4fe48fb0eb35bc7c70108d8cdc2ac46eaafa6d1c 100644 (file)
@@ -2,6 +2,7 @@
 package com.intellij.lang.documentation.ide.ui
 
 import com.intellij.codeInsight.CodeInsightBundle
+import com.intellij.codeInsight.CodeInsightSettings
 import com.intellij.codeInsight.documentation.DocumentationManager.NEW_JAVADOC_LOCATION_AND_SIZE
 import com.intellij.codeInsight.documentation.PopupDragListener
 import com.intellij.codeInsight.documentation.ToggleShowDocsOnHoverAction
@@ -75,6 +76,7 @@ internal class DocumentationPopupUI(
     secondaryActions.add(ToggleShowDocsOnHoverAction())
     secondaryActions.add(AdjustFontSizeAction())
     secondaryActions.add(ShowToolbarAction())
+    secondaryActions.add(ShowPopupAutomaticallyAction())
     secondaryActions.add(RestoreDefaultSizeAction())
 
     val toolbarActionGroup = DefaultActionGroup()
@@ -174,6 +176,17 @@ internal class DocumentationPopupUI(
     popupUpdateFlow.tryEmit("toolbar")
   }
 
+  private class ShowPopupAutomaticallyAction internal constructor() : ToggleAction(
+    CodeInsightBundle.messagePointer("javadoc.show.popup.automatically")), ActionToIgnore {
+    override fun isSelected(e: AnActionEvent): Boolean {
+      return CodeInsightSettings.getInstance().AUTO_POPUP_JAVADOC_INFO
+    }
+
+    override fun setSelected(e: AnActionEvent, state: Boolean) {
+      CodeInsightSettings.getInstance().AUTO_POPUP_JAVADOC_INFO = state
+    }
+  }
+
   private inner class ShowToolbarAction : ToggleAction(
     CodeInsightBundle.messagePointer("javadoc.show.toolbar"),
   ), ActionToIgnore {