From 94f0b1a811ea6dfa70a03e5d9a38bf8090bb59bc Mon Sep 17 00:00:00 2001 From: Randy Rohrbach Date: Fri, 16 May 2008 19:45:43 +0000 Subject: [PATCH] Bugzilla 211487. --- .../register/RegisterRootDMVMNode.java | 50 +++++++ .../register/RegisterVMProvider.java | 129 +++++++++++++++++- 2 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterRootDMVMNode.java diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterRootDMVMNode.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterRootDMVMNode.java new file mode 100644 index 00000000000..4f4a16d1b9d --- /dev/null +++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterRootDMVMNode.java @@ -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(); } + } +} diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterVMProvider.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterVMProvider.java index 6d63f52debc..4fb90cf8903 100644 --- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterVMProvider.java +++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/provisional/ui/viewmodel/register/RegisterVMProvider.java @@ -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(); + } + } }