Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2005-11-07 14:51:24 -0500
committerKevin Barnes2005-11-07 14:51:24 -0500
commitb7aff882959393a9d808cb214795b5c22894683d (patch)
tree711a49a029517fe7822dd7ae00e6d02839563134 /org.eclipse.debug.ui
parent859f54bed006fc4c0e44f8dc46d9076522a7eebc (diff)
downloadeclipse.platform.debug-b7aff882959393a9d808cb214795b5c22894683d.tar.gz
eclipse.platform.debug-b7aff882959393a9d808cb214795b5c22894683d.tar.xz
eclipse.platform.debug-b7aff882959393a9d808cb214795b5c22894683d.zip
Bug 92901 - Popup control should be installed once on each control
Diffstat (limited to 'org.eclipse.debug.ui')
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java3
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties2
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java336
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/PopupInformationControl.java407
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java115
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java247
6 files changed, 365 insertions, 745 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java
index af665c46e..cd741c553 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.java
@@ -14,7 +14,6 @@ import org.eclipse.osgi.util.NLS;
public class DebugUIViewsMessages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.views.DebugUIViewsMessages";//$NON-NLS-1$
- public static String ExpressionInformationControl_5;
public static String find_replace_action_label;
public static String find_replace_action_tooltip;
public static String find_replace_action_image;
@@ -68,4 +67,6 @@ public class DebugUIViewsMessages extends NLS {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, DebugUIViewsMessages.class);
}
+
+ public static String InspectPopupDialog_0;
} \ No newline at end of file
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties
index 6307137bf..e83a1cf30 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/DebugUIViewsMessages.properties
@@ -9,7 +9,6 @@
# IBM Corporation - initial API and implementation
###############################################################################
-ExpressionInformationControl_5=Move to Expressions View
find_replace_action_label=&Find/Replace...@Ctrl+F
find_replace_action_tooltip=Find/Replace
find_replace_action_image=
@@ -58,3 +57,4 @@ OtherBreakpointOrganizer_0=Others
WorkingSetCategory_0=\ (default)
RemoteTreeViewer_0=Restore Viewer State
RemoteTreeContentManager_0=Fetching children from debug target
+InspectPopupDialog_0=Move to Expressions View
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java
deleted file mode 100644
index 0916191a9..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/ExpressionInformationControl.java
+++ /dev/null
@@ -1,336 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.debug.internal.ui.views.expression;
-
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.model.IExpression;
-import org.eclipse.debug.core.model.IValue;
-import org.eclipse.debug.core.model.IVariable;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.debug.internal.ui.VariablesViewModelPresentation;
-import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
-import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
-import org.eclipse.debug.internal.ui.views.variables.VariablesView;
-import org.eclipse.debug.internal.ui.views.variables.VariablesViewer;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.debug.ui.IDebugUIConstants;
-import org.eclipse.debug.ui.IValueDetailListener;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.PartInitException;
-
-/**
- * A popup that displays an expression with a details area.
- * <p>
- * Clients may instantiate this class; this class is not intended
- * to be subclassed.
- * </p>
- * @since 3.0
- */
-public class ExpressionInformationControl extends PopupInformationControl {
- private static final int[] DEFAULT_SASH_WEIGHTS = new int[] {90, 10};
- private static final String SASH_KEY = "SASH_WEIGHT"; //$NON-NLS-1$
-
- private IWorkbenchPage page;
- private IExpression exp;
- private VariablesViewer viewer;
- private IDebugModelPresentation modelPresentation;
- private StyledText valueDisplay;
- private SashForm sashForm;
- private Tree tree;
-
- /**
- * Constructs a popup to display an expression. A label and handler
- * are provided to move the expression to the Expressions view when
- * dismissed with the given command.
- *
- * @param page the workbench page on which the popup should be displayed
- * @param exp the expression to display
- * @param commandId identifier of the command used to dismiss the popup
- */
- public ExpressionInformationControl(IWorkbenchPage page, IExpression exp, String commandId) {
- super(page.getWorkbenchWindow().getShell(), DebugUIViewsMessages.ExpressionInformationControl_5, commandId);
- this.page = page;
- this.exp = exp;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setInformation(String)
- */
- public void setInformation(String information) {
- VariablesView view = getViewToEmulate();
- viewer.getContentProvider();
- if (view != null) {
- StructuredViewer structuredViewer = (StructuredViewer) view.getViewer();
- if (structuredViewer != null) {
- ViewerFilter[] filters = structuredViewer.getFilters();
- for (int i = 0; i < filters.length; i++) {
- viewer.addFilter(filters[i]);
- }
- }
- ((RemoteExpressionsContentProvider)viewer.getContentProvider()).setShowLogicalStructure(view.isShowLogicalStructure());
- Map map = view.getPresentationAttributes(exp.getModelIdentifier());
- Iterator iterator = map.keySet().iterator();
- while (iterator.hasNext()) {
- String key = (String)iterator.next();
- modelPresentation.setAttribute(key, map.get(key));
- }
- }
- viewer.setInput(new Object[]{exp});
- viewer.expandToLevel(2);
- }
-
- private VariablesView getViewToEmulate() {
- VariablesView expressionsView = (VariablesView)page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW);
- if (expressionsView != null && expressionsView.isVisible()) {
- return expressionsView;
- }
- VariablesView variablesView = (VariablesView)page.findView(IDebugUIConstants.ID_VARIABLE_VIEW);
- if (variablesView != null && variablesView.isVisible()) {
- return variablesView;
- }
- if (expressionsView != null) {
- return expressionsView;
- }
- return variablesView;
- }
-
- /*
- * TODO: This method not used yet
- */
- protected int[] getInitialSashWeights() {
- IDialogSettings settings = getDialogSettings();
- int[] sashes = new int[2];
- try {
- sashes[0] = settings.getInt(SASH_KEY+"_ONE"); //$NON-NLS-1$
- sashes[1] = settings.getInt(SASH_KEY+"_TWO"); //$NON-NLS-1$
- return sashes;
- } catch (NumberFormatException nfe) {
- }
-
- return DEFAULT_SASH_WEIGHTS;
- }
-
- private void updateValueDisplay(IValue val) {
- IValueDetailListener valueDetailListener = new IValueDetailListener() {
- public void detailComputed(IValue value, final String result) {
- Display.getDefault().asyncExec(new Runnable() {
- public void run() {
- if (!valueDisplay.isDisposed()) {
- String text = result;
- int max = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH);
- if (max > 0 && result.length() > max) {
- text = result.substring(0, max) + "..."; //$NON-NLS-1$
- }
- valueDisplay.setText(text);
- }
- }
- });
- }
- };
- modelPresentation.computeDetail(val, valueDetailListener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.actions.PopupInformationControl#createControl(org.eclipse.swt.widgets.Composite)
- */
- protected Control createControl(Composite parent) {
- Composite composite = new Composite(parent, parent.getStyle());
- GridLayout layout = new GridLayout();
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- sashForm = new SashForm(composite, parent.getStyle());
- sashForm.setOrientation(SWT.VERTICAL);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- page = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
- VariablesView view = getViewToEmulate();
- IWorkbenchPartSite site = null;
- if (view != null) {
- site = view.getSite();
- } else {
- site = page.getActivePart().getSite();
- }
-
- viewer = new VariablesViewer(sashForm, SWT.NO_TRIM, null);
- viewer.setContentProvider(new ExpressionPopupContentProvider(viewer, site, view));
- modelPresentation = new VariablesViewModelPresentation();
- viewer.setLabelProvider(modelPresentation);
-
- valueDisplay = new StyledText(sashForm, SWT.NO_TRIM | SWT.WRAP | SWT.V_SCROLL);
- valueDisplay.setEditable(false);
-
- tree = viewer.getTree();
- tree.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- try {
- TreeItem[] selections = tree.getSelection();
- if (selections.length > 0) {
- Object data = selections[selections.length-1].getData();
-
- IValue val = null;
- if (data instanceof IndexedVariablePartition) {
- // no details for parititions
- return;
- }
- if (data instanceof IVariable) {
- val = ((IVariable)data).getValue();
- } else if (data instanceof IExpression) {
- val = ((IExpression)data).getValue();
- }
- if (val == null) {
- return;
- }
-
- updateValueDisplay(val);
- }
- } catch (DebugException ex) {
- DebugUIPlugin.log(ex);
- }
-
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- Color background = parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- Color foreground = parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
- tree.setForeground(foreground);
- tree.setBackground(background);
- composite.setForeground(foreground);
- composite.setBackground(background);
- valueDisplay.setForeground(foreground);
- valueDisplay.setBackground(background);
-
- //sashForm.setWeights(getInitialSashWeights());
- sashForm.setWeights(DEFAULT_SASH_WEIGHTS);
-
- return tree;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- Point persistedSize = getInitialSize();
- if (persistedSize != null) {
- return persistedSize;
- }
-
- int height = 0;
- int width = 0;
- int itemCount = 0;
-
- TreeItem[] items = tree.getItems();
- GC gc = new GC(tree);
- for (int i=0; i<items.length; i++) {
- width = Math.max (width, calculateWidth(items[i], gc));
- itemCount++;
-
- // do the same for the children because we expand the first level.
- TreeItem[] children = items[i].getItems();
- for (int j = 0; j < children.length; j++) {
- width = Math.max(width, calculateWidth(children[j], gc));
- itemCount++;
- }
-
- }
- gc.dispose ();
- width += 40; // give a little extra space
-
- height = itemCount * tree.getItemHeight() + 90;
- if (width > 300) {
- width = 300;
- }
- if (height > 300) {
- height = 300;
- }
- return shell.computeSize(width, height, true);
- }
-
- private int calculateWidth (TreeItem item, GC gc) {
- int width = 0;
- Image image = item.getImage ();
- String text = item.getText ();
- if (image != null) width = image.getBounds ().width + 2;
- if (text != null && text.length () > 0) width += gc.stringExtent (text).x;
- return width;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
- */
- public boolean hasContents() {
- return (viewer != null);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.ui.actions.PopupInformationControl#performCommand()
- */
- protected void performCommand() {
- DebugPlugin.getDefault().getExpressionManager().addExpression(exp);
-
- // set exp to null since this dialog does not own the expression anymore
- // the expression now belongs to the Expression View
- exp = null;
-
- IViewPart part = page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW);
- if (part == null) {
- try {
- page.showView(IDebugUIConstants.ID_EXPRESSION_VIEW);
- } catch (PartInitException e) {
- }
- } else {
- page.bringToTop(part);
- }
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#dispose()
- */
- public void dispose() {
- super.dispose();
- if (modelPresentation != null) {
- modelPresentation.dispose();
- }
-
- // expression added to Expression View
- // the expression will be disposed when the expression is
- // removed from the view
- if (exp != null)
- exp.dispose();
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/PopupInformationControl.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/PopupInformationControl.java
deleted file mode 100644
index 7fc30de37..000000000
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/expression/PopupInformationControl.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.debug.internal.ui.views.expression;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.debug.internal.ui.DebugUIMessages;
-import org.eclipse.debug.internal.ui.DebugUIPlugin;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.AbstractHandler;
-import org.eclipse.ui.commands.ExecutionException;
-import org.eclipse.ui.commands.HandlerSubmission;
-import org.eclipse.ui.commands.ICommand;
-import org.eclipse.ui.commands.ICommandManager;
-import org.eclipse.ui.commands.IHandler;
-import org.eclipse.ui.commands.IKeySequenceBinding;
-import org.eclipse.ui.commands.IWorkbenchCommandSupport;
-import org.eclipse.ui.commands.Priority;
-import org.eclipse.ui.contexts.IWorkbenchContextSupport;
-
-/**
- * An information popup window. The window contains a control provided
- * by subclasses. A label is displayed at the bottom of the
- * window describing an action used to dismiss the window, which is invoked
- * with a key binding.
- * <p>
- * Clients are intended to subclass this class.
- * </p>
- * @see org.eclipse.debug.ui.actions.IPopupInformationControlAdapter
- * @see org.eclipse.jface.text.information.IInformationPresenter
- * @see org.eclipse.jface.text.information.IInformationProvider
- * @since 3.0
- */
-public abstract class PopupInformationControl implements IInformationControl, IInformationControlExtension {
-
- private static final String HEIGHT_STRING = "_DEBUGPOPUP_HEIGHT"; //$NON-NLS-1$
- private static final String WIDTH_STRING = "_DEBUGPOPUP_WIDTH"; //$NON-NLS-1$
-
- /**
- * The popup window
- */
- protected Shell shell;
-
- /**
- * The maximum width of the popup
- */
- private int maxWidth = 300;
-
- /**
- * The maximum height of the popup
- */
- private int maxHeight = 300;
-
- /**
- * ActionHandler for closeAction
- */
- private HandlerSubmission submission;
-
- /**
- * Handler used to close this popup, or <code>null</code> if none
- */
- private IHandler closeHandler = null;
-
- /**
- * Command id that provides a key sequence used to invoke this
- * popup's close handler, or <code>null</code> if none
- */
- private String commandId = null;
-
- /**
- * Popup control
- */
- private Control control = null;
-
- /**
- * Creates a popup information control. When the specified command
- * is invoked, the handler is invoked and the popup is closed.
- *
- * @param parent the shell to parent the popup
- * @param labelText label to display at the bottom of the popup window.
- * The label will be augmented with the key-sequence asscoaited with the
- * given commandId.
- * @param commandId command identifier used to bind a key sequence to
- * close the popup invoking <code>performCommand()</code>
- */
- public PopupInformationControl(Shell parent, String labelText, String commandId) {
- this.closeHandler = new CloseHandler();
- this.commandId = commandId;
-
- shell= new Shell(parent, SWT.RESIZE);
- Display display = shell.getDisplay();
- shell.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- shell.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- GridLayout layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- shell.setLayout(layout);
- shell.setLayoutData(new GridData(GridData.FILL_BOTH));
- control = createControl(shell);
- register();
-
- ICommandManager commandManager= PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
- ICommand command = null;
- if (commandId != null) {
- command = commandManager.getCommand(commandId);
- }
-
- Label separator= new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Label label = new Label(shell, SWT.SHADOW_NONE | SWT.RIGHT);
- label.setText(labelText);
- label.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- label.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- label.setEnabled(false);
- label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
- if (command != null) {
- List keyBindings = command.getKeySequenceBindings();
- if (keyBindings != null && keyBindings.size() > 0) {
- IKeySequenceBinding keySequenceBinding = (IKeySequenceBinding)keyBindings.get(0);
- label.setText(MessageFormat.format(DebugUIMessages.PopupInformationControl_1, new String[] {keySequenceBinding.getKeySequence().format(), labelText}));
- label.getParent().layout();
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- shell.addDisposeListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- shell.addFocusListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- Point persistedSize = getInitialSize();
- if (persistedSize != null) {
- return persistedSize;
- }
-
- Point computedSize = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- if (maxWidth > 0 && computedSize.x > maxWidth)
- computedSize.x = maxWidth;
- if (maxHeight > 0 && computedSize.y > maxHeight)
- computedSize.y = maxHeight;
- return computedSize;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#dispose()
- */
- public void dispose() {
- deregister();
- persistSize();
- shell= null;
- }
-
- /**
- * Deregisters this popup's default close action and turns off the
- * debug popup scope.
- */
- private void deregister() {
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchContextSupport contextSupport = workbench.getContextSupport();
- IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
-
- commandSupport.removeHandlerSubmission(submission);
- contextSupport.unregisterShell(shell);
- }
-
- /**
- * Registers this popup's default close action and turns on the
- * debug popup scope.
- */
- private void register() {
- if (closeHandler != null) {
- IWorkbench workbench = PlatformUI.getWorkbench();
-
- IWorkbenchContextSupport contextSupport = workbench.getContextSupport();
- IWorkbenchCommandSupport commandSupport = workbench.getCommandSupport();
-
- submission = new HandlerSubmission(null, shell, null, commandId, closeHandler, Priority.MEDIUM);
- commandSupport.addHandlerSubmission(submission);
-
- contextSupport.registerShell(shell, IWorkbenchContextSupport.TYPE_DIALOG);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- shell.removeDisposeListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- shell.removeFocusListener(listener);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setBackgroundColor(Color)
- */
- public void setBackgroundColor(Color background) {
- shell.setBackground(background);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setForegroundColor(Color)
- */
- public void setForegroundColor(Color foreground) {
- shell.setForeground(foreground);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setLocation(Point)
- */
- public void setLocation(Point location) {
- Rectangle displayBounds = control.getDisplay().getClientArea();
-
- location.x = location.x < 0 ? displayBounds.x + 25 : location.x;
- location.y = location.y < 0 ? displayBounds.y + 25 : location.y;
-
- Point shellSize = shell.getSize();
- boolean shellSizeChanged = false;
- if (shellSize.x + location.x > displayBounds.width) {
- shellSize.x = displayBounds.width - location.x;
- shellSizeChanged = true;
- }
- if (shellSize.y + location.y > displayBounds.height) {
- shellSize.y = displayBounds.height - location.y;
- shellSizeChanged = true;
- }
- if (shellSizeChanged) {
- shell.setSize(shellSize);
- }
-
- shell.setLocation(location);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setSize(int, int)
- */
- public void setSize(int width, int height) {
- shell.setSize(width, height);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setSizeContraints(int, int)
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- this.maxWidth = maxWidth;
- this.maxHeight = maxHeight;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- shell.setVisible(visible);
- if (!visible) {
- deregister();
- shell.dispose();
- }
- }
-
- /**
- * Creates and returns the control for this popup.
- *
- * @param parent parent control
- * @return control
- */
- protected abstract Control createControl(Composite parent);
-
- /**
- * Attempts to retrieve the size of the popup when it was last disposed.
- * @return The size the initial size of the popup if available, otherwise null
- */
- protected Point getInitialSize() {
- Point point = null;
- try {
- IDialogSettings settings = getDialogSettings();
- if (settings != null) {
- String key = getClass().getName();
-
- int height = settings.getInt(key+HEIGHT_STRING);
- int width = settings.getInt(key+WIDTH_STRING);
-
- point = new Point(width, height);
- }
- } catch (NumberFormatException e) {
- }
-
- return point;
- }
-
- /**
- * Returns a dialog settings in which to persist/restore popup control size.
- *
- * @return dialog settings
- */
- protected IDialogSettings getDialogSettings() {
- return DebugUIPlugin.getDefault().getDialogSettings();
- }
-
- /**
- * Attempts to store the current size of the popup in the adapter's IDialogSettings.
- * Uses the adapters fully qualified class name to create unique keys.
- */
- protected void persistSize() {
- if (shell == null) {
- return;
- }
-
- IDialogSettings settings = getDialogSettings();
- if (settings != null) {
- String key = getClass().getName();
- Point size = shell.getSize();
- settings.put(key+WIDTH_STRING, size.x);
- settings.put(key+HEIGHT_STRING, size.y);
- }
- }
-
- /**
- * Handler to closes this popup
- */
- private class CloseHandler extends AbstractHandler {
- /* (non-Javadoc)
- * @see org.eclipse.ui.commands.IHandler#execute(java.lang.Object)
- */
- public Object execute(Map parameter) throws ExecutionException {
- performCommand();
- if (shell != null) {
- shell.dispose();
- }
- return null;
- }
-
- }
-
- /**
- * Called when this popup is closed via its command.
- * Subclasses must override.
- */
- protected abstract void performCommand();
-
- /**
- * Returns this popup's shell.
- *
- * @return shell
- */
- protected Shell getShell() {
- return shell;
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#isFocusControl()
- */
- public boolean isFocusControl() {
- return control.isFocusControl();
- }
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.IInformationControl#setFocus()
- */
- public void setFocus() {
- control.setFocus();
- }
-}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java
new file mode 100644
index 000000000..2bc9dc0b4
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/DebugPopup.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.ui;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.PopupDialog;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+
+public abstract class DebugPopup extends PopupDialog {
+
+ private ITextViewer fViewer;
+
+ private IHandlerActivation fActivation;
+
+ private IHandlerService fHandlerService;
+
+ public DebugPopup(Shell parent, ITextViewer viewer) {
+ super(parent, PopupDialog.INFOPOPUPRESIZE_SHELLSTYLE, true, true, false, true, null, null);
+ fViewer = viewer;
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+
+ String commandId = getCommandId();
+ if (commandId != null) {
+ IHandler fCloseHandler = new AbstractHandler() {
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ persist();
+ close();
+ return null;
+ }
+ };
+
+ fHandlerService = (IHandlerService) workbench.getAdapter(IHandlerService.class);
+ fActivation = fHandlerService.activateHandler(commandId, fCloseHandler);
+ }
+
+ String infoText = getInfoText();
+ if (infoText != null)
+ setInfoText(infoText);
+ }
+
+ protected String getInfoText() {
+ return null;
+ }
+
+ protected String getCommandId() {
+ return null;
+ }
+
+ protected void persist() {
+ }
+
+ protected abstract Control createDialogArea(Composite parent);
+
+ protected Point getInitialLocation(Point initialSize) {
+ StyledText textWidget = fViewer.getTextWidget();
+ Point docRange = textWidget.getSelectionRange();
+ int midOffset = docRange.x + (docRange.y / 2);
+ Point point = textWidget.getLocationAtOffset(midOffset);
+ point = textWidget.toDisplay(point);
+
+ GC gc = new GC(textWidget);
+ gc.setFont(textWidget.getFont());
+ int height = gc.getFontMetrics().getHeight();
+ gc.dispose();
+ point.y += height;
+
+ Rectangle monitor = textWidget.getMonitor().getClientArea();
+ if (monitor.width < point.x + initialSize.x) {
+ point.x = Math.max(0, point.x - initialSize.x);
+ }
+ if (monitor.height < point.y + initialSize.y) {
+ point.y = Math.max(0, point.y - initialSize.y - height);
+ }
+
+ return point;
+ }
+
+ protected IDialogSettings getDialogSettings() {
+ IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings();
+ return settings;
+ }
+
+ public boolean close() {
+ if (fActivation != null)
+ fHandlerService.deactivateHandler(fActivation);
+
+ return super.close();
+ }
+}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java
new file mode 100644
index 000000000..e89682647
--- /dev/null
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/ui/InspectPopupDialog.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.debug.ui;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IExpression;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.DebugUIPlugin;
+import org.eclipse.debug.internal.ui.VariablesViewModelPresentation;
+import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages;
+import org.eclipse.debug.internal.ui.views.expression.ExpressionPopupContentProvider;
+import org.eclipse.debug.internal.ui.views.expression.RemoteExpressionsContentProvider;
+import org.eclipse.debug.internal.ui.views.variables.IndexedVariablePartition;
+import org.eclipse.debug.internal.ui.views.variables.VariablesView;
+import org.eclipse.debug.internal.ui.views.variables.VariablesViewer;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.PartInitException;
+
+public class InspectPopupDialog extends DebugPopup {
+ private static final int[] DEFAULT_SASH_WEIGHTS = new int[] { 90, 10 };
+
+ private static final int MIN_WIDTH = 250;
+
+ private static final int MIN_HEIGHT = 200;
+
+ private IWorkbenchPage fPage;
+
+ private VariablesViewer fVariablesViewer;
+
+ private IDebugModelPresentation fModelPresentation;
+
+ private StyledText fValueDisplay;
+
+ private SashForm fSashForm;
+
+ private Tree fTree;
+
+ private IExpression fExpression;
+
+ private String fCommandId;
+
+ public InspectPopupDialog(Shell shell, ITextViewer viewer, String commandId, IExpression expression) {
+ super(shell, viewer);
+ fCommandId = commandId;
+ fExpression = expression;
+ }
+
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = new Composite(parent, parent.getStyle());
+ GridLayout layout = new GridLayout();
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fSashForm = new SashForm(composite, parent.getStyle());
+ fSashForm.setOrientation(SWT.VERTICAL);
+ fSashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ fPage = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
+ VariablesView view = getViewToEmulate();
+ IWorkbenchPartSite site = null;
+ if (view != null) {
+ site = view.getSite();
+ } else {
+ site = fPage.getActivePart().getSite();
+ }
+
+ fVariablesViewer = new VariablesViewer(fSashForm, SWT.NO_TRIM, null);
+ fVariablesViewer.setContentProvider(new ExpressionPopupContentProvider(fVariablesViewer, site, view));
+ fModelPresentation = new VariablesViewModelPresentation();
+ fVariablesViewer.setLabelProvider(fModelPresentation);
+
+ fValueDisplay = new StyledText(fSashForm, SWT.NO_TRIM | SWT.WRAP | SWT.V_SCROLL);
+ fValueDisplay.setEditable(false);
+
+ fTree = fVariablesViewer.getTree();
+ fTree.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ try {
+ TreeItem[] selections = fTree.getSelection();
+ if (selections.length > 0) {
+ Object data = selections[selections.length - 1].getData();
+
+ IValue val = null;
+ if (data instanceof IndexedVariablePartition) {
+ // no details for parititions
+ return;
+ }
+ if (data instanceof IVariable) {
+ val = ((IVariable) data).getValue();
+ } else if (data instanceof IExpression) {
+ val = ((IExpression) data).getValue();
+ }
+ if (val == null) {
+ return;
+ }
+
+ updateValueDisplay(val);
+ }
+ } catch (DebugException ex) {
+ DebugUIPlugin.log(ex);
+ }
+
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ Color background = parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ Color foreground = parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ fTree.setForeground(foreground);
+ fTree.setBackground(background);
+ composite.setForeground(foreground);
+ composite.setBackground(background);
+ fValueDisplay.setForeground(foreground);
+ fValueDisplay.setBackground(background);
+
+ // sashForm.setWeights(getInitialSashWeights());
+ fSashForm.setWeights(DEFAULT_SASH_WEIGHTS);
+
+ fVariablesViewer.getContentProvider();
+ if (view != null) {
+ StructuredViewer structuredViewer = (StructuredViewer) view.getViewer();
+ if (structuredViewer != null) {
+ ViewerFilter[] filters = structuredViewer.getFilters();
+ for (int i = 0; i < filters.length; i++) {
+ fVariablesViewer.addFilter(filters[i]);
+ }
+ }
+ ((RemoteExpressionsContentProvider) fVariablesViewer.getContentProvider()).setShowLogicalStructure(view.isShowLogicalStructure());
+ Map map = view.getPresentationAttributes(fExpression.getModelIdentifier());
+ Iterator iterator = map.keySet().iterator();
+ while (iterator.hasNext()) {
+ String key = (String) iterator.next();
+ fModelPresentation.setAttribute(key, map.get(key));
+ }
+ }
+ fVariablesViewer.setInput(new Object[] { fExpression });
+ fVariablesViewer.expandToLevel(2);
+
+ return fTree;
+ }
+
+ void updateValueDisplay(IValue val) {
+ IValueDetailListener valueDetailListener = new IValueDetailListener() {
+ public void detailComputed(IValue value, final String result) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ if (!fValueDisplay.isDisposed()) {
+ String text = result;
+ int max = DebugUIPlugin.getDefault().getPreferenceStore().getInt(IDebugUIConstants.PREF_MAX_DETAIL_LENGTH);
+ if (max > 0 && result.length() > max) {
+ text = result.substring(0, max) + "..."; //$NON-NLS-1$
+ }
+ fValueDisplay.setText(text);
+ }
+ }
+ });
+ }
+ };
+ fModelPresentation.computeDetail(val, valueDetailListener);
+ }
+
+ VariablesView getViewToEmulate() {
+ IWorkbenchPage page = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
+ VariablesView expressionsView = (VariablesView) page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW);
+ if (expressionsView != null && expressionsView.isVisible()) {
+ return expressionsView;
+ }
+ VariablesView variablesView = (VariablesView) page.findView(IDebugUIConstants.ID_VARIABLE_VIEW);
+ if (variablesView != null && variablesView.isVisible()) {
+ return variablesView;
+ }
+ if (expressionsView != null) {
+ return expressionsView;
+ }
+ return variablesView;
+ }
+
+ protected String getCommandId() {
+ return fCommandId;
+ }
+
+ protected String getInfoText() {
+ return DebugUIViewsMessages.InspectPopupDialog_0;
+ }
+
+ protected void persist() {
+ DebugPlugin.getDefault().getExpressionManager().addExpression(fExpression);
+
+ fExpression = null;
+ IWorkbenchPage page = DebugUIPlugin.getActiveWorkbenchWindow().getActivePage();
+ IViewPart part = page.findView(IDebugUIConstants.ID_EXPRESSION_VIEW);
+ if (part == null) {
+ try {
+ page.showView(IDebugUIConstants.ID_EXPRESSION_VIEW);
+ } catch (PartInitException e) {
+ }
+ } else {
+ page.bringToTop(part);
+ }
+ }
+
+ protected Point getInitialSize() {
+ Point initialSize = super.getInitialSize();
+ initialSize.x = Math.max(initialSize.x, MIN_WIDTH);
+ initialSize.y = Math.max(initialSize.y, MIN_HEIGHT);
+ return initialSize;
+ }
+
+
+
+}

Back to the top