[jboss-user] [JBoss Tools] - Extending the Eclipse Annotation Properties view

Brian Fitzpatrick do-not-reply at jboss.com
Wed Sep 15 06:15:44 EDT 2010


Brian Fitzpatrick [http://community.jboss.org/people/bfitzpat] modified the blog post:

"Extending the Eclipse Annotation Properties view"

To view the blog post, visit: http://community.jboss.org/community/jbosstools/blog/2010/09/13/extending-the-eclipse-annotation-properties-view

--------------------------------------------------------------
While looking into some options on how to make the use of annotations simpler for users, I ran across the Annotation Properties view, which is in Helios in the JAX-WS->Annotation Properties view category when you're trying to open a view (Window->Show View->Other).

If you haven't seen this view before (and I know I hadn't), it offers a way to register annotation classes in a common place to allow you to add/remove/edit annotations in a class. By default in the Helios JEE package, it comes with JAXB and JAX-WS annotations already set up. It's a little clunky in spots, but I think it offers some interesting options as far as functionality goes.

For example, to create a new JAX-WS annotated class, you can start with your favorite POJO and annotate it pretty quickly:
 http://community.jboss.org/servlet/JiveServlet/showImage/38-1946-7286/Annotation_Properties_View_For_Blog.jpg  http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1946-7286/450-297/Annotation_Properties_View_For_Blog.jpg 
The view also offers the ability to filter the available annotations so you're not simply overwhelmed. To get to the Filters dialog, use the View menu and select Filters...
 http://community.jboss.org/servlet/JiveServlet/showImage/38-1946-7287/annotation_properties_view_filters_dialog.jpg  http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1946-7287/354-464/annotation_properties_view_filters_dialog.jpg 
This is a little clunky as far as an interface goes. You can only open one instance of the view at a time and can't easily switch between annotation types. But it's a start anyway.

So with this in mind, I asked in the WTP newsgroup about how to go about extending it. Shane Clarke was nice enough to provide some tips...

The two extension points associated with the Annotation Properties view are located in the org.eclipse.jst.ws.annotations.core plug-in. The main two are the the org.eclipse.jst.ws.annotations.core.annotationCategory and org.eclipse.jst.ws.annotations.core.annotationDefinition extension points. Basically you just define a category (which shows up in the Filters dialog) and then define one or more associated annotation classes.

The only trick is making sure that the annotations are on the plug-in classpath and then adding the line "Eclipse-RegisterBuddy: org.eclipse.jst.ws.annotations.core" to your MANIFEST.MF.

So as an example, we'll just create a new category:

   <extension
         point="org.eclipse.jst.ws.annotations.core.annotationCategory">
      <category
            id="org.my.annotation.category"
            name="My Category Name">
      </category>
   </extension>

And then we'll define a new annotation for it:

   <extension
         point="org.eclipse.jst.ws.annotations.core.annotationDefinition">
      <annotation
            category="org.my.annotation.category"
            class="some.annotation.class.MyAnnotation"
            name="MyAnnotation">
      </annotation>
   </extension>

For examples of how they implemented the JAX-WS and JAXB annotations, check out org.eclipse.jst.ws.jaxws.core and org.eclipse.jst.ws.jaxb.core.

Pretty easy. I was able to define annotations for some new functionality in our JBoss ESB product that allows you to annotate a class instead of extending a particular interface or extending an existing class.

 http://community.jboss.org/servlet/JiveServlet/showImage/38-1946-7288/annotation_properties_view_esb_blog.jpg  http://community.jboss.org/servlet/JiveServlet/downloadImage/38-1946-7288/450-297/annotation_properties_view_esb_blog.jpg 

I obviously think that the Annotation Properties view could be used for more than just Web Service class annotations.

But it needs a bit of work... For example, it would be nice if you could create a saved setting like a working set and made more visible - perhaps in the toolbar area at the top of the view. And it would be great if you could create multiple instances and associate a particular view instance with an editor, similar to how the Project Explorer can be linked to the editors and show which file is being worked on.

And I'm not quite sure how to use all of the functionality - like those other two extension points - or some of the settings on the annotationDefinition extension.

That said, I think it's a great start and it would be awesome to have a consistent way to annotate Java classes. I'm not sure that this is really a WTP-specific view and think it would make more sense in the more general Java tools category, but that's just me.

Big thanks to Shane for the pointers and I'm looking forward to seeing how this functionality improves in future releases!

--Fitz
--------------------------------------------------------------

Comment by going to Community
[http://community.jboss.org/community/jbosstools/blog/2010/09/13/extending-the-eclipse-annotation-properties-view]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100915/80fc55f9/attachment.html 


More information about the jboss-user mailing list