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 EditPart Providers"

 
Line 4: Line 4:
 
Annotation Framework provides own edit parts to show annotations on the GMF diagram. This parts can be customized by user. It can be done with the annotation edit part provider which map annotations to the specified edit parts:
 
Annotation Framework provides own edit parts to show annotations on the GMF diagram. This parts can be customized by user. It can be done with the annotation edit part provider which map annotations to the specified edit parts:
  
    public interface IAnnotationEditPartProvider {
+
  public interface IAnnotationEditPartProvider {
        public Class<? extends AnnotationEditPart> getAnnotationEditPartClass(Annotation annotation);
+
    public Class<? extends AnnotationEditPart> getAnnotationEditPartClass(Annotation annotation);
    }
+
  }
 +
 
 +
This provider should be registered using <code>org.eclipse.tigerstripe.annotation.ui.diagrams.annotationEditpartProviders</code> extension point:
 +
 
 +
  <extension
 +
      point="org.eclipse.tigerstripe.annotation.ui.diagrams.annotationEditpartProviders">
 +
    <provider
 +
        class="org.eclipse.tigerstripe.annotation.ui.example.editpartProvider.AnnotationEditPartProvider"
 +
        id="org.eclipse.tigerstripe.annotation.ui.example.editpartProvider">
 +
    </provider>
 +
  </extension>
  
 
All annotation edit parts should extend <code>org.eclipse.tigerstripe.annotation.ui.diagrams.parts.AnnotationEditPart</code> class and will be automatically refreshed when annotation changed and so on. The simple example of the annotation edit part is following:
 
All annotation edit parts should extend <code>org.eclipse.tigerstripe.annotation.ui.diagrams.parts.AnnotationEditPart</code> class and will be automatically refreshed when annotation changed and so on. The simple example of the annotation edit part is following:

Latest revision as of 07:47, 1 July 2008

< To: Tigerstripe_APIs

Annotation Framework provides own edit parts to show annotations on the GMF diagram. This parts can be customized by user. It can be done with the annotation edit part provider which map annotations to the specified edit parts:

 public interface IAnnotationEditPartProvider {
   public Class<? extends AnnotationEditPart> getAnnotationEditPartClass(Annotation annotation);
 }

This provider should be registered using org.eclipse.tigerstripe.annotation.ui.diagrams.annotationEditpartProviders extension point:

 <extension
     point="org.eclipse.tigerstripe.annotation.ui.diagrams.annotationEditpartProviders">
   <provider
       class="org.eclipse.tigerstripe.annotation.ui.example.editpartProvider.AnnotationEditPartProvider"
       id="org.eclipse.tigerstripe.annotation.ui.example.editpartProvider">
   </provider>
 </extension>

All annotation edit parts should extend org.eclipse.tigerstripe.annotation.ui.diagrams.parts.AnnotationEditPart class and will be automatically refreshed when annotation changed and so on. The simple example of the annotation edit part is following:

 public class SimpleAnnotationEditPart extends AnnotationEditPart {
   public SimpleAnnotationEditPart (View view) {
     super(view);
   }
   protected NodeFigure createNodeFigure() {
     BorderedNodeFigure figure = new BorderedNodeFigure(new Label());
     return figure;
   }
   protected void refreshVisuals() {
     BorderedNodeFigure figure = (BorderedNodeFigure)getFigure();
     Label label = (Label)figure.getMainFigure();
     Annotation annotation = getAnnotation();
     label.setText(DisplayAnnotationUtil.getText(annotation));
     label.setIcon(DisplayAnnotationUtil.getImage(annotation));
     super.refreshVisuals();
   }
 }

Annotation edit part can use getAnnotation() method to get annotation represented by this part. This part also free to use custom edit policies and other edit part features.

Back to the top