Blog
How to apply the e4 programming model to 3.x
So while I could only encourage everyone to use the Eclipse 4.1 Application Platform (EAP) to write UI-applications, this post is for those who have existing 3.x code which they want to refactor step by step to run on EAP. So if you ever looked at how EAP are developed the first thing you notice is the new programming model or better said the paradigm shift happing because you use DI and Services instead of subclassing and use of statics. So if you want to move your code gradually from a 3.x development model to EAP what you need is a bridge that allows you to run the refactored UI-Code in your existing 3.x runtime. This is exactly where the Tools Bridge feature as part of the e4 updatesite might catch your attention. It allows you to use the e4 programming model inside the 3.x runtime. All you need to do to get started is to install this feature into your 3.x workspace.
Now you are able to write code that follows the e4 programming model and hence runs natively on the EAP (=without any compat layer). All you need to do to integrate your code afterwards is to subclass one of the generic ViewPart/EditorPart classes:
- DIViewPart
- DISaveableViewPart
- DIEditorPart
who'll act as the integration points into Eclipse 3.x. Now you might be confused, right? So just checkout the git-repo with a view i've written which works inside 3.x and 4.x and brings a feature into Eclipse I always wanted to have. It shows all images in a folder as a preview. Here's the view in a running 3.7 RC4:
And here in a 4.1 RC4:
You can naturally also install the view into your 3.x/4.x Eclipse Install: For 3.x:
- Add the e4 update site as shown above
- Get the p2repo and add it to your update configuration
For 4.x:
- Get the p2repo and add it to your update configuration
Please note that there's a bug in the plugin version of one of the plugins from e4 so you won't be able to upgrade after having installed it so only give it a try on an installation which you have no problem with reverting. Final note: The bridge I introduced here has been built for the e4 modeltooling but will quite likely get more customers in 4.2 because we plan to refactor parts of the exiting platform code to be useable in EAP applications so it might get a key component in 4.2.