Typy treści

org.eclipse.core.runtime.contentTypes

3.0

Punkt rozszerzenia typów treści umożliwia modułom dodatkowym wnoszenie katalogu typów treści platformy. Wnoszone mogą być elementy dwojakiego rodzaju: typy treści i powiązania plików.

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

Jeśli atrybut obiektu opisu jest używany w elemencie typu treści, ten element jest ignorowany.



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

Deklaruje właściwość dotyczącą tego typu treści, przypisując opcjonalnie wartość domyślną. Więcej informacji o właściwościach zawiera dokumentacja interfejsu org.eclipse.core.runtime.content.IContentDescription.



Poniżej przedstawiono przykładową deklarację typu treści opartego na języku XML, która używa wbudowanego obiektu opisu org.eclipse.core.runtime.content.XMLRootElementContentDescriber:

   

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

Oto przykład prostego typu treści opartego na tekście z przypisanym konkretnym rozszerzeniem pliku:

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"MyText"

base-type=

"org.eclipse.core.runtime.text"

file-extensions=

"mytxt"

/>

</extension>

Jeśli istnieje potrzeba powiązania nowych nazw/rozszerzeń plików z istniejącym typem treści (w przeciwieństwie do definiowania nowego typu treści), moduł dodatkowy może dostarczać powiązanie pliku, tak jak pokazano to poniżej. Powoduje to rozszerzenie definicji typu tekstowego o pliki z nazwami pasującymi do wzorca "*.mytxt".

   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<file-association content-type=

"org.eclipse.core.runtime.text"

file-extensions=

"mytxt"

/>

</extension>

Poniżej przedstawiono przykład typu treści, który definiuje właściwości:
   

<extension point=

"org.eclipse.core.runtime.contentTypes"

>

<content-type id=

"MyContentType"

file-extensions=

"dat"

>

<property name=

"file-format"

value=

"1"

/>

</content-type>

</extension>

Wartość atrybutu klasy w elemencie obiektu opisu musi reprezentować implementator obiektów org.eclipse.core.runtime.content.IContentDescriber, org.eclipse.core.runtime.content.ITextContentDescriber lub org.eclipse.core.runtime.content.IContentDescription zwróconych przez interfejs API org.eclipse.core.runtime.content.

Moduł dodatkowy org.eclipse.core.runtime udostępnia następujące typy treści:

Pozostałe moduły dodatkowe platformy wnoszą inne typy treści.

Także moduł dodatkowy org.eclipse.core.runtime udostępnia gotowe do użycia implementacje obiektów opisu treści: