This document will give an introduction to extending eclipse and the JBoss IDE plug-ins with plug-ins of your own. It will give an introduction into the main libraries the JBoss IDE plug-ins make use of (webtools, JDT, etc), and a general overview of the structure of the JBoss IDE projects. All plug-ins to eclipse and JBoss IDE are written in Java. It will detail how to use common extension points in eclipse.
This document will not teach you how to use eclipse, JBoss IDE, or program in Java. A familiarity with eclipse and java in general will be assumed. For those who are not familiar with eclipse, a good guide on the software is available at http://www.eclipse.org/documentation/pdf/org.eclipse.platform.doc.user_3.0.1.pdf. Terminology from this document (view, context menu, editor, perspective, etc) will be used throughout the document. If you've never used eclipse to program in Java, the Java Development User Guide is available at http://www.eclipse.org/documentation/pdf/org.eclipse.jdt.doc.user_3.0.1.pdf. Other resources are listed at the end of the article.
Aside from being an IDE, what exactly is eclipse? Eclipse in a programatic sense is simply a plug-in loader. It has a small core codebase which is in charge of loading plug-ins, libraries, and other resources. Each plug-in is represented by an OSGi bundle when running.
Part of eclipse's success has been due to its extensible nature and the ease with which plugins can extend and enhance each other. Any plug-in can define their own extension points through which others may extend them. Any plug-in, for example, can add a top level menu to the main menu bar of the application, because the plug-in in charge of that menu has defined extension points through which to do so. If a plug-in defines no extension points for others to use, then the plug-in is not extendable.
JBoss IDE is a term that refers to a handfull of projects, specifically: JBoss Aop IDE, EJB3 tools, jBPM tools, Hibernate Tools, and what is called the IDE Core. Each one of them may consist of multiple plug-ins themselves. Aop IDE, for example, consists of two plugins: aop.core and aop.ui. Other projects consist of several plugin-ins as well.
JBoss is currently growing, and is always taking on and integrating new projects. The IDE team, likewise, has also taken on new contributers, and a refactoring may be necessary in the future. Historically the IDE has not had many re-usable features separated, and hopefully this will change. Because of this, JBoss IDE currently does not define any extension points, but we encourage you to contact us with requests or ideas as to which views, context menus, or other eclipse elements in our plug-ins you'd like to see extensible. Also, if you see some functionality (a dialog box for example) that you think could be separated and put in some IDE-commons project for others to use, that would also be helpful.
If you'd like to add additional functionality to the AOP AspectManager view's context menu, for example, and would like us to define an extension point there so that your plug-in can do so, don't hesitate to ask. If you desired, and your added features proved helpful to others, you could contribute your code back to JBoss IDE for integration. Because JBoss IDE currently does not define any extension points, this document will focus primarily on using eclipse's extension points.
You will not need to understand all of these technologies to extend eclipse, however each one has a purpose and if your plugin intends to provide similar functionality, they should make use of these libraries whenever possible. These libraries are currently used by some of our plug-ins, and so there will be example code to look at.
Java Development Tooling "allows users to write, compile, test, debug, and edit programs written in the Java programming language." Through APIs they can create java source files, add methods, fields, or inner types. These APIs are used throughout the JBoss IDE plug-ins. One example would be in the ejb3 plugin, adding a business or home method via the j2ee context menu. Another example is reflection and using the JDT to check if a user's java source file in an editor has a specific method. These are, of course, just two examples of many.
Eclipse provides a tutorial on JDT here: http://www.eclipse.org/documentation/pdf/org.eclipse.jdt.doc.isv_3.0.1.pdf
Gef is the Graphical Editing Framework. It "allows developers to create a rich graphical editor from an existing application model." This library allows you to use graphical shapes, arrows, etc, to create flow charts, uml diagrams, or other things. JBoss IDE primarily uses this library in JBoss jBPM's Graphical Process Designer.
Further information on GEF can be found at: http://www.eclipse.org/gef/
"EMF is a modeling framework and code generation facility for building tools and other applications based on a structured data model. From a model specification described in XMI, EMF provides tools and runtime support to produce a set of Java classes for the model, a set of adapter classes that enable viewing and command-based editing of the model, and a basic editor. Models can be specified using annotated Java, XML documents, or modeling tools like Rational Rose, then imported into EMF. Most important of all, EMF provides the foundation for interoperability with other EMF-based tools and applications. "
More information can be found at: http://www.eclipse.org/emf/
"The WTP project includes the following tools: source editors for HTML, Javascript, CSS, JSP, SQL, XML, DTD, XSD, and WSDL; graphical editors for XSD and WSDL; J2EE project natures, builders, and models and a J2EE navigator; a Web service wizard and explorer, and WS-I Test Tools; and database access and query tools and models."
More information can be found at http://www.eclipse.org/webtools/
SWT: Swt is a graphics widget toolkit that competes with Swing. It is used entirely throughout eclipse and is a nececssity for any and all gui plug-ins. JFace is a layer above SWT, and is also used extensively. SWT is implemented specifically for each hardware platform, unlike Swing which is coded platform independent. This should not affect your coding, however, as SWT contains a consistant API across platforms. In eclipse, all SWT elements run as one thread.
More information can be found at http://www.eclipse.org/swt/
Following is a description of the current plugins in the IDE, as well as some information about their plug-in structure and what other parts of eclipse they extend. This information can be used later when looking for a concrete example of some type of extension.
Homepage: http://jboss.com/products/jbosside
This project is an IDE layer on top of the JBoss AOP libraries, used to make development of AOP projects easier. (AOP IDE: , AOP: http://www.jboss.org/products/aop ) It makes use of JDT throughout the application. It contains two main views, the Aspect Manager and Advised Members views. It comprises two main plugins, a core and a ui. The core has a model that allows the ui to graphically represent pointcuts, expressions, typedefs, advisors, and other information graphically through the views.
Each view has a context menu that changes depending upon what is currently selected. This plug-in also adds to the other views' context menus via the org.eclipse.ui.popupMenus extension point. Other features include resource listeners that update the model every time a file is changed, markers on the sides of editors to more easily show information, and MarkerResolutionGenerators (ctrl+1) which pops up advice to the user based on what markers are present on the selected element. It also marginally extends the default editor.
Homepage: http://jboss.com/products/jbosside
This a project centered around the simplification of development of EJB3 elements such as session beans, message driven beans, and entity beans.
Homepage: http://jbpm.org/gpd/
A graphical designer for jBPM. Automatically works on PARs as a mutli-tabbed editor with a graphical process design editor and XML descriptor editor.
Homepage: http://tools.hibernate.org
A fully featured hibernate toolset that includes reverse engineering (with ant integration and ejb3 source support), context-sensitive auto complete on hibernate descriptors, HQL query editor and result set view, live entity property viewing and editing, and more.