What exactly is e4 and what is its meaning if I want to write a new eclipse plugin? - eclipse

I am interested in writing an eclipse plugin.
After reading various tutorials around the internet and working through some simple plugin examples, I am quite confused as to how you are supposed to use the new dependency injection/services style of programming I have read about in various places as one of the primary features of eclipse 4.
http://wiki.eclipse.org/Eclipse4/FAQ#For_Adopters_.28Plug-In_Developers.29
The tutorials I've seen, and the eclipse wizard-generated plugins themselves, all use the "old" style of programming using extension points and referencing things using the singleton pattern. Apparently, this style is supported using a compatibility layer.
The information on 3.x style plugin development seems perfectly reasonable and workable to me, but it sounds bad that it is only supported using a "compatibility layer." Is this a style of programming that is going to be phased out/deprecated for Eclipse development?
Where can I find a guide on writing a plugin that uses the new, preferred style? And why do the eclipse plugin wizards themselves not even use this style, if it has been the preferred development model since eclipse 4 was originally released?! Everything I have found about writing eclipse 4 style programs focuses on standalone rcp "applications", not actual plugins to eclipse IDE.
Here are some tutorials I found which use what I understand to be the old style of plugin:
http://www.eclipsepluginsite.com/
http://www.ibm.com/developerworks/opensource/library/os-ecplug/
http://www.vogella.com/tutorials/EclipsePlugIn/article.html
Can someone explain to me clearly what the current status of the eclipse 4 programming model for plugin development is? And if you could point me to some documentation of it that would be great as well.
Thanks!

It will be very long time before the compatibility layer goes as a huge amount of code depends on it.
You can only really use e4 if you are developing a new RCP and don't need any of the existing 3.x style plugins. e4 development is perfectly practical for new apps that don't use compatibility layer plugins - I have several such apps.
An e4 app can use extension points from core plugins which are not part of the compatibility layer. e4 applications make more use of direct injection and the application model which replace some of the old extension points.
For a plugin to an existing RCP (such as Eclipse itself) the 3.x style is required, although
Eclipse Luna provides some support for using e4 style views in a 3.x application.

Related

Making org.eclipse.e4.ui.workbench.swt.E4Application work with org.eclipse.ui.IStartup

I am quite new to the RCP world and need some help.
I want to have E4Application work with IStartup. According to the documentation, I should use the "LifeCycleHandler" approach as in these 2 links.
How to make something on startup in Eclipse E4 application?
and
Eclipse e4 : IStartup extension not working
But I can't use them as I don't want to make code changes to my plugin. So I also went through the link below which talks about "Use the Compatibility Layer" but I could not really understand much. I would be great to have a solution to this since I can't modify the plugin code(may be by putting some plugin in the plugins dir etc).
My RCP is eclipse 4.6.2 based.
Observation: Eclipse 4.6.2 IDE is able to load my plugin but with version 4.6.2 based RCP, its not loading.
TIA
A pure e4 RCP using E4Application cannot use IStartup or any of the other org.eclipse.ui.xxxx extension points and classes. You will have to use the Life Cycle class and rewrite your code.
If you want to use org.eclipse.ui.xxx classes and extension point stick to the traditional Eclipse RCP (which uses 3.x compatibility mode).

Eclipse e4 migrating 3.x plugin to 4.x?

I have been working with Eclipse RCP for over a week now, and I've now been given an Eclipse plugin written in 3.x, which I need to migrate to 4.x. I'm using a book called Eclipse 4 RCP by Lars Vogel which has a small section on this, but I can't for the life of me figure out what I'm to do.
I'm trying to do this throught the use of the compatiblity layer. It mentions to add a couple of features for this (org.eclipse.rcp, org.eclipse.emf.ecore, org.eclipse.emf.common) and your ready to go, but I don't exactly know what I'm to do here. Like do I add these to the existing product file of the 3.x plugin I've been given, or do I create a separate e4 project and point to that. Many of the tutorials I read are a bit vague with the details and its a shame there's no proper step by step guide for beginners with this. Any help would be great.
Probably, you should be creating a separate e4 plug-in project for this. And where you have to configure your extensions/extension points in e4 ways.
Basically, like creating a new project.
If you want to migrate your Eclipse 3.x RCP application to the Eclipse 4 programming model, you can't directly reuse existing plugin.xml based user interface components, e.g. Views or Editors based on the definition in plugin.xml .
Components based on the plugin.xml file must be adjusted to avoid inheritance of Eclipse classes and to use the programming model based on #Inject . They also must be contributed to the application model.
Components which are not directly based on the plugin.xml file must be adjusted if they use Eclipse 3.x singletons, as for example Platform or PlatformUI , to access Eclipse API
you may want to take a look at this page: https://www.eclipse.org/community/eclipse_newsletter/2013/february/article3.php

Integration of Xtext DSL editors and e4-based RCP

I am working on RCP application for editing dsl files.
For now I managed to create two editors using Xtext 2.5 that works fine in Eclipse (validation, cross references, etc.). Also there is e4 based RCP application skeleton with custom navigation tree (files are loaded from remote server not from local workspace).
Now I have to integrate those both of them. Unfortunately I didn't find any up to date tutorials about this topic that works for my case.
Here are links that I tried:
This blog post describes integration for Eclipse 3.x
This one about e4 but version of Xtext is less than 2.5
Here is a lot of information about RCP but I didn't found anything about plugins integration with RCP.
There is similar question but it is not clear for me how to use obtained editor or how to get resourceProvider instance.
Does anyone have a reference to the relevant tutorial or sample?
According to Eclipse bug 401309 and various comments in the Eclipse forums XText editors are not compatible with a pure e4 RCP because they rely on lots of code from the 3.x compatibility layer.
You can still create an Eclipse 3.x style RCP, as described in your second reference.
I have added a comment to Bug 401309 where I describe how to make it work.

Migrating eclipse 3.x application application to eclipse 4.x

I'm working on a product which is an RCP application based on Eclipse 3.x api. Now we are trying to move it to Eclipse 4.x. We are using some internal classes in our code. I've already read the tutorial provided by Vogella about migrating to Eclipse 4.x from 3.x, but I'm still not getting how to start.
We want to take advantage of the new Eclipse features, my main question is that we have good number of views, layouts in our old code, so what should be the approach I should follow. Also is there a way to create an application model from my older application using 3.x API.
I'm stuck and not getting how to proceed.
this really depends what you are trying to do. Do you just want to update your IDE? Or should the project be based on the e4 platform.
I recently updated a project from 3.x to the new IDE. This works very good, the compatibility layer does a good job and you are able to run the application with minimal changes. However if you do this, you cannot use the benefits of the e4 platform.
If you want to move your application to e4, thats more work to do. Mostly you will not want to touch all the old code, so there is a possiblity to have 3.x and e4 plugins run together in your application. Thats done with the e4 bridge and wrapper classes for old code. Most of the IDE views and editor are also still based on 3.x, so if you use them, the e4 bridge is also a good way to incorporate them.
Some information can be found here:
http://tomsondev.bestsolution.at/2011/06/10/how-to-apply-the-e4-programming-model-to-3-x/
http://eclipsesource.com/blogs/2012/06/18/migrating-from-eclipse-3-x-to-eclipse-4-e4/
Andy
I've read both the tutorial.But I am stucked and got too much confused as to where to start from. Basically 3 features are there
1. css styling of widgets(which i understood and did a bit of it)
2. to introduce dependency injection in my code
3. to put the application model
What approach I should follow?
This document helped me in deciding which strategy to adopt. http://www.eclipse.org/forums/index.php/fa/17403/ for migration.Indicates clearly which strategy you should adopt based on your existing code structure.Hope it helps

Eclipse 4: Default commands

I apologise for the very amateur question about E4 but I am a bit confused about a couple of things about RCP development using the new Eclipse 4 framework. I read in this tutorial that one can no longer use any default commands the way we could in 3.x especially for common things like Save, Save As... in the File menu. It says that in E4 we have to write our own commands. The reason I am confused is because the thing I liked about Eclipse previously is that a lot of things are already implemented and we can just extend that to our own needs. But it feels like now everything must be written from scratch.
That led me to considering reusing the command code already written for Eclipse Juno. I had the Live Editor open so I could see the list of commands etc but I don't really see any Handlers implemented for any of them. Then I used the Spy on Eclipse Juno and checked out some of the menu items and they all seem to point to Actions. That really confused me as I thought Juno was based on E4.
I could be completely wrong so I am sorry for asking such a silly question. I only just started using E4 and need to decide whether one of fairly young Eclipse 3.x projects should be migrated to 4.x.
AfaIk, in Juno the compatibility layer translates the 3.x based implementation of the IDE into E4 concepts. This is also the reason why the reusable commands are not yet available.
If you have an 3.x based RCP it should also run using the compatibility layer (and you can reuse the commands mentioned in your question) if no incompatible APIs have been used.
Here is more information (also a tutorial from Lars Vogel): http://www.vogella.com/articles/Eclipse4CompatibilityLayer/article.html