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.