Creating a eclipse plugin with text hover(创建带有文本悬停的 Eclipse 插件)
问题描述
我想做一个 Eclipse 插件(文本编辑器).我会阅读"光标下的文本并显示取决于文本的动态生成悬停.现在我的问题是我不知道如何阅读文本并添加"悬停.
I would like to make a Eclipse plugin (text editor). I would "read" the text under the cursor and show a dynamical generated hover that depends on the text. Now I have the problem that I don't know how I can read the text and "add" the hover.
这是我的第一个 Eclipse 插件,所以我很高兴能得到每一个提示.
It's my first Eclipse Plugin so I am happy for each tip I can get.
我想将它集成到默认的 Eclipse Java 编辑器中.我曾尝试使用编辑器模板创建一个新的 plugin,但我认为这是错误的方式.
I'd like to integrate it into the default Eclipse Java editor. I have tried to create a new plugin with a editor template but I think it is the wrong way.
上次
来自 PKeidel 的答案正是我想要的 :)
The answer from PKeidel is exactly what I'm looking for :)
感谢 PKeidel
推荐答案
你的错是你创建了一个全新的编辑器,而不是为现有的 Java 编辑器创建一个插件.插件将通过 extension points 激活.在您的情况下,您必须使用 org.eclipse.jdt.ui.javaEditorTextHovers 更多....
Your fault is that you created a completly new Editor instead of a plugin for the existing Java Editor. Plugins will be activated via extension points. In your case you have to use org.eclipse.jdt.ui.javaEditorTextHovers more....
<plugin>
<extension
point="org.eclipse.jdt.ui.javaEditorTextHovers">
<hover
activate="true"
class="path.to_your.hoverclass"
id="id.path.to_your.hoverclass">
</hover>
</extension>
</plugin>
class 参数保存实现 IJavaEditorTextHover 的类的路径.
public class LangHover implements IJavaEditorTextHover
{
@Override
public String getHoverInfo(ITextViewer textviewer, IRegion region)
{
if(youWantToShowAOwnHover)
return "Your own hover Text goes here"";
return null; // Shows the default Hover (Java Docs)
}
}
应该这样做;-)
这篇关于创建带有文本悬停的 Eclipse 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:创建带有文本悬停的 Eclipse 插件
基础教程推荐
- 在springboot中如何给mybatis加拦截器 2023-04-29
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
