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:
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.
Can’t get it to work, I have a dependecy failure : http://my.jetscreenshot.com/3027/20110620-catd-87kb.
I am using Eclipse 3.7 and try to create a target platform to run your iconviewer but without luck yet.
I never tried creating a target platform. All tried was to install the e4-bridge feature into my 3.7 which worked quite well.
Hi, there is a typo in your text.
The generic ViewPart/EditorPart classes are:
DIViewPart
DISaveableViewPart
DIEditorPart <—-
Thanks – fixed
Is there a generic class for Command/Handler to use DI?
No did not work on command and handler yet
Pingback: RCP Best Practices – Use the correct version of RCP :: Modular Mind
I am trying to use the bridge for my RCP and I have contributions to the View Toolbar and ContextMenu. I was able to resolve the context menu by using EMenuService.registerContextMenu(myTreeViewer, myMenuMgr.getID()). I am having trouble with the Toolbar. Currenlty, I have IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager(); but there is no way, I could find, to use getViewSite() as that was the same problem I had with the contextmenu. Is there any way to handle this?