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