idea-plugin / arrow.meta.ide.dsl.editor.action / AnActionSyntax / addAnAction

addAnAction

open fun MetaIde.addAnAction(actionId: String, action: AnAction): ExtensionPhase

Registers the action with actionId as its identifier. The actionId is solely used internally.

import com.intellij.openapi.wm.ToolWindowManager
import arrow.meta.ide.resources.ArrowIcons
import arrow.meta.ide.invoke
import arrow.meta.ide.IdePlugin
import arrow.meta.ide.MetaIde
import com.intellij.openapi.project.Project
import com.intellij.openapi.actionSystem.AnActionEvent

val MetaIde.exampleAction: IdePlugin
get() = "Example Action" {
  meta(
  //sampleStart
    addAnAction(
     actionId = "Unique",
     action = anAction(
      title = "MetaAction",
      actionPerformed = { e: AnActionEvent ->
       // e.project?.let { project: Project -> ToolWindowManager.getInstance(project)?.getToolWindow("MetaToolWindow")?.activate(null) }
       }
      )
     )
  //sampleEnd
   )
 }

MetaAction is registered with the id Unique and opens a tool window with a registered Id MetaToolWindow, assuming this ToolWindowId is registered. User’s are able to search this Action with its title: MetaAction.

Parameters

actionId - needs to be unique

action - can be composed with various anAction implementations

Do you like Arrow?

Arrow Org
<