Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application
Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690158] Wed, 25 March 2015 13:55 Go to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Hello,

So I have an existing Eclipse 3 RCP application and I would like to add to it a perspective (with parts, toolbars menus, etc ..) developed with Eclipse 4.4 in Luna. N.B. The existing Eclipse 3 RCP App already has the compatibility layer.
So is it possible to do that ? I mean to mix Eclipse 3 and Eclipse 4.4 components ?

Thank you all for your help Smile
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690255 is a reply to message #1690158] Thu, 26 March 2015 07:26 Go to previous messageGo to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
I assume your Eclipse3 Application has no application.xmi defined. When running in compatibility mode it uses the LegacyIDE.e4xmi (./eclipse.platform.ui/bundles/org.eclipse.ui.workbench/LegacyIDE.e4xmi). So if you want to add an e4 perspective, this should be the target.

I would do the following:
1. Use the "Live model editor" in your e3 application to take a look a the e4xmi. Identify the node of the perspective stack.
2. Create a new bundle with an fragment.e4xmi which contains your e4 perspective under the perspective stack id discovered in step1.


This is just an quick idea how it should work, let me now if it worked or if you need more details.
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690264 is a reply to message #1690255] Thu, 26 March 2015 08:34 Go to previous messageGo to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
First of all, Thank you for your response. And could you please give me more details if possible ?
Smile
Thank you Smile
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690276 is a reply to message #1690264] Thu, 26 March 2015 09:49 Go to previous messageGo to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
One more post to overcome this "You can only use links to eclipse.org sites while you have fewer than 5 messages" and post links.
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690277 is a reply to message #1690276] Thu, 26 March 2015 09:49 Go to previous messageGo to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member

Ok, at first read http://www.vogella.com/tutorials/Eclipse4LiveModelEditor/article.html and get it running in your E3 application. With this you can investigate the application model of your application.

And then read http://www.vogella.com/tutorials/Eclipse4Modularity/article.html and contribute a perspective to an application.e4xmi via an fragment.e4xmi.

If you know how to do both, combine them. Smile
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690283 is a reply to message #1690277] Thu, 26 March 2015 10:17 Go to previous messageGo to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Thank you so much for your help truly apreciate it Smile
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690630 is a reply to message #1690277] Mon, 30 March 2015 09:03 Go to previous messageGo to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Hi Alexander, The advices you gave me worked perfectly Thank you. But now I have a small issue. I would like to add my perspective to the perspective switcher, so do you know how can I do so ? Thanks Very Happy
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690790 is a reply to message #1690630] Tue, 31 March 2015 09:50 Go to previous messageGo to next message
Alexander Bunkowski is currently offline Alexander BunkowskiFriend
Messages: 29
Registered: February 2014
Junior Member
Add a new e3 perspective extension to your application via plugin.xml and the extension point org.eclipse.ui.perspectives. something like:

 <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            class="(yourpackage).E3PerspectiveFactory"
            id="E4Perspective"
            name="E4Perspective">
      </perspective>
   </extension>


Inside the e3 factory do magic to receive e4 services (outch) and search and open your e4 perspective.
public class E3PerspectiveFactory implements IPerspectiveFactory {

	private static final String E4_PERSPECTIVE_ID = "your_id_here";

	@Override
	public void createInitialLayout(IPageLayout layout) {
		//required magic to get e4 services here
		WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
		MWindow window = activeWorkbenchWindow.getModel();
		EModelService modelService = window.getContext().get(EModelService.class);
		MApplication mApplication = window.getContext().get(MApplication.class);
		EPartService ePartService = window.getContext().get(EPartService.class);
		
		//normal e4 perspective switch call
		MPerspective e4Perspective = (MPerspective) modelService.find(E4_PERSPECTIVE_ID, mApplication);
		ePartService.switchPerspective(e4Perspective);
	}
}


Smile Looks a bit ugly using the org.eclipse.ui.internal.WorkbenchWindow but I know no other way to get the EModelService/MApplication.

Maybe someone else has a cleaner solution ?
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1690791 is a reply to message #1690790] Tue, 31 March 2015 09:55 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
On 31.03.15 11:50, Alexander Bunkowski wrote:
> Add a new e3 perspective extension to your application via plugin.xml
> and the extension point org.eclipse.ui.perspectives. something like:
>
>
> <extension
> point="org.eclipse.ui.perspectives">
> <perspective
> class="(yourpackage).E3PerspectiveFactory"
> id="E4Perspective"
> name="E4Perspective">
> </perspective>
> </extension>
>
>
> Inside the e3 factory do magic to receive e4 services (outch) and search
> and open your e4 perspective.
>
> public class E3PerspectiveFactory implements IPerspectiveFactory {
>
> private static final String E4_PERSPECTIVE_ID = "your_id_here";
>
> @Override
> public void createInitialLayout(IPageLayout layout) {
> //required magic to get e4 services here
> WorkbenchWindow activeWorkbenchWindow = (WorkbenchWindow)
> PlatformUI.getWorkbench().getActiveWorkbenchWindow();
> MWindow window = activeWorkbenchWindow.getModel();
> EModelService modelService =
> window.getContext().get(EModelService.class);
> MApplication mApplication =
> window.getContext().get(MApplication.class);
> EPartService ePartService =
> window.getContext().get(EPartService.class);
>
> //normal e4 perspective switch call
> MPerspective e4Perspective = (MPerspective)
> modelService.find(E4_PERSPECTIVE_ID, mApplication);
> ePartService.switchPerspective(e4Perspective);
> }
> }
>
>
> :) Looks a bit ugly using the org.eclipse.ui.internal.WorkbenchWindow
> but I know no other way to get the EModelService/MApplication.
> Maybe someone else has a cleaner solution ?

You can always use the

IEclipseContext ctx =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IEclipseContext.class);

EModelService modelService = ctx.get(EModelService.class);
....

Tom
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1691001 is a reply to message #1690791] Wed, 01 April 2015 13:50 Go to previous messageGo to next message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
Hi,

Well I tried another solution, I downloaded the E4p-perspective-switcher made by Lars Vogella. I used it and it added a new e4 perspective switcher to my existant application (the one developped in Eclipse 3) And in the perspective switcher I do have the defautl perspective wich is developed in Eclipse 3 and the new perspective which is developed in Eclipse 4. The only thing that bothers me with this solution is that the only perspective from the existing app that I have and that I can access is the one loaded initially (the default one) but the other perspectives(in Eclipse 3) disapear. I then understood why. It's because when the app is launched and the perspective switcher gathers the perspectives to add, he doesn't find the other perspectives since they are not created yet in launch time and now my only trouble is to find how to add the other perspectives to the perspective switcher. As for my understanding of this situation, the Eclipse 3 uses a lazy instanciation protocol for the perspectives creation. So do you have any ideas on how to overcome this issue ? Any help is truely appreciated. @Tom @Alexander. Thank you all.

Inès
Re: Add an Eclipse 4.4 perspective into an existing Eclipse 3 RCP application [message #1691221 is a reply to message #1691001] Fri, 03 April 2015 14:45 Go to previous message
Ines El Euch is currently offline Ines El EuchFriend
Messages: 35
Registered: March 2015
Member
I am happy to say that I finally got it to work Very Happy
Previous Topic:Help My Rcp application suddenly looks weird I dont know what I messed
Next Topic:Develop Eclipse Plugins with e4
Goto Forum:
  


Current Time: Fri Mar 29 13:57:58 GMT 2024

Powered by FUDForum. Page generated in 0.03857 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top