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

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).

Related

How to use eclipse 3.X perspective in eclipse 4.X application

We have old RCP application written in eclipse 3.x, it has one perspective and 6 views in it (these are added using extensions). I have given a task to enhance its functionality. After going through the requirements, we decided to create multi-perspective RCP eclipse 4.x. application. In which we use old application perspective as it is and we create new perspective for the new requirement. I am java developer, not much know about the eclipse 3.x & 4.x. But since one week read lot of material on net, learnt and confused. Following link and sample code is working to use - 3.x views in 4.x RCP application, but my code is not working with this approach (i tried to add only 3.x views with CompatibilityView to newly created perspective of 4.x application model using e4xmi).
https://dirksmetric.wordpress.com/2012/08/01/tutorial-eclipse-rcp-e4-with-3-x-views-like-project-explorer-properties-etc/
Can any one please help me with step by step approach on how to use RCP eclipse 3.X perspective (without code migration) in eclipse 4.X RCP application? it will be great help. Thanks in advance.

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

Is it possible to use a FormEditor in an e4 application?

Is there a way to use a FormEditor in an e4 application? I want to migrate an 3.x Eclipse RCP application to e4 and it would be great if there would be a simple way to reuse existing editors.
No you can't use any editor based on the 3.x EditorPart.
I think you can use the org.eclipse.ui.forms plug-in that contains things like FormToolkit, but I have not tried this. The dependencies for this plug-in only contain optional dependencies on 3.x code.

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

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.

Eclipse e4 and plug-in development

Is it possible to create Eclipse plug-ins (e.g view parts) using Eclipse e4 incubator?
Or is e4 only useful for 'window-based' applications?
I already checked How can I create a view using the E4 programming model to be a plug-in for Eclipse 4.2 or above?, but this did not give me an useful answer.
Add:
I want to create an Eclipse plug-in and not a standalone rcp application.
I'm not sure what exactly you want to achieve.
Option 1:
You want to write a plug-in for an e4 RCP application:
You can do this (e.g., contribute ViewParts to an e4 application model) via a model fragment.
Basically, instead of extending the org.eclipse.ui.views extension point in Eclipse 3.x you create an application model fragment file in your plug-in and reference this in an extension to the extension point org.eclipse.e4.workbench.model.
In the model fragment, you define the parts, commands, etc. you want to contribute.
See for example these tutorials for more details:
http://eclipsesource.com/blogs/2012/06/26/eclipse-4-e4-tutorial-part-3-extending-the-application-model/
http://www.vogella.com/articles/Eclipse4Modularity/article.html
Option 2:
You want to write a plug-in e4 style for Eclipse itself.
As far as I know this is not possible straightforward, because currently, the Eclipse IDE cannot be enhanced with fragments (at least that is what https://bugs.eclipse.org/bugs/show_bug.cgi?id=376486 indicates ...)
But when that works, see Option 1.
Until then, you'd have to use the classic extension points. You can still write your view using the POJO/Injection approach of e4, but you need to use the 3.x to e4 bridge. You can get some hints from
http://eclipsesource.com/blogs/2012/06/18/migrating-from-eclipse-3-x-to-eclipse-4-e4/ .
In particular, see the paragraph starting "The third option is to use the 3.x e4 bridge from the e4 tools project"