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

- Ported to new debugger command APIs (bug# 163623). This makes DSF build with 3.3 M3, but breaks compatibility with 3.2.

- Warnings cleanup.
This commit is contained in:
Pawel Piech 2006-11-08 03:00:20 +00:00
parent 26390e0a8c
commit 94841c4ee3
30 changed files with 175 additions and 176 deletions

View file

@ -11,17 +11,18 @@
package org.eclipse.dd.dsf.debug.ui.viewmodel; package org.eclipse.dd.dsf.debug.ui.viewmodel;
import org.eclipse.dd.dsf.concurrent.DsfExecutor; import org.eclipse.dd.dsf.concurrent.DsfExecutor;
import org.eclipse.dd.dsf.concurrent.DsfRunnable;
import org.eclipse.dd.dsf.datamodel.DMContexts; import org.eclipse.dd.dsf.datamodel.DMContexts;
import org.eclipse.dd.dsf.datamodel.IDMContext; import org.eclipse.dd.dsf.datamodel.IDMContext;
import org.eclipse.dd.dsf.datamodel.IDMEvent; import org.eclipse.dd.dsf.datamodel.IDMEvent;
import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMRootLayoutNode; import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode; import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode.DMContextVMContext; import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode.DMContextVMContext;
import org.eclipse.debug.internal.ui.contexts.DebugContextManager; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
/** /**
@ -29,7 +30,6 @@ import org.eclipse.ui.IWorkbenchWindow;
* Views such as variables and registers base their content based on the * Views such as variables and registers base their content based on the
* selection in Debug view, and this node provides tracking of that selection. * selection in Debug view, and this node provides tracking of that selection.
*/ */
@SuppressWarnings("restriction")
public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
implements IVMRootLayoutNode, IDebugContextListener implements IVMRootLayoutNode, IDebugContextListener
{ {
@ -37,18 +37,18 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
public DebugViewSelectionRootLayoutNode(DsfExecutor executor, IWorkbenchWindow window) { public DebugViewSelectionRootLayoutNode(DsfExecutor executor, IWorkbenchWindow window) {
super(executor); super(executor);
ISelection selection = DebugContextManager.getDefault().getActiveContext(window); ISelection selection = DebugUITools.getDebugContextManager().getContextService(window).getActiveContext();
if (selection instanceof IStructuredSelection) { if (selection instanceof IStructuredSelection) {
fRootVMC = new RootVMC<Object>( this, ((IStructuredSelection)selection).getFirstElement() ); fRootVMC = new RootVMC<Object>( this, ((IStructuredSelection)selection).getFirstElement() );
} else { } else {
fRootVMC = new RootVMC<Object>( this, null ); fRootVMC = new RootVMC<Object>( this, null );
} }
DebugContextManager.getDefault().addDebugContextListener(this, window); DebugUITools.getDebugContextManager().addDebugContextListener(this);
} }
@Override @Override
public void sessionDispose() { public void sessionDispose() {
DebugContextManager.getDefault().removeDebugContextListener(this); DebugUITools.getDebugContextManager().removeDebugContextListener(this);
super.sessionDispose(); super.sessionDispose();
} }
@ -75,17 +75,14 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
*/ */
@Override @Override
public boolean hasDeltaFlags(Object event) { public boolean hasDeltaFlags(Object event) {
/*
* TODO: This logic needs to be tested and probably enhanced.
*/
if (event instanceof IDMEvent && fRootVMC.getInputObject() instanceof DMContextVMContext) { if (event instanceof IDMEvent && fRootVMC.getInputObject() instanceof DMContextVMContext) {
boolean potentialMatchFound = false; boolean potentialMatchFound = false;
boolean matchFound = false; boolean matchFound = false;
IDMContext eventDmc = ((IDMEvent)event).getDMContext(); IDMContext<?> eventDmc = ((IDMEvent)event).getDMContext();
IDMContext inputDmc = ((DMContextVMContext)fRootVMC.getInputObject()).getDMC(); IDMContext<?> inputDmc = ((DMContextVMContext)fRootVMC.getInputObject()).getDMC();
for (IDMContext eventDmcAncestor : DMContexts.toList(eventDmc)) { for (IDMContext<?> eventDmcAncestor : DMContexts.toList(eventDmc)) {
IDMContext inputDmcAncestor = DMContexts.getAncestorOfType(inputDmc, eventDmcAncestor.getClass()); IDMContext<?> inputDmcAncestor = DMContexts.getAncestorOfType(inputDmc, eventDmcAncestor.getClass());
if (inputDmcAncestor != null) { if (inputDmcAncestor != null) {
potentialMatchFound = true; potentialMatchFound = true;
if (inputDmcAncestor.equals(eventDmcAncestor)) { if (inputDmcAncestor.equals(eventDmcAncestor)) {
@ -105,16 +102,17 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode
return fRootVMC; return fRootVMC;
} }
public void contextActivated(ISelection selection, IWorkbenchPart part) { public void debugContextChanged(DebugContextEvent event) {
if (selection instanceof IStructuredSelection) { final ISelection selection = event.getContext();
fRootVMC = new RootVMC<Object>( this, ((IStructuredSelection)selection).getFirstElement() ); getExecutor().execute(new DsfRunnable() {
} else { public void run() {
fRootVMC = new RootVMC<Object>( this, null ); if (selection instanceof IStructuredSelection) {
} fRootVMC = new RootVMC<Object>( DebugViewSelectionRootLayoutNode.this,
} ((IStructuredSelection)selection).getFirstElement() );
} else {
public void contextChanged(ISelection selection, IWorkbenchPart part) { fRootVMC = new RootVMC<Object>( DebugViewSelectionRootLayoutNode.this, null );
// No need to do anything. Element changes should be handled }
// through standard event handlers. }
});
} }
} }

View file

@ -20,9 +20,9 @@ import org.eclipse.dd.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.dd.dsf.mi.service.MIRunControl; import org.eclipse.dd.dsf.mi.service.MIRunControl;
import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.DsfSession;
import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode; import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode;
import org.eclipse.dd.dsf.ui.viewmodel.GetDataDoneWithRequestMonitor;
import org.eclipse.dd.dsf.ui.viewmodel.IVMContext; import org.eclipse.dd.dsf.ui.viewmodel.IVMContext;
import org.eclipse.dd.dsf.ui.viewmodel.VMDelta; import org.eclipse.dd.dsf.ui.viewmodel.VMDelta;
import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode.DMContextVMContext;
import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor; import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
@ -69,9 +69,16 @@ public class ThreadLayoutNode extends DMContextVMLayoutNode {
processes.getModelData( processes.getModelData(
processes.getThreadForExecutionContext(dmc), processes.getThreadForExecutionContext(dmc),
new GetDataDoneWithRequestMonitor<IThreadDMData>(result) { public void doRun() { new GetDataDone<IThreadDMData>() {
result.setLabels(new String[] { getData().getName() }); public void run() {
}}); if (!getStatus().isOK() || !getData().isValid()) {
result.done();
return;
}
result.setLabels(new String[] { getData().getName() });
result.done();
}
});
} }
public boolean hasDeltaFlagsForDMEvent(IDMEvent e) { public boolean hasDeltaFlagsForDMEvent(IDMEvent e) {

View file

@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext;
public class DsfDebugPlugin extends Plugin { public class DsfDebugPlugin extends Plugin {
// The plug-in ID // The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.dd.dsf.debug.debug.service"; public static final String PLUGIN_ID = "org.eclipse.dd.dsf.debug.debug.service"; //$NON-NLS-1$
// The shared instance // The shared instance
private static DsfDebugPlugin fgPlugin; private static DsfDebugPlugin fgPlugin;

View file

@ -26,7 +26,7 @@ public interface IBackEndProcess extends IDsfService {
* same time, a service property is needed to allow clients to distinguish * same time, a service property is needed to allow clients to distinguish
* between them. * between them.
*/ */
static final String PROCESS_ID = "org.eclipse.dsdp.DSF.debug.BackendProcess.PROCESS_ID"; static final String PROCESS_ID = "org.eclipse.dsdp.DSF.debug.BackendProcess.PROCESS_ID"; //$NON-NLS-1$
/** /**
* Event indicating that the back end process has terminated. * Event indicating that the back end process has terminated.

View file

@ -30,12 +30,12 @@ public interface IModules extends IDMService {
* types of debugging, like kernel or no-OS debugging, it's useful to * types of debugging, like kernel or no-OS debugging, it's useful to
* separate the concept of a symbol context from a process. * separate the concept of a symbol context from a process.
*/ */
public interface ISymbolDMContext extends IDMContext {} public interface ISymbolDMContext extends IDMContext<ISymbolDMData>{}
/** /**
* Module context represents a single module that is loaded. * Module context represents a single module that is loaded.
*/ */
public interface IModuleDMContext extends IDMContext<ModuleDMData> {} public interface IModuleDMContext extends IDMContext<IModuleDMData> {}
/** /**
* Event indicating a change in the symbol information for given context. * Event indicating a change in the symbol information for given context.
@ -90,7 +90,7 @@ public interface IModules extends IDMService {
* Symbol context data includes a mapping between run-time addresses and * Symbol context data includes a mapping between run-time addresses and
* module-section-offset coordinates. * module-section-offset coordinates.
*/ */
public interface SymbolDMData extends IDMData { public interface ISymbolDMData extends IDMData {
/** Convert link-time address 'addr' to run-time address */ /** Convert link-time address 'addr' to run-time address */
public long convertToRT(ModuleSectionOffset mso); public long convertToRT(ModuleSectionOffset mso);
@ -99,7 +99,7 @@ public interface IModules extends IDMService {
} }
/** Module information. */ /** Module information. */
public interface ModuleDMData extends IDMData { public interface IModuleDMData extends IDMData {
String getName(); String getName();
String getFile(); String getFile();
long getTimeStamp(); long getTimeStamp();

View file

@ -29,7 +29,7 @@ public interface ITargets extends IDMService {
boolean isConnected(); boolean isConnected();
} }
public interface ITargetStateChanged extends IDMEvent {} public interface ITargetStateChanged extends IDMEvent<ITargetDMContext> {}
public interface ICoreDMContext extends IDMContext<ICoreDMData> {} public interface ICoreDMContext extends IDMContext<ICoreDMData> {}
@ -39,7 +39,7 @@ public interface ITargets extends IDMService {
IOS.IOSDMContext getOSDMContext(); IOS.IOSDMContext getOSDMContext();
} }
public interface ICoreStateChangedDMEvent extends IDMEvent {} public interface ICoreStateChangedDMEvent extends IDMEvent<ICoreDMContext> {}
public void getTargets(GetDataDone<ITargetDMContext> done); public void getTargets(GetDataDone<ITargetDMContext> done);
public void getCores(ITargetDMContext target, GetDataDone<ICoreDMContext> done); public void getCores(ITargetDMContext target, GetDataDone<ICoreDMContext> done);

View file

@ -19,7 +19,7 @@ import org.osgi.framework.BundleContext;
public class DsfUIPlugin extends AbstractUIPlugin { public class DsfUIPlugin extends AbstractUIPlugin {
// The plug-in ID // The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.dd.dsf.ui"; public static final String PLUGIN_ID = "org.eclipse.dd.dsf.ui"; //$NON-NLS-1$
// The shared instance // The shared instance
private static DsfUIPlugin fgPlugin; private static DsfUIPlugin fgPlugin;

View file

@ -98,13 +98,13 @@ abstract public class AbstractVMAdapter
VMProvider provider = getViewModelProvider(context); VMProvider provider = getViewModelProvider(context);
if (provider == null) { if (provider == null) {
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + object.toString(), null)); result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + object.toString(), null)); //$NON-NLS-1$
result.done(); result.done();
} }
provider.retrieveLabel(object, result); provider.retrieveLabel(object, result);
} }
@Override @Override
public String toString() { return "Switch to dispatch thread to execute retrieveLabel()"; } public String toString() { return "Switch to dispatch thread to execute retrieveLabel()"; } //$NON-NLS-1$
}); });
} catch(RejectedExecutionException e) { } catch(RejectedExecutionException e) {
// This can happen if session is being shut down. // This can happen if session is being shut down.
@ -120,12 +120,12 @@ abstract public class AbstractVMAdapter
VMProvider provider = getViewModelProvider(context); VMProvider provider = getViewModelProvider(context);
if (provider == null) { if (provider == null) {
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null)); result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null)); //$NON-NLS-1$
result.done(); result.done();
} }
provider.isContainer(element, result); provider.isContainer(element, result);
} }
public String toString() { return "Switch to dispatch thread to execute isContainer()"; } public String toString() { return "Switch to dispatch thread to execute isContainer()"; } //$NON-NLS-1$
}); });
} catch(RejectedExecutionException e) { } catch(RejectedExecutionException e) {
// This can happen if session is being shut down. // This can happen if session is being shut down.
@ -141,12 +141,12 @@ abstract public class AbstractVMAdapter
VMProvider provider = getViewModelProvider(context); VMProvider provider = getViewModelProvider(context);
if (provider == null) { if (provider == null) {
result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null)); result.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfService.INTERNAL_ERROR, "No model provider for object: " + element.toString(), null)); //$NON-NLS-1$
result.done(); result.done();
} }
provider.retrieveChildren(element, result); provider.retrieveChildren(element, result);
} }
public String toString() { return "Switch to dispatch thread to execute retrieveChildren()"; } public String toString() { return "Switch to dispatch thread to execute retrieveChildren()"; } //$NON-NLS-1$
}); });
} catch(RejectedExecutionException e) { } catch(RejectedExecutionException e) {
// This can happen if session is being shut down. // This can happen if session is being shut down.
@ -155,8 +155,13 @@ abstract public class AbstractVMAdapter
} }
public IModelProxy createModelProxy(Object element, IPresentationContext context) { public IModelProxy 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.
*/
VMProvider provider = getViewModelProvider(context); VMProvider provider = getViewModelProvider(context);
if (provider != null) { if (provider != null && element.equals(provider.getRootLayoutNode().getRootVMC().getInputObject())) {
return provider.getModelProxy(); return provider.getModelProxy();
} }
return null; return null;

View file

@ -94,7 +94,16 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode {
parent.getVMC(), parent.getVMC(),
new GetDataDone<IVMContext[]>() { new GetDataDone<IVMContext[]>() {
public void run() { public void run() {
if (propagateError(getExecutor(), done, "Failed to retrieve elements in layout node " + AbstractVMLayoutNode.this)) return; if (propagateError(getExecutor(), done, "Failed to retrieve elements in layout node " + AbstractVMLayoutNode.this)) return; //$NON-NLS-1$
/*
* Check for an empty list of elements. If it's empty then we
* don't have to call the children nodes, so return here.
*/
if (getData().length == 0) {
getExecutor().execute(done);
}
/* /*
* The execution for this node is not done until all the child nodes * The execution for this node is not done until all the child nodes
* are done. Use the tracker to wait for all children to complete. * are done. Use the tracker to wait for all children to complete.
@ -152,7 +161,7 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode {
* that the layout node depends on, are not available. * that the layout node depends on, are not available.
*/ */
protected void handleFailedRetrieveLabel(ILabelRequestMonitor result) { protected void handleFailedRetrieveLabel(ILabelRequestMonitor result) {
result.setLabels(new String[] { "..."} ); result.setLabels(new String[] { "..."} ); //$NON-NLS-1$
result.done(); result.done();
} }

View file

@ -39,6 +39,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
public IVMLayoutNode getLayoutNode() { return fVMRootLayoutNode; } public IVMLayoutNode getLayoutNode() { return fVMRootLayoutNode; }
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
if (fInputObject instanceof IAdaptable) { if (fInputObject instanceof IAdaptable) {
return ((IAdaptable)fInputObject).getAdapter(adapter); return ((IAdaptable)fInputObject).getAdapter(adapter);
@ -55,7 +56,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
return fInputObject.hashCode(); return fInputObject.hashCode();
} }
public String toString() { return "Root VMC for " + fInputObject.toString(); } public String toString() { return "Root VMC for " + fInputObject.toString(); } //$NON-NLS-1$
} }
public AbstractVMRootLayoutNode(DsfExecutor executor) { public AbstractVMRootLayoutNode(DsfExecutor executor) {
@ -111,7 +112,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl
*/ */
final DoneCollector doneCollector = new DoneCollector(getExecutor()) { final DoneCollector doneCollector = new DoneCollector(getExecutor()) {
public void run() { public void run() {
if (propagateError(getExecutor(), done, "Failed to generate child deltas.")) return; if (propagateError(getExecutor(), done, "Failed to generate child deltas.")) return; //$NON-NLS-1$
done.setData(rootDelta); done.setData(rootDelta);
getExecutor().execute(done); getExecutor().execute(done);
} }

View file

@ -38,17 +38,18 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
@Immutable @Immutable
public class DMContextVMContext implements IVMContext { public class DMContextVMContext implements IVMContext {
private final IVMContext fParent; private final IVMContext fParent;
private final IDMContext fDmc; private final IDMContext<?> fDmc;
public DMContextVMContext(IVMContext parent, IDMContext dmc) { public DMContextVMContext(IVMContext parent, IDMContext<?> dmc) {
fParent = parent; fParent = parent;
fDmc = dmc; fDmc = dmc;
} }
public IDMContext getDMC() { return fDmc; } public IDMContext<?> getDMC() { return fDmc; }
public IVMContext getParent() { return fParent; } public IVMContext getParent() { return fParent; }
public IVMLayoutNode getLayoutNode() { return DMContextVMLayoutNode.this; } public IVMLayoutNode getLayoutNode() { return DMContextVMLayoutNode.this; }
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
return fDmc.getAdapter(adapter); return fDmc.getAdapter(adapter);
} }
@ -66,7 +67,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
} }
public String toString() { public String toString() {
return fParent.toString() + "->" + fDmc.toString(); return fParent.toString() + "->" + fDmc.toString(); //$NON-NLS-1$
} }
} }
@ -75,7 +76,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
/** Class type that the elements of this schema node are based on. */ /** Class type that the elements of this schema node are based on. */
private Class<? extends IDMContext> fDMCClassType; private Class<? extends IDMContext<?>> fDMCClassType;
/** /**
* Constructor initializes instance data, except for the child nodes. * Constructor initializes instance data, except for the child nodes.
@ -84,7 +85,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
* @param dmcClassType * @param dmcClassType
* @see #setChildNodes(IVMLayoutNode[]) * @see #setChildNodes(IVMLayoutNode[])
*/ */
public DMContextVMLayoutNode(DsfSession session, Class<? extends IDMContext> dmcClassType) { public DMContextVMLayoutNode(DsfSession session, Class<? extends IDMContext<?>> dmcClassType) {
super(session.getExecutor()); super(session.getExecutor());
fServices = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId()); fServices = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId());
fDMCClassType = dmcClassType; fDMCClassType = dmcClassType;
@ -112,7 +113,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
* DMC-specific version of {@link IVMLayoutNode#hasDeltaFlags(Object)}. * DMC-specific version of {@link IVMLayoutNode#hasDeltaFlags(Object)}.
* By default, it falls back on the super-class implementation. * By default, it falls back on the super-class implementation.
*/ */
protected boolean hasDeltaFlagsForDMEvent(IDMEvent e) { protected boolean hasDeltaFlagsForDMEvent(IDMEvent<?> e) {
return super.hasDeltaFlags(e); return super.hasDeltaFlags(e);
} }
@ -129,7 +130,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
* Adds an optimization (over the AbstractViewModelLayoutNode) which * Adds an optimization (over the AbstractViewModelLayoutNode) which
* narrows down the list of children based on the DMC within the event. * narrows down the list of children based on the DMC within the event.
*/ */
public void buildDeltaForDMEvent(final IDMEvent e, final VMDelta parent, final Done done) { public void buildDeltaForDMEvent(final IDMEvent<?> e, final VMDelta parent, final Done done) {
/* /*
* Take the IDMContext (DMC) that the event is based on, and * Take the IDMContext (DMC) that the event is based on, and
* search its ancestors. Look for the DMC class typs that this schema * search its ancestors. Look for the DMC class typs that this schema
@ -138,7 +139,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
* behavior and generate a IModelDelta for every element in this schema * behavior and generate a IModelDelta for every element in this schema
* node. * node.
*/ */
IDMContext dmc = DMContexts.getAncestorOfType(e.getDMContext(), fDMCClassType); IDMContext<?> dmc = DMContexts.getAncestorOfType(e.getDMContext(), fDMCClassType);
if (dmc != null) { if (dmc != null) {
IVMLayoutNode[] childNodes = getChildNodesWithDeltas(e); IVMLayoutNode[] childNodes = getChildNodesWithDeltas(e);
if (childNodes.length == 0) { if (childNodes.length == 0) {
@ -179,7 +180,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode {
* @param dmcs Array of DMC objects to build return array on. * @param dmcs Array of DMC objects to build return array on.
* @return Array of IVMContext objects. * @return Array of IVMContext objects.
*/ */
protected IVMContext[] dmcs2vmcs(IVMContext parent, IDMContext[] dmcs) { protected IVMContext[] dmcs2vmcs(IVMContext parent, IDMContext<?>[] dmcs) {
IVMContext[] vmContexts = new IVMContext[dmcs.length]; IVMContext[] vmContexts = new IVMContext[dmcs.length];
for (int i = 0; i < dmcs.length; i++) { for (int i = 0; i < dmcs.length; i++) {
vmContexts[i] = new DMContextVMContext(parent, dmcs[i]); vmContexts[i] = new DMContextVMContext(parent, dmcs[i]);

View file

@ -1,51 +0,0 @@
/*******************************************************************************
* Copyright (c) 2006 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.ui.viewmodel;
import org.eclipse.dd.dsf.concurrent.GetDataDone;
import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousRequestMonitor;
/**
* Convenience extension to GetDataDone, which handles notifying the
* IAsynchronousRequestMonitor when the done is executed.
* @param <V> Class type of data.
*/
@SuppressWarnings("restriction")
public abstract class GetDataDoneWithRequestMonitor<V> extends GetDataDone<V> {
/** Monitor to be posted when this done is executed. */
private IAsynchronousRequestMonitor fMonitor;
/** Constructor requires the monitor */
public GetDataDoneWithRequestMonitor(IAsynchronousRequestMonitor monitor) {
fMonitor = monitor;
}
/**
* Run method checks the request monitor for cancellation and checks this
* done's status before calling doRun(). Finally it takes care of
* notifying the request montior that request is finished.
*/
public final void run() {
if (fMonitor.isCanceled()) return;
if (!getStatus().isOK()) {
fMonitor.setStatus(getStatus());
} else {
doRun();
}
fMonitor.done();
}
/**
* Method to perform the actual work. It should not call monitor.done(),
* because it will be called by this class in run().
*/
protected abstract void doRun();
}

View file

@ -29,6 +29,7 @@ import org.eclipse.debug.internal.ui.viewers.provisional.IAsynchronousLabelAdapt
import org.eclipse.debug.internal.ui.viewers.provisional.IChildrenRequestMonitor; import org.eclipse.debug.internal.ui.viewers.provisional.IChildrenRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.provisional.IContainerRequestMonitor; import org.eclipse.debug.internal.ui.viewers.provisional.IContainerRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor; import org.eclipse.debug.internal.ui.viewers.provisional.ILabelRequestMonitor;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelChangedListener;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta; import org.eclipse.debug.internal.ui.viewers.provisional.IModelDelta;
import org.eclipse.debug.internal.ui.viewers.provisional.IModelProxy; import org.eclipse.debug.internal.ui.viewers.provisional.IModelProxy;
@ -76,6 +77,18 @@ public class VMProvider
super.dispose(); super.dispose();
} }
@Override
public void removeModelChangedListener(IModelChangedListener listener) {
// TODO Auto-generated method stub
super.removeModelChangedListener(listener);
}
@Override
public void addModelChangedListener(IModelChangedListener listener) {
// TODO Auto-generated method stub
super.addModelChangedListener(listener);
}
/** /**
* Fires given delta using a job. Processing the delta on the dispatch * Fires given delta using a job. Processing the delta on the dispatch
* thread can lead to dead-locks. * thread can lead to dead-locks.
@ -206,7 +219,7 @@ public class VMProvider
* nothing to do, just mark the monitor done. * nothing to do, just mark the monitor done.
*/ */
if (parentVmc.getLayoutNode().getChildLayoutNodes().length == 0) { if (parentVmc.getLayoutNode().getChildLayoutNodes().length == 0) {
assert false : "We should never get here, because isContainer() should have returned false"; assert false : "We should never get here, because isContainer() should have returned false"; //$NON-NLS-1$
monitor.done(); monitor.done();
return; return;
} }
@ -310,7 +323,7 @@ public class VMProvider
* @param e * @param e
*/ */
@DsfServiceEventHandler @DsfServiceEventHandler
public void eventDispatched(final IDMEvent event) { public void eventDispatched(final IDMEvent<?> event) {
if (fRootLayoutNode.hasDeltaFlags(event)) { if (fRootLayoutNode.hasDeltaFlags(event)) {
fRootLayoutNode.createDelta(event, new GetDataDone<IModelDelta>() { fRootLayoutNode.createDelta(event, new GetDataDone<IModelDelta>() {
public void run() { public void run() {
@ -319,7 +332,7 @@ public class VMProvider
} }
} }
@Override public String toString() { @Override public String toString() {
return "Result of a delta for event: '" + event.toString() + "' in VMP: '" + VMProvider.this + "'"; return "Result of a delta for event: '" + event.toString() + "' in VMP: '" + VMProvider.this + "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
}); });
} }

View file

@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext;
public class DsfPlugin extends Plugin { public class DsfPlugin extends Plugin {
// The plug-in ID // The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.dd.dsf"; public static final String PLUGIN_ID = "org.eclipse.dd.dsf"; //$NON-NLS-1$
// The shared instance // The shared instance
private static DsfPlugin fgPlugin; private static DsfPlugin fgPlugin;

View file

@ -43,7 +43,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
Thread fThread; Thread fThread;
public Thread newThread(Runnable r) { public Thread newThread(Runnable r) {
assert fThread == null; // Should be called only once. assert fThread == null; // Should be called only once.
fThread = new Thread(new ThreadGroup("DSF Thread Group"), r, "DSF Dispatch Thread", 0); fThread = new Thread(new ThreadGroup("DSF Thread Group"), r, "DSF Dispatch Thread", 0); //$NON-NLS-1$//$NON-NLS-2$
return fThread; return fThread;
} }
} }
@ -64,7 +64,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
@Override @Override
protected void afterExecute(Runnable r, Throwable t) { protected void afterExecute(Runnable r, Throwable t) {
if (r instanceof Future) { if (r instanceof Future) {
Future future = (Future)r; Future<?> future = (Future<?>)r;
try { try {
/* /*
* Try to retrieve the value, which should throw exception in * Try to retrieve the value, which should throw exception in
@ -89,14 +89,14 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
ILog log = DsfPlugin.getDefault().getLog(); ILog log = DsfPlugin.getDefault().getLog();
if (log != null) { if (log != null) {
log.log(new Status( log.log(new Status(
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Uncaught exception in DSF executor thread", t)); IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Uncaught exception in DSF executor thread", t)); //$NON-NLS-1$
} }
// Print out the stack trace to console if assertions are enabled. // Print out the stack trace to console if assertions are enabled.
if(ASSERTIONS_ENABLED) { if(ASSERTIONS_ENABLED) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream(512); ByteArrayOutputStream outStream = new ByteArrayOutputStream(512);
PrintStream printStream = new PrintStream(outStream); PrintStream printStream = new PrintStream(outStream);
try { try {
printStream.write("Uncaught exception in session executor thread: ".getBytes()); printStream.write("Uncaught exception in session executor thread: ".getBytes()); //$NON-NLS-1$
} catch (IOException e2) {} } catch (IOException e2) {}
t.printStackTrace(new PrintStream(outStream)); t.printStackTrace(new PrintStream(outStream));
System.err.println(outStream.toString()); System.err.println(outStream.toString());
@ -180,32 +180,32 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
traceBuilder.append(getExecutable().getClass().getName()); traceBuilder.append(getExecutable().getClass().getName());
// Add executable's toString(). // Add executable's toString().
traceBuilder.append("\n "); traceBuilder.append("\n "); //$NON-NLS-1$
traceBuilder.append(getExecutable().toString()); traceBuilder.append(getExecutable().toString());
// Append "create by" info. // Append "create by" info.
if (getExecutable() instanceof DsfExecutable) { if (getExecutable() instanceof DsfExecutable) {
DsfExecutable dsfExecutable = (DsfExecutable)getExecutable(); DsfExecutable dsfExecutable = (DsfExecutable)getExecutable();
if (dsfExecutable.fCreatedAt != null || dsfExecutable.fCreatedBy != null) { if (dsfExecutable.fCreatedAt != null || dsfExecutable.fCreatedBy != null) {
traceBuilder.append("\n created "); traceBuilder.append("\n created "); //$NON-NLS-1$
if (dsfExecutable.fCreatedBy != null) { if (dsfExecutable.fCreatedBy != null) {
traceBuilder.append(" by #"); traceBuilder.append(" by #"); //$NON-NLS-1$
traceBuilder.append(dsfExecutable.fCreatedBy.fSequenceNumber); traceBuilder.append(dsfExecutable.fCreatedBy.fSequenceNumber);
} }
if (dsfExecutable.fCreatedAt != null) { if (dsfExecutable.fCreatedAt != null) {
traceBuilder.append(" at "); traceBuilder.append(" at "); //$NON-NLS-1$
traceBuilder.append(dsfExecutable.fCreatedAt.fStackTraceElements[0].toString()); traceBuilder.append(dsfExecutable.fCreatedAt.fStackTraceElements[0].toString());
} }
} }
} }
// Submitted info // Submitted info
traceBuilder.append("\n submitted"); traceBuilder.append("\n submitted"); //$NON-NLS-1$
if (fSubmittedBy != null) { if (fSubmittedBy != null) {
traceBuilder.append(" by #"); traceBuilder.append(" by #"); //$NON-NLS-1$
traceBuilder.append(fSubmittedBy.fSequenceNumber); traceBuilder.append(fSubmittedBy.fSequenceNumber);
} }
traceBuilder.append(" at "); traceBuilder.append(" at "); //$NON-NLS-1$
traceBuilder.append(fSubmittedAt.fStackTraceElements[0].toString()); traceBuilder.append(fSubmittedAt.fStackTraceElements[0].toString());
// Finally write out to console // Finally write out to console

View file

@ -66,6 +66,6 @@ abstract public class Done extends DsfRunnable {
} }
public String toString() { public String toString() {
return "Done: " + getStatus().toString(); return "Done: " + getStatus().toString(); //$NON-NLS-1$
} }
} }

View file

@ -48,7 +48,7 @@ public abstract class DoneCollector extends Done {
* *
*/ */
public DoneCollector(DsfExecutor executor) { public DoneCollector(DsfExecutor executor) {
setStatus(new MultiStatus(DsfPlugin.PLUGIN_ID, 0, "Collective status for set of sub-operations.", null)); setStatus(new MultiStatus(DsfPlugin.PLUGIN_ID, 0, "Collective status for set of sub-operations.", null)); //$NON-NLS-1$
fExecutor = executor; fExecutor = executor;
} }
@ -108,6 +108,6 @@ public abstract class DoneCollector extends Done {
@Override @Override
public String toString() { public String toString() {
return "Done Collector: " + getStatus().toString(); return "Done Collector: " + getStatus().toString(); //$NON-NLS-1$
} }
} }

View file

@ -115,9 +115,9 @@ public class DsfExecutable {
traceBuilder.append(' '); traceBuilder.append(' ');
// Record the event // Record the event
traceBuilder.append("DsfExecutable was never executed:\n "); traceBuilder.append("DsfExecutable was never executed:\n "); //$NON-NLS-1$
traceBuilder.append(this); traceBuilder.append(this);
traceBuilder.append("\nCreated at:"); traceBuilder.append("\nCreated at:"); //$NON-NLS-1$
traceBuilder.append(fCreatedAt); traceBuilder.append(fCreatedAt);
DsfPlugin.debug(traceBuilder.toString()); DsfPlugin.debug(traceBuilder.toString());

View file

@ -128,12 +128,12 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
/** Convenience constructor with limited arguments. */ /** Convenience constructor with limited arguments. */
public DsfSequence(DsfExecutor executor) { public DsfSequence(DsfExecutor executor) {
this(executor, new NullProgressMonitor(), "", "", null); this(executor, new NullProgressMonitor(), "", "", null); //$NON-NLS-1$ //$NON-NLS-2$
} }
/** Convenience constructor with limited arguments. */ /** Convenience constructor with limited arguments. */
public DsfSequence(DsfExecutor executor, Done done) { public DsfSequence(DsfExecutor executor, Done done) {
this(executor, new NullProgressMonitor(), "", "", done); this(executor, new NullProgressMonitor(), "", "", done); //$NON-NLS-1$ //$NON-NLS-2$
} }
/** /**
@ -285,7 +285,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
} }
} }
public String toString() { public String toString() {
return "DsfSequence \"" + fTaskName + "\", result for executing step #" + fStepIdx + " = " + getStatus(); return "DsfSequence \"" + fTaskName + "\", result for executing step #" + fStepIdx + " = " + getStatus(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
}); });
} catch(Throwable t) { } catch(Throwable t) {
@ -297,7 +297,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
*/ */
abortExecution(new Status( abortExecution(new Status(
IStatus.ERROR, DsfPlugin.PLUGIN_ID, 0, IStatus.ERROR, DsfPlugin.PLUGIN_ID, 0,
"Unhandled exception when executing DsfSequence " + this + ", step #" + fCurrentStepIdx, "Unhandled exception when executing DsfSequence " + this + ", step #" + fCurrentStepIdx, //$NON-NLS-1$ //$NON-NLS-2$
t)); t));
/* /*
@ -338,7 +338,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
}; };
@Override @Override
public String toString() { public String toString() {
return "DsfSequence \"" + fTaskName + "\", result for rolling back step #" + fStepIdx + " = " + getStatus(); return "DsfSequence \"" + fTaskName + "\", result for rolling back step #" + fStepIdx + " = " + getStatus(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
} }
}); });
} catch(Throwable t) { } catch(Throwable t) {
@ -350,7 +350,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
*/ */
abortRollBack(new Status( abortRollBack(new Status(
IStatus.ERROR, DsfPlugin.PLUGIN_ID, 0, IStatus.ERROR, DsfPlugin.PLUGIN_ID, 0,
"Unhandled exception when rolling back DsfSequence " + this + ", step #" + fCurrentStepIdx, "Unhandled exception when rolling back DsfSequence " + this + ", step #" + fCurrentStepIdx, //$NON-NLS-1$ //$NON-NLS-2$
t)); t));
/* /*
@ -369,7 +369,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
if (fRollbackTaskName != null) { if (fRollbackTaskName != null) {
fProgressMonitor.subTask(fRollbackTaskName); fProgressMonitor.subTask(fRollbackTaskName);
} }
fStatus = new Status(IStatus.CANCEL, DsfPlugin.PLUGIN_ID, -1, "Sequence \"" + fTaskName + "\" cancelled.", null); fStatus = new Status(IStatus.CANCEL, DsfPlugin.PLUGIN_ID, -1, "Sequence \"" + fTaskName + "\" cancelled.", null); //$NON-NLS-1$ //$NON-NLS-2$
if (fDone != null) { if (fDone != null) {
fDone.setStatus(fStatus); fDone.setStatus(fStatus);
} }
@ -418,7 +418,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future<Object>
*/ */
MultiStatus newStatus = MultiStatus newStatus =
new MultiStatus(DsfPlugin.PLUGIN_ID, error.getCode(), new MultiStatus(DsfPlugin.PLUGIN_ID, error.getCode(),
"Sequence \"" + fTaskName + "\" failed while rolling back.", null); "Sequence \"" + fTaskName + "\" failed while rolling back.", null); //$NON-NLS-1$ //$NON-NLS-2$
newStatus.merge(error); newStatus.merge(error);
newStatus.merge(fStatus); newStatus.merge(fStatus);
fStatus = newStatus; fStatus = newStatus;

View file

@ -24,7 +24,7 @@ class StackTraceWrapper {
StringBuilder builder = new StringBuilder(fStackTraceElements.length * 30); StringBuilder builder = new StringBuilder(fStackTraceElements.length * 30);
for (int i = 0; i < fStackTraceElements.length && i < 10; i++) { for (int i = 0; i < fStackTraceElements.length && i < 10; i++) {
builder.append(fStackTraceElements[i]); builder.append(fStackTraceElements[i]);
if (i < fStackTraceElements.length && i < 10) builder.append("\n at "); if (i < fStackTraceElements.length && i < 10) builder.append("\n at "); //$NON-NLS-1$
} }
return builder.toString(); return builder.toString();
} }

View file

@ -27,20 +27,20 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
{ {
private final String fSessionId; private final String fSessionId;
private final String fServiceFilter; private final String fServiceFilter;
private final IDMContext[] fParents; private final IDMContext<?>[] fParents;
/** /**
* Main constructor provides all data needed to implement the IModelContext * Main constructor provides all data needed to implement the IModelContext
* interface. * interface.
*/ */
public AbstractDMContext(String sessionId, String filter, IDMContext[] parents) { public AbstractDMContext(String sessionId, String filter, IDMContext<?>[] parents) {
fSessionId = sessionId; fSessionId = sessionId;
fServiceFilter = filter; fServiceFilter = filter;
fParents = parents; fParents = parents;
} }
/** Convenience constructor */ /** Convenience constructor */
public AbstractDMContext(AbstractDsfService service, IDMContext parent) { public AbstractDMContext(AbstractDsfService service, IDMContext<?> parent) {
this(service.getSession().getId(), this(service.getSession().getId(),
service.getServiceFilter(), service.getServiceFilter(),
parent == null ? new IDMContext[] {} : new IDMContext[] { parent }); parent == null ? new IDMContext[] {} : new IDMContext[] { parent });
@ -55,13 +55,13 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
protected boolean baseEquals(Object other) { protected boolean baseEquals(Object other) {
if (other == null) return false; if (other == null) return false;
if ( !(other.getClass().equals(getClass()))) return false; if ( !(other.getClass().equals(getClass()))) return false;
IDMContext otherCtx = (IDMContext)other; IDMContext<?> otherCtx = (IDMContext<?>)other;
return getSessionId().equals(otherCtx.getSessionId()) && return getSessionId().equals(otherCtx.getSessionId()) &&
getServiceFilter().equals(otherCtx.getServiceFilter()) && getServiceFilter().equals(otherCtx.getServiceFilter()) &&
areParentsEqual(otherCtx.getParents()); areParentsEqual(otherCtx.getParents());
} }
private boolean areParentsEqual(IDMContext[] otherParents) { private boolean areParentsEqual(IDMContext<?>[] otherParents) {
if ( !(fParents.length == otherParents.length) ) return false; if ( !(fParents.length == otherParents.length) ) return false;
for (int i = 0; i < fParents.length; i++) { for (int i = 0; i < fParents.length; i++) {
if (!fParents[i].equals(otherParents[i])) { if (!fParents[i].equals(otherParents[i])) {
@ -81,7 +81,7 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
protected String baseToString() { protected String baseToString() {
StringBuffer retVal = new StringBuffer(); StringBuffer retVal = new StringBuffer();
for (IDMContext parent : fParents) { for (IDMContext<?> parent : fParents) {
retVal.append(parent); retVal.append(parent);
} }
return retVal.toString(); return retVal.toString();
@ -89,7 +89,7 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
public String getSessionId() { return fSessionId; } public String getSessionId() { return fSessionId; }
public String getServiceFilter() { return fServiceFilter; } public String getServiceFilter() { return fServiceFilter; }
public IDMContext[] getParents() { return fParents; } public IDMContext<?>[] getParents() { return fParents; }
/** /**
* Overrides the standard platform getAdapter to provide session-specific * Overrides the standard platform getAdapter to provide session-specific
@ -106,6 +106,7 @@ public class AbstractDMContext<V extends IDMData> extends PlatformObject
* session is equally important. * session is equally important.
* @see org.eclipse.runtime.IAdapterManager * @see org.eclipse.runtime.IAdapterManager
*/ */
@SuppressWarnings("unchecked")
public Object getAdapter(Class adapterType) { public Object getAdapter(Class adapterType) {
Object retVal = null; Object retVal = null;
DsfSession session = DsfSession.getSession(fSessionId); DsfSession session = DsfSession.getSession(fSessionId);

View file

@ -17,7 +17,7 @@ import org.eclipse.dd.dsf.concurrent.Immutable;
* required DM-Context reference. * required DM-Context reference.
*/ */
@Immutable @Immutable
public class AbstractDMEvent<V extends IDMContext> implements IDMEvent<V> { public class AbstractDMEvent<V extends IDMContext<?>> implements IDMEvent<V> {
private final V fModelContext; private final V fModelContext;
public AbstractDMEvent(V context) { public AbstractDMEvent(V context) {

View file

@ -56,16 +56,16 @@ public class DMContexts {
* @return true if a match is found. * @return true if a match is found.
*/ */
@ThreadSafe @ThreadSafe
public static boolean isAncestorOf(IDMContext dmc, IDMContext potentialAncestor) { public static boolean isAncestorOf(IDMContext<?> dmc, IDMContext<?> potentialAncestor) {
// Check the direct parents for a match. // Check the direct parents for a match.
for (IDMContext parentDmc : dmc.getParents()) { for (IDMContext<?> parentDmc : dmc.getParents()) {
if (potentialAncestor.equals(parentDmc)) { if (potentialAncestor.equals(parentDmc)) {
return true; return true;
} }
} }
// Recursively check the parents' parents for a match. // Recursively check the parents' parents for a match.
for (IDMContext parentDmc : dmc.getParents()) { for (IDMContext<?> parentDmc : dmc.getParents()) {
if (isAncestorOf(parentDmc, potentialAncestor)) { if (isAncestorOf(parentDmc, potentialAncestor)) {
return true; return true;
} }
@ -80,15 +80,15 @@ public class DMContexts {
* into a list. * into a list.
*/ */
@ThreadSafe @ThreadSafe
public static List<IDMContext> toList(IDMContext dmc) { public static List<IDMContext<?>> toList(IDMContext<?> dmc) {
/* /*
* This method is implemented recursively, which is not necessarily * This method is implemented recursively, which is not necessarily
* the most efficient way to do this. * the most efficient way to do this.
*/ */
List<IDMContext> list = new ArrayList<IDMContext>(); List<IDMContext<?>> list = new ArrayList<IDMContext<?>>();
list.add(dmc); list.add(dmc);
for (IDMContext parentDmc : dmc.getParents()) { for (IDMContext<?> parentDmc : dmc.getParents()) {
list.addAll(toList(parentDmc)); list.addAll(toList(parentDmc));
} }
return list; return list;

View file

@ -73,5 +73,5 @@ public interface IDMContext<V extends IDMData> extends IAdaptable
* the client. * the client.
* @return parent context of this context. * @return parent context of this context.
*/ */
public IDMContext[] getParents(); public IDMContext<?>[] getParents();
} }

View file

@ -16,6 +16,6 @@ package org.eclipse.dd.dsf.datamodel;
* this base class only identifies the DM Context that is affected. * this base class only identifies the DM Context that is affected.
* @param <V> Data Model context type that is affected by this event. * @param <V> Data Model context type that is affected by this event.
*/ */
public interface IDMEvent <V extends IDMContext> { public interface IDMEvent <V extends IDMContext<?>> {
V getDMContext(); V getDMContext();
} }

View file

@ -26,7 +26,7 @@ public interface IDMService extends IDsfService, IDMData {
* usually used in events to indicate that lists of contexts in this * usually used in events to indicate that lists of contexts in this
* service are changed. * service are changed.
*/ */
IDMContext getServiceContext(); IDMContext<?> getServiceContext();
/** /**
* Retrieves model data object for given context. This method makes it * Retrieves model data object for given context. This method makes it

View file

@ -42,6 +42,7 @@ abstract public class AbstractDsfService
private DsfServicesTracker fTracker; private DsfServicesTracker fTracker;
/** Properties that this service was registered with */ /** Properties that this service was registered with */
@SuppressWarnings("unchecked")
private Dictionary fProperties; private Dictionary fProperties;
/** Properties that this service was registered with */ /** Properties that this service was registered with */
@ -58,9 +59,14 @@ abstract public class AbstractDsfService
} }
public DsfExecutor getExecutor() { return fSession.getExecutor(); } public DsfExecutor getExecutor() { return fSession.getExecutor(); }
@SuppressWarnings("unchecked")
public Dictionary getProperties() { return fProperties; } public Dictionary getProperties() { return fProperties; }
public String getServiceFilter() { return fFilter; } public String getServiceFilter() { return fFilter; }
public int getStartupNumber() { return fStartupNumber; } public int getStartupNumber() { return fStartupNumber; }
public void initialize(Done done) { public void initialize(Done done) {
fTracker = new DsfServicesTracker(getBundleContext(), fSession.getId()); fTracker = new DsfServicesTracker(getBundleContext(), fSession.getId());
fStartupNumber = fSession.getAndIncrementServiceStartupCounter(); fStartupNumber = fSession.getAndIncrementServiceStartupCounter();
@ -136,9 +142,10 @@ abstract public class AbstractDsfService
/** /**
* Generates an LDAP filter to uniquely identify this service. * Generates an LDAP filter to uniquely identify this service.
*/ */
@SuppressWarnings("unchecked")
private String generateFilter(Dictionary properties) { private String generateFilter(Dictionary properties) {
StringBuffer filter = new StringBuffer(); StringBuffer filter = new StringBuffer();
filter.append("(&"); filter.append("(&"); //$NON-NLS-1$
for (Enumeration keys = properties.keys(); keys.hasMoreElements();) { for (Enumeration keys = properties.keys(); keys.hasMoreElements();) {
Object key = keys.nextElement(); Object key = keys.nextElement();
@ -151,7 +158,7 @@ abstract public class AbstractDsfService
for (Object arrayValue : (Object[])value) { for (Object arrayValue : (Object[])value) {
filter.append('('); filter.append('(');
filter.append(key.toString()); filter.append(key.toString());
filter.append("=*"); filter.append("=*"); //$NON-NLS-1$
filter.append(arrayValue.toString()); filter.append(arrayValue.toString());
filter.append(')'); filter.append(')');
} }

View file

@ -43,7 +43,7 @@ import org.osgi.framework.ServiceReference;
public class DsfServicesTracker { public class DsfServicesTracker {
private static String getServiceFilter(String sessionId) { private static String getServiceFilter(String sessionId) {
return ("(" + IDsfService.PROP_SESSION_ID + "=" + sessionId + ")").intern(); return ("(" + IDsfService.PROP_SESSION_ID + "=" + sessionId + ")").intern(); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
} }
private static class ServiceKey private static class ServiceKey
@ -93,6 +93,7 @@ public class DsfServicesTracker {
* session-ID * session-ID
* @return OSGI service reference object to the desired service, null if not found * @return OSGI service reference object to the desired service, null if not found
*/ */
@SuppressWarnings("unchecked")
public ServiceReference getServiceReference(Class serviceClass, String filter) { public ServiceReference getServiceReference(Class serviceClass, String filter) {
ServiceKey key = new ServiceKey(serviceClass.getName().intern(), filter != null ? filter : fServiceFilter); ServiceKey key = new ServiceKey(serviceClass.getName().intern(), filter != null ? filter : fServiceFilter);
if (fServiceReferences.containsKey(key)) { if (fServiceReferences.containsKey(key)) {
@ -109,7 +110,7 @@ public class DsfServicesTracker {
return references[0]; return references[0];
} }
} catch(InvalidSyntaxException e) { } catch(InvalidSyntaxException e) {
assert false : "Invalid session ID syntax"; assert false : "Invalid session ID syntax"; //$NON-NLS-1$
} }
return null; return null;
} }
@ -154,8 +155,8 @@ public class DsfServicesTracker {
* to avoid leaking OSGI service references. * to avoid leaking OSGI service references.
*/ */
public void dispose() { public void dispose() {
for (Iterator itr = fServices.keySet().iterator(); itr.hasNext();) { for (Iterator<ServiceReference> itr = fServices.keySet().iterator(); itr.hasNext();) {
fBundleContext.ungetService((ServiceReference)itr.next()); fBundleContext.ungetService(itr.next());
itr.remove(); itr.remove();
} }
} }

View file

@ -222,6 +222,7 @@ public class DsfSession
* IModelContext.getAdapter() method. * IModelContext.getAdapter() method.
* @see org.eclipse.dd.dsf.datamodel.AbstractDMContext#getAdapter * @see org.eclipse.dd.dsf.datamodel.AbstractDMContext#getAdapter
*/ */
@SuppressWarnings("unchecked")
private Map<Class,Object> fAdapters = Collections.synchronizedMap(new HashMap<Class,Object>()); private Map<Class,Object> fAdapters = Collections.synchronizedMap(new HashMap<Class,Object>());
/** Returns the owner ID of this session */ /** Returns the owner ID of this session */
@ -271,10 +272,11 @@ public class DsfSession
* @param serviceProperties properties of the service requesting the event to be dispatched * @param serviceProperties properties of the service requesting the event to be dispatched
*/ */
@ThreadSafe @ThreadSafe
@SuppressWarnings("unchecked")
public void dispatchEvent(final Object event, final Dictionary serviceProperties) { public void dispatchEvent(final Object event, final Dictionary serviceProperties) {
getExecutor().submit(new DsfRunnable() { getExecutor().submit(new DsfRunnable() {
public void run() { doDispatchEvent(event, serviceProperties);} public void run() { doDispatchEvent(event, serviceProperties);}
public String toString() { return "Event: " + event + ", from service " + serviceProperties; } public String toString() { return "Event: " + event + ", from service " + serviceProperties; } //$NON-NLS-1$ //$NON-NLS-2$
}); });
} }
@ -285,6 +287,7 @@ public class DsfSession
* @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter * @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter
*/ */
@ThreadSafe @ThreadSafe
@SuppressWarnings("unchecked")
public void registerModelAdapter(Class adapterType, Object adapter) { public void registerModelAdapter(Class adapterType, Object adapter) {
fAdapters.put(adapterType, adapter); fAdapters.put(adapterType, adapter);
} }
@ -295,6 +298,7 @@ public class DsfSession
* @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter * @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter
*/ */
@ThreadSafe @ThreadSafe
@SuppressWarnings("unchecked")
public void unregisterModelAdapter(Class adapterType) { public void unregisterModelAdapter(Class adapterType) {
fAdapters.remove(adapterType); fAdapters.remove(adapterType);
} }
@ -306,6 +310,7 @@ public class DsfSession
* @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter * @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter
*/ */
@ThreadSafe @ThreadSafe
@SuppressWarnings("unchecked")
public Object getModelAdapter(Class adapterType) { public Object getModelAdapter(Class adapterType) {
return fAdapters.get(adapterType); return fAdapters.get(adapterType);
} }
@ -318,6 +323,7 @@ public class DsfSession
@ThreadSafe @ThreadSafe
public int hashCode() { return fId.hashCode(); } public int hashCode() { return fId.hashCode(); }
@SuppressWarnings("unchecked")
private void doDispatchEvent(Object event, Dictionary serviceProperties) { private void doDispatchEvent(Object event, Dictionary serviceProperties) {
// Build a list of listeners; // Build a list of listeners;
SortedMap<ListenerEntry,List<Method>> listeners = new TreeMap<ListenerEntry,List<Method>>(new Comparator<ListenerEntry>() { SortedMap<ListenerEntry,List<Method>> listeners = new TreeMap<ListenerEntry,List<Method>>(new Comparator<ListenerEntry>() {
@ -349,8 +355,8 @@ public class DsfSession
Method[] allMethods = entry.getValue(); Method[] allMethods = entry.getValue();
List<Method> matchingMethods = new ArrayList<Method>(); List<Method> matchingMethods = new ArrayList<Method>();
for (Method method : allMethods) { for (Method method : allMethods) {
assert method.getParameterTypes().length > 0 : eventClass.getName() + "." + method.getName() assert method.getParameterTypes().length > 0 : eventClass.getName() + "." + method.getName() //$NON-NLS-1$
+ " signature contains zero parameters"; + " signature contains zero parameters"; //$NON-NLS-1$
if ( method.getParameterTypes()[0].isAssignableFrom(eventClass) ) { if ( method.getParameterTypes()[0].isAssignableFrom(eventClass) ) {
matchingMethods.add(method); matchingMethods.add(method);
} }
@ -368,13 +374,13 @@ public class DsfSession
} }
catch (IllegalAccessException e) { catch (IllegalAccessException e) {
DsfPlugin.getDefault().getLog().log(new Status( DsfPlugin.getDefault().getLog().log(new Status(
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Security exception when calling a service event handler method", e)); IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Security exception when calling a service event handler method", e)); //$NON-NLS-1$
assert false : "IServiceEventListener.ServiceHandlerMethod method not accessible, is listener declared public?"; assert false : "IServiceEventListener.ServiceHandlerMethod method not accessible, is listener declared public?"; //$NON-NLS-1$
} }
catch (InvocationTargetException e) { catch (InvocationTargetException e) {
DsfPlugin.getDefault().getLog().log(new Status( DsfPlugin.getDefault().getLog().log(new Status(
IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Invocation exception when calling a service event handler method", e)); IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Invocation exception when calling a service event handler method", e)); //$NON-NLS-1$
assert false : "Exception thrown by a IServiceEventListener.ServiceHandlerMethod method"; assert false : "Exception thrown by a IServiceEventListener.ServiceHandlerMethod method"; //$NON-NLS-1$
} }
} }
} }
@ -389,17 +395,17 @@ public class DsfSession
if (method.isAnnotationPresent(DsfServiceEventHandler.class)) { if (method.isAnnotationPresent(DsfServiceEventHandler.class)) {
Class<?>[] paramTypes = method.getParameterTypes(); Class<?>[] paramTypes = method.getParameterTypes();
if (paramTypes.length > 2) { if (paramTypes.length > 2) {
throw new IllegalArgumentException("ServiceEventHandler method has incorrect number of parameters"); throw new IllegalArgumentException("ServiceEventHandler method has incorrect number of parameters"); //$NON-NLS-1$
} }
retVal.add(method); retVal.add(method);
} }
} }
} catch(SecurityException e) { } catch(SecurityException e) {
throw new IllegalArgumentException("No permission to access ServiceEventHandler method"); throw new IllegalArgumentException("No permission to access ServiceEventHandler method"); //$NON-NLS-1$
} }
if (retVal.isEmpty()) { if (retVal.isEmpty()) {
throw new IllegalArgumentException("No methods marked with @ServiceEventHandler in listener, is listener declared public?"); throw new IllegalArgumentException("No methods marked with @ServiceEventHandler in listener, is listener declared public?"); //$NON-NLS-1$
} }
return retVal.toArray(new Method[retVal.size()]); return retVal.toArray(new Method[retVal.size()]);
} }

View file

@ -42,7 +42,7 @@ public interface IDsfService {
* Property name for the session-id of this service. This property should be set by * Property name for the session-id of this service. This property should be set by
* all DSF services when they are registered with OSGI service framework. * all DSF services when they are registered with OSGI service framework.
*/ */
final static String PROP_SESSION_ID = "org.eclipse.dd.dsf.service.IService.session_id"; final static String PROP_SESSION_ID = "org.eclipse.dd.dsf.service.IService.session_id"; //$NON-NLS-1$
/** /**
* Error code indicating that the service is in a state which does not allow the * Error code indicating that the service is in a state which does not allow the
@ -84,6 +84,7 @@ public interface IDsfService {
/** /**
* Returns the map of properties that this service was registered with. * Returns the map of properties that this service was registered with.
*/ */
@SuppressWarnings("unchecked")
Dictionary getProperties(); Dictionary getProperties();
/** /**