Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Switch Perspective on startup in E4 application(After displaying a login window, I want to switch perspectives according to user choice. Accessing the workbench to do so results in an OSGI exception.)
Switch Perspective on startup in E4 application [message #1128137] Mon, 07 October 2013 11:34 Go to next message
Stefanie Hasler is currently offline Stefanie HaslerFriend
Messages: 3
Registered: October 2013
Junior Member
Hi all!

My RCP application is supposed to display a login window and then display the correct perspective for the specific user who logged in.

Is there any way to do this in E4? I get as far as the login window; the communication to the server is working, the user is identified. But whenever I want to switch to the correct perspective, I get a nullpointer exception upon accessing the workbench ("workbench has not been started yet").


I assume the workbench bundle really has not been loaded yet. What is the correct way to do this?

Re: Switch Perspective on startup in E4 application [message #1128235 is a reply to message #1128137] Mon, 07 October 2013 13:32 Go to previous messageGo to next message
Jonas Helming is currently offline Jonas HelmingFriend
Messages: 699
Registered: July 2009
Senior Member
When do you trigger the switch of the perspective and where?
A lifecyle handler might be the right thing for you:
http://eclipsesource.com/blogs/tutorials/eclipse-4-e4-tutorial-part-6-behavior-annotations/

Am 07.10.2013 14:01, schrieb Stefanie Hasler:
> Hi all!
>
> My RCP application is supposed to display a login window and then
> display the correct perspective for the specific user who logged in.
> Is there any way to do this in E4? I get as far as the login window; the
> communication to the server is working, the user is identified. But
> whenever I want to switch to the correct perspective, I get a
> nullpointer exception upon accessing the workbench ("workbench has not
> been started yet").
>
>
> I assume the workbench bundle really has not been loaded yet. What is
> the correct way to do this?
>
>
Re: Switch Perspective on startup in E4 application [message #1129013 is a reply to message #1128235] Tue, 08 October 2013 07:55 Go to previous messageGo to next message
Stefanie Hasler is currently offline Stefanie HaslerFriend
Messages: 3
Registered: October 2013
Junior Member
Thank you for your reply.

I tried it both

- using a lifecycle handler (in the @PostContextCreate method
- using an Addon

In both instances, I can open the login window (but only my login window shows, the main application certainly has not been started yet). However, the workbench is not accessible at those points.
Re: Switch Perspective on startup in E4 application [message #1129053 is a reply to message #1129013] Tue, 08 October 2013 08:37 Go to previous messageGo to next message
Eclipse UserFriend
You should listen for the APP_STARTUP_COMPLETE event. I think the workbench is available at that moment. https://bugs.eclipse.org/bugs/show_bug.cgi?id=376821
Re: Switch Perspective on startup in E4 application [message #1129082 is a reply to message #1129053] Tue, 08 October 2013 09:14 Go to previous messageGo to next message
Stefanie Hasler is currently offline Stefanie HaslerFriend
Messages: 3
Registered: October 2013
Junior Member
Thank you, that was it.

I registered an addon listening for the APP_STARTUP_COMPLETE event and it's working in there.
Re: Switch Perspective on startup in E4 application [message #1256846 is a reply to message #1129082] Tue, 25 February 2014 21:41 Go to previous message
Nate Lew is currently offline Nate LewFriend
Messages: 1
Registered: July 2009
Junior Member
What method are you using to switch the perspective from the APP_STARTUP_COMPLETE listener? I am getting into the listener fine after my login screen completes however I can't find a way to actually get the perspective to switch.

I have handler already registered that switches the perspective however i cant seem to access the handler from this class.

@Execute
public void execute(MApplication app, EPartService partService,
EModelService modelService) {
MPerspective element =
(MPerspective) modelService.find("cmd.id", app);
// Now switch perspective
if(element!=null){
partService.switchPerspective(element);
}

thanks for the help.
Previous Topic:Changing menu programmatically
Next Topic:Migrate Preferences to pure e4 application
Goto Forum:
  


Current Time: Mon Apr 22 23:13:19 GMT 2024

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

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

Back to the top