Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » setEditorAreaVisible(false) ignored when switching between perspectives
setEditorAreaVisible(false) ignored when switching between perspectives [message #673836] Tue, 24 May 2011 17:51 Go to next message
Eclipse UserFriend
If I have two perspectives, one with and one without an editor area (configured with layout.setEditorAreaVisible(b)), and I switch from the one without to the one with the editor area and back, the perspective without the editor area now also shows an editor area.

Before I file a bug: Has anyone else seen (or have an explanation for) this behavior?

Here's how I switch perspectives:

void setPerspective(IWorkbenchPage page, String perspectiveId) {
  IPerspectiveRegistry registry = page.getWorkbenchWindow()
    .getWorkbench().getPerspectiveRegistry();
  page.setPerspective(registry.findPerspectiveWithId(perspectiveId));
}
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #673961 is a reply to message #673836] Wed, 25 May 2011 05:52 Go to previous messageGo to next message
Eclipse UserFriend
This is the code I use:
    public void switchToPerspective(String perspectiveId, IWorkbenchWindow win) {
        try {
            IPerspectiveDescriptor descr = win.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(perspectiveId);
            if (descr == null) {
                log.error("Cannot find perspective ID "+perspectiveId);
                return;
            }
            IPerspectiveDescriptor currentPersp = win.getActivePage().getPerspective();
            if (currentPersp.getId().equals(perspectiveId)) {
                return;
            }
            win.getWorkbench().showPerspective(perspectiveId, win);
        } catch (WorkbenchException ex) {
            log.error("", ex);
        }
    }


and it works ok.
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #673974 is a reply to message #673836] Wed, 25 May 2011 07:13 Go to previous messageGo to next message
Eclipse UserFriend
Eric Jain wrote on Tue, 24 May 2011 17:51
If I have two perspectives, one with and one without an editor area (configured with layout.setEditorAreaVisible(b)), and I switch from the one without to the one with the editor area and back, the perspective without the editor area now also shows an editor area.


Does it happen if you switch perspectives via the perspective bar? Either way, it sounds like a bug and I think you should open one: https://bugs.eclipse.org/bugs/enter_bug.cgi?product=Platform&component=UI

PW
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #674390 is a reply to message #673974] Thu, 26 May 2011 14:07 Go to previous messageGo to next message
Eclipse UserFriend
Paul Webster wrote on Wed, 25 May 2011 07:13
Does it happen if you switch perspectives via the perspective bar?


It happens in a PartListener that switches to an editor-less perspective when the last editor is closed, but also if I switch the perspective through Window > Open Perspective, but then only if there are one or more open editors.

So it looks like the normal perspective switching mechanism won't hide the editor area if one or more editors are open? My current workaround is to register IPerspectiveListeners that call setEditorAreaVisible(b) on perspective activation...

Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #674394 is a reply to message #674390] Thu, 26 May 2011 14:19 Go to previous messageGo to next message
Eclipse UserFriend
Correct, if there is an editor open we will always show the editor area, even in perspectives that say not to show it. That is done deliberately.

PW
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #674424 is a reply to message #674394] Thu, 26 May 2011 17:22 Go to previous messageGo to next message
Eclipse UserFriend
Paul Webster wrote on Thu, 26 May 2011 14:19
Correct, if there is an editor open we will always show the editor area, even in perspectives that say not to show it. That is done deliberately.


Thanks for clarifying.

I tried closing all open editors when switching to a perspective that doesn't have an editor area, but ran into two problems:

1. Can't get isEditorAreaVisible from an IPerspectiveDescriptor, so I need to maintain a separate list of perspectives that have (or do not have) editor areas.

2. Closing the editors with page.closeAllEditors(true) in IPerspectiveListener.perspectiveActivated(...) appears to be too late to prevent the (now empty) editor area from appearing.

Any ideas?
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #674565 is a reply to message #674424] Fri, 27 May 2011 07:25 Go to previous messageGo to next message
Eclipse UserFriend
We extended IPerspectiveListener after it was released, so new methods went on other intfs. Try org.eclipse.ui.IPerspectiveListener4.perspectivePreDeactivate(IWorkbenchPage, IPerspectiveDescriptor) and see if that helps.

Later,
PW
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #674649 is a reply to message #674565] Fri, 27 May 2011 13:30 Go to previous messageGo to next message
Eclipse UserFriend
Paul Webster wrote on Fri, 27 May 2011 07:25
Try org.eclipse.ui.IPerspectiveListener4.perspectivePreDeactivate(IWorkbenchPage, IPerspectiveDescriptor) and see if that helps.


I might be switching from one perspective with an editor area to another perspective with an editor area, in which case I don't want to close the editors. The perspectivePreDeactivate callback doesn't let me see what perspective I'm switching into, right?

In any case, the workaround with the IPerspectiveListener that calls setEditorAreaVisible(b) seems to work fine; the main ugliness is that there does not appear to be a direct way to check if the editor area should be visible for a given IPerspectiveDescriptor, so I end up having to keep track of that myself.
Re: setEditorAreaVisible(false) ignored when switching between perspectives [message #1840602 is a reply to message #674649] Tue, 20 April 2021 09:01 Go to previous message
Eclipse UserFriend
thank you for implementing buggy behavior deliberately
Previous Topic:-Declipse.pluginCustomization not working for RCP application
Next Topic:Define a "Run As" submenus on method level
Goto Forum:
  


Current Time: Wed Apr 23 07:43:07 EDT 2025

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

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

Back to the top