Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Divided Loyalty: Create Plugins that Work in Eclipse and NetBeans

One of the benefits of today's open source IDEs is that anyone can design a tool that plugs in to the IDE using an API, but Eclipse and NetBeans each uses a different API. This article will show you how to make your tool plug in to both environments with the least amount of coding work.


advertisement
e've come a long way from the days when the tools to which we most often turned to support us in developing applications were off-the-shelf commercial products. Today, thousands of developers have already adopted the open source frameworks Eclipse and NetBeans, and they haven't looked back.

One of the advantages of using Eclipse or NetBeans, of course, is that these frameworks are open to being extended however you like. Not surprisingly, there is great interest and excitement around doing just that. Companies and individuals alike are learning how to take their own tools and create plugins to one or both of the popular IDEs. The advantages of doing so include not just better productivity for your own team of Eclipse/NetBeans users, but a large, potential new audience of users and customers for your tool itself.

For the last year, I have been developing plugins for both frameworks, discovering the differences between NetBeans and Eclipse, and designing a code base that can be reused as much as possible. I've learned that there is no magic API that will work in both IDEs. However, there is a way to structure your code to minimize the amount of "re-write" necessary to achieve success in both IDEs.



Where appropriate, I have leveraged code from an existing tool I developed that plugs into both IDEs. These IDE plugins provide a visual UI design tool for building rich Internet applications (RIAs) in a drag-and-drop fashion.

What You Need
Eclipse version 3.0 and NetBeans version 3.6
Analyze Your Tool's Needs
A typical UI design tool will consist of one or more the following pieces of functionality that will need to be integrated into the IDE:
  • Actions—Menu items and toolbar buttons that enable users to perform some kind of function.
  • Wizards / Templates<—Enable the user to quickly create objects needed for development, such as Java classes, SQL statements, and/or a wizard.
  • Preferences / Options<—Provide the user with the ability to store customization settings for their workspace.
  • Views<—Provide the user with a visual display for working with a specific piece of functionality.
  • Editors<—Provide functionality that increases the speed and accuracy of the code the developer is typing. Features such as auto-formatting and code completion are standards in today's editors.
Once you have decided what your tool needs to implement, you will need to architect your program to maximize code reuse. If you are integrating an existing tool into Eclipse and NetBeans, you will now have three applications to maintain. For this reason, it's critical that you reuse as much code as possible.

Eclipse vs. NetBeans
Once you have decided on the functionality that your plugin will need, it's time to integrate your tool into both IDEs, I'll walk through the steps to develop the plugins. I will not cover the basic steps of creating your plugin projects here because both IDEs have a set of wizards to guide you through that process. Instead, I will focus on differences in the code needed to get a tool to work in both IDEs.

The first thing I want to do is integrate an action (menu item) into both environments. This is a good example case for doing other types of integrations because the code needed to integrate an action is similar to most other types of functionality.

Step 1—Define the action in the plugin's manifest file. Both Eclipse and NetBeans have the concept of a manifest file that describes the integration points of the plugin. Eclipse's manifest file is called plugin.xml. In NetBeans, you can specify the module's manifest file in the Manifest.mf file of your module's jar.

Manifest-Version: 1.0 OpenIDE-Module-Specification-Version: 1.0 OpenIDE-Module-Layer: com/nexaweb/mf-layer.xml

Step 2—Implement the IDE's action interface that will be called when the user clicks on the menu item or toolbar button. In order for the IDE to interact with your plugin's functionality, you must implement an interface that the IDE knows about. This allows either NetBeans or Eclipse to invoke your object through reflection and then call method in classes. In the next section I show the interfaces you will need to implement to integrate an action into both IDEs.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date