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 插件
基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
