Layout Image
  • Home
  • RCP Training
  • OSGi Training
  • Contact

Archive for December 2008

Making Music with Eclipse RCP

by Patrick
December 18th, 2008

I’m always on the lookout for Eclipse Rich Client Platform applications that push boundaries. RCP is much too often associated with the Eclipse IDE itself, and this leads us to think that RCP applications need to be IDE-like. But there are many more uses to which RCP can be put, and I think we’re still only beginning to scratch the surface.

For example, check out Neck Diagrams (nice web site, by the way!), an RCP application that allows guitarists to create chord boxes and neck diagrams using a visual editor. I’m not much of a musician myself, but this seems like a great tool. What I really like, though, is how this program stretches the idea of what we think of as an “RCP application”.

neckdiagrams11

This is also a great example of software created by a single developer. I love that RCP makes it possible for a solo developer to realize their vision and bring a product to market quickly.

neckdiagrams2

If you’re interested in seeing this software in action, check out the screencast.

DZoneLinkedInDeliciousDiggEvernoteFacebookFriendFeedGoogle BookmarksRedditSquidooStumbleUponTechnorati FavoritesTwitterYahoo BookmarksShare/Save
Categories Applications, Rich Client Platform
Comments (3)

Perspective Layouts – Programmatic vs Declarative

by Patrick
December 11th, 2008

One issue that developers new to RCP face is whether to add UI elements programmatically or declaratively. In my experience, most initially choose the programmatic approach because it seems more familiar. You know, why mess with extension points when you can just code it up and be done with it.

But it’s almost always better to do things declaratively through extension points, the main reason being that doing so allows you leverage the power of RCP as a modular user interface framework. To illustrate this, let’s look at our options for laying out perspectives.

Programmatic Layout = Centralized / Hard Coded

Here is the simplest code needed to add a view to a perspective programmatically. To do so, we implement the IPerspectiveFactory interface and add a view using its string id.

public class MyPerspectiveFactory implements IPerspectiveFactory {

	public void createInitialLayout(IPageLayout layout) {
		layout.addView(MyView.ID, IPageLayout.BOTTOM, 0.5f, layout.getEditorArea());
	}

}

The problem here is that we’ve coupled our perspective to the view being added. This view may exist in the same plug-in as the perspective, but often it does not. If the view is in a different plug-in, we have to declare a dependency on that plug-in just to add the view. It’s possible to reduce the coupling somewhat by replacing MyView.ID with the actual string id itself, but hidden dependencies based on string equivalency are arguably even more smelly.

In the end, a programmatic perspective layout results in a hard-coded and centralized architecture looking like this.

perspective-layouts-central

Declarative Layout = Decentralized / Modular

The declarative approach based on extension points resolves these issues. To layout a perspective declaratively we extend the org.eclipse.ui.perspectiveExtensions extension point.

   <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="com.mycompany.myperspective">
         <view
               id="com.mycompany.myview"
               minimized="false"
               ratio="0.5"
               relationship="left"
               relative="org.eclipse.ui.editorss">
         </view>
      </perspectiveExtension>
   </extension>

Using this approach, each plug-in adds the views that it knows about, resulting in a decentralized architecture where the plug-ins containing the views are now in control.

perspective-layouts-decentr

Note that we have not eliminated all coupling, as the perspective extensions still need to refer to the perspective by its string id, but this is not as bad as it sounds. Perspectives are much more static than views – you typically define them and make few changes afterwards. Views, on the other hand are often moved from one plug-in to another or have their purpose (and potentially their id) redefined. Decentralizing control allows you to make these kinds of changes without breaking the perspective layout.

Conclusion

Adding UI elements declaratively is definitely the way to go. It gives you much more flexibility (e.g. you can add views to perspectives you didn’t create) and also allows you to leverage the modular nature of the framework.

Sure, there will always be cases where a declarative approach cannot be taken, particularly when some part of an API is not yet surfaced in the related extension point. But in the absence of such a need, I urge RCP developers to always turn first to the extension point mechanisms and fall back to programmatic approaches as a last resort. As your application evolves over time, you’ll really come to enjoy the flexibility and increased reusability that a declarative approach makes possible.

DZoneLinkedInDeliciousDiggEvernoteFacebookFriendFeedGoogle BookmarksRedditSquidooStumbleUponTechnorati FavoritesTwitterYahoo BookmarksShare/Save
Categories Rich Client Platform, Tips
Comments (18)

What a month!

by Patrick
December 11th, 2008

I haven’t been posting much as I’ve been buried with work lately. Considering the state of the economy, I guess I should feel lucky! I hope to get back to posting more now that things have calmed down.

Also, I wanted to apologize to anyone who was hoping to attend my Eclipse World presentations in October. My daughter, who goes to college in Manhattan, needed to have an emergency appendectomy. I flew up to New York for the surgery and needed to cancel the presentations. Her surgery went well and she’s fine now. Hopefully there will be opportunities in the future to present the Eclipse World material.

DZoneLinkedInDeliciousDiggEvernoteFacebookFriendFeedGoogle BookmarksRedditSquidooStumbleUponTechnorati FavoritesTwitterYahoo BookmarksShare/Save
Categories Announcement
Comments (0)

Want to know more about RCP training?

Get information on private training options, pricing, availability and references.

Email address

Want to learn RCP online?

There are still spots available in the next online RCP Quickstart course being held February 27 - 29.

About me

Patrick Paulin

Patrick Paulin is a software developer and trainer specializing in modular technologies such as OSGi and the Eclipse Rich Client Platform.

Patrick lives in Madison, Wisconsin with his wife and two daughters.

Email - patrick at modumind dot com

Modular Mind
Copyright © 2012 All Rights Reserved
iThemes Builder by iThemes
Powered by WordPress