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

Howto: Register Annotation Types

< To: Tigerstripe_APIs

Introduction

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

  • Core extension point described general information, like name, description and EMF object.
  • 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
          id="org.eclipse.tigerstripe.annotation.example.person"
          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.

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

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"
          typeID="org.eclipse.tigerstripe.annotation.example.person"/>
 </extension>

The attributes are described as following:

  • class - ILabelProvider class name that will be used to display this annotation type
  • typeID - an annotation type identifier

Back to the top