如何告诉Eclipse首选的内容类型的文件
-
22-09-2019 - |
题
我工作的一个插件时,在Eclipse中我尝试打开一个.xyz
文件,将处理特定的类型,比如说,xyz
的文件。我试图用
org.eclipse.core.runtime.content.IContentType type =
org.eclipse.core.runtime.Platform.getContentTypeManager().findContentTypeFor(
fileURI.getPath());
我有代码来查找所需要的工厂,一旦我有IContentType
。
我需要找出如何使用Eclipse那么“注册”我的文件类型,当我选择我喜欢的类型的要打开的文件,Eclipse应用程序知道使用我的代码来处理它。我已经去了我Manifest.MF
的扩展选项卡,并添加我的扩展元素详细信息,如基本类型,文件扩展名,ID(包在我的代码)和名称。但仍然键入为空结束。
解决方案
我猜你想用编辑器打开文件。如果我没有记错(从.properties
编辑器的例子),你的编辑器的贡献应该看起来像:
<extension point="org.eclipse.ui.editors">
<editor>
...
<extensions>xyz,txt,jpg</extensions> <!-- .xyz .txt and .jpg files -->
<default>true</default> <!-- default editor for these types -->
</editor>
</extension>
不隶属于 StackOverflow