IntelliJ IDEA Open API and Plugin Development Is Deprecated. Join our JetBrains Platform Community.
How to click my gutter icons to go to plugin panel to highlight the corresponding tree node
3 人关注
已回答
Hi,
I want to add a feature to my plugin that will allow me by clicking on the icon that I defined in the gutter area to jump to a specific location in the plugin panel.
I've marked my icon in the gutter area by implementing the LineMarkerProvider.
My plug-in panel shows a tree that marks my file structure. I want to get the corresponding node position on the tree by clicking my icon.
thanks,
请先登录再写评论。
It's difficult to provide a specific answer without more context about what you're working on. However, here are some general steps you can follow to implement a feature that allows clicking on gutter icons to go to a plugin panel and highlight the corresponding tree node:
Add gutter icons to your code editor. Gutter icons are small icons that appear in the vertical gutter of the code editor next to each line of code. You can add them using the appropriate API provided by your code editor.
Bind an event handler to the gutter icons to listen for click events. When a gutter icon is clicked, the event handler should retrieve the line number of the clicked icon and pass it to the plugin panel.
Create a plugin panel that displays the code tree and highlights the corresponding node. The plugin panel should receive the line number of the clicked gutter icon from the event handler and use it to highlight the corresponding node in the code tree.
Connect the gutter icons to the plugin panel. When a gutter icon is clicked, the event handler should pass the line number to the plugin panel and activate it so that it is displayed and the corresponding node is highlighted.
Note that the exact implementation details may vary depending on the specific code editor and plugin system you're using.
You can use custom Message Topic to send such events/commands. https://plugins.jetbrains.com/docs/intellij/messaging-infrastructure.html