创建带有文本悬停的 Eclipse 插件

2023-08-23Java开发问题
4

本文介绍了创建带有文本悬停的 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 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13