Content Types

org.eclipse.core.runtime.contentTypes

3.0

The content types extension point allows plug-ins to contribute to the platform content type catalog. There are two forms of contributions: content types and file associations.

<!ELEMENT extension (content-type* , file-association*)>

<!ATTLIST extension

point CDATA #REQUIRED

id    CDATA #IMPLIED

name  CDATA #IMPLIED>


<!ELEMENT content-type (describer? , property*)>

<!ATTLIST content-type

id              CDATA #REQUIRED

base-type       CDATA #IMPLIED

name            CDATA #REQUIRED

file-extensions CDATA #IMPLIED

file-names      CDATA #IMPLIED

priority        (low|normal|high) "normal"

default-charset CDATA #IMPLIED

describer       CDATA #IMPLIED

alias-for       CDATA #IMPLIED>


<!ELEMENT describer (parameter*)>

<!ATTLIST describer

class  CDATA #REQUIRED

plugin CDATA #IMPLIED>

If the describer attribute is used in the content-type element, this element is ignored.



<!ELEMENT file-association EMPTY>

<!ATTLIST file-association

content-type    CDATA #REQUIRED

file-names      CDATA #IMPLIED

file-extensions CDATA #IMPLIED>


<!ELEMENT parameter EMPTY>

<!ATTLIST parameter

name  CDATA #REQUIRED

value CDATA #REQUIRED>


<!ELEMENT property EMPTY>

<!ATTLIST property

name    CDATA #REQUIRED

default CDATA #IMPLIED>

Declares a property related to this content type, optionally assigning a default value. See org.eclipse.core.runtime.content.IContentDescription for more information on properties.



Following is an example of a XML-based content type declaration using org.eclipse.core.runtime.content.XMLRootElementContentDescriber, a built-in describer:

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"ABC"

base-type=

"org.eclipse.core.runtime.xml"

file-extensions=

"a,b,c"

>

<describer class=

"org.eclipse.core.runtime.content.XMLRootElementContentDescriber"

>

<parameter name=

"element"

value=

"abc"

/>

</describer>

</content-type>

</extension>

Here is an example of a simple text-based content type that has a specific file extension:

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"MyText"

base-type=

"org.eclipse.core.runtime.text"

file-extensions=

"mytxt"

/>

</extension>

When there is need to associate new file names/extensions to an existing content type (as opposed to defining a new content type), a plug-in can contribute a file association as seen below. This has the effect of enhancing the definition of the text content type to include files with names following the "*.mytxt" pattern.

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<file-association content-type=

"org.eclipse.core.runtime.text"

file-extensions=

"mytxt"

/>

</extension>

Here is an example of a content type that defines properties:
   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"MyContentType"

file-extensions=

"dat"

>

<property name=

"file-format"

value=

"1"

/>

</content-type>

</extension>

The value of the class attribute in the describer element must represent an implementor of org.eclipse.core.runtime.content.IContentDescriber or org.eclipse.core.runtime.content.ITextContentDescriber. org.eclipse.core.runtime.content.IContentDescription objects returned by the org.eclipse.core.runtime.content API

The org.eclipse.core.runtime plug-in provides the following content types:

Other plug-ins in the platform contribute other content types.

Also, the org.eclipse.core.runtime plug-in provides ready-to-use implementations of content describers: