mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 310425 - [hover][api] Add support for optional details pane and default expansion level to advanced hover
This commit is contained in:
parent
ea6bcda223
commit
048ebbf014
2 changed files with 104 additions and 34 deletions
|
@ -226,6 +226,15 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
||||||
return super.computeSizeHint();
|
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
|
* 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();
|
Point size = shell.getSize();
|
||||||
settings.put(WIDTH, size.x);
|
settings.put(WIDTH, size.x);
|
||||||
settings.put(HEIGHT, size.y);
|
settings.put(HEIGHT, size.y);
|
||||||
int[] weights = fSashForm.getWeights();
|
int[] weights = fSashForm.getWeights();
|
||||||
settings.put(SASH_WEIGHT_TREE, weights[0]);
|
if (weights.length == 1) {
|
||||||
settings.put(SASH_WEIGHT_DETAILS, weights[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 = new TreeModelViewer(fSashForm, SWT.MULTI | SWT.VIRTUAL | SWT.FULL_SELECTION, context);
|
||||||
fViewer.setAutoExpandLevel(1);
|
fViewer.setAutoExpandLevel(fExpansionLevel);
|
||||||
|
|
||||||
if (view != null) {
|
if (view != null) {
|
||||||
// copy over filters
|
// copy over filters
|
||||||
|
@ -325,26 +339,28 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fInputService = new ViewerInputService(fViewer, this);
|
fInputService = new ViewerInputService(fViewer, this);
|
||||||
|
fTree = fViewer.getTree();
|
||||||
|
|
||||||
fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
|
if (fShowDetailPane) {
|
||||||
Layout layout = fDetailPaneComposite.getLayout();
|
fDetailPaneComposite = SWTFactory.createComposite(fSashForm, 1, 1, GridData.FILL_BOTH);
|
||||||
if (layout instanceof GridLayout) {
|
Layout layout = fDetailPaneComposite.getLayout();
|
||||||
GridLayout gl = (GridLayout) layout;
|
if (layout instanceof GridLayout) {
|
||||||
gl.marginHeight = 0;
|
GridLayout gl = (GridLayout) layout;
|
||||||
gl.marginWidth = 0;
|
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
|
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() {
|
fTree.addSelectionListener(new SelectionListener() {
|
||||||
public void widgetSelected(SelectionEvent e) {
|
public void widgetSelected(SelectionEvent e) {
|
||||||
fDetailPane.display((IStructuredSelection)fViewer.getSelection());
|
fDetailPane.display((IStructuredSelection)fViewer.getSelection());
|
||||||
}
|
}
|
||||||
public void widgetDefaultSelected(SelectionEvent e) {}
|
public void widgetDefaultSelected(SelectionEvent e) {}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
initSashWeights();
|
initSashWeights();
|
||||||
|
|
||||||
// add update listener to auto-select and display details of root expression
|
// 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());
|
selection = new TreeSelection(fViewer.getTopElementPath());
|
||||||
}
|
}
|
||||||
fViewer.setSelection(selection);
|
fViewer.setSelection(selection);
|
||||||
fDetailPane.display(selection);
|
if (fDetailPane != null) {
|
||||||
|
fDetailPane.display(selection);
|
||||||
|
}
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
public void viewerUpdatesBegin() {
|
public void viewerUpdatesBegin() {
|
||||||
|
@ -402,10 +420,16 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
||||||
if (settings != null) {
|
if (settings != null) {
|
||||||
int tree = getIntSetting(settings, SASH_WEIGHT_TREE);
|
int tree = getIntSetting(settings, SASH_WEIGHT_TREE);
|
||||||
if (tree > 0) {
|
if (tree > 0) {
|
||||||
int details = getIntSetting(settings, SASH_WEIGHT_DETAILS);
|
if (fDetailPane != null) {
|
||||||
if (details > 0) {
|
int details = getIntSetting(settings, SASH_WEIGHT_DETAILS);
|
||||||
fSashForm.setWeights(new int[]{tree, 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
|
@Override
|
||||||
public void setBackgroundColor(Color background) {
|
public void setBackgroundColor(Color background) {
|
||||||
super.setBackgroundColor(background);
|
super.setBackgroundColor(background);
|
||||||
fDetailPaneComposite.setBackground(background);
|
if (fDetailPaneComposite != null) {
|
||||||
|
fDetailPaneComposite.setBackground(background);
|
||||||
|
}
|
||||||
fTree.setBackground(background);
|
fTree.setBackground(background);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -445,7 +471,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IInformationControlCreator getInformationPresenterControlCreator() {
|
public IInformationControlCreator getInformationPresenterControlCreator() {
|
||||||
return new ExpressionInformationControlCreator() {
|
return new ExpressionInformationControlCreator(fShowDetailPane, fExpansionLevel) {
|
||||||
@Override
|
@Override
|
||||||
public IInformationControl createInformationControl(Shell shell) {
|
public IInformationControl createInformationControl(Shell shell) {
|
||||||
return new ExpressionInformationControl(shell, true);
|
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)
|
* @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
|
||||||
*/
|
*/
|
||||||
public IInformationControl createInformationControl(Shell parent) {
|
public IInformationControl createInformationControl(Shell parent) {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Nokia Corporation - initial API and implementation
|
* Nokia Corporation - initial API and implementation
|
||||||
|
* Wind River Systems - Added support for advanced expression hover
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.debug.ui;
|
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.debug.ui.editors.AbstractDebugTextHover;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
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.concurrent.Query;
|
||||||
import org.eclipse.cdt.dsf.debug.internal.ui.ExpressionInformationControlCreator;
|
import org.eclipse.cdt.dsf.debug.internal.ui.ExpressionInformationControlCreator;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IExpressions;
|
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) {
|
protected void execute(final DataRequestMonitor<FormattedValueDMData> rm) {
|
||||||
DsfSession session = DsfSession.getSession(frame.getSessionId());
|
DsfSession session = DsfSession.getSession(frame.getSessionId());
|
||||||
IExpressions expressions = dsfServicesTracker.getService(IExpressions.class);
|
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);
|
IExpressionDMContext expressionDMC = expressions.createExpression(frame, expression);
|
||||||
FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, getHoverFormat());
|
FormattedValueDMContext formattedValueContext = expressions.getFormattedValueContext(expressionDMC, getHoverFormat());
|
||||||
expressions.getFormattedExpressionValue(formattedValueContext,
|
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>.
|
* The default implementation returns <code>false</code>.
|
||||||
*/
|
*/
|
||||||
protected boolean useExpressionExplorer() {
|
protected boolean useExpressionExplorer() {
|
||||||
return false;
|
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
|
@Override
|
||||||
public IInformationControlCreator getHoverControlCreator() {
|
public IInformationControlCreator getHoverControlCreator() {
|
||||||
if (useExpressionExplorer()) {
|
if (useExpressionExplorer()) {
|
||||||
return new ExpressionInformationControlCreator();
|
return createExpressionInformationControlCreator(true, 1);
|
||||||
} else {
|
} else {
|
||||||
return new IInformationControlCreator() {
|
return new IInformationControlCreator() {
|
||||||
public IInformationControl createInformationControl(Shell parent) {
|
public IInformationControl createInformationControl(Shell parent) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue