Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 87587

Summary: Debugging views automatically opened before perspective switch
Product: [Eclipse Project] Platform Reporter: Jared Burns <jared_burns>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P2 CC: chanskw, darin.eclipse
Version: 3.1   
Target Milestone: 3.1 RC1   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
patch to org.eclipse.debug.ui
none
patch none

Description Jared Burns CLA 2005-03-09 17:49:23 EST
1. Enable automatic view management in the Java and Debug perspectives.
2. Open the Debug view in the Java perspective.
2. Debug to a breakpoint.
  2a. Debugging views are automatically opened in the Java perspective.
3. When you're prompted to switch perspectives, switch to Debug.
4. Do your debugging in the Debug perspective, terminate the launch, and go back
to Java. The perspective is now cluttered with debugging views from step 2a
("You're welcome.").

Automatic view management should not happen until after the perspective
switching code has run.
Comment 1 Samantha Chan CLA 2005-05-19 18:04:50 EDT
Created attachment 21479 [details]
patch to org.eclipse.debug.ui

* Added a class name PerspectiveSwitchLock in Perspective Manager.  This class
has one boolean field and is used to indicate if the Perspective may swtich
perspective as a result of some events.
* When the Perspective Manager gets a debug event or launch added event, the
manager sets a the perspective switch lock to true.  When the perspective
manager has finished handling the event, it will sets the lock back to false
and will notify all who is waiting on this lock.
* LaunchViewContextListener #contextEnabled(...) method is changed.  The method
now define two jobs.  One for opening context-enabled views on the UI thread. 
Another job for waiting for the perspective manager to finish perspective
switch.  When #contextEnabled(...) is called, the listener checks with the
Perspective Manger to see if it may be switching perspective.  If the
perspective manager may be switching perspective, the listener schedules a job
to wait.  When the perspective manager is done, the listener gets notify and
will schedule an UI job to open context-enabled views.	If the perspective
manager is not switching perspective when #contextEnabled(...) is called, the
listener schedules a job to open views immediately.
* This design requires that the Perspective Manager gets the suspend event
before other event handlers.  (i.e. LaunchViewEventHandler).  Otherwise, the
launch view may enable a context before the perspective manager has a chance to
set up its lock.  In DebugUIPlugin, I am creating the Perspective Manager when
the plugin is created.	This ensures that the manager is the first listener to
debug events and will process the event before everyone else.
Comment 2 Samantha Chan CLA 2005-05-19 18:05:23 EDT
Darin -
Please review code and let me know what you think...  Thanks...
Samantha
Comment 3 Darin Wright CLA 2005-05-20 11:31:03 EDT
Created attachment 21515 [details]
patch

Samantha, please review this alternative patch. The design is the same but the
implementation hides the lock in the perspective manager. Clients simple
scheule jobs with the perspective manager, to be run after any ongoing
perspective switch. I think it makes the client code simpler and avoids a
public lock.
Comment 4 Jared Burns CLA 2005-05-20 14:04:00 EDT
Relying on the order of the listener registries is scary and making the
listeners so tightly coupled to each other makes this code even more complicated
than it already is.

What about creating one debug event handler that dispatches debug events to the
perspective manager and the context listener in sequence?
Comment 5 Darin Wright CLA 2005-05-20 15:33:29 EDT
The context listener is not actually a debug event/launch listener. The debug 
view explicitly updates the context listener (via the message 
updateForSelection(...)). So, the important thing is that the perspective 
manager is a listener before the debug view. I'm not excited about having the 
debug view register with the perspective manager for events.
Comment 6 Samantha Chan CLA 2005-05-24 11:36:23 EDT
Verified that the alternative patch is good.  Thanks for making the 
enhancements.  

Samantha
Comment 7 Darin Wright CLA 2005-05-24 12:29:51 EDT
Released patch. I feel this is the simplest/safest fix for 3.1.
Comment 8 Darin Wright CLA 2005-05-26 15:17:01 EDT
Verified.