views:

96

answers:

1

I'm working on a plugin that will handle files of a given type, say, .xyz when in eclipse I try to open an xyz file. I'm trying to use

org.eclipse.core.runtime.content.IContentType type = 
  org.eclipse.core.runtime.Platform.getContentTypeManager().findContentTypeFor(
      fileURI.getPath());

I've got code to look up the needed factory once I have the IContentType. 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 Manifest.MF 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. Any ideas?

Thanks!

+1  A: 

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">
  <editor>
  ...
  <extensions>xyz,txt,jpg</extensions> <!-- .xyz .txt and .jpg files       --> 
  <default>true</default>              <!-- default editor for these types -->
  </editor>
</extension>
Andreas_D

related questions