Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Swiching perspectives
Swiching perspectives [message #581861] Thu, 16 September 2010 04:49 Go to next message
Christian Sorensen is currently offline Christian Sorensen
Messages: 8
Registered: September 2010
Junior Member
Hi all

I can't seem to figure out how to change perspectives in the new 4.0 framework. I have created two different perspectives in the e4xmi file and would like to be able to switch between them dynamically.

Could somebody please point me in the right direction or maybe even provide example code.

Best regards
Christian
Re: Swiching perspectives [message #581894 is a reply to message #581861] Thu, 16 September 2010 06:04 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5245
Registered: July 2009
Senior Member
You need to set the selectedElement in the PerspectiveStack.

Tom

Am 16.09.10 10:49, schrieb Christian Sorensen:
> Hi all
>
> I can't seem to figure out how to change perspectives in the new 4.0
> framework. I have created two different perspectives in the e4xmi file
> and would like to be able to switch between them dynamically.
>
> Could somebody please point me in the right direction or maybe even
> provide example code.
>
> Best regards Christian
Re: Swiching perspectives [message #581918 is a reply to message #581861] Thu, 16 September 2010 06:13 Go to previous messageGo to next message
Christian Sorensen is currently offline Christian Sorensen
Messages: 8
Registered: September 2010
Junior Member
Thanks for your reply Tom.

I now how to do that in the e4xmi file. But how do I do it in code? For instance if something is selected (by the user) in my application that makes me want to display another perspective.
Re: Swiching perspectives [message #581960 is a reply to message #581861] Thu, 16 September 2010 08:02 Go to previous messageGo to next message
Paul Webster is currently offline Paul Webster
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

You can have a look at
/org.eclipse.e4.ui.workbench.addons.swt/src/org/eclipse/e4/u i/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.j ava
and that bundle's extensions to see how we do it in the compatibility layer

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm


Re: Swiching perspectives [message #581978 is a reply to message #581861] Thu, 16 September 2010 08:30 Go to previous message
Christian Sorensen is currently offline Christian Sorensen
Messages: 8
Registered: September 2010
Junior Member
Thanks to both of you for helping. I tried to work with the example Tom provided and ended up with something like this:

@Inject private MPerspective perspective;

MElementContainer<MUIElement> stack = (MElementContainer<MUIElement>) perspective.getParent();
for( MUIElement p : stack.getChildren() ) {
System.out.println("PER: " + ((MPerspective)p).getLabel());
if (((MPerspective)p).getLabel().equals("Tokens")) {
stack.setSelectedElement(p);
}
}

I couldn't get the perspective stack injected for some reason.

\Christian
Previous Topic:Printing a message to the e4 status bar
Next Topic:Swiching perspectives
Goto Forum:
  


Current Time: Sat Jul 26 11:28:44 EDT 2014

Powered by FUDForum. Page generated in 0.03194 seconds