Writing your own Eclipse plugin: How to show the blog headlines in Eclipse

0 0
Read Time:4 Minute, 37 Second

Writing a plugin for Eclipse sounds scary and difficult. A
few years ago I had to do a project with some other students for school. The
project was writing an application that works as a plugin in  Eclipse. It was terrible, no documentation about creating the plugin,
the javadoc didn’t help either and the teachers that should have helped use
were busy figuring out how it worked themselves. That time is past.
Creating plugins is easy now. 



Let’s create a simple plugin that reads the headlines of the
AMIS technology blog (that was the most useful plugin I could come up with )

Go to the menu File, New, Project.. and select “Plug-in

Enter the name of your project and select next. Change the
class name to nl.amis.BlogPlugin at the next screen.

The following screen will appear after clicking next

Select “Plug-in with a view”, click next and change first five fields:

Click finish. A new view will open with the plugin details.
You can open this view any time by double clicking the plugin.xml file.

Click on ‘Launch an Eclipse application’ to test your plugin.
It’s also possible to debug the plugin, but there is nothing to debug yet. A new Eclipse window will open. The new plugin is a view for Eclipse, so
we should open a view by clicking on Window, show view, RSS Feeds, Amis RSS and
click ok.

At the bottom of your Eclipse window a new view will
appear.  The view contains 3 items which
are definitely not articles on the blog.

Add RSS to the plugin

Let’s put the RSS-feed in the plugin. Of course I’ll use ROME for it.

Create a lib dir in your plugin directory and copy the files
for JDOM and ROME
to it. Add the libraries to your project by right clicking your project,
properties, java build path, libraries, add jars and select both jars in the
lib directory and hit ok.

The class where all the action happens is BlogView (package
nl.amis.plugin.views). Today we’re only changing the method createPartControl.

Remove the String array in the getElements method of the
inner class ViewContentProvider :

public Object[]
getElements(Object parent) {

    return new String[] {};


Overwrite the method createPartControl with the following

public void
createPartControl(Composite parent) {

    viewer = new TableViewer(parent, SWT.MULTI

            | SWT.V_SCROLL);





    // create table headers

    TableColumn titleColumn = new
TableColumn(viewer.getTable(), SWT.LEFT);



    TableColumn titleColumn2 = new
TableColumn(viewer.getTable(), SWT.LEFT);





    // parsing rss and putting it in the

    try {

        SyndFeedInput sfi = new

        URL url = new

        SyndFeed feed = sfi.build(new

        List<SyndEntry> entries =


        Table table = viewer.getTable();

        for (SyndEntry entry : entries) {

            TableItem item = new TableItem(table,

            item.setText(0, entry.getTitle());

entry.getPublishedDate() + “”);


    } catch (Exception e) {

        // TODO catch specific exceptions and
do something useful with them








So what did I do? I removed the Sorter because the items are
already sorted. In the next section I created the table headers so we get nice
headers with the title and date.

After creating the headers I parsed the RSS (if you don’t
have a clue what happens there read the blog entry about ROME (https://technology.amis.nl/blog/?p=1165). The entries of the feed are put in a table object. This is a standard SWT object. So it should be easy to port your plugin to a SWT application.

When you run the plugin again the blog entries should show

It would be nice if the purple Eclipse icon was something
else, like the AMIS company logo. The icon can be changed in the plugin page at
the tab Extensions. Expand org.eclipse.ui.views and select Amis RSS (view).
Click on the browse button and select amis.gif (which you just saved in your
icons directory  )

Now you have a basic plugin running, the next step is
auto-updating the RSS view, if you want to update now you have to restart the
view and that isn’t really practical. But this article was just to show how
easy it is to create a plugin.


When you start creating serious plugins you should first
learn SWT because creating a plugin involves a lot of SWT. A useful book is Eclipse:
Building Commercial Quality Plug-ins

There is a second edition available that covers Eclipse 3.1
(my edition covered 3.0). I don’t think the differences are big, in Eclipse 3.1
the wizard screens are a bit more intuitive.

SWT stands for Standards Widget Toolkit and is the
foundation of the Eclipse user interface. The goal of SWT is to go native as
soon as possible. This results in a component toolkit that looks and feels the
same as a normal application in every operating system. SWT was initiated as an
alternative for AWT and Swing and did a great job. I think it’s easier to
understand and performs better. In the book is also an example of a standalone
application using SWT, so you don’t need Eclipse when you want to use SWT.

Files needed

rome-0.8.jar and jdom-1.0jar

About Post Author

Jeroen van Wilgenburg

Oracle Consultant at AMIS
0 %
0 %
0 %
0 %
0 %
0 %

Average Rating

5 Star
4 Star
3 Star
2 Star
1 Star

2 thoughts on “Writing your own Eclipse plugin: How to show the blog headlines in Eclipse

  1. Hi, i am newbie to write plug-in.
    i have some problem with your example.
    When the example is ready, and launch Eclipse application with this plug-in, it view show “Unable to create view: com/sun/syndication/io/XmlReader”.
    This is caused by rome-0.8.jar. How to import this jar library into Eclipse?

Comments are closed.

Next Post

Joyful Successor to Forms - Introduction to JSF (Java Server Faces) and ADF Faces

Developing Web Applications using Java/J2EE technology has not been a picnic over the last few years. It was often hard work, complex, not very productive and the results were disappointing too. Especially for developers with an Oracle Forms background. Now, at last there is a Joyful Successor to Forms: JSF […]
%d bloggers like this: