1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Replaced IRootVMLayoutNode.getRootObject() with IVMProvider.getRootElement() (bug 195182).

This commit is contained in:
Pawel Piech 2007-07-02 21:27:05 +00:00
parent 68cf334f92
commit 6a33c3118c
14 changed files with 96 additions and 94 deletions

View file

@ -11,7 +11,6 @@
package org.eclipse.dd.dsf.debug.ui.viewmodel.expression;
import org.eclipse.dd.dsf.debug.service.IFormattedValues;
import org.eclipse.dd.dsf.debug.ui.viewmodel.DebugViewSelectionRootLayoutNode;
import org.eclipse.dd.dsf.debug.ui.viewmodel.formatsupport.IFormattedValuePreferenceStore;
import org.eclipse.dd.dsf.debug.ui.viewmodel.register.RegisterGroupLayoutNode;
import org.eclipse.dd.dsf.debug.ui.viewmodel.register.RegisterLayoutNode;
@ -25,6 +24,7 @@ import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProviderWithCache;
import org.eclipse.dd.dsf.ui.viewmodel.dm.DMVMRootLayoutNode;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IExpressionsListener;
import org.eclipse.debug.core.model.IExpression;
@ -71,7 +71,7 @@ public class ExpressionVMProvider extends AbstractDMVMProviderWithCache
/*
* Create the top level node which provides the anchor starting point.
*/
IVMRootLayoutNode debugViewSelectionNode = new DebugViewSelectionRootLayoutNode(this);
IVMRootLayoutNode debugViewSelectionNode = new DMVMRootLayoutNode(this);
/*
* Now the Overarching management node.
@ -145,7 +145,7 @@ public class ExpressionVMProvider extends AbstractDMVMProviderWithCache
if (rootLayoutNode == null) {
return null;
}
else if (element.equals(rootLayoutNode.getRootObject())) {
else if (element.equals(getRootElement())) {
return rootLayoutNode;
}
else if (element instanceof IVMContext){

View file

@ -17,7 +17,7 @@ import java.util.Map;
import org.eclipse.dd.dsf.concurrent.RequestMonitor;
import org.eclipse.dd.dsf.concurrent.DataRequestMonitor;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.VMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
@ -35,7 +35,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
* functionality, so the default adapters should be used to retrieve the label.
*/
@SuppressWarnings("restriction")
public class StandardLaunchRootLayoutNode extends AbstractVMRootLayoutNode
public class StandardLaunchRootLayoutNode extends VMRootLayoutNode
implements IVMRootLayoutNode
{
public static class LaunchesEvent {

View file

@ -11,13 +11,13 @@
package org.eclipse.dd.dsf.debug.ui.viewmodel.register;
import org.eclipse.dd.dsf.debug.service.IFormattedValues;
import org.eclipse.dd.dsf.debug.ui.viewmodel.DebugViewSelectionRootLayoutNode;
import org.eclipse.dd.dsf.debug.ui.viewmodel.formatsupport.IFormattedValuePreferenceStore;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProviderWithCache;
import org.eclipse.dd.dsf.ui.viewmodel.dm.DMVMRootLayoutNode;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
@ -43,7 +43,7 @@ public class RegisterVMProvider extends AbstractDMVMProviderWithCache implements
/*
* Create the top level node to deal with the root selection.
*/
IVMRootLayoutNode debugViewSelection = new DebugViewSelectionRootLayoutNode(this);
IVMRootLayoutNode debugViewSelection = new DMVMRootLayoutNode(this);
/*
* Create the Group nodes next. They represent the first level shown in the view.

View file

@ -9,13 +9,13 @@
package org.eclipse.dd.dsf.debug.ui.viewmodel.variable;
import org.eclipse.dd.dsf.debug.service.IFormattedValues;
import org.eclipse.dd.dsf.debug.ui.viewmodel.DebugViewSelectionRootLayoutNode;
import org.eclipse.dd.dsf.debug.ui.viewmodel.formatsupport.IFormattedValuePreferenceStore;
import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMAdapter;
import org.eclipse.dd.dsf.ui.viewmodel.IVMLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMProviderWithCache;
import org.eclipse.dd.dsf.ui.viewmodel.dm.DMVMRootLayoutNode;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentation;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
@ -37,7 +37,7 @@ public class VariableVMProvider extends AbstractDMVMProviderWithCache implements
/*
* Create the top level node to deal with the root selection.
*/
IVMRootLayoutNode debugViewSelection = new DebugViewSelectionRootLayoutNode(this);
IVMRootLayoutNode debugViewSelection = new DMVMRootLayoutNode(this);
/*
* Create the local variables nodes next. They represent the first level shown in the view.

View file

@ -67,15 +67,8 @@ abstract public class AbstractVMAdapter implements IVMAdapter
return fExecutor;
}
/**
* Creates a new View Model Provider for given presentation context. Returns null
* if the presentation context is not supported.
*/
@ThreadSafe
abstract protected IVMProvider createViewModelProvider(IPresentationContext context);
@ThreadSafe
private IVMProvider getViewModelProvider(IPresentationContext context) {
public IVMProvider getVMProvider(IPresentationContext context) {
synchronized(fViewModelProviders) {
if (fDisposed) return null;
@ -142,7 +135,7 @@ abstract public class AbstractVMAdapter implements IVMAdapter
}
private void callProviderWithUpdate(IViewerUpdate[] updates, int startIdx, int endIdx) {
final IVMProvider provider = getViewModelProvider(updates[0].getPresentationContext());
final IVMProvider provider = getVMProvider(updates[0].getPresentationContext());
if (provider == null) {
for (IViewerUpdate update : updates) {
update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR,
@ -175,7 +168,7 @@ abstract public class AbstractVMAdapter implements IVMAdapter
}
public IModelProxy createModelProxy(Object element, IPresentationContext context) {
IVMProvider provider = getViewModelProvider(context);
IVMProvider provider = getVMProvider(context);
if (provider != null) {
return provider.createModelProxy(element, context);
}
@ -183,7 +176,7 @@ abstract public class AbstractVMAdapter implements IVMAdapter
}
public IColumnPresentation createColumnPresentation(IPresentationContext context, Object element) {
final IVMProvider provider = getViewModelProvider(context);
final IVMProvider provider = getVMProvider(context);
if (provider != null) {
return provider.createColumnPresentation(context, element);
}
@ -191,12 +184,17 @@ abstract public class AbstractVMAdapter implements IVMAdapter
}
public String getColumnPresentationId(IPresentationContext context, Object element) {
final IVMProvider provider = getViewModelProvider(context);
final IVMProvider provider = getVMProvider(context);
if (provider != null) {
return provider.getColumnPresentationId(context, element);
}
return null;
}
/**
* Creates a new View Model Provider for given presentation context. Returns null
* if the presentation context is not supported.
*/
@ThreadSafe
abstract protected IVMProvider createViewModelProvider(IPresentationContext context);
}

View file

@ -447,7 +447,7 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode {
return path.getLastSegment();
}
// Calculate the root of the viewer.
return getVMProvider().getRootLayoutNode().getRootObject();
return getVMProvider().getRootElement();
}
public Object getElement() {

View file

@ -62,8 +62,21 @@ import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapt
@SuppressWarnings("restriction")
abstract public class AbstractVMProvider implements IVMProvider
{
/** Reference to the VM adapter that owns this provider */
private final AbstractVMAdapter fVMAdapter;
/** The presentation context that this provider is associated with */
private final IPresentationContext fPresentationContext;
/**
* The current root element of this view model. This element is obtained
* from the argument to {@link #createModelProxy(Object, IPresentationContext)}.
*/
private Object fRootElement;
/**
*
*/
private ModelProxy fModelProxy = new ModelProxy();
private boolean fDisposed = false;
@ -104,10 +117,16 @@ abstract public class AbstractVMProvider implements IVMProvider
}
}
@ThreadSafe
protected synchronized ModelProxy getModelProxy() {
return fModelProxy;
}
@ThreadSafe
public synchronized Object getRootElement() {
return fRootElement;
}
@ThreadSafe
public IVMRootLayoutNode getRootLayoutNode() {
return fRootLayoutNodeRef.get();
@ -385,19 +404,17 @@ abstract public class AbstractVMProvider implements IVMProvider
public ModelProxy createModelProxy(Object element, IPresentationContext context) {
/*
* Model proxy is the object that correlates events from the data model
* into view model deltas that the view can process. We only need to
* create a proxy for the root element of the tree.
* into view model deltas that the view can process. This method is called
* by the viewer when a new input object is set to the view. We need to create
* a new instance of the ModelProxy object with every call, because the viewer
* disposes the old proxy before calling this method.
*/
if (getRootLayoutNode() != null &&
element.equals(getRootLayoutNode().getRootObject()))
{
synchronized(this) {
fRootElement = element;
fModelProxy = new ModelProxy();
}
return fModelProxy;
}
return null;
}
/**
* Creates the column presentation for the given object. This method is meant
@ -456,7 +473,7 @@ abstract public class AbstractVMProvider implements IVMProvider
if (rootLayoutNode == null) {
return null;
}
else if (element.equals(rootLayoutNode.getRootObject())) {
else if (element.equals(getRootElement())) {
return rootLayoutNode;
}
else if (element instanceof IVMContext){

View file

@ -4,6 +4,7 @@ import org.eclipse.dd.dsf.concurrent.ThreadSafe;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
/**
* The View Model adapter handles the layout of a given data model within a
@ -16,4 +17,9 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelProxyFactor
public interface IVMAdapter
extends IElementContentProvider, IModelProxyFactory, IColumnPresentationFactory
{
/**
* Returns the View Model Provider that is registered for the given presentation
* context. Returns <code>null</code> if there is none.
*/
public IVMProvider getVMProvider(IPresentationContext presentationContext);
}

View file

@ -22,6 +22,15 @@ public interface IVMProvider
*/
public IVMRootLayoutNode getRootLayoutNode();
/**
* Returns the root element of the view model. If the given view model is
* used to populate the entire contents of the view, then this is the input
* element for the viewer. If the view model is used to populate only a
* sub-tree section of the view, then this is the root element of that
* sub-tree.
*/
public Object getRootElement();
/**
* Returns the presentation context of the viewer that this provider
* is configured for.
@ -32,4 +41,5 @@ public interface IVMProvider
* Cleans up the resources associated with this provider.
*/
public void dispose();
}

View file

@ -21,14 +21,6 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
@SuppressWarnings("restriction")
public interface IVMRootLayoutNode extends IVMLayoutNode{
/**
* Returns the single element of this node. Root layout node can only have
* one element, and this is a convenience method to access this element.
* Alternatively getElements() could be used.
* @return
*/
public Object getRootObject();
/**
* Version of the {@link IVMLayoutNode#buildDelta(Object, ViewModelDelta, org.eclipse.dd.dsf.concurrent.RequestMonitor)}
* method, which creates and returns the root node of the delta. It does

View file

@ -21,28 +21,29 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
/**
*
* Default implementation of a root layout node. This class may be sub-classed
* to implement model-specific event handling.
*/
@SuppressWarnings("restriction")
abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode implements IVMRootLayoutNode {
public class VMRootLayoutNode extends AbstractVMLayoutNode implements IVMRootLayoutNode {
public AbstractVMRootLayoutNode(AbstractVMProvider provider) {
public VMRootLayoutNode(AbstractVMProvider provider) {
super(provider);
}
/**
* This implementation only fulfils the requirements of the super-interface.
* This implementation only fulfills the requirements of the super-interface.
* There is no use case for a root node implementing this method, but its
* easier to just impelemnt it for sake of uniformity of model.
* easier to just implement it for sake of uniformity of model.
*/
public void updateElements(IChildrenUpdate update) {
// Ignore startIdx, endIdx, since there's only one element to be had.
update.setChild(getRootObject(), 0);
update.setChild(getVMProvider().getRootElement(), 0);
update.done();
}
/**
* This implementation only fulfils the requirements of the super-interface.
* This implementation only fulfills the requirements of the super-interface.
* There is no use case for a root node implementing this method, but its
* easier to just impelemnt it for sake of uniformity of model.
*/
@ -52,9 +53,9 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
}
/**
* This implementation only fulfils the requirements of the super-interface.
* This implementation only fulfills the requirements of the super-interface.
* There is no use case for a root node implementing this method, but its
* easier to just impelemnt it for sake of uniformity of model.
* easier to just implement it for sake of uniformity of model.
*/
public void updateHasElements(IHasChildrenUpdate[] updates) {
for (IHasChildrenUpdate update : updates) {
@ -64,9 +65,9 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
}
/**
* This implementation only fulfils the requirements of the super-interface.
* This implementation only fulfills the requirements of the super-interface.
* There is no use case for a root node implementing this method, but its
* easier to just impelemnt it for sake of uniformity of model.
* easier to just implement it for sake of uniformity of model.
*/
public void updateLabel(@SuppressWarnings("unused")
IVMContext vmc, ILabelUpdate update) {
@ -82,7 +83,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
assert childNodeDeltas.size() != 0 : "Caller should make sure that there are deltas for given event."; //$NON-NLS-1$
// Always create the rootDelta, no matter what delta flags the child nodes have.
final VMDelta rootDelta = new VMDelta(getRootObject(), IModelDelta.NO_CHANGE);
final VMDelta rootDelta = new VMDelta(getVMProvider().getRootElement(), IModelDelta.NO_CHANGE);
callChildNodesToBuildDelta(
childNodeDeltas, rootDelta, event,
@ -99,4 +100,8 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
}
});
}
public Object getRootObject() {
return getVMProvider().getRootElement();
}
}

View file

@ -534,7 +534,7 @@ abstract public class AbstractDMVMLayoutNode<V extends IDMData> extends Abstract
}
// Search the root object of the layout hierarchy.
if (retVal == null) {
Object inputObject = getVMProvider().getRootLayoutNode().getRootObject();
Object inputObject = getVMProvider().getRootElement();
if (inputObject instanceof ITreeSelection) {
ITreeSelection inputSelection = (ITreeSelection)inputObject;
if (inputSelection.getPaths().length == 1) {

View file

@ -34,7 +34,7 @@ public abstract class AbstractDMVMProviderWithCache extends AbstractDMVMProvider
public void cacheFlushed(Object context) {
if(getPresentationContext().equals(context))
getModelProxy().fireModelChanged(new ModelDelta(this.getRootLayoutNode().getRootObject(),IModelDelta.CONTENT));
getModelProxy().fireModelChanged(new ModelDelta(getRootElement(),IModelDelta.CONTENT));
}
public AbstractDMVMProviderWithCache(AbstractVMAdapter adapter, IPresentationContext presentationContext, DsfSession session) {

View file

@ -8,21 +8,16 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.dd.dsf.debug.ui.viewmodel;
package org.eclipse.dd.dsf.ui.viewmodel.dm;
import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.datamodel.IDMEvent;
import org.eclipse.dd.dsf.debug.ui.DsfDebugUIPlugin;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMProvider;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.VMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.dm.AbstractDMVMLayoutNode.DMVMContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchWindow;
/**
* This is is a standard root node which listens to the selection in Debug View.
@ -36,13 +31,11 @@ import org.eclipse.ui.IWorkbenchWindow;
* whole selection.
*/
@SuppressWarnings("restriction")
public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
public class DMVMRootLayoutNode extends VMRootLayoutNode
implements IVMRootLayoutNode
{
private final IWorkbenchWindow fWindow;
public DebugViewSelectionRootLayoutNode(AbstractVMProvider provider) {
public DMVMRootLayoutNode(AbstractVMProvider provider) {
super(provider);
fWindow = DsfDebugUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
}
/**
@ -91,34 +84,15 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
return super.getDeltaFlags(event);
}
/**
* Returns the full selection as it came from the DebugContextManager.
* @return
*/
public ISelection getSelection() {
return DebugUITools.getDebugContextManager().getContextService(fWindow).getActiveContext();
}
public Object getRootObject() {
ISelection selection = getSelection();
if (selection instanceof IStructuredSelection) {
return ((IStructuredSelection)selection).getFirstElement();
}
return null;
}
private IDMContext<?> getSelectedDMC() {
Object selection = getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structSelection = (IStructuredSelection)selection;
if (structSelection.getFirstElement() instanceof DMVMContext)
Object rootObject = getVMProvider().getRootElement();
if (rootObject instanceof DMVMContext)
{
// Correct cast: (AbstractDMVMLayoutNode<?>.DMVMContext) breaks the javac compiler
@SuppressWarnings("unchecked")
DMVMContext vmc = (DMVMContext)structSelection.getFirstElement();
DMVMContext vmc = (DMVMContext)rootObject;
return vmc.getDMC();
}
}
return null;
}
}