Geertjan is a DZone Zone Leader and has posted 459 posts at DZone. You can read more from them at their website. View Full User Profile

Once, Twice, Three Times a Plugin

04.23.2008
| 3920 views |
  • submit to reddit
Tuesday at JavaOne, from 20.30-21.20, BOF-5193 features Mark Stephens and the IDE plugins for his PDF Viewer library. And now, a preview! Mark, from IDRSolutions, will talk about the JPedal plugins he created for Eclipse, NetBeans IDE, and IntelliJ. Without giving too much away, he discusses the plugins and outlines his key learnings below.

Hi Mark, who are you and where?

I'm Mark Stephens, I come from deepest Kent in the United Kingdom and I work for IDRsolutions, developing a Java PDF viewer library. We started it in 1999 and reckoned it would take maybe 6 months at most...

You've created a plugin for IDEA IntelliJ, Eclipse, and NetBeans IDE. Why did you decide to do that?

We were looking for a way to raise the profile of the library and we thought it would be really useful to add integrated PDF support to all the IDEs as lots of documentation is now available in PDF format. There seemed to be a gap which it could fill, both for the PDF functionality and also for an example of a plugin on spanning all three platforms.

It provides integral PDF display inside the three IDEs, along with searching. You can bookmark files from your machine or the Internet, which it will download and cache. You can also popup the PDF in an external window and print it. And its free.

We added some example links to some sample online chapters from Bruno Lowagie's excellent Itext in Action book as a demo of the bookmark feature. If anyone wants to recommend any useful links to online resources, we would be delighted to include them.

How was it to create three different plugins? Any highlights or frustrations you'd like to mention?

There is a hard initial learning curve, but it is actually fairly straight-forward to build a plugin for all three platforms - we sometimes forget we are rather spoiled for choice with three very active platforms constantly moving the game forward. When you look at the plugin architectures, you see three very intelligent solutions with some slightly different approaches. All three offer a great deal of help with sample code and wizards to make it very straight-forward. Deployment is really well handled as well.

The hardest thing is switching mindset - its interfaces and implementations in IDEA, extensions and SWT in Eclipse, and Lookups and Folders in NetBeans.

For the non-expert, I think error reporting could be improved - especially checking all the settings are correct so the finished plugin will run on other peoples machines. There is a wealth of documentation out there but it is sometimes not as clear as it could be - its written by talented experts who can sometimes find it hard to relate to what its like to be starting out.

All three have really great communities and people are always eager to help on the forums.

OK, now how does your plugin look in each of the IDEs?

Here it is for Eclipse:

NetBeans IDE:

IntelliJ IDEA:

Can you give us one or two tips for plugin development in each of the IDE's?

Here are some:

  • You don't need to start from scratch - there are loads of examples out there and wizards to build boilerplate code, help with branding, deployment and so forth.
  • With our PDF viewer, we wanted to make it easy to update, so we tried as much as possible to split out the platform specific items for easy maintenance. Several environments are very similar in certain features - for example, our code to store information between sessions was virtually identical in NetBeans and Eclipse.
  • Stick to plugin naming conventions for platform specific stuff but try and keep other classes the same in terms of names and usage. Our PDFSettings class works slightly differently on each setup but the function is identical so it is easy to maintain.
  • Don't pepper the toolbars and menus with lots of new options by default - it really annoys users especially if they are only used occasionally and never disappear.
  • Now that IDEA 7, Eclipse 3.3 and NetBeans 6 are well-established, I would recommend making these the minimum benchmark - they all added major new features for plugins which make your life much easier.
  • You also need to strike a balance on how much you want to customise for each platform and how consistent to be. NetBeans and Eclipse both have some really cool features which do not directly translate across. Do you want the same keyboard shortcuts on all three (which might rather limit your choice)? Which GUI elements do you want to recode in SWT on Eclipse?
  • Decide if you want to make the plugin available for developers to build on or is it for end users only? The second option is going to be more complicated and platform-specific so maybe keep it for version two.
  • I was pleasantly surprised at how things such as Persistence, progress monitors and a suitable store for transient files were easy to translate between versions.
  • Lastly, make use of Eclipse's Plugin Central or the built-in plugin repositories in NetBeans and IDEA and get people using your plugin.

Different plugins for different IDEs imply that there are different instructions for installing and working with them...

Yes. Here they are:

The sources are available there too.

Complete this sentence (any way you like): "If I had known from the start that...

...we would license our PDF library to Adobe, I would have been less negative about things at the start."

You're going to do a BOF about all of this. What can we expect from it?

We're not going to tell you which product to use or which is 'best'. What we're doing is a side by side comparison of how a graphical plugin works so you can see the key concepts and implementation in each case and how they compare.

Its going to be a very hands on demonstration, showing you around each plugin, pointing out the key files and classes, showing how the menus and windows work and having a moan about problems we had and how we solved them. All the platforms offer some really useful features and we will be showing these.

If you have an idea for a plugin or a product you would like to wrap in a plugin, you really want to be on all platforms. And even if you only write for one target, we found that adapting it to another gave us a much deeper understanding of both platforms.

If you have never bothered looking at plugins because it seems irrelevant, you are missing a huge improvement in the way you can develop any graphical applications. Its like sticking with Notepad to write your code when you could be using Eclipse, IDEA or NetBeans...

AttachmentSize
eclipse.png68.03 KB
idea.png101.88 KB
markee.jpg4.04 KB
netbeans.png54.33 KB
Published at DZone with permission of its author, Geertjan Wielenga.