mring mring - 9 months ago 25
Java Question

How to tell eclipse preferred content type for a file

I'm working on a plugin that will handle files of a given type, say,

when in Eclipse I try to open an
file. I'm trying to use

org.eclipse.core.runtime.content.IContentType type =

I've got code to look up the needed factory once I have the
I need to find out how to "register" my file type with Eclipse So when I select a file of my type to open, the Eclipse application knows to use my code to handle it. I've already gone to the Extensions tab of my
and added my Extension Element Details such as base-type, file-extensions, id (package where my code is) and name. But type still ends up as null.


I guess that you want to open the files with an editor. If I remember correctly (from a .properties editor example), your editor contribution should look like that:

<extension point="org.eclipse.ui.editors">
  <extensions>xyz,txt,jpg</extensions> <!-- .xyz .txt and .jpg files       --> 
  <default>true</default>              <!-- default editor for these types -->