Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 21479 Details for
Bug 87587
Debugging views automatically opened before perspective switch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
patch to org.eclipse.debug.ui
ui.txt (text/plain), 18.15 KB, created by
Samantha Chan
on 2005-05-19 18:04:50 EDT
(
hide
)
Description:
patch to org.eclipse.debug.ui
Filename:
MIME Type:
Creator:
Samantha Chan
Created:
2005-05-19 18:04:50 EDT
Size:
18.15 KB
patch
obsolete
>Index: ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java,v >retrieving revision 1.256 >diff -u -r1.256 DebugUIPlugin.java >--- ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java 21 Apr 2005 16:30:17 -0000 1.256 >+++ ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java 19 May 2005 21:55:33 -0000 >@@ -239,6 +239,11 @@ > public DebugUIPlugin() { > super(); > fgDebugUIPlugin= this; >+ >+ // make sure the perspective manager is created >+ // and be the first debug event listener >+ fPerspectiveManager = new PerspectiveManager(); >+ fPerspectiveManager.startup(); > } > > /** >@@ -652,10 +657,9 @@ > DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); > getProcessConsoleManager().startup(); > >- if (fPerspectiveManager == null) { >- PerspectiveManager manager = getPerspectiveManager(); >- manager.launchAdded(launch); >- } >+ // fPerspectiveManager created when DebugUIPlugin is constructed >+ // It should never be null. >+ fPerspectiveManager.launchAdded(launch); > > if (fStepFilterManager == null) { > getStepFilterManager().launchAdded(launch); >@@ -670,10 +674,9 @@ > * @return > */ > public PerspectiveManager getPerspectiveManager() { >- if (fPerspectiveManager == null) { >- fPerspectiveManager = new PerspectiveManager(); >- fPerspectiveManager.startup(); >- } >+ >+ // fPerspectiveManager created when DebugUIPlugin is constructed >+ // It should never be null. > return fPerspectiveManager; > } > >Index: ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java,v >retrieving revision 1.70 >diff -u -r1.70 PerspectiveManager.java >--- ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java 19 Apr 2005 21:01:28 -0000 1.70 >+++ ui/org/eclipse/debug/internal/ui/launchConfigurations/PerspectiveManager.java 19 May 2005 21:55:33 -0000 >@@ -85,7 +85,38 @@ > * prompts at the same time. > */ > private boolean fPrompting; >+ private PerspectiveSwitchLock fPerspectiveSwitchLock = new PerspectiveSwitchLock(); >+ >+ /** >+ * Flag to indicate that the workench may be switching perspective. >+ * When PerspectiveManager gets a suspend event and the workbench may require >+ * too switch perspective, the manager sets this lock to equal to true. When the manager >+ * has finished processing the event and the workbench is in the correct perspective, the >+ * manager sets this lock to false. >+ * >+ * In LaunchViewContextListener, before trying to open views associated with enabled context, >+ * the listener checks with this manager to determine if it is possible to switch perspective. >+ * If so, the listener wait on this lock. When the listener receives a notify from this lock, >+ * the listener wakes up and checks to see if views need to be opened from the current >+ * perspective. >+ */ >+ public class PerspectiveSwitchLock >+ { >+ >+ private boolean fIsSwithingPerspective = false; > >+ public void setSwitchingPerspective(boolean b) >+ { >+ fIsSwithingPerspective = b; >+ } >+ >+ public boolean isSwitchingPerspective() >+ { >+ return fIsSwithingPerspective; >+ } >+ } >+ >+ > /** > * Called by the debug ui plug-in on startup. > * The perspective manager starts listening for >@@ -131,6 +162,18 @@ > * @see ILaunchListener#launchAdded(ILaunch) > */ > public void launchAdded(ILaunch launch) { >+ >+ boolean unlock = false; >+ synchronized(fPerspectiveSwitchLock) >+ { >+ if (!isSwitchingPerspective()) >+ { >+ fPerspectiveSwitchLock.setSwitchingPerspective(true); >+ unlock = true; >+ } >+ } >+ final boolean unlockLater = unlock; >+ > String perspectiveId = null; > // check event filters > try { >@@ -152,13 +195,26 @@ > // switch > async(new Runnable() { > public void run() { >- IWorkbenchWindow window = getWindowForPerspective(id); >- if (id != null && window != null && shouldSwitchPerspectiveForLaunch(window, id)) { >- switchToPerspective(window, id); >+ try >+ { >+ IWorkbenchWindow window = getWindowForPerspective(id); >+ if (id != null && window != null && shouldSwitchPerspectiveForLaunch(window, id)) { >+ switchToPerspective(window, id); >+ } >+ } >+ finally >+ { >+ synchronized(fPerspectiveSwitchLock) >+ { >+ if (unlockLater) >+ { >+ fPerspectiveSwitchLock.setSwitchingPerspective(false); >+ fPerspectiveSwitchLock.notifyAll(); >+ } >+ } > } > } > }); >- > } > > >@@ -284,6 +340,24 @@ > * @param event the suspend event > */ > private void handleBreakpointHit(DebugEvent event) { >+ >+ // Must be called here to indicate that the perspective >+ // may be switching. >+ // Putting this in the async UI call will cause the Perspective >+ // Manager to turn on the lock too late. Consequently, LaunchViewContextListener >+ // may not know that the perspective will switch and will open view before >+ // the perspective switch. >+ boolean unlock = false; >+ synchronized(fPerspectiveSwitchLock) >+ { >+ if (!isSwitchingPerspective()) >+ { >+ fPerspectiveSwitchLock.setSwitchingPerspective(true); >+ unlock = true; >+ } >+ } >+ final boolean unlockLater = unlock; >+ > // apply event filters > ILaunch launch= null; > Object source = event.getSource(); >@@ -307,34 +381,48 @@ > Runnable r = new Runnable() { > public void run() { > IWorkbenchWindow window = null; >+ try{ > if (targetId != null) { >- window = getWindowForPerspective(targetId); >- if (window == null) { >- return; >- } >- if (shouldSwitchPerspectiveForSuspend(window, targetId)) { >- switchToPerspective(window, targetId); >- // Showing the perspective can open a new window >- // (based on user prefs). So check again in case a >- // new window has been opened. > window = getWindowForPerspective(targetId); > if (window == null) { > return; > } >- } >- // re-open the window if minimized >- Shell shell= window.getShell(); >- if (shell != null) { >- if (shell.getMinimized()) { >- shell.setMinimized(false); >+ >+ if (shouldSwitchPerspectiveForSuspend(window, targetId)) { >+ switchToPerspective(window, targetId); >+ // Showing the perspective can open a new window >+ // (based on user prefs). So check again in case a >+ // new window has been opened. >+ window = getWindowForPerspective(targetId); >+ if (window == null) { >+ return; >+ } > } >- if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_ACTIVATE_WORKBENCH)) { >- shell.forceActive(); >+ // re-open the window if minimized >+ Shell shell= window.getShell(); >+ if (shell != null) { >+ if (shell.getMinimized()) { >+ shell.setMinimized(false); >+ } >+ if (DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_ACTIVATE_WORKBENCH)) { >+ shell.forceActive(); >+ } > } > } >+ if (window != null && DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_ACTIVATE_DEBUG_VIEW)) { >+ showDebugView(window); >+ } > } >- if (window != null && DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_ACTIVATE_DEBUG_VIEW)) { >- showDebugView(window); >+ finally >+ { >+ synchronized(fPerspectiveSwitchLock) >+ { >+ if (unlockLater) >+ { >+ fPerspectiveSwitchLock.setSwitchingPerspective(false); >+ fPerspectiveSwitchLock.notifyAll(); >+ } >+ } > } > } > }; >@@ -742,4 +830,21 @@ > > } > >+ /** >+ * @return if the perspective manager is in the process of switching perspective. >+ */ >+ public boolean isSwitchingPerspective() >+ { >+ return fPerspectiveSwitchLock.isSwitchingPerspective(); >+ } >+ >+ /** >+ * @return the lock to wait on if the manger is switching perspective. >+ * The lock will notify when the manager has finished switching perspective. >+ */ >+ public PerspectiveSwitchLock getPerspectiveSwitchLock() >+ { >+ return fPerspectiveSwitchLock; >+ } >+ > } >Index: ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java,v >retrieving revision 1.54 >diff -u -r1.54 LaunchViewContextListener.java >--- ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java 18 May 2005 15:52:18 -0000 1.54 >+++ ui/org/eclipse/debug/internal/ui/views/launch/LaunchViewContextListener.java 19 May 2005 21:55:33 -0000 >@@ -24,7 +24,11 @@ > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtensionPoint; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.debug.core.ILaunch; > import org.eclipse.debug.core.model.IDebugElement; > import org.eclipse.debug.core.model.IDebugModelProvider; >@@ -32,6 +36,7 @@ > import org.eclipse.debug.core.model.IStackFrame; > import org.eclipse.debug.internal.ui.DebugUIPlugin; > import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; >+import org.eclipse.debug.internal.ui.launchConfigurations.PerspectiveManager; > import org.eclipse.debug.ui.DebugUITools; > import org.eclipse.debug.ui.IDebugUIConstants; > import org.eclipse.jface.preference.IPreferenceStore; >@@ -56,6 +61,7 @@ > import org.eclipse.ui.contexts.IContextManagerListener; > import org.eclipse.ui.contexts.IWorkbenchContextSupport; > import org.eclipse.ui.contexts.NotDefinedException; >+import org.eclipse.ui.progress.UIJob; > > /** > * A context listener which automatically opens/closes/activates views in >@@ -530,87 +536,157 @@ > * @param contextId the ID of the context that has been > * enabled > */ >- public void contextEnabled(Set contextIds) { >+ public void contextEnabled(final Set contextIds) { > if (!isAutoManageViews()) { > return; > } >- IWorkbenchPage page= getPage(); >- // We ignore the "Debugging" context since we use it >- // to provide a base set of views for other context >- // bindings to inherit. If we don't ignore it, we'll >- // end up opening those views whenever a debug session >- // starts, which is not the desired behavior. >- contextIds.remove(DEBUG_CONTEXT); >- if (page == null || contextIds.size() == 0) { >- return; >- } >- Set viewsToShow= new HashSet(); >- Set viewsToOpen= new HashSet(); >- computeViewActivation(contextIds, viewsToOpen, viewsToShow); > >- boolean resetTrackingPartChanges = false; >- if (fIsTrackingPartChanges) >- { >- // only change the flag if it is currently >- // tracking part changes. >- fIsTrackingPartChanges= false; >- resetTrackingPartChanges = true; >- } >- >- Iterator iterator= viewsToOpen.iterator(); >- >- String id = page.getPerspective().getId(); >- Set views = (Set)openedViewIds.get(id); >- if (views == null) >- { >- views = new HashSet(); >- } >- >- while (iterator.hasNext()) { >- String viewId = (String) iterator.next(); >- try { >- IViewPart view = page.showView(viewId, null, IWorkbenchPage.VIEW_CREATE); >- views.add(viewId); >- >- viewsToShow.add(view); >- } catch (PartInitException e) { >- DebugUIPlugin.log(e.getStatus()); >+ final UIJob openViewsJob = new UIJob("Open Context-Enabled Views") { //$NON-NLS-1$ >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ IWorkbenchPage page = getPage(); >+ if (page == null) >+ return Status.OK_STATUS; >+ >+ // Since we run this job asynchronously on the UI Thread, >+ // #getPerspective() may return null when this job is run >+ // when the workbench is shutting down. >+ if (page.getPerspective() == null) >+ return Status.OK_STATUS; >+ >+ // We ignore the "Debugging" context since we use it >+ // to provide a base set of views for other context >+ // bindings to inherit. If we don't ignore it, we'll >+ // end up opening those views whenever a debug session >+ // starts, which is not the desired behavior. >+ contextIds.remove(DEBUG_CONTEXT); >+ if (page == null || contextIds.size() == 0) { >+ return Status.OK_STATUS; >+ } >+ Set viewsToShow = new HashSet(); >+ Set viewsToOpen = new HashSet(); >+ computeViewActivation(contextIds, viewsToOpen, viewsToShow); >+ >+ boolean resetTrackingPartChanges = false; >+ if (fIsTrackingPartChanges) { >+ // only change the flag if it is currently >+ // tracking part changes. >+ fIsTrackingPartChanges = false; >+ resetTrackingPartChanges = true; >+ } >+ >+ Iterator iterator = viewsToOpen.iterator(); >+ >+ String id = page.getPerspective().getId(); >+ Set views = (Set) openedViewIds.get(id); >+ if (views == null) { >+ views = new HashSet(); >+ } >+ >+ while (iterator.hasNext()) { >+ String viewId = (String) iterator.next(); >+ try { >+ IViewPart view = page.showView(viewId, null, >+ IWorkbenchPage.VIEW_CREATE); >+ views.add(viewId); >+ >+ viewsToShow.add(view); >+ } catch (PartInitException e) { >+ DebugUIPlugin.log(e.getStatus()); >+ } >+ } >+ >+ if (!viewsToOpen.isEmpty()) { >+ openedViewIds.put(id, views); >+ saveOpenedViews(); >+ } >+ iterator = viewsToShow.iterator(); >+ while (iterator.hasNext()) { >+ boolean activate = true; >+ IViewPart view = (IViewPart) iterator.next(); >+ IViewPart[] stackedViews = page.getViewStack(view); >+ if (stackedViews == null) { >+ continue; >+ } >+ // For each applicable view, iterate through the view stack. >+ // If we find that view before any other applicable views, >+ // show it. Otherwise, don't. >+ for (int i = 0; i < stackedViews.length; i++) { >+ IViewPart stackedView = stackedViews[i]; >+ if (view == stackedView) { >+ break; >+ } else if (viewsToShow.contains(stackedView)) { >+ // If this view is below an appropriate view, don't >+ // show it >+ activate = false; >+ break; >+ } >+ } >+ if (activate) { >+ page.bringToTop(view); >+ } >+ } >+ >+ // Reset if we have previously changed this setting >+ if (resetTrackingPartChanges) >+ loadTrackViews(); >+ >+ return Status.OK_STATUS; > } >- } >+ }; > >- if (!viewsToOpen.isEmpty()) { >- openedViewIds.put(id, views); >- saveOpenedViews(); >- } >- iterator= viewsToShow.iterator(); >- while (iterator.hasNext()) { >- boolean activate= true; >- IViewPart view = (IViewPart) iterator.next(); >- IViewPart[] stackedViews = page.getViewStack(view); >- if (stackedViews == null) { >- continue; >- } >- // For each applicable view, iterate through the view stack. >- // If we find that view before any other applicable views, >- // show it. Otherwise, don't. >- for (int i = 0; i < stackedViews.length; i++) { >- IViewPart stackedView= stackedViews[i]; >- if (view == stackedView) { >- break; >- } else if (viewsToShow.contains(stackedView)) { >- // If this view is below an appropriate view, don't show it >- activate= false; >- break; >+ openViewsJob.setSystem(true); >+ >+ final PerspectiveManager manager = DebugUIPlugin.getDefault().getPerspectiveManager(); >+ if (manager.isSwitchingPerspective()) { >+ Job waitForPerspectiveSwitch = new Job("Wait For Perspective Switch") { //$NON-NLS-1$ >+ >+ protected IStatus run(IProgressMonitor monitor) { >+ if (manager.isSwitchingPerspective()) { >+ synchronized (manager.getPerspectiveSwitchLock()) { >+ try { >+ manager.getPerspectiveSwitchLock().wait(); >+ } catch (InterruptedException e) { >+ >+ } >+ } >+ } >+ openViewsJob.schedule(); >+ >+ return Status.OK_STATUS; > } >+ }; >+ >+ waitForPerspectiveSwitch.setSystem(true); >+ // do not wait if no view needs to be opened >+ if (isBoundToViews(contextIds)) >+ waitForPerspectiveSwitch.schedule(); >+ } else >+ { >+ // do not schedule openViewsJob if no view needs to be opened >+ if(isBoundToViews(contextIds)) >+ { >+ openViewsJob.schedule(); > } >- if (activate) { >- page.bringToTop(view); >- } >+ } >+ } >+ >+ /** >+ * @param contextIds >+ * @return if the specified the context ids are tied >+ * to any context-enabled views. >+ */ >+ private boolean isBoundToViews(Set contextIds) >+ { >+ Set possibleViewsToShow = new HashSet(); >+ Iterator iter = contextIds.iterator(); >+ while (iter.hasNext()) >+ { >+ String contextId = (String)iter.next(); >+ Set viewIds = getApplicableViewIds(contextId); >+ possibleViewsToShow.addAll(viewIds); > } > >- // Reset if we have previously changed this setting >- if (resetTrackingPartChanges) >- loadTrackViews(); >+ return !possibleViewsToShow.isEmpty(); > } > > /** >@@ -661,7 +737,7 @@ > * @param contexts > */ > public void contextsDisabled(Set contexts) { >- IWorkbenchPage page= getPage(); >+ IWorkbenchPage page= getPage(); > if (page == null || contexts.size() == 0 || !isAutoManageViews()) { > return; > } >@@ -715,7 +791,12 @@ > Set viewIdsToClose= new HashSet(); > Set viewIdsToKeepOpen= getViewIdsForEnabledContexts(); > Iterator contexts = contextIds.iterator(); >- String currentPerspId = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getPerspective().getId(); >+ IWorkbenchPage page = getPage(); >+ if (page == null) >+ return viewIdsToClose; >+ if (page.getPerspective() == null) >+ return viewIdsToClose; >+ String currentPerspId = page.getPerspective().getId(); > Set viewIds = (Set)openedViewIds.get(currentPerspId); > while (contexts.hasNext()) { > String contextId = (String) contexts.next();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 87587
: 21479 |
21515