mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
[306007] [expressions][hover] Modifying a value in the hover does not show right away in the hover
This commit is contained in:
parent
f4e45adcea
commit
ea688d344d
4 changed files with 96 additions and 42 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2008, 2010 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
|
||||
|
@ -18,7 +18,6 @@ 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.IChildrenUpdate;
|
||||
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;
|
||||
|
@ -67,6 +66,35 @@ import org.eclipse.ui.IWorkbenchPartSite;
|
|||
@SuppressWarnings("restriction")
|
||||
public class ExpressionInformationControlCreator implements IInformationControlCreator {
|
||||
|
||||
/**
|
||||
* A presentation context for the expression hover control.
|
||||
* Implements equals and hashCode based on id comparison.
|
||||
*/
|
||||
private static final class ExpressionHoverPresentationContext extends PresentationContext {
|
||||
|
||||
private ExpressionHoverPresentationContext(String id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ExpressionHoverPresentationContext) {
|
||||
if (getId().equals(((PresentationContext) obj).getId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getId().hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
class ExpressionInformationControl extends AbstractInformationControl implements IInformationControlExtension2, IViewerInputRequestor {
|
||||
|
||||
/**
|
||||
|
@ -102,7 +130,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 {
|
||||
|
@ -268,7 +296,7 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
|||
|
||||
// update presentation context
|
||||
AbstractDebugView view = getViewToEmulate();
|
||||
IPresentationContext context = new PresentationContext(IDsfDebugUIConstants.ID_EXPRESSION_HOVER);
|
||||
IPresentationContext context = new ExpressionHoverPresentationContext(IDsfDebugUIConstants.ID_EXPRESSION_HOVER);
|
||||
if (view != null) {
|
||||
// copy over properties
|
||||
IPresentationContext copy = ((TreeModelViewer)view.getViewer()).getPresentationContext();
|
||||
|
@ -283,9 +311,9 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
|||
}
|
||||
}
|
||||
|
||||
fViewer = new TreeModelViewer(fSashForm, SWT.NO_TRIM | SWT.MULTI | SWT.VIRTUAL, context);
|
||||
fViewer = new TreeModelViewer(fSashForm, SWT.MULTI | SWT.VIRTUAL | SWT.FULL_SELECTION, context);
|
||||
fViewer.setAutoExpandLevel(1);
|
||||
|
||||
|
||||
if (view != null) {
|
||||
// copy over filters
|
||||
StructuredViewer structuredViewer = (StructuredViewer) view.getViewer();
|
||||
|
@ -322,21 +350,21 @@ public class ExpressionInformationControlCreator implements IInformationControlC
|
|||
// add update listener to auto-select and display details of root expression
|
||||
fViewer.addViewerUpdateListener(new IViewerUpdateListener() {
|
||||
public void viewerUpdatesComplete() {
|
||||
fViewer.getDisplay().timerExec(100, new Runnable() {
|
||||
public void run() {
|
||||
TreeSelection selection = (TreeSelection) fViewer.getSelection();
|
||||
if (selection.isEmpty()) {
|
||||
selection = new TreeSelection(fViewer.getTopElementPath());
|
||||
}
|
||||
fViewer.setSelection(selection);
|
||||
fDetailPane.display(selection);
|
||||
}});
|
||||
}
|
||||
public void viewerUpdatesBegin() {
|
||||
}
|
||||
public void updateStarted(IViewerUpdate update) {
|
||||
}
|
||||
public void updateComplete(IViewerUpdate update) {
|
||||
if (update instanceof IChildrenUpdate) {
|
||||
fViewer.removeViewerUpdateListener(this);
|
||||
fViewer.getDisplay().timerExec(100, new Runnable() {
|
||||
public void run() {
|
||||
TreeSelection selection = new TreeSelection(fViewer.getTopElementPath());
|
||||
fViewer.setSelection(selection);
|
||||
fDetailPane.display(selection);
|
||||
}});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 IBM Corporation and others.
|
||||
* Copyright (c) 2006, 2010 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
|
||||
|
@ -27,6 +27,7 @@ import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.DetailPaneM
|
|||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.DetailPaneWordWrapAction;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.MessagesForDetailPane;
|
||||
import org.eclipse.cdt.dsf.debug.internal.ui.viewmodel.detailsupport.TextViewerAction;
|
||||
import org.eclipse.cdt.dsf.debug.ui.IDsfDebugUIConstants;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants;
|
||||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil;
|
||||
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
|
||||
|
@ -630,10 +631,15 @@ public class NumberFormatDetailPane implements IDetailPane2, IAdaptable, IProper
|
|||
} else if (firstElement instanceof IDMVMContext) {
|
||||
IVMNode vmNode = ((IDMVMContext) firstElement).getVMNode();
|
||||
if (vmNode != null) {
|
||||
Object input = firstElement;
|
||||
IVMProvider vmProvider = vmNode.getVMProvider();
|
||||
fDetailJob = new DetailJob(vmProvider.getPresentationContext(), firstElement,
|
||||
(ITreeSelection)selection, null);
|
||||
fDetailJob.schedule();
|
||||
final IPresentationContext context= vmProvider.getPresentationContext();
|
||||
if (IDsfDebugUIConstants.ID_EXPRESSION_HOVER.equals(context.getId())) {
|
||||
// magic access to viewer input - see ExpressionVMProvider
|
||||
input = context.getProperty("__viewerInput"); //$NON-NLS-1$
|
||||
}
|
||||
fDetailJob = new DetailJob(context, input, (ITreeSelection)selection, null);
|
||||
fDetailJob.schedule();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +700,7 @@ public class NumberFormatDetailPane implements IDetailPane2, IAdaptable, IProper
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Class required) {
|
||||
if (IFindReplaceTarget.class.equals(required)) {
|
||||
return fTextViewer.getFindReplaceTarget();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2006, 2009 Wind River Systems and others.
|
||||
* Copyright (c) 2006, 2010 Wind River Systems 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
|
||||
|
@ -11,6 +11,7 @@
|
|||
package org.eclipse.cdt.dsf.debug.ui.viewmodel.expression;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
|
||||
|
@ -41,6 +42,7 @@ import org.eclipse.cdt.dsf.ui.viewmodel.IVMModelProxy;
|
|||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.RootDMVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.update.IVMUpdatePolicy;
|
||||
|
@ -143,8 +145,10 @@ public class ExpressionVMProvider extends AbstractDMVMProvider
|
|||
*/
|
||||
public int getDeltaFlagsForExpression(IExpression expression, Object event) {
|
||||
// Workaround: find the first active proxy and use it.
|
||||
if (!getActiveModelProxies().isEmpty()) {
|
||||
return ((ExpressionVMProviderModelProxyStrategy)getActiveModelProxies().get(0)).getDeltaFlagsForExpression(expression, event);
|
||||
final List<IVMModelProxy> activeModelProxies= getActiveModelProxies();
|
||||
int count = activeModelProxies.size();
|
||||
if (count > 0) {
|
||||
return ((ExpressionVMProviderModelProxyStrategy)activeModelProxies.get(count - 1)).getDeltaFlagsForExpression(expression, event);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -397,7 +401,12 @@ public class ExpressionVMProvider extends AbstractDMVMProvider
|
|||
IExpressionDMContext dmc = (IExpressionDMContext) input;
|
||||
SingleExpressionVMNode vmNode = (SingleExpressionVMNode) getChildVMNodes(getRootVMNode())[0];
|
||||
vmNode.setExpression(dmc);
|
||||
update.setInputElement(vmNode.createVMContext(dmc));
|
||||
final IDMVMContext viewerInput= vmNode.createVMContext(dmc);
|
||||
|
||||
// provide access to viewer (needed by details pane)
|
||||
getPresentationContext().setProperty("__viewerInput", viewerInput); //$NON-NLS-1$
|
||||
|
||||
update.setInputElement(viewerInput);
|
||||
update.done();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Wind River Systems, Inc. and others.
|
||||
* Copyright (c) 2009, 2010 Wind River Systems, Inc. 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
|
||||
|
@ -24,9 +24,9 @@ import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.ExpressionsChangedEvent
|
|||
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.InvalidExpressionVMContext;
|
||||
import org.eclipse.cdt.dsf.ui.concurrent.ViewerCountingRequestMonitor;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMContext;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.AbstractVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.IVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMNode;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.debug.core.ILaunch;
|
||||
import org.eclipse.debug.core.model.IDebugTarget;
|
||||
|
@ -42,8 +42,10 @@ import org.eclipse.jface.viewers.TreePath;
|
|||
|
||||
/**
|
||||
* A VM node for displaying a single expression in the expression hover.
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class SingleExpressionVMNode extends AbstractDMVMNode implements IElementLabelProvider {
|
||||
public class SingleExpressionVMNode extends AbstractVMNode implements IElementLabelProvider {
|
||||
|
||||
private static class RootDMVMContext extends AbstractVMContext implements IDMVMContext {
|
||||
private final IDMContext fDmc;
|
||||
|
@ -72,10 +74,14 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof RootDMVMContext)) return false;
|
||||
RootDMVMContext otherVmc = (RootDMVMContext)other;
|
||||
return getVMNode().equals(otherVmc.getVMNode()) &&
|
||||
fDmc.equals(otherVmc.fDmc);
|
||||
if (this == other) {
|
||||
return true;
|
||||
}
|
||||
if (other instanceof RootDMVMContext) {
|
||||
RootDMVMContext otherVmc = (RootDMVMContext)other;
|
||||
return getVMNode().equals(otherVmc.getVMNode()) && fDmc.equals(otherVmc.fDmc);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -111,7 +117,20 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
public Object getAdapter(Class adapter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof SimpleExpression) {
|
||||
return fExpressionText.equals(((SimpleExpression) obj).getExpressionText());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return fExpressionText.hashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private static class SingleExpressionManager {
|
||||
|
@ -133,7 +152,7 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
private final SingleExpressionManager fManager;
|
||||
|
||||
public SingleExpressionVMNode(ExpressionVMProvider provider) {
|
||||
super(provider, provider.getSession(), IExpressionDMContext.class);
|
||||
super(provider);
|
||||
fManager = new SingleExpressionManager();
|
||||
}
|
||||
|
||||
|
@ -146,7 +165,6 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
return (ExpressionVMProvider)getVMProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(IHasChildrenUpdate[] updates) {
|
||||
// Test availability of children based on whether there are any expressions
|
||||
// in the manager. We assume that the getExpressions() will just read
|
||||
|
@ -158,7 +176,6 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(IChildrenCountUpdate[] updates) {
|
||||
for (IChildrenCountUpdate update : updates) {
|
||||
if (!checkUpdate(update)) continue;
|
||||
|
@ -170,7 +187,6 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(final IChildrenUpdate[] updates) {
|
||||
for (IChildrenUpdate update : updates) {
|
||||
doUpdateChildren(update);
|
||||
|
@ -294,7 +310,7 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
: -1;
|
||||
getExpressionVMProvider().buildDeltaForExpression(
|
||||
event.getExpressions()[i], expIndex, event, parentDelta, getTreePathFromDelta(parentDelta),
|
||||
new RequestMonitor(getExecutor(), multiRm));
|
||||
new RequestMonitor(getExecutor(), multiRm));
|
||||
}
|
||||
multiRm.setDoneCount(event.getExpressions().length);
|
||||
}
|
||||
|
@ -310,19 +326,14 @@ public class SingleExpressionVMNode extends AbstractDMVMNode implements IElement
|
|||
return new TreePath(elementList.toArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateElementsInSessionThread(IChildrenUpdate update) {
|
||||
doUpdateChildren(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IDMVMContext createVMContext(IDMContext dmc) {
|
||||
return new RootDMVMContext(getVMProvider().getRootVMNode(), dmc);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.1
|
||||
*/
|
||||
public void setExpression(IExpressionDMContext dmc) {
|
||||
String text = dmc.getExpression();
|
||||
fManager.setExpression(new SimpleExpression(text));
|
||||
|
|
Loading…
Add table
Reference in a new issue