Friday, October 8, 2010

WindowBuilder Pro brief sample – Part 3 of 3

In my previous post, WindowBuilder Pro brief sample – Part 2 of 3, I explained how to create a simple Swing frame with WindowsBuilder Pro. This time, I'm going to make some examples using SWT and Eclipse RCP.

The SWT plugin has biding capabilities that are similar to the Swing one (which I tested in my previous post), so I'm not going to cover them in this post. I prefer to show you integration with Eclipse RCP, which is really cool (sometimes, when I test new frameworks and tools, I feel like Hommer criticizing dinner).

The plugin can create a new SWT / JFace project, but this just adds such libraries to the project. I't is nice if you want to play for a while with SWT shells and JFace components.

But if we want to build an Eclipse RCP project, we must use the standard Eclipse option, Plugin Project:

You'll need the Eclipse Plug-in Development Environment installed. I recommend you reading this excellent Eclipse RCP tutorial before trying this one. At least, read the installation section.

Put any name for the project on the first wizard page. On the second one:

be sure of checking "This plug-in makes contributions to the UI" and choosing "yes" on "Would you like to create a rich client application?" radiobutton.

On the next step, select "RCP application with a view" template (some Eclipse versions have other templates, in such cases, look for a template that creates a view and a perspective).

In the last step, be sure of selecting "Add branding" option:

The wizard will create a View and a Perspective.  You can edit them just by opening with the graphical editor provided by the plugin. Let's add a button to the generated view. Before dropping the button, I recommend you dropping an absolute layout.

In order to run the application, select Run As -> Eclipse Application in project contextual menu. Something like this should appear:

Now, we aere going to add a new View and a new  Perspective. Start adding the view by selecting New -> WindowBuilder -> SWT Designer -> View Part. Follow the same path in order to create a Perspective. I'm going to call MyView and MyPerspective.

If you open the MANIFEST.MF file, you will see that the plugin automatically edited it in order to add the perspective. Cool.

Now, let's play with the perspective editor. Drop on it both, the first generated view and the new one. They appear in the "other" section.

And as last step (I promise), add the following line:


to the preWindowOpen method on ApplicationWorkbenchWindowAdvisor class. Now, running the project, you should see something like this:

Changing the perspective, you will see the one that you created:

And that's all folks. I hope you enjoyed this three-steps tutorial.

Related posts:


  1. Hi Lautaro. Great tutorial! I will write in english, maybe it is not a good idea but I do this anyway!!
    Another tool that Google relaunched for free is CodePro Analytix (It was created by Instantiations too). This tool has several functionalities, for example, a code analiser (similar to PMD, checkstyle), JUnits test generator.... among other. I used a previous version only for review the code. I think it is an interesting tool.
    If you have time to review this tool, can you tell me your opinion about it? Maybe you can post a review.
    Sorry for my english (I am learning english and I need practice).

  2. Thanks a lot, Héctor.

    I would like to continue with some other topics, such as ORM on Android or IoC on iPhone ( and

    But I'll try to get some time to make the review. Otherwise, I'll put it on "queue" :)