1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-02 22:55:26 +02:00

Bugzilla 211487.

This commit is contained in:
Randy Rohrbach 2008-05-16 19:45:43 +00:00
parent 03d512d2ef
commit 94f0b1a811
2 changed files with 174 additions and 5 deletions

View file

@ -0,0 +1,50 @@
/*******************************************************************************
* Copyright (c) 2008 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.RootDMVMNode;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
@SuppressWarnings("restriction")
public class RegisterRootDMVMNode extends RootDMVMNode implements IElementMementoProvider {
/*
* We are extending the ROOT VM node for the register view so we can provide Memento providers for the root
* node. In the Register VM Provider we are returning a pseudo VMContext selection when the original input
* is a StackFrame we return a selection which represents an Execution Context instead. This ensures that
* the Register View does not collapse and redraw when going from frame to frame when stepping or just when
* selecting within the view.
*/
public RegisterRootDMVMNode(AbstractVMProvider provider) {
super(provider);
}
/*
* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[])
*/
public void compareElements(IElementCompareRequest[] requests) {
for ( IElementCompareRequest request : requests ) { request.done(); }
}
/*
* (non-Javadoc)
* @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[])
*/
public void encodeElements(IElementMementoRequest[] requests) {
for ( IElementMementoRequest request : requests ) { request.done(); }
}
}

View file

@ -10,20 +10,26 @@
*******************************************************************************/
package org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.register;
import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.numberformat.FormattedValuePreferenceStore;
import org.eclipse.dd.dsf.debug.internal.provisional.ui.viewmodel.update.BreakpointHitUpdatePolicy;
import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.dd.dsf.debug.service.IRunControl.ISuspendedDMEvent;
import org.eclipse.dd.dsf.debug.service.IStack.IFrameDMContext;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMContext;
import org.eclipse.dd.dsf.ui.viewmodel.IRootVMNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMNode;
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.RootDMVMNode;
import org.eclipse.dd.dsf.ui.viewmodel.datamodel.IDMVMContext;
import org.eclipse.dd.dsf.ui.viewmodel.update.AutomaticUpdatePolicy;
import org.eclipse.dd.dsf.ui.viewmodel.update.IVMUpdatePolicy;
import org.eclipse.dd.dsf.ui.viewmodel.update.ManualUpdatePolicy;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
@ -50,7 +56,7 @@ public class RegisterVMProvider extends AbstractDMVMProvider
/*
* Create the top level node to deal with the root selection.
*/
IRootVMNode rootNode = new RootDMVMNode(this);
IRootVMNode rootNode = new RegisterRootDMVMNode(this);
/*
* Create the Group nodes next. They represent the first level shown in the view.
@ -76,37 +82,150 @@ public class RegisterVMProvider extends AbstractDMVMProvider
setRootNode(rootNode);
}
/*
* (non-Javadoc)
* @see org.eclipse.dd.dsf.ui.viewmodel.update.AbstractCachingVMProvider#createUpdateModes()
*/
@Override
protected IVMUpdatePolicy[] createUpdateModes() {
return new IVMUpdatePolicy[] { new AutomaticUpdatePolicy(), new ManualUpdatePolicy(), new BreakpointHitUpdatePolicy() };
}
/*
* (non-Javadoc)
* @see org.eclipse.dd.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider#dispose()
*/
@Override
public void dispose() {
getPresentationContext().removePropertyChangeListener(this);
super.dispose();
}
/*
* (non-Javadoc)
* @see org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider#createColumnPresentation(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
*/
@Override
public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
return new RegisterColumnPresentation();
}
/*
* (non-Javadoc)
* @see org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider#getColumnPresentationId(org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext, java.lang.Object)
*/
@Override
public String getColumnPresentationId(IPresentationContext context, Object element) {
return RegisterColumnPresentation.ID;
}
/*
* (non-Javadoc)
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent event) {
handleEvent(event);
}
/*
* (non-Javadoc)
* @see org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider#canSkipHandlingEvent(java.lang.Object, java.lang.Object)
*/
@Override
protected boolean canSkipHandlingEvent(Object newEvent, Object eventToSkip) {
// To optimize the performance of the view when stepping rapidly, skip all
// other events when a suspended event is received, including older suspended
// events.
/*
* To optimize the performance of the view when stepping rapidly, skip all
* other events when a suspended event is received, including older suspended
* events.
*/
return newEvent instanceof ISuspendedDMEvent;
}
/*
* (non-Javadoc)
* @see org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider#update(org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerInputUpdate)
*/
@Override
public void update(IViewerInputUpdate update) {
/*
* Get the selection input object from and see if it is a STACK FRAME. If not then do
* the standard policy. If it is then we will always provide and execution selection.
* This insures that the REGISTER VIEW will not collapse and expand on stepping or on
* re-selection in the DEBUG VIEW. Currently the register content is not stack frame
* specific. If it were to become so then we would need to modify this policy.
*/
Object element = update.getElement();
IDMContext ctx = ((IDMVMContext) element).getDMContext();
if ( ctx instanceof IFrameDMContext ) {
IExecutionDMContext execDmc = DMContexts.getAncestorOfType(ctx, IExecutionDMContext.class);
if ( execDmc != null ) {
/*
* This tells the Flexible Hierarchy that element driving this view has not changed
* and there is no need to redraw the view. Since this is a somewhat fake VMContext
* we provide our Root Layout node as the representative VM node.
*/
update.setInputElement(new ViewInputElement(RegisterVMProvider.this.getRootVMNode(), execDmc));
update.done();
return;
}
}
/*
* If we reach here, then we did not override the standard behavior. Invoke the
* super class and this will provide the default standard behavior.
*/
super.update(update);
}
/*
* Provides a local implementation of the IDMVMContext. This allows us to return one
* of our own making, representing the DMContext we want to use as selection criteria.
*/
private class ViewInputElement extends AbstractVMContext implements IDMVMContext {
final private IDMContext fDMContext;
public ViewInputElement(IVMNode node, IDMContext dmc) {
super(node);
fDMContext = dmc;
}
public IDMContext getDMContext() {
return fDMContext;
}
/**
* The IAdaptable implementation. If the adapter is the DM context,
* return the context, otherwise delegate to IDMContext.getAdapter().
*/
@Override
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) {
Object superAdapter = super.getAdapter(adapter);
if (superAdapter != null) {
return superAdapter;
} else {
// Delegate to the Data Model to find the context.
if (adapter.isInstance(fDMContext)) {
return fDMContext;
} else {
return fDMContext.getAdapter(adapter);
}
}
}
@Override
public boolean equals(Object obj) {
if ( obj instanceof ViewInputElement && ((ViewInputElement) obj).fDMContext.equals(fDMContext) ) {
return true;
}
return false;
}
@Override
public int hashCode() {
return fDMContext.hashCode();
}
}
}