Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Howto: Register Annotation Types"

(New page: __TOC__ {{backlink|Tigerstripe_APIs}} === Introduction === A new annotation type is added to the framework using a simple two extension point. * Core extension point described general inf...)
 
 
(5 intermediate revisions by 2 users not shown)
Line 2: Line 2:
 
{{backlink|Tigerstripe_APIs}}
 
{{backlink|Tigerstripe_APIs}}
 
=== Introduction ===
 
=== Introduction ===
A new annotation type is added to the framework using a simple two extension point.
+
A new annotation type is added to the framework using a simple three extension point.
  
 
* Core extension point described general information, like name, description and EMF object.
 
* Core extension point described general information, like name, description and EMF object.
* UI extension point provided annotation type icon which will be used in all dialogs, views, etc.
+
* Extension point for human-readable namespace label.
 +
* UI extension point provided annotation type display information which will be used in all dialogs, views, etc.
  
 
=== Adding extension ===
 
=== Adding extension ===
Line 13: Line 14:
 
   <extension point="org.eclipse.tigerstripe.annotation.core.annotationType">
 
   <extension point="org.eclipse.tigerstripe.annotation.core.annotationType">
 
     <definition
 
     <definition
          id="org.eclipse.tigerstripe.annotation.example.person"
 
 
           name="Person"
 
           name="Person"
 
           description="Personal information, like a full name, e-mail address, telephone number and so on"
 
           description="Personal information, like a full name, e-mail address, telephone number and so on"
 
           epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
 
           epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
 
           eclass="Person">
 
           eclass="Person">
 +
        <target
 +
            type="org.eclipse.core.resources.IResource" unique="true"/>
 
     </definition>
 
     </definition>
 
   </extension>
 
   </extension>
Line 23: Line 25:
 
The attributes are described as follows.
 
The attributes are described as follows.
  
* id - a unique name that will be used to identify this annotation type
+
* '''name''' - a human-readable name that will be used in the UI
* name - a human-readable name that will be used in the UI
+
* '''description''' - an annotation type description
* description - an annotation type description
+
* '''epackage-uri''' - identity of the EMF package contains annotation object
* epackage-uri - identity of the EMF package contains annotation object
+
* '''eclass''' - EMF class name from the specified package which will be used as an annotation object
* eclass - EMF class name from the specified package which will be used as an annotation object
+
* '''target''' - target allow to add annotations with the specified type only for specified annotable objects. For example, Person annotation can be attached only to the IResource. If there are no one target defined, annotation of this type can be attached to any annotable objects.
 +
** '''type''' - target type
 +
** '''unique''' - create no more than one unique annotation of the same type ('''true''' by default)
  
This extension point allow to use org.eclipse.tigerstripe.annotation.example.person.Person EMF class as an annotation.This annotation type would be also added to the Create Annotation Wizard.
+
This extension point allow to use org.eclipse.tigerstripe.annotation.example.person.Person EMF class as an annotation. This annotation type would be also added to the Create Annotation Wizard.
  
=== Contribute Image to the Annotation Type ===
+
=== Adding package label ===
  
An UI extension point (org.eclipse.tigerstripe.annotation.ui.annotationTypeImages) just provide an icon for this annotation type using in the Create Annotation Wizard, Annotations View, etc.
+
Annotation types grouped by package to simply navigate in the annotation creation menu/wizard. To create human-readable package label we need to contributed org.eclipse.tigerstripe.annotation.core.packageLabel extension point:
  
   <extension point="org.eclipse.tigerstripe.annotation.ui.annotationTypeImages">
+
   <extension
    <annotationTypeImage
+
      point="org.eclipse.tigerstripe.annotation.core.packageLabel">
          icon="icons/person.gif"
+
    <label
           typeID="org.eclipse.tigerstripe.annotation.example.person"/>
+
        epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
 +
        name="Personality"/>
 +
  </extension>
 +
 
 +
This extension should be added once for every package.
 +
 
 +
=== Display Annotation Type ===
 +
 
 +
An UI extension point (org.eclipse.tigerstripe.annotation.ui.annotationLabelProvider) just provide an JFace label provider for this annotation type using in the Create Annotation Wizard, Annotations View, etc.
 +
 
 +
  <extension point="org.eclipse.tigerstripe.annotation.ui.annotationLabelProvider">
 +
    <provider
 +
           class="org.eclipse.tigerstripe.annotation.example.person.PersonLabelProvider"
 +
          epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
 +
          eclass="Person"/>
 
   </extension>
 
   </extension>
  
 
The attributes are described as following:
 
The attributes are described as following:
  
* icon - a relative name of the icon that will be associated with the annotation type
+
* class - ILabelProvider class name that will be used to display this annotation type
* typeID - an annotation type identifier
+
* epackage-uri - an annotation type EMF package URI
 +
* eclass - an annotation type EMF class name
  
 
[[Category:Tigerstripe_APIs]]
 
[[Category:Tigerstripe_APIs]]

Latest revision as of 00:51, 4 September 2008

< To: Tigerstripe_APIs

Introduction

A new annotation type is added to the framework using a simple three extension point.

  • Core extension point described general information, like name, description and EMF object.
  • Extension point for human-readable namespace label.
  • UI extension point provided annotation type display information which will be used in all dialogs, views, etc.

Adding extension

To create new annotation type we need first create EMF class with standard EMF facilities. This EMF class will be used as an annotation type content, i.e. any annotation would be an instance of this EMF class. It can be any EMF class, it need not implement any interface or something else. Annotation type should be contributed with the org.eclipse.tigerstripe.annotation.core.annotationType extension point:

 <extension point="org.eclipse.tigerstripe.annotation.core.annotationType">
    <definition
          name="Person"
          description="Personal information, like a full name, e-mail address, telephone number and so on"
          epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
          eclass="Person">
        <target
            type="org.eclipse.core.resources.IResource" unique="true"/>
    </definition>
 </extension>

The attributes are described as follows.

  • name - a human-readable name that will be used in the UI
  • description - an annotation type description
  • epackage-uri - identity of the EMF package contains annotation object
  • eclass - EMF class name from the specified package which will be used as an annotation object
  • target - target allow to add annotations with the specified type only for specified annotable objects. For example, Person annotation can be attached only to the IResource. If there are no one target defined, annotation of this type can be attached to any annotable objects.
    • type - target type
    • unique - create no more than one unique annotation of the same type (true by default)

This extension point allow to use org.eclipse.tigerstripe.annotation.example.person.Person EMF class as an annotation. This annotation type would be also added to the Create Annotation Wizard.

Adding package label

Annotation types grouped by package to simply navigate in the annotation creation menu/wizard. To create human-readable package label we need to contributed org.eclipse.tigerstripe.annotation.core.packageLabel extension point:

 <extension
     point="org.eclipse.tigerstripe.annotation.core.packageLabel">
   <label
       epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
       name="Personality"/>
 </extension>

This extension should be added once for every package.

Display Annotation Type

An UI extension point (org.eclipse.tigerstripe.annotation.ui.annotationLabelProvider) just provide an JFace label provider for this annotation type using in the Create Annotation Wizard, Annotations View, etc.

 <extension point="org.eclipse.tigerstripe.annotation.ui.annotationLabelProvider">
    <provider
          class="org.eclipse.tigerstripe.annotation.example.person.PersonLabelProvider"
          epackage-uri="http:///org/eclipse/tigerstripe/annotation/example/person.ecore"
          eclass="Person"/>
 </extension>

The attributes are described as following:

  • class - ILabelProvider class name that will be used to display this annotation type
  • epackage-uri - an annotation type EMF package URI
  • eclass - an annotation type EMF class name

Back to the top