### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.debug.ui Index: ui/org/eclipse/jdt/internal/debug/ui/actions/PopupDisplayAction.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/PopupDisplayAction.java,v retrieving revision 1.29 diff -u -r1.29 PopupDisplayAction.java --- ui/org/eclipse/jdt/internal/debug/ui/actions/PopupDisplayAction.java 27 Mar 2007 02:35:57 -0000 1.29 +++ ui/org/eclipse/jdt/internal/debug/ui/actions/PopupDisplayAction.java 30 Sep 2007 19:10:08 -0000 @@ -14,6 +14,8 @@ import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; import org.eclipse.jdt.internal.debug.ui.display.DisplayView; import org.eclipse.jdt.internal.debug.ui.display.IDataDisplay; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; import org.eclipse.swt.layout.GridData; @@ -22,6 +24,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.texteditor.ITextEditor; public class PopupDisplayAction extends DisplayAction { @@ -31,6 +34,10 @@ private String resultString; + private boolean fPopupOpened; + private ITextEditor fTextEditor; + private ISelection fSelectionBeforeEvaluation; + public PopupDisplayAction() { super(); } @@ -38,6 +45,8 @@ private void showPopup(StyledText textWidget) { DebugPopup displayPopup = new DisplayPopup(getShell(), textWidget); displayPopup.open(); + fPopupOpened = true; + fSelectionBeforeEvaluation = getTargetSelection(); } private class DisplayPopup extends DebugPopup { @@ -79,6 +88,10 @@ protected void displayStringResult(String currentSnippet, String currentResultString) { IWorkbenchPart part = getTargetPart(); + + if (part instanceof ITextEditor) { + fTextEditor = (ITextEditor) part; + } if (part instanceof DisplayView) { super.displayStringResult(currentSnippet, currentResultString); @@ -100,4 +113,16 @@ } } + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + if ( fPopupOpened && fSelectionBeforeEvaluation != null) { + fPopupOpened = false; + fTextEditor.getSelectionProvider().setSelection(fSelectionBeforeEvaluation); + fSelectionBeforeEvaluation = null; + } + } + } Index: ui/org/eclipse/jdt/internal/debug/ui/actions/PopupInspectAction.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/actions/PopupInspectAction.java,v retrieving revision 1.23 diff -u -r1.23 PopupInspectAction.java --- ui/org/eclipse/jdt/internal/debug/ui/actions/PopupInspectAction.java 3 Apr 2007 20:23:51 -0000 1.23 +++ ui/org/eclipse/jdt/internal/debug/ui/actions/PopupInspectAction.java 30 Sep 2007 19:10:08 -0000 @@ -15,8 +15,11 @@ import org.eclipse.jdt.debug.eval.IEvaluationResult; import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; import org.eclipse.jdt.internal.debug.ui.display.JavaInspectExpression; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; import org.eclipse.swt.custom.StyledText; import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.texteditor.ITextEditor; public class PopupInspectAction extends InspectAction { @@ -24,11 +27,18 @@ JavaInspectExpression expression; + private boolean fPopupOpened; + private ITextEditor fTextEditor; + private ISelection fSelectionBeforeEvaluation; + /** * @see EvaluateAction#displayResult(IEvaluationResult) */ protected void displayResult(final IEvaluationResult result) { IWorkbenchPart part = getTargetPart(); + if (part instanceof ITextEditor) { + fTextEditor = (ITextEditor) part; + } final StyledText styledText = getStyledText(part); if (styledText == null) { super.displayResult(result); @@ -47,6 +57,20 @@ protected void showPopup(StyledText textWidget) { DebugPopup displayPopup = new InspectPopupDialog(getShell(), getPopupAnchor(textWidget), ACTION_DEFININITION_ID, expression); displayPopup.open(); + fPopupOpened = true; + fSelectionBeforeEvaluation = getTargetSelection(); } + /* (non-Javadoc) + * @see org.eclipse.jdt.internal.debug.ui.actions.EvaluateAction#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + super.selectionChanged(action, selection); + if ( fPopupOpened && fSelectionBeforeEvaluation != null) { + fPopupOpened = false; + fTextEditor.getSelectionProvider().setSelection(fSelectionBeforeEvaluation); + fSelectionBeforeEvaluation = null; + } + } + }