Anbu
Anbu

Reputation: 953

How to open a xml file with my editor in eclipse plugin development?

I have a flowchart editor for which xml file is the input. in the plugin.xml i have specified the extension as xml for my editor but it is opening in the default xml editor. what makes the file opening in my editor ? i want to do this in my plugin development. after i launch my plugin there is no preference or open with context menu. and i want to keep my editor as default for xml files

Upvotes: 2

Views: 1677

Answers (2)

Anbu
Anbu

Reputation: 953

Eclipse provides a mechanism to programmatically identify file types based on their actual content. The org. eclipse. core. contenttype. contentTypes extension point can be used to define a content type described by a "describer," which is a class capable of recognizing specific types of content given an input stream. Editors designed to work with a specific content type can be bound to it instead of a file extension.

We need to specify the content type in the plugin.xml like below

<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type base-type="org.eclipse.core.runtime.xml"
             file-extensions="xml"
             id="ca.ecliptical.examples.contenttype.apples"
             name="Apples File"
             priority="normal">
  <describer class="org.eclipse.core.runtime.content
                    .XMLRootElementContentDescriber">
     <parameter name="element"
                value="apples">
     </parameter>
  </describer>
</content-type>

below is the references and it works fine

http://www.developer.com/java/data/article.php/3648736/Eclipse-Tip-Define-Custom-Content-Types-to-Identify-Your-Data-Files.htm

Upvotes: 2

nitind
nitind

Reputation: 20013

Check the file's Open With context menu, and the defaults on the File Associations preference page.

Upvotes: 2

Related Questions