Monday, August 4, 2008

Sash IP Messenger

Forces compelling to learn RCP:-
For quite some time I have been involved in creating helper projects, small projects that help in coding, generate code etc. This seemed to be a very nice and effective way of producing a very nice UI for them.
It’s eclipse; I like the IDE and is my IDE of choice for Java. Using RCP would mean I could integrate the tools written with eclipse.
I have done some Swing coding, it’s not a very easy to write a nice UI. RCP provided a dream of producing feature rich applications written in java fast and clean.
Since the release of eclipse 3 the documentation there have been major modifications in the way eclipse works (or so I have read) and made RCP integration easier. I started with reading a book Eclipse Rich Client Platform: Designing, Coding, and Packaging Java Applications - By Jeff McAffer, Jean-Michel Lemieux. Very nice book, made the journey simpler.
When I had just started coding one of my leads had told me, the best way to learn was to implement a small project. Execute it like a real project, and you would learn what are the where a tool can be best utilized, what is the effort required for implementation and any issues with the tool. Quite a few books are written in similar fashion where they build one application from start to the end. So does the book Eclipse Rich Client Platform. This book creates a chat application using the XMPP protocol and smack library.
I decided to create a UI for IP Messenger, since this is the messaging tool I usually use and it does not have any nice UI. This is a free messenger available and does not need a server.
I have just downloaded Ganymede so I created a new Eclipse plug-in project in Ganymede. I realized later that the version I should have used is Eclipse Europa since Ganymede is still to be used widely. I was able to convert the project into an eclipse 3.3 compatible plugin, the only drawback was that I could not use an image with menu manager. I had to replace

MenuManager helpMenu = new MenuManager("&Help", AbstractUIPlugin.imageDescriptorFromPlugin(Application.PLUGIN_ID, IImageKeys.HELP) ,"help");

I had to remove the image from the menu manager to use it with Eclipse Europa. Now it is compatible with both Eclipse Europa and Eclipse Ganymede.
The prerequisites for learning RCP are basic knowledge of Java, SWT and Eclipse. I am still learning new things about RCP everyday but creating a feature rich UI using RCP was fun and fast. The working RCP application can be found at: http://code.google.com/p/sashipmessenger/downloads/list
Features:-
Customized splash screen, the project uses a very simple splash screen. I have just replaced the splash.bmp file in the project. I decided not to use a progress bar, which can easily be added. More customizations are possible. While googling I also found a nice article that used the splash screen for login.



Saving the workbench state. Include the code in the class that extends WorkbenchAdvisor.

public void initialize(IWorkbenchConfigurer configurer) { super.initialize(configurer); configurer.setSaveAndRestore(true); }
This ensures that the windows appear in the same location as when you closed the views.

Use perspective to decide the initial layout of the application
Minimize to system tray. RCP provides a good level of integration with the system tray.



Also to provide a notification when a message has arrived and application is not visible or inactive, the icon changes to a message and a system beep is sound.


In the menu preferences have been added, the preferences configuration is as shown below. This integrates nicely with the eclipse editor if this is used as an eclipse plugin.



The configurations shown are the display name for the user, group name and the log folder. The messenger shows the chat history with a user. The broadcast address is used to specify address not in the same subnet.
The application has two different views and an editor. The contacts view shows all the users on IP Messenger. The console view at the bottom provides information about different events. The different events like message read event, user removed message added etc. can be seen. The editor is open whenever a message is sent or received from a user.


The messenger saves the chat log. When the editor is opened again the log is greyed out.


The views can be closed and moved around.


The view can be opened from the menu.



Users can be found from the find item on the top of contacts view.


The RCP application can be integrated with the existing eclipse. Just drop the plugin jar into the plugin folder of eclipse dump.