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.
Asked
Active
Viewed 896 times
2 Answers
1
You need to add an org.eclipse.ui.editors extension point.
<extension point="org.eclipse.ui.editors">
<editor
name="MyEditor Name"
extensions="my_file_extension"
icon="icons/sample.gif"
class="com.me.MyEditor"
id="com.me.MyEditorID">
</editor>

Pushkar
- 7,450
- 10
- 38
- 57
-
Thanks.ive added that.But if you let me know how should i configure eclipse to open the file – s_wiki Jan 17 '13 at 09:03
-
You have written your own editor? Or do you want to use some default editor? – Pushkar Jan 17 '13 at 09:08
-
i want to create a default editor for that .xyz particular extension – s_wiki Jan 17 '13 at 09:09
-
I would suggest that you follow this tutorial. http://www.vogella.com/articles/EclipseEditors/article.html – Pushkar Jan 17 '13 at 09:29
0
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?

Waqas Ilyas
- 3,116
- 1
- 17
- 27