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 21515 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
ui-87587.patch (text/plain), 16.88 KB, created by
Darin Wright
on 2005-05-20 11:31:03 EDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Darin Wright
Created:
2005-05-20 11:31:03 EDT
Size:
16.88 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 20 May 2005 15:28:29 -0000 >@@ -389,6 +389,11 @@ > public void start(BundleContext context) throws Exception { > super.start(context); > >+ // make sure the perspective manager is created >+ // and be the first debug event listener >+ fPerspectiveManager = new PerspectiveManager(); >+ fPerspectiveManager.startup(); >+ > // Listen to launches to lazily create "launch processors" > DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); > >@@ -652,11 +657,6 @@ > DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); > getProcessConsoleManager().startup(); > >- if (fPerspectiveManager == null) { >- PerspectiveManager manager = getPerspectiveManager(); >- manager.launchAdded(launch); >- } >- > if (fStepFilterManager == null) { > getStepFilterManager().launchAdded(launch); > } >@@ -665,15 +665,11 @@ > } > > /** >- * Returns the persepective manager - instantiating it if required. >+ * Returns the persepective manager. > * > * @return > */ > public PerspectiveManager getPerspectiveManager() { >- if (fPerspectiveManager == null) { >- fPerspectiveManager = new PerspectiveManager(); >- fPerspectiveManager.startup(); >- } > 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 20 May 2005 15:28:30 -0000 >@@ -14,14 +14,17 @@ > import java.io.IOException; > import java.io.StringReader; > import java.text.MessageFormat; >+import java.util.ArrayList; > import java.util.HashMap; > import java.util.Iterator; >+import java.util.List; > import java.util.Map; > import javax.xml.parsers.DocumentBuilder; > import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; > import javax.xml.transform.TransformerException; > import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.debug.core.DebugEvent; > import org.eclipse.debug.core.DebugPlugin; > import org.eclipse.debug.core.IDebugEventSetListener; >@@ -85,7 +88,44 @@ > * prompts at the same time. > */ > private boolean fPrompting; >+ private PerspectiveSwitchLock fPerspectiveSwitchLock = new PerspectiveSwitchLock(); >+ >+ /** >+ * Lock used to synchronize perspective switching with view activation. >+ * Clients wanting to perform an action after a perspective switch should >+ * schedule jobs with the perspective manager via #schedulePostSwitch(..) >+ */ >+ public class PerspectiveSwitchLock >+ { >+ >+ private int fSwitch = 0; >+ private List fJobs = new ArrayList(); > >+ public synchronized void startSwitch() { >+ fSwitch++; >+ } >+ >+ public synchronized void endSwitch() { >+ fSwitch--; >+ if (fSwitch == 0) { >+ Iterator jobs = fJobs.iterator(); >+ while (jobs.hasNext()) { >+ ((Job)jobs.next()).schedule(); >+ } >+ fJobs.clear(); >+ } >+ } >+ >+ public synchronized void schedulePostSwitch(Job job) { >+ if (fSwitch > 0) { >+ fJobs.add(job); >+ } else { >+ job.schedule(); >+ } >+ } >+ } >+ >+ > /** > * Called by the debug ui plug-in on startup. > * The perspective manager starts listening for >@@ -131,6 +171,9 @@ > * @see ILaunchListener#launchAdded(ILaunch) > */ > public void launchAdded(ILaunch launch) { >+ >+ fPerspectiveSwitchLock.startSwitch(); >+ > String perspectiveId = null; > // check event filters > try { >@@ -152,13 +195,19 @@ > // 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 >+ { >+ fPerspectiveSwitchLock.endSwitch(); > } > } > }); >- > } > > >@@ -284,6 +333,15 @@ > * @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. >+ fPerspectiveSwitchLock.startSwitch(); >+ > // apply event filters > ILaunch launch= null; > Object source = event.getSource(); >@@ -307,34 +365,41 @@ > 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 >+ { >+ fPerspectiveSwitchLock.endSwitch(); > } > } > }; >@@ -742,4 +807,13 @@ > > } > >+ /** >+ * Schedules the given job after perspective switching is complete, or >+ * immediately if a perspective switch is not in progress. >+ * >+ * @param job job to run after perspective switching >+ */ >+ public void schedulePostSwitch(Job job) { >+ fPerspectiveSwitchLock.schedulePostSwitch(job); >+ } > } >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 20 May 2005 15:28:30 -0000 >@@ -24,7 +24,10 @@ > 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.debug.core.ILaunch; > import org.eclipse.debug.core.model.IDebugElement; > import org.eclipse.debug.core.model.IDebugModelProvider; >@@ -32,6 +35,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 +60,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 +535,129 @@ > * @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(); >+ openViewsJob.setSystem(true); >+ >+ final PerspectiveManager manager = DebugUIPlugin.getDefault().getPerspectiveManager(); >+ if (isBoundToViews(contextIds)) { >+ manager.schedulePostSwitch(openViewsJob); > } >- 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); >- } >+ } >+ >+ /** >+ * @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 +708,7 @@ > * @param contexts > */ > public void contextsDisabled(Set contexts) { >- IWorkbenchPage page= getPage(); >+ IWorkbenchPage page= getPage(); > if (page == null || contexts.size() == 0 || !isAutoManageViews()) { > return; > } >@@ -715,7 +762,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