From 0d4f5c71b649e545cf6bdee53bbaaa509fbfa5ea Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Wed, 28 Apr 2010 08:18:59 +0000 Subject: Bug 310425 - incorporate Marc's feedback --- .../ui/ExpressionInformationControlCreator.java | 41 ++++++---------------- .../dsf/debug/ui/AbstractDsfDebugTextHover.java | 25 ++++++++++--- 2 files changed, 32 insertions(+), 34 deletions(-) (limited to 'dsf/org.eclipse.cdt.dsf.ui') diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java index 2f0e2cee589..a8587ca401a 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java @@ -14,10 +14,7 @@ package org.eclipse.cdt.dsf.debug.internal.ui; import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.internal.ui.SWTFactory; -import org.eclipse.debug.internal.ui.model.elements.ElementContentProvider; import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputRequestor; import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate; @@ -130,23 +127,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC private ViewerInputService fInputService; - /** - * Creates the content for the root element of the tree viewer in the hover - */ - private class TreeRoot extends ElementContentProvider { - @Override - protected int getChildCount(Object element, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return 1; - } - @Override - protected Object[] getChildren(Object parent, int index, int length, IPresentationContext context, IViewerUpdate monitor) throws CoreException { - return new Object[] { fVariable }; - } - @Override - protected boolean supportsContextId(String id) { - return true; - } - } + private IInformationControlCreator fInformationControlCreator; /** * Inner class implementing IDetailPaneContainer methods. Handles changes to detail @@ -463,20 +444,20 @@ public class ExpressionInformationControlCreator implements IInformationControlC if (input instanceof IExpressionDMContext) { fVariable = input; fInputService.resolveViewerInput(input); - } else if (input instanceof IVariable) { - fVariable = input; - fViewer.setInput(new TreeRoot()); } } @Override public IInformationControlCreator getInformationPresenterControlCreator() { - return new ExpressionInformationControlCreator(fShowDetailPane, fExpansionLevel) { - @Override - public IInformationControl createInformationControl(Shell shell) { - return new ExpressionInformationControl(shell, true); - } - }; + if (fInformationControlCreator == null) { + fInformationControlCreator = new ExpressionInformationControlCreator(fShowDetailPane, fExpansionLevel) { + @Override + public IInformationControl createInformationControl(Shell shell) { + return new ExpressionInformationControl(shell, true); + } + }; + } + return fInformationControlCreator; } public void viewerInputComplete(IViewerInputUpdate update) { @@ -491,7 +472,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC /** * Create default expression information control creator. *
- * Same as {@link ExpressionInformationControlCreator(true, 1)}. + * Same as {@code ExpressionInformationControlCreator(true, 1)}. *
*/ public ExpressionInformationControlCreator() { diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java index d3115574dd4..e1ac76a9da1 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java @@ -157,9 +157,10 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i /** * Create an information control creator for the "advanced" hover. - * Called by {@link #getHoverControlCreator()} when {@link #useExpressionExplorer()} - * returnstrue
.
- *
+ * + * Clients can call this method to create an information control creator + * with custom options. + *
* @param showDetailPane whether the detail pane should be visible * @param defaultExpansionLevel automatically expand the expression to this level * @return the information control creator @@ -167,11 +168,27 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i protected final IInformationControlCreator createExpressionInformationControlCreator(boolean showDetailPane, int defaultExpansionLevel) { return new ExpressionInformationControlCreator(showDetailPane, defaultExpansionLevel); } + + /** + * Create an information control creator for the "advanced" hover. + * Called by {@link #getHoverControlCreator()} when {@link #useExpressionExplorer()} + * returnstrue
.
+ * + * The default implementation returns an information control creator with + * details pane enabled and default expansion level = 1. + * Clients may override this method to return an instance with different options. + *
+ * @return the information control creator + * @see {@link #createExpressionInformationControlCreator(boolean, int)} + */ + protected IInformationControlCreator createExpressionInformationControlCreator() { + return createExpressionInformationControlCreator(true, 1); + } @Override public IInformationControlCreator getHoverControlCreator() { if (useExpressionExplorer()) { - return createExpressionInformationControlCreator(true, 1); + return createExpressionInformationControlCreator(); } else { return new IInformationControlCreator() { public IInformationControl createInformationControl(Shell parent) { -- cgit v1.2.3