mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 203597 - [number format detail] Details pane displays live values when view is in Manul Update mode
This commit is contained in:
parent
f88b03fbd0
commit
97c4e5d095
1 changed files with 74 additions and 26 deletions
|
@ -45,9 +45,14 @@ import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMContext;
|
||||||
import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMData;
|
import org.eclipse.dd.dsf.debug.service.IRegisters.IRegisterDMData;
|
||||||
import org.eclipse.dd.dsf.debug.ui.IDsfDebugUIConstants;
|
import org.eclipse.dd.dsf.debug.ui.IDsfDebugUIConstants;
|
||||||
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
import org.eclipse.dd.dsf.service.DsfServicesTracker;
|
||||||
|
import org.eclipse.dd.dsf.ui.viewmodel.IVMNode;
|
||||||
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
import org.eclipse.dd.dsf.ui.viewmodel.update.AbstractCachingVMProvider;
|
||||||
|
import org.eclipse.debug.core.model.IDebugModelProvider;
|
||||||
import org.eclipse.debug.core.model.IValue;
|
import org.eclipse.debug.core.model.IValue;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
|
||||||
|
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
|
||||||
import org.eclipse.debug.ui.IDebugModelPresentation;
|
import org.eclipse.debug.ui.IDebugModelPresentation;
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
import org.eclipse.debug.ui.IDebugView;
|
import org.eclipse.debug.ui.IDebugView;
|
||||||
|
@ -76,7 +81,10 @@ import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.ITreeSelection;
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.TreePath;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.custom.StyledText;
|
import org.eclipse.swt.custom.StyledText;
|
||||||
import org.eclipse.swt.events.FocusAdapter;
|
import org.eclipse.swt.events.FocusAdapter;
|
||||||
|
@ -91,6 +99,7 @@ import org.eclipse.swt.widgets.Control;
|
||||||
import org.eclipse.swt.widgets.Menu;
|
import org.eclipse.swt.widgets.Menu;
|
||||||
import org.eclipse.ui.IViewSite;
|
import org.eclipse.ui.IViewSite;
|
||||||
import org.eclipse.ui.IWorkbenchActionConstants;
|
import org.eclipse.ui.IWorkbenchActionConstants;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.IWorkbenchPartSite;
|
import org.eclipse.ui.IWorkbenchPartSite;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
import org.eclipse.ui.actions.ActionFactory;
|
import org.eclipse.ui.actions.ActionFactory;
|
||||||
|
@ -104,6 +113,7 @@ import org.eclipse.ui.texteditor.IUpdate;
|
||||||
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
|
import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
|
||||||
import org.eclipse.ui.texteditor.StatusLineContributionItem;
|
import org.eclipse.ui.texteditor.StatusLineContributionItem;
|
||||||
|
|
||||||
|
@SuppressWarnings("restriction")
|
||||||
public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropertyChangeListener {
|
public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropertyChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,15 +288,20 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
* Job to compute the details for a selection
|
* Job to compute the details for a selection
|
||||||
*/
|
*/
|
||||||
class DetailJob extends Job implements IValueDetailListener {
|
class DetailJob extends Job implements IValueDetailListener {
|
||||||
|
private IPresentationContext fPresentationContext;
|
||||||
private IStructuredSelection fElements;
|
private Object fViewerInput;
|
||||||
|
private ITreeSelection fElements;
|
||||||
private boolean fFirst = true;
|
private boolean fFirst = true;
|
||||||
private IProgressMonitor fMonitor;
|
private IProgressMonitor fMonitor;
|
||||||
private boolean fComputed = false;
|
private boolean fComputed = false;
|
||||||
|
|
||||||
public DetailJob(IStructuredSelection elements, IDebugModelPresentation model) {
|
public DetailJob(IPresentationContext context, Object viewerInput, ITreeSelection elements,
|
||||||
|
IDebugModelPresentation model)
|
||||||
|
{
|
||||||
super("compute variable details"); //$NON-NLS-1$
|
super("compute variable details"); //$NON-NLS-1$
|
||||||
setSystem(true);
|
setSystem(true);
|
||||||
|
fPresentationContext = context;
|
||||||
|
fViewerInput = viewerInput;
|
||||||
fElements = elements;
|
fElements = elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +310,10 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
* for a given element. It is expected and required that this routine will be
|
* for a given element. It is expected and required that this routine will be
|
||||||
* called from within a DSF executor.
|
* called from within a DSF executor.
|
||||||
*/
|
*/
|
||||||
private void putInformationIntoDetailPane( final IFormattedDataDMContext finalDmc ,
|
private void putInformationIntoDetailPane( final AbstractCachingVMProvider provider,
|
||||||
|
final IVMNode node,
|
||||||
|
final TreePath path,
|
||||||
|
final IFormattedDataDMContext finalDmc ,
|
||||||
final IFormattedValues service,
|
final IFormattedValues service,
|
||||||
final IProgressMonitor monitor,
|
final IProgressMonitor monitor,
|
||||||
final String name ) {
|
final String name ) {
|
||||||
|
@ -381,8 +399,20 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
*/
|
*/
|
||||||
final FormattedValueDMContext valueDmc = service.getFormattedValueContext(finalDmc, str);
|
final FormattedValueDMContext valueDmc = service.getFormattedValueContext(finalDmc, str);
|
||||||
|
|
||||||
service.getFormattedExpressionValue(
|
provider.getModelData(
|
||||||
valueDmc,
|
node,
|
||||||
|
new IViewerUpdate() {
|
||||||
|
public void cancel() {}
|
||||||
|
public void done() {}
|
||||||
|
public Object getViewerInput() { return fViewerInput; }
|
||||||
|
public TreePath getElementPath() { return path; }
|
||||||
|
public Object getElement() { return path.getLastSegment(); }
|
||||||
|
public IPresentationContext getPresentationContext() { return fPresentationContext; }
|
||||||
|
public boolean isCanceled() { return monitor.isCanceled(); }
|
||||||
|
public void setStatus(IStatus status) {}
|
||||||
|
public IStatus getStatus() { return null; }
|
||||||
|
},
|
||||||
|
service, valueDmc,
|
||||||
new DataRequestMonitor<FormattedValueDMData>(service.getExecutor(), null) {
|
new DataRequestMonitor<FormattedValueDMData>(service.getExecutor(), null) {
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted() {
|
public void handleCompleted() {
|
||||||
|
@ -411,8 +441,8 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
}
|
}
|
||||||
countingRm.done();
|
countingRm.done();
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
provider.getExecutor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -426,7 +456,6 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(final IProgressMonitor monitor) {
|
protected IStatus run(final IProgressMonitor monitor) {
|
||||||
|
|
||||||
|
@ -435,17 +464,19 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
fMonitor.setCanceled(true);
|
fMonitor.setCanceled(true);
|
||||||
}
|
}
|
||||||
fMonitor = monitor;
|
fMonitor = monitor;
|
||||||
Iterator<Object> iterator = fElements.iterator();
|
TreePath[] paths = fElements.getPaths();
|
||||||
while (iterator.hasNext()) {
|
for (int i = 0; i < paths.length; i++) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Object element = iterator.next();
|
final TreePath path = paths[i];
|
||||||
|
Object element = paths[i].getLastSegment();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure this is an element we want to deal with.
|
* Make sure this is an element we want to deal with.
|
||||||
*/
|
*/
|
||||||
if ( element instanceof IDMVMContext) {
|
if ( element instanceof IDMVMContext) {
|
||||||
|
IDMVMContext vmc = (IDMVMContext)element;
|
||||||
/*
|
/*
|
||||||
* We are specifically looking to support the following Data Model Contexts
|
* We are specifically looking to support the following Data Model Contexts
|
||||||
*
|
*
|
||||||
|
@ -468,10 +499,12 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
* register not the bit field.
|
* register not the bit field.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DsfServicesTracker tracker = new DsfServicesTracker(DsfDebugUIPlugin.getBundleContext(), ((IDMVMContext) element).getDMContext().getSessionId());
|
DsfServicesTracker tracker = new DsfServicesTracker(DsfDebugUIPlugin.getBundleContext(), vmc.getDMContext().getSessionId());
|
||||||
|
|
||||||
|
final AbstractCachingVMProvider provider = (AbstractCachingVMProvider)vmc.getAdapter(AbstractCachingVMProvider.class);
|
||||||
|
final IVMNode node = (IVMNode)vmc.getAdapter(IVMNode.class);
|
||||||
|
|
||||||
final IBitFieldDMContext bitfieldDmc = DMContexts.getAncestorOfType(((IDMVMContext) element).getDMContext(), IBitFieldDMContext.class);
|
final IBitFieldDMContext bitfieldDmc = DMContexts.getAncestorOfType(((IDMVMContext) element).getDMContext(), IBitFieldDMContext.class);
|
||||||
|
|
||||||
if ( bitfieldDmc != null ) {
|
if ( bitfieldDmc != null ) {
|
||||||
/*
|
/*
|
||||||
* Get the name so we can construct the header which identifies the detail
|
* Get the name so we can construct the header which identifies the detail
|
||||||
|
@ -488,7 +521,7 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted() {
|
public void handleCompleted() {
|
||||||
if (getStatus().isOK()) {
|
if (getStatus().isOK()) {
|
||||||
putInformationIntoDetailPane(bitfieldDmc , regService, monitor, getData().getName());
|
putInformationIntoDetailPane(provider, node, path, bitfieldDmc , regService, monitor, getData().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -516,7 +549,7 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
@Override
|
@Override
|
||||||
public void handleCompleted() {
|
public void handleCompleted() {
|
||||||
if (getStatus().isOK()) {
|
if (getStatus().isOK()) {
|
||||||
putInformationIntoDetailPane(regDmc , regService, monitor, getData().getName());
|
putInformationIntoDetailPane(provider, node, path, regDmc , regService, monitor, getData().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,7 +567,7 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
exprService.getExecutor().submit(
|
exprService.getExecutor().submit(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
putInformationIntoDetailPane(exprDmc , exprService, monitor, exprDmc.getExpression());
|
putInformationIntoDetailPane(provider, node, path, exprDmc , exprService, monitor, exprDmc.getExpression());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -870,25 +903,40 @@ public class NumberFormatDetailPane implements IDetailPane, IAdaptable, IPropert
|
||||||
|
|
||||||
fLastDisplayed = selection;
|
fLastDisplayed = selection;
|
||||||
|
|
||||||
if (selection.isEmpty()){
|
if ( selection.isEmpty() || !(selection instanceof ITreeSelection) ) {
|
||||||
clearSourceViewer();
|
clearSourceViewer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object firstElement = selection.getFirstElement();
|
Object firstElement = selection.getFirstElement();
|
||||||
if (firstElement != null && firstElement instanceof IDebugElement) {
|
if (firstElement instanceof IAdaptable) {
|
||||||
String modelID = ((IDebugElement)firstElement).getModelIdentifier();
|
IDebugModelProvider debugModelProvider =
|
||||||
setDebugModel(modelID);
|
(IDebugModelProvider)((IAdaptable)firstElement).getAdapter(IDebugModelProvider.class);
|
||||||
|
if (debugModelProvider != null) {
|
||||||
|
String[] ids = debugModelProvider.getModelIdentifiers();
|
||||||
|
if (ids != null && ids.length > 0) {
|
||||||
|
setDebugModel(ids[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (fDetailJob != null) {
|
if (fDetailJob != null) {
|
||||||
fDetailJob.cancel();
|
fDetailJob.cancel();
|
||||||
}
|
}
|
||||||
fDetailJob = new DetailJob(selection, null);
|
IWorkbenchPart part = fWorkbenchPartSite.getPart();
|
||||||
|
if (part instanceof IDebugView) {
|
||||||
|
Viewer viewer = ((IDebugView)part).getViewer();
|
||||||
|
Object input = viewer.getInput();
|
||||||
|
if (input != null && viewer instanceof TreeModelViewer) {
|
||||||
|
TreeModelViewer treeModelViewer = (TreeModelViewer)viewer;
|
||||||
|
fDetailJob = new DetailJob(treeModelViewer.getPresentationContext(), input,
|
||||||
|
(ITreeSelection)selection, null);
|
||||||
fDetailJob.schedule();
|
fDetailJob.schedule();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.debug.ui.IDetailPane#setFocus()
|
* @see org.eclipse.debug.ui.IDetailPane#setFocus()
|
||||||
|
|
Loading…
Add table
Reference in a new issue