如何使用插件放大eclipse java编辑器功能? [英] How to enlarge eclipse java editor functionality using plugins?

查看:625
本文介绍了如何使用插件放大eclipse java编辑器功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望有人可以帮助我,给出一个提示和出路。
现在我参与了一个雄心勃勃的项目,试图创建混合​​的数学和编程IDE。
经过巨大的预测,我们决定使用eclipse作为基础,并以某种方式添加Mathematica,maple功能。
一般来说,我们想让数学表达式(a = sin(Pi)+ 10 ^ 2)成为java代码。此外,这些表达式应该在LaTex视图中显示,在代码中,使工程师更易于阅读,来说明我们要在注释中实现插入图像的代码。
由于我们需要所有的java编辑器功能,在我看来,使用standart eclipse java编辑器是正确的,并学习它与其他对象的行为,e。 G。图像。



所以我的问题是:
- 有人可以分享开发类似产品的经验吗?
- 可能有像我们要开发的东西吗?



可能我会写更多的问题,特别是更紧密的问题。

解决方案

这当然是一个有趣的探索项目。正如Gilbert Le Blanc所说,Java编辑器经过高度优化来编辑Java代码,并不意味着可扩展。



据说,我可以推荐两个选项(按照规则播放一个,反之亦然)。


  1. 您可以通过org.eclipse.jdt.ui.JavaEditorTextHovers扩展点实现自己的悬停代码,而不是直接将图像嵌入到Java编辑器中(因此它将像JavaDoc一样工作悬停),或位于编辑器旁边的单独视图中(因此它将像JavaDoc视图一样工作)。 (这是按照规则播放的。)

  2. 之前,我实现了一个原型编辑器,可以让您编辑Java代码,其中嵌入了一个嵌入其中的CAL(功能性JVM语言) 。这些代码片段存储在编辑器内的自己的小窗口中。这是一个原型,并不是一切顺利,它也使用Eclipse 3.2,但这正是你想要做的事情。编译和运行代码是不容易的,但你可以看看它....好吧,也许。我必须找到源代码的EPL变体。在此之前,只要意识到黑客Java编辑器需要一些关于JDT的专业知识,并且您需要注意如何做,以免您无意中破坏其他的东西。






修改



这是一个zip我所描述的项目。它不会原样编译,但您可以查看源代码:



尝试此链接。它应该是可以看到的世界。



要实现的基本要素是,swt StyledText小部件本身可以包含其他小部件。这个项目在Java编辑器中使用。



具体来说,看一下类 org.openquark.cal.eclipse.embedded.containing.ContainingEditor ,它是CompilaitonUnitEditor的子类。这个特殊的类在另一个编辑器(包含的编辑器)中嵌入了第二个文本编辑器(包含的编辑器)。



另外,看一下org.openquark.cal。 eclipse.embedded.containing.ControlManager。该类管理包含CompilationUnitEditor的样式文本中的不同控件。



这个项目所做的是创建类似Java的编辑器,并允许用户将编辑器嵌入Java编辑器中的另一种语言。这些编辑器实际上由包含的Java编辑器中的文本支持,但文本由包含的编辑器覆盖。



所包含的编辑器在输入文本时上下移动包含编辑器。此外,您可以使用键盘在包含的编辑器中获得/失去焦点。



从我看过这段代码已经好几年了,但如果您有任何问题,给我一条线或添加这个问题。


Hope somebody could help me, giving a hint and way out. Right now I'm involved in a ambitious project trying to create mixed math and programming IDE. After a huge prestudy we decided to use eclipse as a base, and somehow add Mathematica,maple functionality. Generally speaking we want to make entering math expressions (a = sin(Pi)+10^2) into java code possible. Also those expressions should be showed in LaTex view, right in the code to make it more readable for engineers, to illustrate the code we want to implement insertion images in comments. As we need all th java editor functionality, in my opinion it's correct to use standart eclipse java editor, and learn it to behave with other objects, e. g. images.

So my questions are: - Could somebody share experience developing similar products? - May be there are something like we are going to develop?

Probably I'll write more questions, especially tighter ones.

解决方案

That is certainly an interesting sounding project. As Gilbert Le Blanc mentions, the Java Editor is highly optimized to edit Java code and is not meant to be extensible.

That being said, I can recommend two options (one that plays by the rules, and one that goes against them).

  1. Instead of embedding your images directly in the Java editor, you could implement your own hover, through the org.eclipse.jdt.ui.JavaEditorTextHovers extension point (so it would work like JavaDoc hovers), or in a separate view that sits beside the editor (so it would work like the JavaDoc view). (This is playing by the rules.)
  2. A while ago, I implemented a prototype editor that allows you to edit Java code with snippets of CAL (a functional JVM language) embedded inside of it. The snippets were stored in there own little window inside the editor. This was a prototype and not everything worked smoothly and it was also using Eclipse 3.2, but this is exactly the kind of thing that you want to do. It won't be easy to compile and run the code, but you can have a look at it....well, maybe. I have to find an EPL variant of the source code. Until then, just realize that hacking the Java Editor like this requires some specialized knowledge about the JDT and you need to be careful about how you do it so that you do inadvertently break other things.


Edit

Here is a zip of the project I described. It will not compile as it is, but you can look at the source code:

Try this link. It should be viewable by the world.

The essential thing to realize is that swt StyledText widgets can themselves contain other widgets. This project leverages that in Java editors.

In particular, look at the class org.openquark.cal.eclipse.embedded.containing.ContainingEditor, which is a sub-class of CompilaitonUnitEditor. This particular class embeds a second text editor (the contained editor) inside of another editor (the containing editor).

Also, take a look at org.openquark.cal.eclipse.embedded.containing.ControlManager. This class manages the different controls inside of a styled text of the containing CompilationUnitEditor.

What this project does is creates a Java-like editor, and allows users to embed editors for another language inside of the Java editor. These editors are actually backed by text in the containing Java editor, but the text is covered by the contained editor.

The contained editors move up and down as text is entered into containing editor. Also, you can use the keyboard to gain/lose focus in a contained editor.

It's been several years since I looked at this code, but if you have any questions, drop me a line or add to this question.

这篇关于如何使用插件放大eclipse java编辑器功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆