Bug 46336 - [viewmgmt][perspectives] Automatically switch from Debug to Java perspective
Summary: [viewmgmt][perspectives] Automatically switch from Debug to Java perspective
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 enhancement with 26 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 76899 175621 312762 327983 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-10 09:40 EST by Peter Boheme CLA
Modified: 2020-03-29 11:47 EDT (History)
28 users (show)

See Also:


Attachments
patch to switch to initial perspective when all launches are termianted (23.51 KB, patch)
2011-03-29 16:16 EDT, Patrick Chuong CLA
no flags Details | Diff
patch with perspective selection (29.23 KB, patch)
2011-04-12 15:17 EDT, Patrick Chuong CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Boheme CLA 2003-11-10 09:40:29 EST
After debugging a java application it would be nice to switch back automaticly 
from the debug perspective to the java perspective.
Comment 1 Darin Wright CLA 2003-11-10 21:31:40 EST
I think the heuristic is as follows:

* If a launch causes a perspective change, then when the launch terminates, we 
should return the user to the original perspective (that the launch occurred 
from)
* this should only happen if the user has checked the preference to do so (on a 
config by config type basis, which could be displayed with the perspective 
switching info on the "perspective" tab of the launch config)
* this should only happen when all launches are terminated

Marking as a P4 enhancement (may not happen in 3.0). Contributions welcome :-)
Comment 2 Darin Wright CLA 2004-03-01 17:26:15 EST
Deferred
Comment 3 Darin Wright CLA 2004-10-25 13:43:01 EDT
*** Bug 76899 has been marked as a duplicate of this bug. ***
Comment 4 Channing Walton CLA 2006-01-20 15:08:28 EST
I would find this feature very useful. A few people at work have commented about it too. Any chance of reopening it?

Channing
Comment 5 Darin Wright CLA 2006-01-23 22:06:55 EST
We won't have the resources to do this in 3.2
Comment 6 Darin Wright CLA 2007-02-27 00:35:06 EST
*** Bug 175621 has been marked as a duplicate of this bug. ***
Comment 7 Remy Suen CLA 2007-05-24 23:02:44 EDT
Can we get this reopened for future considerations?
Comment 8 Curtis Windatt CLA 2007-05-25 10:01:25 EDT
This won't happen in 3.3, so it will be left as resolve LATER.  It is still open for consideration in later releases (as it is not marked WONTFIX or INVALID).
Comment 9 Eclipse Webmaster CLA 2009-08-30 02:41:53 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.
Comment 10 Darin Wright CLA 2010-10-18 09:25:19 EDT
Re-opening
Comment 11 Darin Wright CLA 2010-10-18 09:25:38 EDT
*** Bug 327983 has been marked as a duplicate of this bug. ***
Comment 12 Patrick Chuong CLA 2011-03-29 16:16:23 EDT
Created attachment 192129 [details]
patch to switch to initial perspective when all launches are termianted

We have the same issue raised by our customer using CDT, so this is not a JDT specific issue and this bug should be assigned to platform debug.

Can any committer take a look at this patch, I would like to have this included for Indigo.
Comment 13 Pawel Piech CLA 2011-04-01 15:52:05 EDT
It's funny that we're looking at another perspective-related preference: bug 341559.  

Out of curiosity.  Is this a preference you expect users to tinkle with, or you want it to be a product customization option?
Comment 14 Michael Rennie CLA 2011-04-01 16:06:22 EDT
Testing the patch I found that it does not ever switch back to the initial perspective. The steps I tried:

1. start existing target workspace (in the Java perspective)
2. set preferences 1) prompt to switch on suspend 2) prompt to switch back on terminate
3. create simple HelloWorld class with bp in it
4. hit the debug button

Expected:

That I would be prompted to switch to the debug perspective and then prompted to switch back when HelloWorld terminates

Happens:

I am prompted to switch to the debug perspective [OK], but no matter how I terminate HelloWorld - via resuming or the terminate button - I am never prompted to switch back to the Java perspective where I started from.
Comment 15 Walter Harley CLA 2011-04-01 16:30:43 EDT
I think Darin's algorithm in comment #1 was the right idea.
Comment 16 Pawel Piech CLA 2011-04-01 16:52:06 EDT
Seems like there's some logistical problems of what to do when one launch takes you to one perspective then another launch to another.... you may not end up where you started when all said and done.  To me that's an edge case though and shouldn't stop us from implementing it.

(In reply to comment #15)
> I think Darin's algorithm in comment #1 was the right idea.

As far as I can tell the only difference is that Darin suggested to make the preference per launch config type, the given patch has a global preference.  Personally, I'm neutral on it.
Comment 17 Dani Megert CLA 2011-04-04 09:41:16 EDT
The patch didn't seem to do anything for me either.

I agree with Darin that this should be per launch config type. There are other things that need to be considered:
- Should it really only happen when the last launch is terminated? If so, a
  long running launch might render the feature useless.
- What if the user manually changed perspective while the launch was running?
  Do we still restore the originating perspective which might no longer be
  interesting at this point?
- Do we only switch when the launch is terminated manually or also when the
  launched program exits? If we do the latter, we might end up with a very
  disruptive/unpredictable UI.
- Should we record the originating perspective and return to that one or is it
  maybe more useful to be able to specify the perspective that gets opened once
  a launch is terminated?
Comment 18 Patrick Chuong CLA 2011-04-04 11:29:50 EDT
(In reply to comment #13)
> Out of curiosity.  Is this a preference you expect users to tinkle with, or 
> you want it to be a product customization option?
I think this should be included in the platform debug and not a product customization option. In this bug, people requested to have this feature in JDT as well. Do you see products that don't want this feature included?

(In reply to comment #14)
> Testing the patch I found that it does not ever switch back to the initial
> perspective. The steps I tried:
I have tested this patch with CDT-GDB launch type and TI-Debugger launch type, but hasn't try JDT yet. I'll give it a try.

(In reply to comment #17)
> The patch didn't seem to do anything for me either.
I guess you are doing what Michael is doing, I'll take a look.

> - Should it really only happen when the last launch is terminated? If so, a
>   long running launch might render the feature useless.
I believe so, wouldn’t you terminate non interested launch and free up the Debug view? 

For example, I have two debug launch types, JDT and CDT. I launch JDT from java perspective and then switch to C/C++ Perspective and launch CDT. Than few minutes later, I terminate JDT in Debug perspective, I wouldn’t want it to switch back to Java perspective yet.

Someone might want to switch back for every launch terminated. In this case, we can have an option (checkbox) to enable always switch back.

> - What if the user manually changed perspective while the launch was running?
Gets ignored, only applies to the perspective where you launch a debug session.

>   Do we still restore the originating perspective which might no longer be
>   interesting at this point?
I would say no, which is what this patch does, it switch back to perspective where the last launch was terminated.

> - Do we only switch when the launch is terminated manually or also when the
>   launched program exits? If we do the latter, we might end up with a very
>   disruptive/unpredictable UI.
I agree. This is also problematic for forward switch as well, where I have a program runs to completion very fast and I can't see anything in the Debug view.

> - Should we record the originating perspective and return to that one or is it
>   maybe more useful to be able to specify the perspective that gets opened 
> once a launch is terminated?
I would say the original perspective should be open. Does people want to switch to a different perspective when terminate debug session?
Comment 19 Patrick Chuong CLA 2011-04-04 12:19:51 EDT
(In reply to comment #14)
> Testing the patch I found that it does not ever switch back to the initial
> perspective. The steps I tried:
> 1. start existing target workspace (in the Java perspective)
> 2. set preferences 1) prompt to switch on suspend 2) prompt to switch back on
> terminate
> 3. create simple HelloWorld class with bp in it
> 4. hit the debug button
> Expected:
> That I would be prompted to switch to the debug perspective and then prompted
> to switch back when HelloWorld terminates
> Happens:
> I am prompted to switch to the debug perspective [OK], but no matter how I
> terminate HelloWorld - via resuming or the terminate button - I am never
> prompted to switch back to the Java perspective where I started from.

Are you prompted to switch perspective due to breakpoint hit and not due to launching a debug session? This patch doesn't remember perspective switch due to breakpoint hit? If this is what we want, I can update the patch.
Comment 20 Dani Megert CLA 2011-04-06 06:52:41 EDT
> (In reply to comment #17)
> > The patch didn't seem to do anything for me either.
> I guess you are doing what Michael is doing, I'll take a look.
I guess so.

> > - Should it really only happen when the last launch is terminated? If so, a
> >   long running launch might render the feature useless.
> I believe so, wouldn’t you terminate non interested launch and free up the
> Debug view? 
Not really. I often keep terminated launches to reach their console again.

> > - What if the user manually changed perspective while the launch was running?
> Gets ignored, only applies to the perspective where you launch a debug session.
What gets ignored: the auto-switch or my manual change?

> >   Do we still restore the originating perspective which might no longer be
> >   interesting at this point?
> I would say no, which is what this patch does, it switch back to perspective
> where the last launch was terminated.
You probably meant "launch was STARTED"?

> > - Do we only switch when the launch is terminated manually or also when the
> >   launched program exits? If we do the latter, we might end up with a very
> >   disruptive/unpredictable UI.
> I agree. This is also problematic for forward switch as well, where I have a
> program runs to completion very fast and I can't see anything in the Debug
> view.
I disagree with that. Forward search is predictable in the sense that it activates exactly the specified perspective (or prompts).

> > - Should we record the originating perspective and return to that one or is it
> >   maybe more useful to be able to specify the perspective that gets opened 
> > once a launch is terminated?
> I would say the original perspective should be open.
I agree with that assuming no manual perspective switching too place between launch and termination.
Comment 21 Patrick Chuong CLA 2011-04-06 10:08:38 EDT
(In reply to comment #20)
> What gets ignored: the auto-switch or my manual change?
Manual switch.

> You probably meant "launch was STARTED"?
Yes, I meant STARTED.

> I disagree with that. Forward search is predictable in the sense that it
> activates exactly the specified perspective (or prompts).
After thinking a bit more about this, I think we should swtich back when the user manually terminate and when the program run to exit. What do you think?

> I agree with that assuming no manual perspective switching too place between
> launch and termination.
Are you suggesting we need a similar approach as forward switch? i.e let the user pick which perspective to switch back when all launches are terminated. And perhaps have an additional choice to switch back to where the last terminated debug session is launched from.
Comment 22 Michael Rennie CLA 2011-04-06 12:26:20 EDT
(In reply to comment #21)
 
> After thinking a bit more about this, I think we should swtich back when the
> user manually terminate and when the program run to exit. What do you think?
> 

I agree, we should switch back on terminate, regardless of how the terminate occurs.

> Are you suggesting we need a similar approach as forward switch? i.e let the
> user pick which perspective to switch back when all launches are terminated.
> And perhaps have an additional choice to switch back to where the last
> terminated debug session is launched from.

It would be nice to give the user a bit of control over this process, so I can see the utility in having the "switch back" case behave identically to the "switch forward" case.
Comment 23 Patrick Chuong CLA 2011-04-06 13:45:02 EDT
To summarize what we want.

1) Switch back when all launches are terminated and does not tied to launch type.

2) Create an option similar to the forward switch and place it at the bottom of the Perspectives preferences. User can select which perspective to switch back (same as forward switch).

Did I missed anything? I’ll try to rework the patch. I guess this feature is too late for Indigo, right? If it is, than can we get this in for post Indigo? Thanks.
Comment 24 Dani Megert CLA 2011-04-12 11:44:55 EDT
See also http://wiki.eclipse.org/Debug/Phone_7-Apr-2011
Comment 25 Patrick Chuong CLA 2011-04-12 15:17:14 EDT
Created attachment 193086 [details]
patch with perspective selection

This patch provides the UI to select the desired perspective for backward switching per launch type. By default, when all launches of the "same type" are terminated, than the perspective will switch back according to the configured perspective. You can also override the backward switch to occur when all launches are terminated, and the perspective that is configured for the last terminated launch type will be use.

Please provide better wording in the dialog if you can think of better one.

Let me know whether this patch works for you guys. Thanks for giving suggestions and testing the patches.
Comment 26 Patrick Chuong CLA 2011-04-13 10:12:44 EDT
I am trying to use plugin_customization.ini to set default values for both forward and backward switch for some of the launch type/delegate. However it works the first time, but the restore to default doesn't pickup the values from the ini file. Is this a bug?

Another question, should we define the backward switch (terminate) as another mode (i.e terminateMode)? Right now, there are run, debug and profile launchMode. Does it make sense to have terminate as another mode? With terminate beening a mode, I should be able to provide the default perspective for launchMode and terminateMode. And I wouldn't need the plugin_customization.ini to set the default value.
Comment 27 Leonard Ritter CLA 2011-05-23 11:13:21 EDT
Bump!

I'd expect the functionality to simply save the perspective active before debug was started, and return to the saved perspective upon termination, in blatant disregard of user perspective changes in between.
Comment 28 Johan CLA 2011-05-29 22:55:27 EDT
> Another question, should we define the backward switch (terminate) as another
> mode (i.e terminateMode)? Right now, there are run, debug and profile
> launchMode. Does it make sense to have terminate as another mode? With
> terminate beening a mode, I should be able to provide the default perspective
> for launchMode and terminateMode. And I wouldn't need the
> plugin_customization.ini to set the default value.

As Leonard Ritter pointed out, it would be enough to (automatically) change back to the "saved" perspective that was shown before you started the run/debug/profile operation. A preconfigured stwich-back shouldn't be the default one, any kind of other perspective-changes-back should really be only "on" (and therefore somehow prioritized) if you actually set them to be on.

To your question, no I can't see the point in having an "on-terminate" switch. In what cases would you use that? An avarage user starts the debug/run session and after that (usually) expects the application to return to where he has been before.
Comment 29 Patrick Chuong CLA 2011-05-30 09:42:46 EDT
(In reply to comment #28)
> As Leonard Ritter pointed out, it would be enough to (automatically) change
> back to the "saved" perspective that was shown before you started the
> run/debug/profile operation. A preconfigured stwich-back shouldn't be the
> default one, any kind of other perspective-changes-back should really be only
> "on" (and therefore somehow prioritized) if you actually set them to be on.
> To your question, no I can't see the point in having an "on-terminate" switch.
> In what cases would you use that? An avarage user starts the debug/run session
> and after that (usually) expects the application to return to where he has been
> before.

Hi Johan, can you give the current patch a try and let me know what you think? The previous patch that I have created, marked as absoleted, simply switch back to the perspective before a launch happend. Can you also try that patch out?
Comment 30 Pawel Piech CLA 2011-06-03 12:02:35 EDT
Currently being worked on.
Comment 31 Pawel Piech CLA 2011-06-08 00:15:21 EDT
*** Bug 312762 has been marked as a duplicate of this bug. ***
Comment 32 Dani Megert CLA 2011-10-14 09:45:02 EDT
I looked at how the patch works (no code review). It goes into the right direction. There are some unexpected issues:
- The 'Open associated perspective when all ...' checkbox seems to do nothing.
  I don't see why we need this.
- The dialog that asks after all launches are terminated talks about switching
  back to the "initial" perspective. This is not what I see. It switches to the
  one selected in the [Terminate]: drop down.
Comment 33 Dani Megert CLA 2011-10-14 09:47:15 EDT
> - The dialog that asks after all launches are terminated talks about switching
>   back to the "initial" perspective. This is not what I see. It switches to the
>   one selected in the [Terminate]: drop down.
Which is good. Going back to some "initial" perspective is not predictable.
Comment 34 Matthias Hryniszak CLA 2013-08-24 09:48:31 EDT
This is probably one of the biggest drawbacks and the sole reason I'm not using the debug perspective at all.

By comparison NetBeans, Delphi, MonoDevelop, SharpDevelop and VisualStudio are all doing a good job in switching back and forth between a debug and "normal" perspective.

I agree that there might be some difficulties in defining which is actually the "original" perspective but what that really is is an edge case that's been brought before the audience to stop the development of this feature for 10 years.
Comment 35 Nathan Reynolds CLA 2013-08-26 11:39:59 EDT
I've been using a buggy third party plugin.  Most of the time it manages to switch the perspective back to the perspective before debugging.  This is good enough for me to keep using it.  Occasionally, I have to manually switch the perspective.  That is far better than having to manually switch it every time.

So what if there are bugs.  There will always be bugs and corner cases in all software.  It is better to have a low-risk feature that mostly works than none at all.  As bugs and corner cases arise, they can be dealt with and fixed.
Comment 36 Matthias Hryniszak CLA 2013-08-26 17:50:58 EDT
Can you share which plugin does it?
Comment 37 Nathan Reynolds CLA 2013-08-26 18:38:28 EDT
(In reply to comment #36)
> Can you share which plugin does it?

Here's a link to the blog entry describing the plugin and a download link.

http://www.richinternet.de/blog/index.cfm?entry=1758AACF-910C-DE52-368E1421BEFDA19B
Comment 38 Nobody - feel free to take it CLA 2014-01-31 15:30:14 EST
This problem seems to affect PDT too. I can choose between getting the Debug view opened automatically or getting back to the PHP view automatically, but I didn't manage to get both simultaneously.
Comment 39 Francesco * CLA 2019-05-13 08:12:03 EDT
I've written a plugin for this:
https://marketplace.eclipse.org/content/debug-perspective-auto-closer

It has two possible behaviors:
1) [default] when all debug launches have terminated, changes to perspective active on first launch
2) when any debug launch has terminated, changes to perspective active on that launch

The preferred behavior can be selected on a preference page.

Source:
https://github.com/GammaWolf/eclipse-debug-perspective-auto-closer-plugin
Comment 40 Pierre-Yves Bigourdan CLA 2019-06-04 13:46:27 EDT
As previously mentioned, I still believe this should be part of the IDE rather than a separate plugin. :)
Comment 41 Francesco * CLA 2019-07-02 10:44:23 EDT
(In reply to Pierre-Yves B. from comment #40)
> As previously mentioned, I still believe this should be part of the IDE
> rather than a separate plugin. :)

I agree.

Is there an agreement how the integrated feature should work exactly? 
What would be the correct place(s) in the code to add this feature?
Comment 42 Pierre-Yves Bigourdan CLA 2019-07-02 14:42:50 EDT
(In reply to Francesco * from comment #41)
> (In reply to Pierre-Yves B. from comment #40)
> > As previously mentioned, I still believe this should be part of the IDE
> > rather than a separate plugin. :)
> 
> I agree.
> 
> Is there an agreement how the integrated feature should work exactly? 
> What would be the correct place(s) in the code to add this feature?

Dani Megert would probably be able to provide more guidance. I'm just an occasional contributor to Eclipse, I'm not familiar with Platform Debug. :)
Comment 43 Sarika Sinha CLA 2019-07-03 05:01:43 EDT
(In reply to Francesco * from comment #41)
> (In reply to Pierre-Yves B. from comment #40)
> > As previously mentioned, I still believe this should be part of the IDE
> > rather than a separate plugin. :)
> 
> I agree.
> 
> Is there an agreement how the integrated feature should work exactly? 
> What would be the correct place(s) in the code to add this feature?

You see the attached patch for reference, PerspectiveManager is the place which will handle all this.
Comment 44 Pierre-Yves Bigourdan CLA 2019-10-20 16:06:33 EDT
Any update on this Francesco? :)
Comment 45 Francesco * CLA 2019-10-21 19:07:39 EDT
I have moved on.

The first question (as to the how it should work exactly) has not been answered.
I've also had some trouble setting up a dev environment for it in a reasonable amount of time.
Comment 46 Ivan CLA 2020-03-29 10:40:53 EDT
Strange, this feature is not implemented and not a part of standard Eclipse yet.

Additionally want to mention radio-boxes "Open the associated perspective when launching" and "Open the associated perspective when an application suspends":
1) Ideally... we need 2 separate radio-boxes for each pair of "Application Type/Launchers" and "Modes/Perspectives". That is for each combo-box which can appear during configuration.
2) At least... we need 2 separate radio-boxes for each "Application Type/Launchers". Less flexible, but easier-to-understand interface.
3) Right now... 2 radio-boxes configure all possible launchers and modes. Not flexible at all.

Separate radio-boxes are necessary for example if I want to always switch perspective for local debug, but ask for remote debug (where Expressions window can freeze eclipse because of traffic lags).
Comment 47 Ivan CLA 2020-03-29 11:47:48 EDT
PS. To underline the relation between switching-back and those radio-boxes... the switch-back functionality can be implemented with brand new radio-box (let's say "Switch back to original perspective upon termination" with options e.g.: "Always", "Never", "Prompt", "For selected perspectives:" etc.