Bug 408309 - [Perspectives] Legacy PerspectiveListeners aren't fired for perspectivePreDeactivated and perspectiveDeactivated
Summary: [Perspectives] Legacy PerspectiveListeners aren't fired for perspectivePreDea...
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Windows 7
: P3 normal with 6 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-17 03:46 EDT by Matthias Renz CLA
Modified: 2021-04-13 11:27 EDT (History)
11 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Renz CLA 2013-05-17 03:46:05 EDT
In E4 we are still using IPerspectiveListener3 and IPerspectiveListener4 for listening on perspectiveDeactivated and perspectivePreDeactivated events. But they won't be fired on switching a perspective in the perspective toolbar.
Comment 1 Paul Webster CLA 2013-05-22 10:44:40 EDT
You mean in Kepler running the standard RCP Workbench?  Or in an Eclipse4 application?

PW
Comment 2 Matthias Renz CLA 2013-05-22 11:01:44 EDT
Sorry, it's not Kepler. We are using the perspective listener in a E4.2.1 RCP application.
Comment 3 Henno Vermeulen CLA 2014-02-11 06:48:08 EST
Doesn't work on Kepler (4.3.1) either.

We use this together with hiding editors which is also not yet implemented, see bug 374132
Comment 4 Alain Picard CLA 2015-08-22 14:18:07 EDT
Is there any intention of fixing this and the related bug 374132 or is there just a better way to do it now. We are now at Mars and it is still not resolved.
Comment 5 Lars Vogel CLA 2015-08-23 06:17:07 EDT
(In reply to Alain Picard from comment #4)
> Is there any intention of fixing this and the related bug 374132 or is there
> just a better way to do it now. We are now at Mars and it is still not
> resolved.

Gerrit patches are welcome. See http://www.vogella.com/tutorials/EclipsePlatformDevelopment/article.html for how to do it.
Comment 6 Martin Jedlicka CLA 2016-01-07 09:05:52 EST
There are already any fix or a workaround?

I use Eclipse 4.5.1 and when I call method perspectiveDeactivated in IPerspectiveListener4 so doesn't work it.
Comment 7 Holger Grote CLA 2016-01-08 10:22:52 EST
With Eclipse 4.4 I encountered the following behaviour:

-perspectivePreDeactivated is not called
-perspectiveDeactivated  is called

The Code where the Listener is fired is WorkbenchPage.setPerspective(). Here only perspectiveDeactivated is fired. I compared this to a Code from the 3.X stream. Here both are fired. In the old Code there is a oldPersp.onDeactivate() between both calls which does not exist in the 4.x stream anymore (or I did not find it)

So the suggestion for the problem I have is to do either one of the following:
- mark perspectivePreDeactivated deprecated, so during migration it is possible to find the problem.
- call both Listeners.

As a solution for the 4.4 version I changed the perspectivePreDeactivated implementation to perspectiveDeactivated as the second is fired and during the call the perspective ist still active (perspectives.setSelectedElement() and mperspective.getContext().activate() are not called at that time)
Comment 8 Ben Steffensmeier CLA 2016-01-08 11:01:07 EST
In 4.5 perspectiveDeactivated is not being called consistently.

When a new perspective is opened then WorkbenchPage.setPerspective is used and perspectiveDeactivated is called.

When switching to an already open perspective PerspectiveSwitcher is manipulating the model directly and WorkbenchPage.setPerspective is not used. The WorkbenchPage.selectionHandler listens for this change and perspectiveActivated is called but perspectiveDeactivated is never called.

In our project the workaround is to track the active perspective within our listener and call perspectiveDeactivated from perspectiveActivated if perspectiveDeactivated was not called.
Comment 9 Junhua Chen CLA 2017-10-31 03:12:14 EDT
I am using 4.6.3
Version: Neon.3 (4.6.3)
The problem can also be reproduced.
The perspectiveActivated method is called,
but the perspectivePreDeactivated method is never called.
Comment 10 Eclipse Genie CLA 2020-06-01 13:05:25 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 11 Rolf Theunissen CLA 2021-04-13 11:27:18 EDT
In 4.20, perspectivePreDeactivated  is still not called. 

WorkbenchWindow still contains the method firePerspectivePreDeactivate(..), but behavior is not implemented in 4.x, so it is dead code now.

By now it should be decided if this ever gets implemented, or that the interface is marked deprecated.