Community
Participate
Working Groups
I'm migrating our product from Eclipse 3.7.1 to 4.2.1. I use certain handlers that call: IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); PlatformUI.getWorkbench().showPerspective(id, window); Since I changed the target platform to 4.2.1 this call does nothing. I don't get an exception and nothing happens. If I can be of any assistant, please let me know.
Looks like the org.eclipse.ui.internal.Workbench.showPerspective(String, IWorkbenchWindow, IAdaptable) method calls org.eclipse.ui.internal.Workbench.activate(String, IWorkbenchPage, IAdaptable, boolean) with the new perspective ID, but then activate(*) simply activates the window in the application model, and doesn't do anything with the perspective. Then showPerspective(*) returns instead of going to the end of the method where it would actually set the perspective. PW
Hi Flavio, just as a temporary workaround we are using the solution showed here: http://stackoverflow.com/questions/11523187/switch-perspective-in-a-rcp-application-since-eclipse-juno that is replacing PlatformUI.getWorkbench().showPerspective() with IWorkbenchWindow window = getViewSite().getWorkbenchWindow(); IPerspectiveRegistry registry = workbench.getPerspectiveRegistry(); IWorkbenchPage page = window.getActivePage(); page.setPerspective(registry.findPerspectiveWithId(PRODUCT_PERSPECTIVE_ID)); HTH Vincenzo RCP Vision
Hi Vincenzo Thanks for sharing, I'll keep it in mind. Probably I just wait with upgrading our target to 4.x, until this and some other issues are fixed.
Paul, why don't we change the existing (broken) code in Workbench to be a refactored version of the workaround ??
Created attachment 230778 [details] bug395084.zip
Hello Flavio, I have tested it on 4.3.0.I20130505-2000 (The atest incremental for 4.3) and it is working for me. Attaching my plug-in. Could you test it?
I just tested your plug-in with version 4.3.0.I20130502-0800 and it did not work. Maybe next week I'll be able to test the latest, has there been done any changes to fix this issue, between those two versions?
Sorry my bad, I was bit in a hurry when I tested. I have my own target definition which does not contain the java perspective, I didn't see the exception. Changed the perspective id to "org.eclipse.debug.ui.DebugPerspective" and it worked. I have to get my application running with the new 4.3 target, will report back, but I'm pretty confident that it will work.
After testing my application I found out that it still does not work. I did a little debugging and this is what I found out: public IWorkbenchPage showPerspective(String perspectiveId, IWorkbenchWindow targetWindow, IAdaptable input) throws WorkbenchException { ## REMOVED UNINTERESSTING STUFF if (targetWindow != null) { IWorkbenchPage page = targetWindow.getActivePage(); if (activate(perspectiveId, page, input, false)) { ## MY APPLICATION RETURNS return page; } ## SAMPLE APPLICATION GOES ON IPreferenceStore store = WorkbenchPlugin.getDefault().getPreferenceStore(); int mode = store.getInt(IPreferenceConstants.OPEN_PERSP_MODE); if (IPreferenceConstants.OPM_NEW_WINDOW != mode) { targetWindow.getShell().open(); if (page == null) { page = targetWindow.openPage(perspectiveId, input); } else { page.setPerspective(targetPerspective); } return page; } } return openWorkbenchWindow(perspectiveId, input).getActivePage(); } private boolean activate(String perspectiveId, IWorkbenchPage page, IAdaptable input, boolean checkPerspective) { if (page != null) { for (IPerspectiveDescriptor openedPerspective : page.getOpenPerspectives()) { if (!checkPerspective || openedPerspective.getId().equals(perspectiveId)) { ## INPUT IS NULL IN BOTH CASES, BUT IN THE SAMPLE APPLICATION, page.getInput() DOES NOT RETURN NULL if (page.getInput() == input) { WorkbenchWindow wwindow = (WorkbenchWindow) page.getWorkbenchWindow(); MWindow model = wwindow.getModel(); application.setSelectedElement(model); return true; } } } } return false; } I can not find out what page.getInput() is since the debugger does not show it to me because of some unresovled dependency. Maybe I'm missing some bundles?
Created attachment 230843 [details] workbench comments attached it as txt file since the comment is hard to read
After some more debugging: IWorkbenchPage page = window.getActivePage(); page.getInput(); My application: null Sampel application: org.eclipse.core.internal.resources.WorkspaceRoot object with "R/" as content.
I believe, that original issue (PlatformUI.getWorkbench().showPerspective()) has been fixed. Paul, can you close this defect? For page.getInput() - Flavio - could you open new bug?
Is the page required to deliver an input? I think depending on the application, it should be ok for the page to deliver no input e.g. null.
The original issue has been fixed in kepler. PW
does it handle null inputs now? or do I have to create a new issue for this?
(In reply to comment #15) > does it handle null inputs now? or do I have to create a new issue for this? Please create a new issue for page inputs. PW
Let's look at this again in Luna PW
Created attachment 231152 [details] Standalone Application I created a standalone application, based on the eclipse sample "with view". I just created another perspective/view and added the SWITCH command. You should be able to reproduce this issue with it.
I also ran it on Eclipse 3.7.1 where it worked.
Gerrit change https://git.eclipse.org/r/#/c/14068/ PW
(In reply to comment #18) > Created attachment 231152 [details] > Standalone Application I ran this app, and https://git.eclipse.org/r/#/c/14068 had no effect on using the Switch menu item (there was no visible change to the app) PW
(In reply to comment #21) > (In reply to comment #18) > > Created attachment 231152 [details] > > Standalone Application > > I ran this app, and https://git.eclipse.org/r/#/c/14068 had no effect on > using the Switch menu item (there was no visible change to the app) > > PW It looks like this patch has stopped to work. I'll investigate what happened Daniel
Created attachment 233784 [details] standalone.bug395084 modified It looks that the issue is with the sample application that tries to switch to the same perspective without checking the current one (fixed perspective id). I've slightly modified the application and now after "switch" action the invisible perspective is displayed Daniel
(In reply to comment #23) > Created attachment 233784 [details] > standalone.bug395084 modified The app that was attached starts up in standalone.bug395084.perspective and then the switch handler switches to standalone.bug395084.perspective2 It should work as is at least once, and I don't see that. Can you get the original plugin to work at least once with your fix? PW
Released as http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a7eb676fb6acb5efcf292b051b5bd9684fd19e80 Thanks Daniel. PW
Verified in the build: I20130916-2330