Eclipse插件 - 单独的编辑器和图标分配 [英] Eclipse plugins - separate Editor and icons assignment
问题描述
我已经定义了标准的TextEditor来打开 .git 文件。 ( GitHub的代码)
I have defined standard TextEditor to open .git files. (code at GitHub)
<!-- git -->
<extension
point="org.eclipse.ui.editors">
<editor
class="org.eclipse.ui.editors.text.TextEditor"
contributorClass="org.eclipse.ui.texteditor.BasicTextEditorActionContributor"
default="true"
extensions="gitignore,gitmodules,gitattributes"
icon="icons/git.ico"
id="org.eclipse.ui.DefaultTextEditor"
name="Text Editor">
</editor>
</extension>
然而,此代码更改了TextEditor的图标,无论我打开什么文件。
However this code changes icon for TextEditor, whatever file I open.
自定义文本编辑器的唯一方法是? 只有文件类型有特定的扩展点吗?
Is the only way the custom Text Editor? Are there particular extention points only for file types?
更新:定义自己的编辑器如下
UPDATE: Defining own Editor as below
import org.eclipse.ui.editors.text.TextEditor;
public class GitFilesEditor extends TextEditor{
使事情变得更复杂不喜欢指定所有这些项目的想法)
make matter even more complicated (I don't like idea to specify all those items)
Multiple markers at this line
- The type org.eclipse.jface.text.source.Annotation cannot be resolved. It is indirectly referenced from required .class files
- The type org.eclipse.jface.text.revisions.RevisionInformation cannot be resolved. It is indirectly referenced from required .class files
- The type org.eclipse.jface.text.source.ISourceViewer cannot be resolved. It is indirectly referenced from required .class files
- The type org.eclipse.jface.text.IRegion cannot be resolved. It is indirectly referenced from required .class files
- The type org.eclipse.jface.text.source.IVerticalRuler cannot be resolved. It is indirectly referenced from required .class files
推荐答案
具有与默认文本编辑器相同的ID:
Your editor has the same ID like the default text editor:
id="org.eclipse.ui.DefaultTextEditor"
这肯定会混淆Eclipse编辑器扩展查找。只需使用自定义的ID,例如
That surely confuses the Eclipse editor extension lookup. Just use a self defined ID there, like
id="org.nodeclipse.editor.git"
我还将名称更改为Git Text Editor或类似的东西,以避免编辑器首选项页面中的重复标签。
And I would also change the name to "Git Text Editor" or something like that to avoid duplicate labels in the editor preference page.
这篇关于Eclipse插件 - 单独的编辑器和图标分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!