1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 import org.eclipse.debug.ui.DebugPopup; 14 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 15 import org.eclipse.jdt.internal.debug.ui.display.DisplayView; 16 import org.eclipse.jdt.internal.debug.ui.display.IDataDisplay; 17 import org.eclipse.swt.SWT; 18 import org.eclipse.swt.custom.StyledText; 19 import org.eclipse.swt.layout.GridData; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Control; 22 import org.eclipse.swt.widgets.Display; 23 import org.eclipse.swt.widgets.Shell; 24 import org.eclipse.ui.IWorkbenchPart; 25 26 public class PopupDisplayAction extends DisplayAction { 27 28 public static final String ACTION_DEFINITION_ID = "org.eclipse.jdt.debug.ui.commands.Display"; 30 private String snippet; 31 32 private String resultString; 33 34 public PopupDisplayAction() { 35 super(); 36 } 37 38 private void showPopup(StyledText textWidget) { 39 DebugPopup displayPopup = new DisplayPopup(getShell(), textWidget); 40 displayPopup.open(); 41 } 42 43 private class DisplayPopup extends DebugPopup { 44 public DisplayPopup(Shell shell, StyledText textWidget) { 45 super(shell, getPopupAnchor(textWidget), ACTION_DEFINITION_ID); 46 } 47 48 protected String getActionText() { 49 return ActionMessages.PopupDisplayAction_2; 50 } 51 52 protected void persist() { 53 IDataDisplay directDisplay = getDirectDataDisplay(); 54 Display display = JDIDebugUIPlugin.getStandardDisplay(); 55 56 if (!display.isDisposed()) { 57 IDataDisplay dataDisplay = getDataDisplay(); 58 if (dataDisplay != null) { 59 if (directDisplay == null) { 60 dataDisplay.displayExpression(snippet); 61 } 62 dataDisplay.displayExpressionValue(resultString); 63 } 64 } 65 } 66 67 protected Control createDialogArea(Composite parent) { 68 GridData gd = new GridData(GridData.FILL_BOTH); 69 StyledText text = new StyledText(parent, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL); 70 text.setLayoutData(gd); 71 72 text.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); 73 text.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); 74 75 text.setText(resultString); 76 return text; 77 } 78 } 79 80 protected void displayStringResult(String currentSnippet, String currentResultString) { 81 IWorkbenchPart part = getTargetPart(); 82 83 if (part instanceof DisplayView) { 84 super.displayStringResult(currentSnippet, currentResultString); 85 return; 86 } 87 88 final StyledText textWidget = EvaluateAction.getStyledText(part); 89 if (textWidget == null) { 90 super.displayStringResult(currentSnippet, currentResultString); 91 } else { 92 snippet = currentSnippet; 93 resultString = currentResultString; 94 Display.getDefault().asyncExec(new Runnable () { 95 public void run() { 96 showPopup(textWidget); 97 } 98 }); 99 evaluationCleanup(); 100 } 101 } 102 103 } 104 | Popular Tags |