打开一个默认编辑器,在treeviewer选择eclipse rcp(例如:因为eclipse知道j.java文件必须在文本编辑器中打开) [英] Opening a default editor, on a treeviewer selection eclipse rcp(eg: as eclipse knows that j.java files must be opened in text editor)

查看:278
本文介绍了打开一个默认编辑器,在treeviewer选择eclipse rcp(例如:因为eclipse知道j.java文件必须在文本编辑器中打开)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展名为.xyz的文件.i想要打开一个编辑器,当它双击如何做到这一点。我有一个treeviewer,只列出我需要的文件,在我有一个.xyz file.I添加了一个编辑器在扩展点和扩展文本框我添加了.xyz也。我不想添加一个doubleclicklistener给viewer.Is有一种方法添加或告诉eclipse,如果这是扩展名的文件,那么默认情况下它应该打开。

解决方案

如果你有自己的浏览器实现,你需要定义完整的该查看器中的行为,甚至打开文件。由于您已经注册了一个针对该扩展名的编辑器,所以每当在Eclipse中打开该文件时,由查看器或其他查看器(Project Explorer,Navigator)将Eclipse自动在指定的编辑器中打开该文件。



在您的双击监听器中,您可以使用 org.eclipse.ui.actions.OpenFileAction 或类似的东西来确保文件被打开Eclipse根据Workbench规则。 Btw为什么要避免添加双击监听器?


I have a file with extension .xyz .i want to open an editor when it is double clicked How to go about doing it.I have a treeviewer that lists only my files that i need ,in those i have a .xyz file.I have added an editor in the extension point and in the extensions textfield i hav e added .xyz also.I dont want to add a doubleclicklistener to the viewer.Is there a way to add or tell eclipse that if this is the extension of the file then by default it should open.

解决方案

Well if you have your own viewer implementation you will need to define the complete behavior in that viewer, even the opening of files. Since you have registered an editor against that extension so whenever that file is opened in Eclipse, either by your viewer or some other viewer (Project Explorer, Navigator) Eclipse will automatically open the file in the assigned editor.

In your double click listener you can use org.eclipse.ui.actions.OpenFileAction or something like it to ensure that the file is opened by Eclipse according to Workbench rules. Btw why do you want to avoid adding a double click listener?

这篇关于打开一个默认编辑器,在treeviewer选择eclipse rcp(例如:因为eclipse知道j.java文件必须在文本编辑器中打开)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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