Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Swanson2001-08-14 11:02:11 +0000
committerDarin Swanson2001-08-14 11:02:11 +0000
commit7dcf10ee24a3e42b91dc06cd5b3119511c1fa39a (patch)
treee038ce8adf9bb0e6455cf970bf33e0bd202010da
parent0e4aaa5d5c57dce3fd6b6214e3b75bdd7d26a050 (diff)
downloadeclipse.platform.debug-7dcf10ee24a3e42b91dc06cd5b3119511c1fa39a.tar.gz
eclipse.platform.debug-7dcf10ee24a3e42b91dc06cd5b3119511c1fa39a.tar.xz
eclipse.platform.debug-7dcf10ee24a3e42b91dc06cd5b3119511c1fa39a.zip
1GGNR27: ITPDUI:ALL - Debug target selected instead of top stack frame
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/AbstractDebugView.java57
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BasicContentProvider.java12
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugContentProvider.java88
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java579
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugView.java65
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesView.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesViewer.java4
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ProcessesContentProvider.java8
8 files changed, 505 insertions, 312 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/AbstractDebugView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/AbstractDebugView.java
index 445a16682..58b0160d3 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/AbstractDebugView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/AbstractDebugView.java
@@ -5,13 +5,20 @@ package org.eclipse.debug.internal.ui;
* All Rights Reserved.
*/
-import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugViewAdapter; import org.eclipse.jface.action.*; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.*; import org.eclipse.ui.part.ViewPart;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IDebugViewAdapter;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.ui.*;
+import org.eclipse.ui.part.ViewPart;
/**
* Functionality common to views in the debugger
*/
-public abstract class AbstractDebugView extends ViewPart implements IDebugViewAdapter, IPartListener {
+public abstract class AbstractDebugView extends ViewPart implements IDebugViewAdapter {
protected final static String TITLE_TOOLTIPTEXT= "title_toolTipText";
@@ -25,18 +32,8 @@ public abstract class AbstractDebugView extends ViewPart implements IDebugViewAd
return this;
}
return super.getAdapter(adapter);
- }
-
- /**
- * @see IViewPart
- */
- public void init(IViewSite site) throws PartInitException {
- super.init(site);
- getSite().getPage().addPartListener(this);
- }
-
+ }
public void dispose() {
- getSite().getPage().removePartListener(this);
fViewer= null;
super.dispose();
}
@@ -68,8 +65,7 @@ public abstract class AbstractDebugView extends ViewPart implements IDebugViewAd
// register the context menu such that other plugins may contribute to it
getSite().registerContextMenu(menuMgr, fViewer);
- }
-
+ }
/**
* Configures the toolBar
*/
@@ -121,34 +117,5 @@ public abstract class AbstractDebugView extends ViewPart implements IDebugViewAd
protected abstract void fillContextMenu(IMenuManager mgr);
protected abstract void configureToolBar(IToolBarManager tbm);
- /**
- * @see IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart arg0) {
- }
-
- /**
- * @see IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partDeactivated(IWorkbenchPart arg0) {
- }
-
- /**
- * @see IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart arg0) {
- }
-
- /**
- * @see IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
- */
- public void partBroughtToTop(IWorkbenchPart arg0) {
- }
-
- /**
- * @see IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart arg0) {
- }
}
-
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BasicContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BasicContentProvider.java
index 8d9319f28..4e367204a 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BasicContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/BasicContentProvider.java
@@ -47,6 +47,18 @@ public abstract class BasicContentProvider implements IStructuredContentProvider
}
/**
+ * @see Display.syncExec(Runnable)
+ */
+ protected void syncExec(Runnable r) {
+ if (fViewer != null) {
+ Control ctrl= fViewer.getControl();
+ if (ctrl != null && !ctrl.isDisposed()) {
+ ctrl.getDisplay().syncExec(r);
+ }
+ }
+ }
+
+ /**
* Refreshes the viewer - must be called in UI thread.
*/
protected void refresh() {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugContentProvider.java
index 6548802c8..6d015ae43 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugContentProvider.java
@@ -103,40 +103,10 @@ public class DebugContentProvider extends BasicContentProvider implements IDebug
updateButtons();
break;
case DebugEvent.RESUME :
- if (element instanceof ISuspendResume) {
- if (((ISuspendResume)element).isSuspended()) {
- return;
- }
- }
- clearSourceSelection();
- if (event.getDetail() != DebugEvent.STEP_START) {
- refresh(element);
- if (element instanceof IThread) {
- //select and reveal will update buttons
- //via selection changed callback
- selectAndReveal(element);
- break;
- }
- }
- labelChanged(element);
- updateButtons();
+ doHandleResumeEvent(event, element);
break;
case DebugEvent.SUSPEND :
- refresh(element);
- if (!DebugUIPlugin.getDefault().userPreferenceToSwitchPerspective(true)) {
- Object tos= null;
- if (element instanceof IThread) {
- // select the top stack frame
- try {
- tos= ((IThread) element).getTopStackFrame();
- } catch (DebugException de) {
- }
- }
- if (tos != null) {
- selectAndReveal(tos);
- }
- }
- updateButtons();
+ doHandleSuspendEvent(element);
break;
case DebugEvent.CHANGE :
refresh(element);
@@ -145,6 +115,33 @@ public class DebugContentProvider extends BasicContentProvider implements IDebug
}
}
+ protected void doHandleResumeEvent(DebugEvent event, Object element) {
+ if (element instanceof ISuspendResume) {
+ if (((ISuspendResume)element).isSuspended()) {
+ return;
+ }
+ }
+ clearSourceSelection();
+ if (event.getDetail() != DebugEvent.STEP_START) {
+ refresh(element);
+ if (element instanceof IThread) {
+ //select and reveal will update buttons
+ //via selection changed callback
+ selectAndReveal(element);
+ return;
+ }
+ }
+ labelChanged(element);
+ updateButtons();
+ }
+
+ protected void doHandleSuspendEvent(Object element) {
+ if (element instanceof IThread) {
+ ((LaunchesViewer)fViewer).autoExpand(element, true);
+ }
+ updateButtons();
+ }
+
/**
* Helper method for inserting the given element - must be called in UI thread
*/
@@ -223,6 +220,24 @@ public class DebugContentProvider extends BasicContentProvider implements IDebug
public void run() {
if (!isDisposed()) {
remove(launch);
+ ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
+ IDebugTarget[] targets= lm.getDebugTargets();
+ if (targets.length > 0) {
+ IDebugTarget target= targets[0];
+ try {
+ IDebugElement[] threads= target.getChildren();
+ for (int i=0; i < threads.length; i++) {
+ if (((IThread)threads[i]).isSuspended()) {
+ ((LaunchesViewer)fViewer).autoExpand(threads[i], false);
+ return;
+ }
+ }
+ } catch (DebugException de) {
+ DebugUIUtils.logError(de);
+ }
+
+ ((LaunchesViewer)fViewer).autoExpand(target.getLaunch(), false);
+ }
updateButtons();
}
}
@@ -239,17 +254,12 @@ public class DebugContentProvider extends BasicContentProvider implements IDebug
public void run() {
if (!isDisposed()) {
insert(launch);
- if (!DebugUIPlugin.getDefault().userPreferenceToSwitchPerspective(true)) {
- Object dt = launch.getDebugTarget();
- if (dt != null) {
- selectAndReveal(dt);
- }
- }
+ ((LaunchesViewer)fViewer).autoExpand(launch, false);
}
}
};
- asyncExec(r);
+ syncExec(r);
}
/**
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
index 80b90bcef..d38ccf9c1 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPlugin.java
@@ -5,7 +5,25 @@ package org.eclipse.debug.internal.ui;
* All Rights Reserved.
*/
-import java.util.*; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; import org.eclipse.debug.core.*; import org.eclipse.debug.core.model.*; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIEventFilter; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.jface.text.*; import org.eclipse.jface.util.ListenerList; import org.eclipse.jface.viewers.*; import org.eclipse.swt.custom.BusyIndicator; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.*; import org.eclipse.ui.model.IWorkbenchAdapter; import org.eclipse.ui.plugin.AbstractUIPlugin;
+import java.util.*;
+import org.eclipse.core.resources.*;
+import org.eclipse.core.runtime.*;
+import org.eclipse.debug.core.*;
+import org.eclipse.debug.core.model.*;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.IDebugUIEventFilter;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.text.*;
+import org.eclipse.jface.util.ListenerList;
+import org.eclipse.jface.viewers.*;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.*;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
/**
* The Debug UI Plugin.
@@ -17,7 +35,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
IDocumentListener,
ILaunchListener,
IResourceChangeListener {
-
+
/**
* The singleton debug plugin instance
*/
@@ -95,7 +113,7 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
*/
protected static ResourceDeletedVisitor fgDeletedVisitor;
-
+ protected SwitchContext fSwitchContext= new SwitchContext();
/**
* Visitor for handling resource deltas
*/
@@ -115,6 +133,167 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
}
/**
+ * Tracks the debugger page and perspective for
+ * the DebugUIPlugin
+ */
+ class SwitchContext implements IPartListener, IPageListener {
+ protected IWorkbenchWindow fWindow;
+ protected IWorkbenchPage fPage;
+ protected IPerspectiveDescriptor fPerspective;
+ protected LaunchesView fDebuggerView;
+ protected boolean fPageCreated;
+ protected boolean fContextChanged= true;
+ protected String fMode;
+
+ protected void init(String mode) {
+ fMode= mode;
+ fPageCreated= false;
+ if (fPage != null) {
+ fPage.removePartListener(this);
+ }
+ fPage= null;
+ fDebuggerView= null;
+ if (fWindow != null) {
+ fWindow.removePageListener(this);
+ }
+ fWindow= getActiveWorkbenchWindow();
+ fWindow.addPageListener(this);
+ fContextChanged= false;
+ }
+
+ protected void shutdown() {
+ if (fPage != null) {
+ fPage.removePartListener(this);
+ }
+ fWindow.removePageListener(this);
+ }
+
+ /**
+ * Returns whether the world has changed in a way that will
+ * require switching to the debug perspective.
+ */
+ protected boolean contextChanged(String mode) {
+ if (!fContextChanged) {
+ if (fMode == null || !fMode.equals(mode)) {
+ return true;
+ }
+ }
+ boolean changed= fContextChanged ||
+ !fWindow.equals(getActiveWorkbenchWindow()) ||
+ !fWindow.getActivePage().equals(fPage) ||
+ !fWindow.getActivePage().getPerspective().equals(fPerspective);
+
+ return changed;
+ }
+
+ /**
+ * Returns whether the DebugUIPlugin has recently caused
+ * a debugger page to be created.
+ */
+ protected boolean wasPageCreated() {
+ return fPageCreated;
+ }
+
+ /**
+ * Sets whether the DebugUIPlugin has recently caused
+ * a debugger page to be created.
+ */
+ protected void setPageCreated(boolean created) {
+ fPageCreated= created;
+ }
+
+ protected IWorkbenchPage getPage() {
+ return fPage;
+ }
+
+ protected void setPage(IWorkbenchPage page) {
+ if (fPage != null) {
+ fPage.removePartListener(this);
+ }
+ fPage = page;
+ fPage.addPartListener(this);
+ fPerspective= page.getPerspective();
+ }
+
+ protected IWorkbenchWindow getWindow() {
+ return fWindow;
+ }
+
+ protected void setWindow(IWorkbenchWindow window) {
+ fWindow.removePageListener(this);
+ fWindow = window;
+ fWindow.addPageListener(this);
+ }
+
+ protected LaunchesView getDebuggerView() {
+ return fDebuggerView;
+ }
+
+ protected void setDebuggerView(LaunchesView debuggerView) {
+ fDebuggerView = debuggerView;
+ }
+ /**
+ * @see IPartListener#partActivated(IWorkbenchPart)
+ */
+ public void partActivated(IWorkbenchPart part) {
+ if (part == fDebuggerView) {
+ fContextChanged= false;
+ }
+ }
+ /**
+ * @see IPartListener#partBroughtToTop(IWorkbenchPart)
+ */
+ public void partBroughtToTop(IWorkbenchPart arg0) {
+ }
+
+ /**
+ * @see IPartListener#partClosed(IWorkbenchPart)
+ */
+ public void partClosed(IWorkbenchPart part) {
+ if (part == fDebuggerView) {
+ fContextChanged= true;
+ }
+ }
+
+ /**
+ * @see IPartListener#partDeactivated(IWorkbenchPart)
+ */
+ public void partDeactivated(IWorkbenchPart part) {
+ if (part == fDebuggerView) {
+ fContextChanged= true;
+ }
+ }
+
+ /**
+ * @see IPartListener#partOpened(IWorkbenchPart)
+ */
+ public void partOpened(IWorkbenchPart arg0) {
+ }
+
+ /**
+ * @see IPageListener#pageActivated(IWorkbenchPage)
+ */
+ public void pageActivated(IWorkbenchPage arg0) {
+ }
+
+ /**
+ * @see IPageListener#pageClosed(IWorkbenchPage)
+ */
+ public void pageClosed(IWorkbenchPage page) {
+ if (page.equals(fPage)) {
+ init(null);
+ fContextChanged= true;
+ }
+ }
+
+ /**
+ * @see IPageListener#pageOpened(IWorkbenchPage)
+ */
+ public void pageOpened(IWorkbenchPage arg0) {
+ }
+ }
+
+ /**
* Constructs the debug UI plugin
*/
public DebugUIPlugin(IPluginDescriptor descriptor) {
@@ -123,30 +302,36 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
}
/**
- * On a SUSPEND event, switch to the perspective specified
- * by the launcher.
+ * On a SUSPEND event, show the debug view or if no debug view is open,
+ * switch to the perspective specified by the launcher.
*
* @see IDebugEventListener
*/
public void handleDebugEvent(final DebugEvent event) {
- // open the debugger if this is a suspend event and the debugger is not yet open
+ // open the debugger if this is a suspend event and the debug view is not yet open
// and the preferences are set to switch
if (event.getKind() == DebugEvent.SUSPEND) {
- Display display= getDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
+ getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (fSwitchContext.contextChanged(ILaunchManager.DEBUG_MODE)) {
if (showSuspendEvent(event)) {
if (getPreferenceStore().getBoolean(IDebugUIConstants.PREF_AUTO_SHOW_DEBUG_VIEW)) {
- switchToDebugPerspective0(event.getSource(), ILaunchManager.DEBUG_MODE, true);
+ switchToDebugPerspective(event.getSource(), ILaunchManager.DEBUG_MODE);
}
+ }
+ }
+ if (fSwitchContext.wasPageCreated()) {
+ fSwitchContext.setPageCreated(false);
+ LaunchesView view= fSwitchContext.getDebuggerView();
+ if (view != null) {
+ view.autoExpand(event.getSource(), true);
}
}
- });
- }
+ }
+ });
}
}
-
+
/**
* Poll the filters to determine if the event should be shown
*/
@@ -183,71 +368,54 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
return true;
}
-
/**
* Opens the a workbench page with the layout specified by the launcher
* if it had not already been opened in any workbench window.
- * If the switch is suspend triggered, a switch only occurs if
- * a debug view is not present in any workbench window.
+ *
+ * A switch only occurs if a debug view is not present in any workbench window.
*/
- private void switchToDebugPerspective0(Object source, String mode, boolean suspendTriggered) {
+ protected void switchToDebugPerspective(Object source, String mode) {
+ fSwitchContext.init(mode);
String layoutId= getLauncherPerspective(source);
- Object[] results= findDebugPresentation(source, mode, layoutId, suspendTriggered);
- if (results == null) {
- return;
- }
- IWorkbenchWindow window= null;
- IWorkbenchPage page= null;
- if (results.length == 0) {
- window= getActiveWorkbenchWindow();
- } else {
- window= (IWorkbenchWindow)results[0];
- page= (IWorkbenchPage)results[1];
- }
-
- page= activateDebugLayoutPage(page, window, layoutId);
+ findDebugPresentation(fSwitchContext, mode, layoutId);
+ activateDebugLayoutPage(fSwitchContext, layoutId);
// bring debug to the front
- activateDebuggerPart(source, page, mode);
+ activateDebuggerPart(fSwitchContext, mode);
+ if (fSwitchContext.wasPageCreated()) {
+ LaunchesView view2= fSwitchContext.getDebuggerView();
+ if (view2 != null) {
+ view2.autoExpand(source, true);
+ }
+ }
}
/**
* Debug ui thread safe access to a display
*/
protected Display getDisplay() {
- IWorkbench workbench= getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- Display display= null;
- if (windows != null && windows.length > 0) {
- Shell shell= windows[0].getShell();
- if (!shell.isDisposed()) {
- return shell.getDisplay();
- }
- }
- }
- return null;
+ //we can rely on not creating a display as we
+ //prereq the base eclipse ui plugin.
+ return Display.getDefault();
}
/**
* Activates (may include creates) a debugger part based on the mode
- * in the specified page.
+ * in the specified switch context.
* Must be called in the UI thread.
*/
- protected void activateDebuggerPart(final Object source, IWorkbenchPage page, String mode) {
+ protected void activateDebuggerPart(SwitchContext switchContext, String mode) {
LaunchesView debugPart= null;
try {
if (mode == ILaunchManager.DEBUG_MODE) {
- debugPart= (LaunchesView) page.showView(IDebugUIConstants.ID_DEBUG_VIEW);
+ debugPart= (LaunchesView) switchContext.getPage().showView(IDebugUIConstants.ID_DEBUG_VIEW);
} else {
- debugPart= (LaunchesView) page.showView(IDebugUIConstants.ID_PROCESS_VIEW);
+ debugPart= (LaunchesView) switchContext.getPage().showView(IDebugUIConstants.ID_PROCESS_VIEW);
}
} catch (PartInitException pie) {
IStatus status= new Status(IStatus.ERROR, getDescriptor().getUniqueIdentifier(), IDebugStatusConstants.INTERNAL_ERROR, pie.getMessage(), pie);
- DebugUIUtils.errorDialog(page.getWorkbenchWindow().getShell(), "debug_ui_plugin.switch_perspective.error.", status);
- }
- if (debugPart != null) {
- debugPart.autoExpand(source);
+ DebugUIUtils.errorDialog(getActiveWorkbenchWindow().getShell(), "debug_ui_plugin.switch_perspective.error.", status);
}
+ switchContext.setDebuggerView(debugPart);
}
/**
@@ -255,46 +423,46 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
* If no debugger view is found, looks for a page in any window
* that has the specified debugger layout id.
* Must be called in UI thread.
- * @return an Object array that
- * is null if a debugger part has been found
- * is empty if no page could be found with the debugger layout id
- * has two elements if a debugger layout page is found
- * first element is a window, the second is a page
*/
- protected Object[] findDebugPresentation(final Object source, String mode, String layoutId, boolean suspendTriggered) {
+ protected void findDebugPresentation(SwitchContext switchContext, String mode, String layoutId) {
IWorkbenchWindow[] windows= getWorkbench().getWorkbenchWindows();
IWorkbenchWindow activeWindow= getActiveWorkbenchWindow();
+
+ //check the active page of the active window for
+ //debug view
+ LaunchesView part= findDebugPart(activeWindow, mode);
+ if (part != null) {
+ switchContext.setWindow(activeWindow);
+ switchContext.setPage(part.getSite().getPage());
+ return;
+ }
+ //check active pages of all windows for debug view
int i;
- if (suspendTriggered) {
- LaunchesView part= findDebugPart(activeWindow, mode);
- if (part != null) {
- part.autoExpand(source);
- return null;
- }
- //check active pages for debugger view
- for (i= 0; i < windows.length; i++) {
- IWorkbenchWindow window= windows[i];
- LaunchesView lPart= findDebugPart(window, mode);
- if (lPart != null) {
- lPart.autoExpand(source);
- return null;
- }
+ for (i= 0; i < windows.length; i++) {
+ IWorkbenchWindow window= windows[i];
+ LaunchesView lPart= findDebugPart(window, mode);
+ if (lPart != null) {
+ switchContext.setWindow(window);
+ switchContext.setPage(lPart.getSite().getPage());
+ return;
}
- }
+ }
//check the pages for the debugger layout.
//check the pages of the active window first
IWorkbenchPage page= null;
IWorkbenchPage[] pages= activeWindow.getPages();
- for (int j= 0; j < pages.length; j++) {
- if (pages[j].getPerspective().getId().equals(layoutId)) {
- page= pages[j];
+ for (i= 0; i < pages.length; i++) {
+ if (pages[i].getPerspective().getId().equals(layoutId)) {
+ page= pages[i];
break;
}
}
if (page != null) {
- return new Object[]{activeWindow, page};
+ switchContext.setWindow(activeWindow);
+ switchContext.setPage(page);
+ return;
}
i= 0;
@@ -314,10 +482,10 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
}
if (page != null) {
- return new Object[]{windows[i], page};
+ switchContext.setWindow(windows[i]);
+ switchContext.setPage(page);
+ return;
}
-
- return new Object[0];
}
/**
@@ -342,12 +510,12 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
}
/**
- * Activates (may include creates) and returns a debugger page with the
- * specified layout in the supplied window.
- *
- * @return the page that was activated (and possibly created)
+ * Activates (may include creates) a debugger page with the
+ * specified layout within the switch context.
*/
- protected IWorkbenchPage activateDebugLayoutPage(IWorkbenchPage page, IWorkbenchWindow window, String layoutId) {
+ protected void activateDebugLayoutPage(SwitchContext switchContext, String layoutId) {
+ IWorkbenchPage page= switchContext.getPage();
+ IWorkbenchWindow window= switchContext.getWindow();
if (page == null) {
try {
IContainer root= ResourcesPlugin.getWorkspace().getRoot();
@@ -373,16 +541,19 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
page.setPerspective(wb.getPerspectiveRegistry().findPerspectiveWithId(layoutId));
}
}
+ switchContext.setPageCreated(true);
} catch (WorkbenchException e) {
IStatus status= new Status(IStatus.ERROR, getDescriptor().getUniqueIdentifier(), IDebugStatusConstants.INTERNAL_ERROR, e.getMessage(), e);
DebugUIUtils.errorDialog(window.getShell(), "debug_ui_plugin.switch_perspective.error.", status);
- return null;
+ return;
}
+ switchContext.setPage(page);
+ switchContext.setWindow(window);
} else {
window.getShell().moveAbove(null);
+ window.getShell().setFocus();
window.setActivePage(page);
}
- return page;
}
/**
* Returns the launcher perspective specified in the launcher
@@ -403,18 +574,18 @@ public class DebugUIPlugin extends AbstractUIPlugin implements ISelectionChanged
}
return perspectiveID;
}
-
+
/**
* Returns the singleton instance of the debug plugin.
*/
public static DebugUIPlugin getDefault() {
return fgDebugUIPlugin;
}
-
+
public static IWorkbenchWindow getActiveWorkbenchWindow() {
return getDefault().getWorkbench().getActiveWorkbenchWindow();
}
-
+
/**
* Creates an extension. If the extension plugin has not
* been loaded a busy cursor will be activated during the duration of
@@ -454,7 +625,7 @@ public static Object createExtension(final IConfigurationElement element, final
protected ImageRegistry createImageRegistry() {
return DebugPluginImages.initializeImageRegistry();
}
-
+
/**
* Shuts down this plug-in and discards all plug-in state.
* If a plug-in has been started, this method is automatically
@@ -483,8 +654,9 @@ public static Object createExtension(final IConfigurationElement element, final
doc.removeDocumentListener(this);
doc.close();
}
+ fSwitchContext.shutdown();
}
-
+
/**
* Starts up this plug-in.
* <p>
@@ -504,7 +676,7 @@ public static Object createExtension(final IConfigurationElement element, final
launchRegistered(launches[i]);
}
}
-
+
/**
* Adds the selection provider for the debug UI.
*/
@@ -513,7 +685,7 @@ public static Object createExtension(final IConfigurationElement element, final
fSelectionParts.add(part);
provider.addSelectionChangedListener(this);
}
-
+
/**
* Removes the selection provider from the debug UI.
*/
@@ -523,21 +695,21 @@ public static Object createExtension(final IConfigurationElement element, final
provider.removeSelectionChangedListener(this);
selectionChanged(null);
}
-
+
/**
* Adds an <code>ISelectionListener</code> to the debug selection manager.
*/
public void addSelectionListener(ISelectionListener l) {
fListeners.add(l);
}
-
+
/**
* Removes an <code>ISelectionListener</code> from the debug selection manager.
*/
public synchronized void removeSelectionListener(ISelectionListener l) {
fListeners.remove(l);
}
-
+
/**
* Selection has changed in the debug selection provider.
* Notify the listeners.
@@ -561,7 +733,7 @@ public static Object createExtension(final IConfigurationElement element, final
((ISelectionListener)copiedListeners[i]).selectionChanged(part, selection);
}
}
-
+
/**
* Sets the console document for the specified process.
* If the document is <code>null</code> the mapping for the
@@ -571,11 +743,11 @@ public static Object createExtension(final IConfigurationElement element, final
if (doc == null) {
fConsoleDocuments.remove(process);
} else {
-
+
fConsoleDocuments.put(process, doc);
}
}
-
+
/**
* Returns the correct document for the process, determining the current
* process if required (process argument is null).
@@ -602,7 +774,7 @@ public static Object createExtension(final IConfigurationElement element, final
if (getCurrentProcess() == null) {
setCurrentProcess(determineCurrentProcess());
}
-
+
IProcess currentProcess= getCurrentProcess();
if (currentProcess != null) {
IDocument document= (IDocument) fConsoleDocuments.get(currentProcess);
@@ -614,17 +786,17 @@ public static Object createExtension(final IConfigurationElement element, final
return document;
}
}
-
+
return new ConsoleDocument(null);
}
-
+
/**
* Returns the color manager to use in the debug UI
*/
public ColorManager getColorManager() {
return fColorManager;
}
-
+
/**
* @see AbstractUIPlugin#initializeDefaultPreferences
*/
@@ -632,7 +804,7 @@ public static Object createExtension(final IConfigurationElement element, final
prefs.setDefault(IDebugUIConstants.PREF_AUTO_SHOW_DEBUG_VIEW, true);
prefs.setDefault(IDebugUIConstants.PREF_AUTO_SHOW_PROCESS_VIEW, true);
prefs.setDefault(IDebugPreferenceConstants.CONSOLE_OPEN, true);
-
+
PreferenceConverter.setDefault(prefs, IDebugPreferenceConstants.CONSOLE_SYS_OUT_RGB, new RGB(0, 0, 255));
PreferenceConverter.setDefault(prefs, IDebugPreferenceConstants.CONSOLE_SYS_IN_RGB, new RGB(0, 200, 125));
PreferenceConverter.setDefault(prefs, IDebugPreferenceConstants.CONSOLE_SYS_ERR_RGB, new RGB(255, 0, 0));
@@ -698,7 +870,7 @@ public static Object createExtension(final IConfigurationElement element, final
* Can return <code>null</code>.
*/
public IProcess determineCurrentProcess() {
-
+
ILaunchManager launchManager= DebugPlugin.getDefault().getLaunchManager();
IDebugTarget[] debugTargets= launchManager.getDebugTargets();
for (int i = 0; i < debugTargets.length; i++) {
@@ -708,15 +880,15 @@ public static Object createExtension(final IConfigurationElement element, final
return process;
}
}
-
+
IProcess[] processes= launchManager.getProcesses();
if ((processes != null) && (processes.length > 0)) {
return processes[0];
}
-
+
return null;
}
-
+
protected IProcess getProcessFromInput(Object input) {
IProcess processInput= null;
if (input instanceof IProcess) {
@@ -736,14 +908,14 @@ public static Object createExtension(final IConfigurationElement element, final
if (input instanceof IDebugElement) {
processInput= ((IDebugElement) input).getProcess();
}
-
+
if ((processInput == null) || (processInput.getLaunch() == null)) {
return null;
} else {
return processInput;
}
}
-
+
/**
* @see IDocumentListener
*/
@@ -753,34 +925,31 @@ public static Object createExtension(final IConfigurationElement element, final
return;
}
- Display display= getDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- IWorkbenchWindow window = getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page= window.getActivePage();
- if (page != null) {
- try { // show the console
- ConsoleView consoleView= (ConsoleView)page.findView(IDebugUIConstants.ID_CONSOLE_VIEW);
- if(consoleView == null) {
- IWorkbenchPart activePart= page.getActivePart();
- consoleView= (ConsoleView)page.showView(IDebugUIConstants.ID_CONSOLE_VIEW);
- consoleView.setViewerInput(getCurrentProcess());
- //restore focus stolen by the creation of the console
- page.activate(activePart);
- } else {
- page.bringToTop(consoleView);
- }
- } catch (PartInitException pie) {
+ getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if (window != null) {
+ IWorkbenchPage page= window.getActivePage();
+ if (page != null) {
+ try { // show the console
+ ConsoleView consoleView= (ConsoleView)page.findView(IDebugUIConstants.ID_CONSOLE_VIEW);
+ if(consoleView == null) {
+ IWorkbenchPart activePart= page.getActivePart();
+ consoleView= (ConsoleView)page.showView(IDebugUIConstants.ID_CONSOLE_VIEW);
+ consoleView.setViewerInput(getCurrentProcess());
+ //restore focus stolen by the creation of the console
+ page.activate(activePart);
+ } else {
+ page.bringToTop(consoleView);
}
+ } catch (PartInitException pie) {
}
}
}
- });
- }
+ }
+ });
}
-
+
/**
* @see IDocumentListener
*/
@@ -790,7 +959,7 @@ public static Object createExtension(final IConfigurationElement element, final
public IProcess getCurrentProcess() {
return fCurrentProcess;
}
-
+
public void setCurrentProcess(IProcess process) {
if (fCurrentProcess != null) {
getConsoleDocument(fCurrentProcess).removeDocumentListener(this);
@@ -818,30 +987,28 @@ public static Object createExtension(final IConfigurationElement element, final
}
}
-
+
/**
* @see ILaunchListener
*/
- public void launchDeregistered(ILaunch launch) {
- Display display= getDisplay();
- if (display != null) {
- display.syncExec(new Runnable () {
- public void run() {
- IProcess currentProcess= getCurrentProcess();
- if (currentProcess != null && currentProcess.getLaunch() == null) {
- ConsoleDocument doc= (ConsoleDocument)getConsoleDocument(currentProcess);
- doc.removeDocumentListener(DebugUIPlugin.this);
- doc.close();
- setConsoleDocument(currentProcess, null);
- fCurrentProcess= null;
- }
+ public void launchDeregistered(final ILaunch launch) {
+ getDisplay().syncExec(new Runnable () {
+ public void run() {
+ IProcess[] processes= launch.getProcesses();
+ IProcess currentProcess= getCurrentProcess();
+ if (currentProcess != null && currentProcess.getLaunch() == null) {
+ ConsoleDocument doc= (ConsoleDocument)getConsoleDocument(currentProcess);
+ doc.removeDocumentListener(DebugUIPlugin.this);
+ doc.close();
+ setConsoleDocument(currentProcess, null);
+ fCurrentProcess= null;
}
- });
- }
+ }
+ });
setCurrentProcess(determineCurrentProcess());
setConsoleInput(getCurrentProcess());
}
-
+
/**
* Must not assume that will only be called from the UI thread.
*
@@ -854,8 +1021,20 @@ public static Object createExtension(final IConfigurationElement element, final
updateHistories(launch);
switchToDebugPerspectiveIfPreferred(launch);
+ getDisplay().syncExec(new Runnable () {
+ public void run() {
+ IProcess[] processes= launch.getProcesses();
+ if (processes != null) {
+ for (int i= 0; i < processes.length; i++) {
+ ConsoleDocument doc= new ConsoleDocument(processes[i]);
+ doc.startReading();
+ setConsoleDocument(processes[i], doc);
+ }
+ }
+ }
+ });
+
IProcess newProcess= null;
-
IDebugTarget target= launch.getDebugTarget();
if (target != null) {
newProcess= target.getProcess();
@@ -865,23 +1044,6 @@ public static Object createExtension(final IConfigurationElement element, final
newProcess= processes[processes.length - 1];
}
}
-
- Display display= getDisplay();
- if (display != null) {
- display.syncExec(new Runnable () {
- public void run() {
- IProcess[] processes= launch.getProcesses();
- if (processes != null) {
- for (int i= 0; i < processes.length; i++) {
- ConsoleDocument doc= new ConsoleDocument(processes[i]);
- doc.startReading();
- setConsoleDocument(processes[i], doc);
- }
- }
- }
- });
- }
-
setCurrentProcess(newProcess);
setConsoleInput(newProcess);
}
@@ -891,21 +1053,18 @@ public static Object createExtension(final IConfigurationElement element, final
* if the user preferences specify to do so.
*/
protected void switchToDebugPerspectiveIfPreferred(final ILaunch launch) {
- Display display= getDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- String mode= launch.getLaunchMode();
+ getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ String mode= launch.getLaunchMode();
+ if (fSwitchContext.contextChanged(mode)) {
boolean isDebug= mode.equals(ILaunchManager.DEBUG_MODE);
boolean doSwitch= userPreferenceToSwitchPerspective(isDebug);
- if (doSwitch) {
- if (showLaunch(launch)) {
- switchToDebugPerspective0(launch, mode, false);
- }
+ if (doSwitch && showLaunch(launch)) {
+ switchToDebugPerspective(launch, mode);
}
- }
- });
- }
+ }
+ }
+ });
}
/**
@@ -921,29 +1080,26 @@ public static Object createExtension(final IConfigurationElement element, final
* consoles that exist in a thread safe manner.
*/
protected void setConsoleInput(final IProcess process) {
- Display display= getDisplay();
- if (display != null) {
- display.asyncExec(new Runnable() {
- public void run() {
- IWorkbenchWindow[] windows= getWorkbench().getWorkbenchWindows();
- for (int j= 0; j < windows.length; j++) {
- IWorkbenchWindow window= windows[j];
- IWorkbenchPage[] pages= window.getPages();
- if (pages != null) {
- for (int i= 0; i < pages.length; i++) {
- IWorkbenchPage page= pages[i];
- ConsoleView consoleView= (ConsoleView)page.findView(IDebugUIConstants.ID_CONSOLE_VIEW);
- if (consoleView != null) {
- consoleView.setViewerInput(process);
- }
- }
+ getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchWindow[] windows= getWorkbench().getWorkbenchWindows();
+ for (int j= 0; j < windows.length; j++) {
+ IWorkbenchWindow window= windows[j];
+ IWorkbenchPage[] pages= window.getPages();
+ if (pages != null) {
+ for (int i= 0; i < pages.length; i++) {
+ IWorkbenchPage page= pages[i];
+ ConsoleView consoleView= (ConsoleView)page.findView(IDebugUIConstants.ID_CONSOLE_VIEW);
+ if (consoleView != null) {
+ consoleView.setViewerInput(process);
+ }
}
}
}
- });
- }
+ }
+ });
}
-
+
/**
* Returns the collection of most recent debug launches, which
* can be empty.
@@ -998,7 +1154,7 @@ public static Object createExtension(final IConfigurationElement element, final
}
}
}
-
+
/**
* Given a launch, try to add it to both of the run & debug histories.
*/
@@ -1094,15 +1250,12 @@ public static Object createExtension(final IConfigurationElement element, final
* of events posted to the queue have been processed.
*/
public void removeEventFilter(final IDebugUIEventFilter filter) {
- Display display= getDisplay();
- if (display != null) {
- Runnable runnable = new Runnable() {
- public void run() {
- fEventFilters.remove(filter);
- }
- };
- display.asyncExec(runnable);
- }
+ Runnable runnable = new Runnable() {
+ public void run() {
+ fEventFilters.remove(filter);
+ }
+ };
+ getDisplay().asyncExec(runnable);
}
/**
@@ -1129,4 +1282,4 @@ public static Object createExtension(final IConfigurationElement element, final
return e.getAttribute("wizard") != null;
}
}
-
+
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugView.java
index 7d6ff34c0..13806fa13 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugView.java
@@ -7,7 +7,7 @@ package org.eclipse.debug.internal.ui;
import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.*; import org.eclipse.debug.ui.IDebugModelPresentation; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.action.*; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.*; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.*; import org.eclipse.ui.help.ViewContextComputer; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.texteditor.ITextEditor;
-public class DebugView extends LaunchesView {
+public class DebugView extends LaunchesView implements IPartListener {
protected final static String PREFIX= "debug_view.";
@@ -54,6 +54,14 @@ public class DebugView extends LaunchesView {
}
}
+ /**
+ * @see IViewPart
+ */
+ public void init(IViewSite site) throws PartInitException {
+ super.init(site);
+ getSite().getPage().addPartListener(this);
+ }
+
public void createPartControl(Composite parent) {
super.createPartControl(parent);
WorkbenchHelp.setHelp(
@@ -66,6 +74,7 @@ public class DebugView extends LaunchesView {
*/
public void dispose() {
super.dispose();
+ getSite().getPage().removePartListener(this);
fEditor = null;
}
@@ -414,8 +423,9 @@ public class DebugView extends LaunchesView {
* Auto-expand and select the given element - must be called in UI thread.
* This is used to implement auto-expansion-and-select on a SUSPEND event.
*/
- public void autoExpand(Object element) {
+ public void autoExpand(Object element, boolean refreshNeeded) {
Object selectee = element;
+ Object[] children= null;
if (element instanceof IThread) {
// try the top stack frame
try {
@@ -426,15 +436,27 @@ public class DebugView extends LaunchesView {
selectee = element;
}
} else if (element instanceof ILaunch) {
- Object dt = ((ILaunch)element).getDebugTarget();
+ IDebugTarget dt = ((ILaunch)element).getDebugTarget();
if (dt != null) {
selectee= dt;
+ try {
+ children= dt.getChildren();
+ } catch (DebugException de) {
+ DebugUIUtils.logError(de);
+ }
}
}
- //ensures that the child item exists in the viewer widget
- //set selection only works if the child exists
- fViewer.refresh(element);
- fViewer.setSelection(new StructuredSelection(selectee), true);
+
+ if (refreshNeeded) {
+ //ensures that the child item exists in the viewer widget
+ //set selection only works if the child exists
+ fViewer.refresh(element);
+ }
+ fViewer.setSelection(new StructuredSelection(selectee));
+ if (children != null && children.length > 0) {
+ //reveal the thread children of a debug target
+ fViewer.reveal(children[0]);
+ }
}
/**
@@ -450,9 +472,32 @@ public class DebugView extends LaunchesView {
public void partClosed(IWorkbenchPart part) {
if (part.equals(fEditor)) {
fEditor = null;
- }
- super.partClosed(part);
- }
+ }
+ }
+
+ /**
+ * @see IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void partOpened(IWorkbenchPart arg0) {
+ }
+
+ /**
+ * @see IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void partDeactivated(IWorkbenchPart arg0) {
+ }
+
+ /**
+ * @see IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void partBroughtToTop(IWorkbenchPart arg0) {
+ }
+
+ /**
+ * @see IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
+ */
+ public void partActivated(IWorkbenchPart arg0) {
+ }
/**
* @see IViewPart
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesView.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesView.java
index ca553dcdd..fcae205a8 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesView.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesView.java
@@ -153,6 +153,10 @@ public class LaunchesView extends AbstractDebugView implements ISelectionChanged
* Auto-expand and select the given element - must be called in UI thread.
* This is used to implement auto-expansion-and-select on a SUSPEND event.
*/
+ public void autoExpand(Object element, boolean refreshNeeded) {
+ autoExpand(element);
+ }
+
public void autoExpand(Object element) {
Object selectee = element;
if (element instanceof ILaunch) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesViewer.java
index 22c98512c..90f65f596 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/LaunchesViewer.java
@@ -43,6 +43,10 @@ public class LaunchesViewer extends TreeViewer {
fView.updateButtons();
}
+ protected void autoExpand(Object element, boolean refreshNeeded) {
+ fView.autoExpand(element, refreshNeeded);
+ }
+
protected void updateMarkerForSelection() {
// update the instruction pointer
if (fView instanceof DebugView) {
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ProcessesContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ProcessesContentProvider.java
index a761f803e..9237f3162 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ProcessesContentProvider.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/ProcessesContentProvider.java
@@ -46,11 +46,9 @@ public class ProcessesContentProvider extends DebugContentProvider {
public void run() {
if (!isDisposed()) {
insert(launch);
- if (!DebugUIPlugin.getDefault().userPreferenceToSwitchPerspective(true)) {
- IProcess[] ps= launch.getProcesses();
- if (ps != null && ps.length > 0) {
- selectAndReveal(ps[0]);
- }
+ IProcess[] ps= launch.getProcesses();
+ if (ps != null && ps.length > 0) {
+ selectAndReveal(ps[0]);
}
}
}

Back to the top