コンテンツ型

org.eclipse.core.runtime.contentTypes

3.0

コンテンツ型拡張ポイントにより、プラグインは、プラットフォーム・コンテンツ型カタログにコントリビュートできます。 コントリビューションには、コンテンツ型ファイルの関連付け の 2 つの形式があります。

<!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>

content-type エレメントで describer 属性を使用した場合、このエレメントは無視されます。



<!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>

このコンテンツ型に関連するプロパティーを宣言し、オプションとして、デフォルト値を割り当てます。プロパティーについて詳しくは、org.eclipse.core.runtime.content.IContentDescription を参照してください。



org.eclipse.core.runtime.content.XMLRootElementContentDescriber (組み込みディスクライバー) を使用した XML ベースのコンテンツ型宣言の例を以下に示します。

   

<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>

特定のファイル拡張子を持つテキスト・ベースの単純なコンテンツ型の例を以下に示します。

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"MyText"

base-type=

"org.eclipse.core.runtime.text"

file-extensions=

"mytxt"

/>

</extension>

新規のファイル名/拡張子を既存のコンテンツ型に関連付ける必要がある場合は (新規コンテンツ型を定義する場合と反対)、以下のようにプラグインをファイルの関連付けに役立てることができます。このようにすると、テキスト・コンテンツ型の定義を拡張して、名前が「*.mytxt」パターンに該当するファイルを追加することができます。

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<file-association content-type=

"org.eclipse.core.runtime.text"

file-extensions=

"mytxt"

/>

</extension>

以下にプロパティーを定義するコンテンツ型の例を示します。
   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"MyContentType"

file-extensions=

"dat"

>

<property name=

"file-format"

value=

"1"

/>

</content-type>

</extension>

ディスクライバー・エレメントの class 属性の値は、org.eclipse.core.runtime.content.IContentDescriber または org.eclipse.core.runtime.content.ITextContentDescriber の 実装者を表す必要があります。 org.eclipse.core.runtime.content API によって戻される org.eclipse.core.runtime.content.IContentDescription オブジェクト

org.eclipse.core.runtime プラグインでは、 以下のコンテンツ型が提供されます。

プラットフォームの他のプラグインでは、他のコンテンツ型がコントリビュートされます。

また、org.eclipse.core.runtime プラグインでは、コンテンツ・ディスクライバーのすぐに使用可能な実装が提供されます。