Search code examples
javaeclipseeclipse-plugineclipse-rcprcp

Hide Editor not working for workbenchpage


I would like to hide some editors in my RCP application based on a perspective switch. I extended "PerspectiveAdapter" class and tried hiding editors using IWorkbenchPage.hideEditor(editorReference) in the overridden method "perspectiveActivated". I was not able succeed with this. Later when I checked hideEditor implementation in eclipse source, there was only one line of code "E4Util.unsupported("hideEditor");", from this I understand that eclipse will not support hiding editors in a workbenchpage.

But in the help doc of Eclipse kepler release(http://help.eclipse.org/kepler/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fui%2FIWorkbenchPage.html), the function description of hideEditor is clearly mentioned as:-

"void hideEditor(IEditorReference ref) Remove an open editor, turn it into a non-participating editor. A non-participating editor will not be returned in the list of open editors (getEditorReferences()) and will not be visible in the editor area. However, it will continue to participate in the save lifecycle and may still be closed by some workbench close events.

Behaviour for hiding and showing editors from multiple stacks is not defined (and unsupported) at this time.

Parameters: ref - the editor reference to remove. It must be a current open editor belonging to this page, and must not be null."

Can anyone help me out why there is mismatch between the kepler help document and the actual implementation. Also, I would be really grateful, if someone guides for the problem described above.


Solution

  • This is reported in Eclipse bug 374132. The IWorkbenchPage JavaDoc has never been updated but hideEditor does not work and there does not seem to be any prospect of this being fixed.

    The bug comments do mention a possible way to achieve the same result if you are only targeting Eclipse 4.