Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2010-04-27 13:59:29 +0000
committerAnton Leherbauer2010-04-27 13:59:29 +0000
commit048ebbf014ee6cc0dcac043c9a5de5c506cf5dec (patch)
tree66f98ca3a263cd0bbc8460c09a63a3d624c10357 /dsf/org.eclipse.cdt.dsf.ui
parentea6bcda223210b42e8efdd03290b43ad50d859ba (diff)
downloadorg.eclipse.cdt-048ebbf014ee6cc0dcac043c9a5de5c506cf5dec.tar.gz
org.eclipse.cdt-048ebbf014ee6cc0dcac043c9a5de5c506cf5dec.tar.xz
org.eclipse.cdt-048ebbf014ee6cc0dcac043c9a5de5c506cf5dec.zip
Bug 310425 - [hover][api] Add support for optional details pane and default expansion level to advanced hover
Diffstat (limited to 'dsf/org.eclipse.cdt.dsf.ui')
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/ExpressionInformationControlCreator.java114
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/AbstractDsfDebugTextHover.java26
2 files changed, 105 insertions, 35 deletions
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 d105a7f9886..2f0e2cee589 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
@@ -226,6 +226,15 @@ public class ExpressionInformationControlCreator implements IInformationControlC
return super.computeSizeHint();
}
+ @Override
+ public void setSize(int width, int height) {
+ if (!isResizable() && fDetailPaneComposite != null) {
+ // add height of details pane
+ height += fDetailPaneComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+ }
+ super.setSize(width, height);
+ }
+
/**
* Returns the dialog settings for this hover or <code>null</code> if none
*
@@ -273,9 +282,14 @@ public class ExpressionInformationControlCreator implements IInformationControlC
Point size = shell.getSize();
settings.put(WIDTH, size.x);
settings.put(HEIGHT, size.y);
- int[] weights = fSashForm.getWeights();
- settings.put(SASH_WEIGHT_TREE, weights[0]);
- settings.put(SASH_WEIGHT_DETAILS, weights[1]);
+ int[] weights = fSashForm.getWeights();
+ if (weights.length == 1) {
+ settings.put(SASH_WEIGHT_TREE, weights[0]);
+ }
+ else if (weights.length == 2) {
+ settings.put(SASH_WEIGHT_TREE, weights[0]);
+ settings.put(SASH_WEIGHT_DETAILS, weights[1]);
+ }
}
}
}
@@ -312,7 +326,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC
}
fViewer = new TreeModelViewer(fSashForm, SWT.MULTI | SWT.VIRTUAL | SWT.FULL_SELECTION, context);
- fViewer.setAutoExpandLevel(1);
+ fViewer.setAutoExpandLevel(fExpansionLevel);
if (view != null) {
// copy over filters
@@ -325,26 +339,28 @@ public class ExpressionInformationControlCreator implements IInformationControlC
}
}
fInputService = new ViewerInputService(fViewer, this);
-
- fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
- Layout layout = fDetailPaneComposite.getLayout();
- if (layout instanceof GridLayout) {
- GridLayout gl = (GridLayout) layout;
- gl.marginHeight = 0;
- gl.marginWidth = 0;
- }
-
- fDetailPane = new DetailPaneProxy(new DetailPaneContainer());
- fDetailPane.display(null); // Bring up the default pane so the user doesn't see an empty composite
-
- fTree = fViewer.getTree();
- fTree.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- fDetailPane.display((IStructuredSelection)fViewer.getSelection());
- }
- public void widgetDefaultSelected(SelectionEvent e) {}
- });
-
+ fTree = fViewer.getTree();
+
+ if (fShowDetailPane) {
+ fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
+ Layout layout = fDetailPaneComposite.getLayout();
+ if (layout instanceof GridLayout) {
+ GridLayout gl = (GridLayout) layout;
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ }
+
+ fDetailPane = new DetailPaneProxy(new DetailPaneContainer());
+ fDetailPane.display(null); // Bring up the default pane so the user doesn't see an empty composite
+
+ fTree.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ fDetailPane.display((IStructuredSelection)fViewer.getSelection());
+ }
+ public void widgetDefaultSelected(SelectionEvent e) {}
+ });
+ }
+
initSashWeights();
// add update listener to auto-select and display details of root expression
@@ -357,7 +373,9 @@ public class ExpressionInformationControlCreator implements IInformationControlC
selection = new TreeSelection(fViewer.getTopElementPath());
}
fViewer.setSelection(selection);
- fDetailPane.display(selection);
+ if (fDetailPane != null) {
+ fDetailPane.display(selection);
+ }
}});
}
public void viewerUpdatesBegin() {
@@ -402,10 +420,16 @@ public class ExpressionInformationControlCreator implements IInformationControlC
if (settings != null) {
int tree = getIntSetting(settings, SASH_WEIGHT_TREE);
if (tree > 0) {
- int details = getIntSetting(settings, SASH_WEIGHT_DETAILS);
- if (details > 0) {
- fSashForm.setWeights(new int[]{tree, details});
- }
+ if (fDetailPane != null) {
+ int details = getIntSetting(settings, SASH_WEIGHT_DETAILS);
+ if (details <= 0) {
+ details = tree / 2;
+ }
+ fSashForm.setWeights(new int[]{tree, details});
+ }
+ else {
+ fSashForm.setWeights(new int[]{tree});
+ }
}
}
}
@@ -413,7 +437,9 @@ public class ExpressionInformationControlCreator implements IInformationControlC
@Override
public void setBackgroundColor(Color background) {
super.setBackgroundColor(background);
- fDetailPaneComposite.setBackground(background);
+ if (fDetailPaneComposite != null) {
+ fDetailPaneComposite.setBackground(background);
+ }
fTree.setBackground(background);
}
@@ -445,7 +471,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC
@Override
public IInformationControlCreator getInformationPresenterControlCreator() {
- return new ExpressionInformationControlCreator() {
+ return new ExpressionInformationControlCreator(fShowDetailPane, fExpansionLevel) {
@Override
public IInformationControl createInformationControl(Shell shell) {
return new ExpressionInformationControl(shell, true);
@@ -459,7 +485,31 @@ public class ExpressionInformationControlCreator implements IInformationControlC
}
- /*
+ protected final boolean fShowDetailPane;
+ protected final int fExpansionLevel;
+
+ /**
+ * Create default expression information control creator.
+ * <p>
+ * Same as {@link ExpressionInformationControlCreator(true, 1)}.
+ * </p>
+ */
+ public ExpressionInformationControlCreator() {
+ this(true, 1);
+ }
+
+ /**
+ * Create expression information control creator with customization options.
+ *
+ * @param showDetailPane if <code>true</code> the detail pane will be shown
+ * @param expansionLevel tree level to which the expression should be expanded by default
+ */
+ public ExpressionInformationControlCreator(boolean showDetailPane, int expansionLevel) {
+ fShowDetailPane = showDetailPane;
+ fExpansionLevel = expansionLevel;
+ }
+
+ /*
* @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
*/
public IInformationControl createInformationControl(Shell parent) {
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 81a0aec31c7..d3115574dd4 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Nokia Corporation and others.
+ * Copyright (c) 2009, 2010 Nokia 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Nokia Corporation - initial API and implementation
+ * Wind River Systems - Added support for advanced expression hover
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.ui;
@@ -15,6 +16,7 @@ import java.util.concurrent.ExecutionException;
import org.eclipse.cdt.debug.ui.editors.AbstractDebugTextHover;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.debug.internal.ui.ExpressionInformationControlCreator;
import org.eclipse.cdt.dsf.debug.service.IExpressions;
@@ -71,6 +73,11 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i
protected void execute(final DataRequestMonitor<FormattedValueDMData> rm) {
DsfSession session = DsfSession.getSession(frame.getSessionId());
IExpressions expressions = dsfServicesTracker.getService(IExpressions.class);
+ if (expressions == null) {
+ rm.setStatus(DsfUIPlugin.newErrorStatus(IDsfStatusConstants.REQUEST_FAILED, "No expression service", null)); //$NON-NLS-1$
+ rm.done();
+ return;
+ }
IExpressionDMContext expressionDMC = expressions.createExpression(frame, expression);
FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, getHoverFormat());
expressions.getFormattedExpressionValue(formattedValueContext,
@@ -141,17 +148,30 @@ abstract public class AbstractDsfDebugTextHover extends AbstractDebugTextHover i
}
/**
- * Returns whether the expression explorer information control should be used.
+ * Returns whether the "advanced" expression information control should be used.
* The default implementation returns <code>false</code>.
*/
protected boolean useExpressionExplorer() {
return false;
}
+ /**
+ * Create an information control creator for the "advanced" hover.
+ * Called by {@link #getHoverControlCreator()} when {@link #useExpressionExplorer()}
+ * returns <code>true</code>.
+ *
+ * @param showDetailPane whether the detail pane should be visible
+ * @param defaultExpansionLevel automatically expand the expression to this level
+ * @return the information control creator
+ */
+ protected final IInformationControlCreator createExpressionInformationControlCreator(boolean showDetailPane, int defaultExpansionLevel) {
+ return new ExpressionInformationControlCreator(showDetailPane, defaultExpansionLevel);
+ }
+
@Override
public IInformationControlCreator getHoverControlCreator() {
if (useExpressionExplorer()) {
- return new ExpressionInformationControlCreator();
+ return createExpressionInformationControlCreator(true, 1);
} else {
return new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {

Back to the top