diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/DebugViewSelectionRootLayoutNode.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/DebugViewSelectionRootLayoutNode.java index 0f92b623ca7..9a2722ffd32 100644 --- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/DebugViewSelectionRootLayoutNode.java +++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/DebugViewSelectionRootLayoutNode.java @@ -11,17 +11,18 @@ package org.eclipse.dd.dsf.debug.ui.viewmodel; 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.IDMContext; import org.eclipse.dd.dsf.datamodel.IDMEvent; import org.eclipse.dd.dsf.ui.viewmodel.AbstractVMRootLayoutNode; import org.eclipse.dd.dsf.ui.viewmodel.IVMRootLayoutNode; import org.eclipse.dd.dsf.ui.viewmodel.DMContextVMLayoutNode.DMContextVMContext; -import org.eclipse.debug.internal.ui.contexts.DebugContextManager; -import org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener; +import org.eclipse.debug.ui.DebugUITools; +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.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; 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 * selection in Debug view, and this node provides tracking of that selection. */ -@SuppressWarnings("restriction") public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode implements IVMRootLayoutNode, IDebugContextListener { @@ -37,18 +37,18 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode public DebugViewSelectionRootLayoutNode(DsfExecutor executor, IWorkbenchWindow window) { super(executor); - ISelection selection = DebugContextManager.getDefault().getActiveContext(window); + ISelection selection = DebugUITools.getDebugContextManager().getContextService(window).getActiveContext(); if (selection instanceof IStructuredSelection) { fRootVMC = new RootVMC( this, ((IStructuredSelection)selection).getFirstElement() ); } else { fRootVMC = new RootVMC( this, null ); } - DebugContextManager.getDefault().addDebugContextListener(this, window); + DebugUITools.getDebugContextManager().addDebugContextListener(this); } @Override public void sessionDispose() { - DebugContextManager.getDefault().removeDebugContextListener(this); + DebugUITools.getDebugContextManager().removeDebugContextListener(this); super.sessionDispose(); } @@ -75,17 +75,14 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode */ @Override public boolean hasDeltaFlags(Object event) { - /* - * TODO: This logic needs to be tested and probably enhanced. - */ if (event instanceof IDMEvent && fRootVMC.getInputObject() instanceof DMContextVMContext) { boolean potentialMatchFound = false; boolean matchFound = false; - IDMContext eventDmc = ((IDMEvent)event).getDMContext(); - IDMContext inputDmc = ((DMContextVMContext)fRootVMC.getInputObject()).getDMC(); - for (IDMContext eventDmcAncestor : DMContexts.toList(eventDmc)) { - IDMContext inputDmcAncestor = DMContexts.getAncestorOfType(inputDmc, eventDmcAncestor.getClass()); + IDMContext eventDmc = ((IDMEvent)event).getDMContext(); + IDMContext inputDmc = ((DMContextVMContext)fRootVMC.getInputObject()).getDMC(); + for (IDMContext eventDmcAncestor : DMContexts.toList(eventDmc)) { + IDMContext inputDmcAncestor = DMContexts.getAncestorOfType(inputDmc, eventDmcAncestor.getClass()); if (inputDmcAncestor != null) { potentialMatchFound = true; if (inputDmcAncestor.equals(eventDmcAncestor)) { @@ -105,16 +102,17 @@ public class DebugViewSelectionRootLayoutNode extends AbstractVMRootLayoutNode return fRootVMC; } - public void contextActivated(ISelection selection, IWorkbenchPart part) { - if (selection instanceof IStructuredSelection) { - fRootVMC = new RootVMC( this, ((IStructuredSelection)selection).getFirstElement() ); - } else { - fRootVMC = new RootVMC( this, null ); - } - } - - public void contextChanged(ISelection selection, IWorkbenchPart part) { - // No need to do anything. Element changes should be handled - // through standard event handlers. + public void debugContextChanged(DebugContextEvent event) { + final ISelection selection = event.getContext(); + getExecutor().execute(new DsfRunnable() { + public void run() { + if (selection instanceof IStructuredSelection) { + fRootVMC = new RootVMC( DebugViewSelectionRootLayoutNode.this, + ((IStructuredSelection)selection).getFirstElement() ); + } else { + fRootVMC = new RootVMC( DebugViewSelectionRootLayoutNode.this, null ); + } + } + }); } } diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/ThreadLayoutNode.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/ThreadLayoutNode.java index d3b6d31277b..507dcda8d57 100644 --- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/ThreadLayoutNode.java +++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/ui/viewmodel/ThreadLayoutNode.java @@ -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.service.DsfSession; 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.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.IModelDelta; import org.eclipse.debug.ui.DebugUITools; @@ -69,9 +69,16 @@ public class ThreadLayoutNode extends DMContextVMLayoutNode { processes.getModelData( processes.getThreadForExecutionContext(dmc), - new GetDataDoneWithRequestMonitor(result) { public void doRun() { - result.setLabels(new String[] { getData().getName() }); - }}); + new GetDataDone() { + public void run() { + if (!getStatus().isOK() || !getData().isValid()) { + result.done(); + return; + } + result.setLabels(new String[] { getData().getName() }); + result.done(); + } + }); } public boolean hasDeltaFlagsForDMEvent(IDMEvent e) { diff --git a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/DsfDebugPlugin.java b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/DsfDebugPlugin.java index 3ca12ae0ae0..a0b8f8b600b 100644 --- a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/DsfDebugPlugin.java +++ b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/DsfDebugPlugin.java @@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext; public class DsfDebugPlugin extends Plugin { // 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 private static DsfDebugPlugin fgPlugin; diff --git a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBackEndProcess.java b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBackEndProcess.java index a4f6ed39665..f8a5cfa159e 100644 --- a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBackEndProcess.java +++ b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IBackEndProcess.java @@ -26,7 +26,7 @@ public interface IBackEndProcess extends IDsfService { * same time, a service property is needed to allow clients to distinguish * 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. diff --git a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IModules.java b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IModules.java index f1f8212ecc9..0c96960a1ec 100644 --- a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IModules.java +++ b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/IModules.java @@ -30,12 +30,12 @@ public interface IModules extends IDMService { * types of debugging, like kernel or no-OS debugging, it's useful to * separate the concept of a symbol context from a process. */ - public interface ISymbolDMContext extends IDMContext {} + public interface ISymbolDMContext extends IDMContext{} /** * Module context represents a single module that is loaded. */ - public interface IModuleDMContext extends IDMContext {} + public interface IModuleDMContext extends IDMContext {} /** * 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 * module-section-offset coordinates. */ - public interface SymbolDMData extends IDMData { + public interface ISymbolDMData extends IDMData { /** Convert link-time address 'addr' to run-time address */ public long convertToRT(ModuleSectionOffset mso); @@ -99,7 +99,7 @@ public interface IModules extends IDMService { } /** Module information. */ - public interface ModuleDMData extends IDMData { + public interface IModuleDMData extends IDMData { String getName(); String getFile(); long getTimeStamp(); diff --git a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/ITargets.java b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/ITargets.java index 75fda232788..c6740dea672 100644 --- a/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/ITargets.java +++ b/plugins/org.eclipse.dd.dsf.debug/src/org/eclipse/dd/dsf/debug/service/ITargets.java @@ -29,7 +29,7 @@ public interface ITargets extends IDMService { boolean isConnected(); } - public interface ITargetStateChanged extends IDMEvent {} + public interface ITargetStateChanged extends IDMEvent {} public interface ICoreDMContext extends IDMContext {} @@ -39,7 +39,7 @@ public interface ITargets extends IDMService { IOS.IOSDMContext getOSDMContext(); } - public interface ICoreStateChangedDMEvent extends IDMEvent {} + public interface ICoreStateChangedDMEvent extends IDMEvent {} public void getTargets(GetDataDone done); public void getCores(ITargetDMContext target, GetDataDone done); diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/DsfUIPlugin.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/DsfUIPlugin.java index 9b2c7cb05b7..164a2f69e1f 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/DsfUIPlugin.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/DsfUIPlugin.java @@ -19,7 +19,7 @@ import org.osgi.framework.BundleContext; public class DsfUIPlugin extends AbstractUIPlugin { // 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 private static DsfUIPlugin fgPlugin; diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMAdapter.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMAdapter.java index fd55c73dfc0..b136046b82c 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMAdapter.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMAdapter.java @@ -98,13 +98,13 @@ abstract public class AbstractVMAdapter VMProvider provider = getViewModelProvider(context); 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(); } provider.retrieveLabel(object, result); } @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) { // This can happen if session is being shut down. @@ -120,12 +120,12 @@ abstract public class AbstractVMAdapter VMProvider provider = getViewModelProvider(context); 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(); } 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) { // This can happen if session is being shut down. @@ -141,12 +141,12 @@ abstract public class AbstractVMAdapter VMProvider provider = getViewModelProvider(context); 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(); } 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) { // This can happen if session is being shut down. @@ -155,8 +155,13 @@ abstract public class AbstractVMAdapter } 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); - if (provider != null) { + if (provider != null && element.equals(provider.getRootLayoutNode().getRootVMC().getInputObject())) { return provider.getModelProxy(); } return null; diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMLayoutNode.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMLayoutNode.java index b675706758d..634f03c58b3 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMLayoutNode.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMLayoutNode.java @@ -94,7 +94,16 @@ abstract public class AbstractVMLayoutNode implements IVMLayoutNode { parent.getVMC(), new GetDataDone() { 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 * 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. */ protected void handleFailedRetrieveLabel(ILabelRequestMonitor result) { - result.setLabels(new String[] { "..."} ); + result.setLabels(new String[] { "..."} ); //$NON-NLS-1$ result.done(); } diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMRootLayoutNode.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMRootLayoutNode.java index e443944c525..ab4bbc43d40 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMRootLayoutNode.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/AbstractVMRootLayoutNode.java @@ -39,6 +39,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl public IVMLayoutNode getLayoutNode() { return fVMRootLayoutNode; } + @SuppressWarnings("unchecked") public Object getAdapter(Class adapter) { if (fInputObject instanceof IAdaptable) { return ((IAdaptable)fInputObject).getAdapter(adapter); @@ -55,7 +56,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl 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) { @@ -111,7 +112,7 @@ abstract public class AbstractVMRootLayoutNode extends AbstractVMLayoutNode impl */ final DoneCollector doneCollector = new DoneCollector(getExecutor()) { 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); getExecutor().execute(done); } diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/DMContextVMLayoutNode.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/DMContextVMLayoutNode.java index 4021d4df513..122209c834a 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/DMContextVMLayoutNode.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/DMContextVMLayoutNode.java @@ -38,17 +38,18 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode { @Immutable public class DMContextVMContext implements IVMContext { 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; fDmc = dmc; } - public IDMContext getDMC() { return fDmc; } + public IDMContext getDMC() { return fDmc; } public IVMContext getParent() { return fParent; } public IVMLayoutNode getLayoutNode() { return DMContextVMLayoutNode.this; } + @SuppressWarnings("unchecked") public Object getAdapter(Class adapter) { return fDmc.getAdapter(adapter); } @@ -66,7 +67,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode { } 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. */ - private Class fDMCClassType; + private Class> fDMCClassType; /** * Constructor initializes instance data, except for the child nodes. @@ -84,7 +85,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode { * @param dmcClassType * @see #setChildNodes(IVMLayoutNode[]) */ - public DMContextVMLayoutNode(DsfSession session, Class dmcClassType) { + public DMContextVMLayoutNode(DsfSession session, Class> dmcClassType) { super(session.getExecutor()); fServices = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), session.getId()); fDMCClassType = dmcClassType; @@ -112,7 +113,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode { * DMC-specific version of {@link IVMLayoutNode#hasDeltaFlags(Object)}. * By default, it falls back on the super-class implementation. */ - protected boolean hasDeltaFlagsForDMEvent(IDMEvent e) { + protected boolean hasDeltaFlagsForDMEvent(IDMEvent e) { return super.hasDeltaFlags(e); } @@ -129,7 +130,7 @@ abstract public class DMContextVMLayoutNode extends AbstractVMLayoutNode { * Adds an optimization (over the AbstractViewModelLayoutNode) which * 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 * 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 * node. */ - IDMContext dmc = DMContexts.getAncestorOfType(e.getDMContext(), fDMCClassType); + IDMContext dmc = DMContexts.getAncestorOfType(e.getDMContext(), fDMCClassType); if (dmc != null) { IVMLayoutNode[] childNodes = getChildNodesWithDeltas(e); 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. * @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]; for (int i = 0; i < dmcs.length; i++) { vmContexts[i] = new DMContextVMContext(parent, dmcs[i]); diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/GetDataDoneWithRequestMonitor.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/GetDataDoneWithRequestMonitor.java deleted file mode 100644 index f675bc641d6..00000000000 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/GetDataDoneWithRequestMonitor.java +++ /dev/null @@ -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 Class type of data. - */ -@SuppressWarnings("restriction") -public abstract class GetDataDoneWithRequestMonitor extends GetDataDone { - /** 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(); -} \ No newline at end of file diff --git a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/VMProvider.java b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/VMProvider.java index c14b17e364b..524c92dc0ba 100644 --- a/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/VMProvider.java +++ b/plugins/org.eclipse.dd.dsf.ui/src/org/eclipse/dd/dsf/ui/viewmodel/VMProvider.java @@ -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.IContainerRequestMonitor; 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.IModelProxy; @@ -75,6 +76,18 @@ public class VMProvider fProxyActive--; 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 @@ -206,7 +219,7 @@ public class VMProvider * nothing to do, just mark the monitor done. */ 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(); return; } @@ -310,7 +323,7 @@ public class VMProvider * @param e */ @DsfServiceEventHandler - public void eventDispatched(final IDMEvent event) { + public void eventDispatched(final IDMEvent event) { if (fRootLayoutNode.hasDeltaFlags(event)) { fRootLayoutNode.createDelta(event, new GetDataDone() { public void run() { @@ -319,7 +332,7 @@ public class VMProvider } } @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$ } }); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/DsfPlugin.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/DsfPlugin.java index 0e05acf461c..1e3f7290dec 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/DsfPlugin.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/DsfPlugin.java @@ -20,7 +20,7 @@ import org.osgi.framework.BundleContext; public class DsfPlugin extends Plugin { // 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 private static DsfPlugin fgPlugin; diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DefaultDsfExecutor.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DefaultDsfExecutor.java index df098ee83b3..d4feb038cb5 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DefaultDsfExecutor.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DefaultDsfExecutor.java @@ -43,7 +43,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor Thread fThread; public Thread newThread(Runnable r) { 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; } } @@ -64,7 +64,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor @Override protected void afterExecute(Runnable r, Throwable t) { if (r instanceof Future) { - Future future = (Future)r; + Future future = (Future)r; try { /* * Try to retrieve the value, which should throw exception in @@ -89,14 +89,14 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor ILog log = DsfPlugin.getDefault().getLog(); if (log != null) { 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. if(ASSERTIONS_ENABLED) { ByteArrayOutputStream outStream = new ByteArrayOutputStream(512); PrintStream printStream = new PrintStream(outStream); 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) {} t.printStackTrace(new PrintStream(outStream)); System.err.println(outStream.toString()); @@ -180,32 +180,32 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor traceBuilder.append(getExecutable().getClass().getName()); // Add executable's toString(). - traceBuilder.append("\n "); + traceBuilder.append("\n "); //$NON-NLS-1$ traceBuilder.append(getExecutable().toString()); // Append "create by" info. if (getExecutable() instanceof DsfExecutable) { DsfExecutable dsfExecutable = (DsfExecutable)getExecutable(); if (dsfExecutable.fCreatedAt != null || dsfExecutable.fCreatedBy != null) { - traceBuilder.append("\n created "); + traceBuilder.append("\n created "); //$NON-NLS-1$ if (dsfExecutable.fCreatedBy != null) { - traceBuilder.append(" by #"); + traceBuilder.append(" by #"); //$NON-NLS-1$ traceBuilder.append(dsfExecutable.fCreatedBy.fSequenceNumber); } if (dsfExecutable.fCreatedAt != null) { - traceBuilder.append(" at "); + traceBuilder.append(" at "); //$NON-NLS-1$ traceBuilder.append(dsfExecutable.fCreatedAt.fStackTraceElements[0].toString()); } } } // Submitted info - traceBuilder.append("\n submitted"); + traceBuilder.append("\n submitted"); //$NON-NLS-1$ if (fSubmittedBy != null) { - traceBuilder.append(" by #"); + traceBuilder.append(" by #"); //$NON-NLS-1$ traceBuilder.append(fSubmittedBy.fSequenceNumber); } - traceBuilder.append(" at "); + traceBuilder.append(" at "); //$NON-NLS-1$ traceBuilder.append(fSubmittedAt.fStackTraceElements[0].toString()); // Finally write out to console diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java index 975bdc7add6..34f258266af 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/Done.java @@ -66,6 +66,6 @@ abstract public class Done extends DsfRunnable { } public String toString() { - return "Done: " + getStatus().toString(); + return "Done: " + getStatus().toString(); //$NON-NLS-1$ } } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DoneCollector.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DoneCollector.java index f62a34bf161..8fce539f983 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DoneCollector.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DoneCollector.java @@ -48,7 +48,7 @@ public abstract class DoneCollector extends Done { * */ 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; } @@ -108,6 +108,6 @@ public abstract class DoneCollector extends Done { @Override public String toString() { - return "Done Collector: " + getStatus().toString(); + return "Done Collector: " + getStatus().toString(); //$NON-NLS-1$ } } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfExecutable.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfExecutable.java index 4b2f96e3ee8..748aa8d2772 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfExecutable.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfExecutable.java @@ -115,9 +115,9 @@ public class DsfExecutable { traceBuilder.append(' '); // 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("\nCreated at:"); + traceBuilder.append("\nCreated at:"); //$NON-NLS-1$ traceBuilder.append(fCreatedAt); DsfPlugin.debug(traceBuilder.toString()); diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfSequence.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfSequence.java index ee1dfc7853f..e2ba546b311 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfSequence.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/DsfSequence.java @@ -110,10 +110,10 @@ abstract public class DsfSequence extends DsfRunnable implements Future final private Done fDone; /** Status indicating the success/failure of the test. Used internally only. */ - @ConfinedToDsfExecutor("getExecutor") + @ConfinedToDsfExecutor("getExecutor") private IStatus fStatus = Status.OK_STATUS; - @ConfinedToDsfExecutor("getExecutor") + @ConfinedToDsfExecutor("getExecutor") private int fCurrentStepIdx = 0; /** Task name for this sequence used with the progress monitor */ @@ -128,12 +128,12 @@ abstract public class DsfSequence extends DsfRunnable implements Future /** Convenience constructor with limited arguments. */ 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. */ 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 } } 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) { @@ -297,7 +297,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future */ abortExecution(new Status( 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)); /* @@ -338,7 +338,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future }; @Override 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) { @@ -350,7 +350,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future */ abortRollBack(new Status( 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)); /* @@ -369,7 +369,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future if (fRollbackTaskName != null) { 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) { fDone.setStatus(fStatus); } @@ -418,7 +418,7 @@ abstract public class DsfSequence extends DsfRunnable implements Future */ MultiStatus newStatus = 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(fStatus); fStatus = newStatus; diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/StackTraceWrapper.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/StackTraceWrapper.java index 26352039d28..aa0e71f4498 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/StackTraceWrapper.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/concurrent/StackTraceWrapper.java @@ -24,7 +24,7 @@ class StackTraceWrapper { StringBuilder builder = new StringBuilder(fStackTraceElements.length * 30); for (int i = 0; i < fStackTraceElements.length && i < 10; 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(); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMContext.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMContext.java index a69f213401e..11350e58f13 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMContext.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMContext.java @@ -27,20 +27,20 @@ public class AbstractDMContext extends PlatformObject { private final String fSessionId; private final String fServiceFilter; - private final IDMContext[] fParents; + private final IDMContext[] fParents; /** * Main constructor provides all data needed to implement the IModelContext * interface. */ - public AbstractDMContext(String sessionId, String filter, IDMContext[] parents) { + public AbstractDMContext(String sessionId, String filter, IDMContext[] parents) { fSessionId = sessionId; fServiceFilter = filter; fParents = parents; } /** Convenience constructor */ - public AbstractDMContext(AbstractDsfService service, IDMContext parent) { + public AbstractDMContext(AbstractDsfService service, IDMContext parent) { this(service.getSession().getId(), service.getServiceFilter(), parent == null ? new IDMContext[] {} : new IDMContext[] { parent }); @@ -55,13 +55,13 @@ public class AbstractDMContext extends PlatformObject protected boolean baseEquals(Object other) { if (other == null) return false; if ( !(other.getClass().equals(getClass()))) return false; - IDMContext otherCtx = (IDMContext)other; + IDMContext otherCtx = (IDMContext)other; return getSessionId().equals(otherCtx.getSessionId()) && getServiceFilter().equals(otherCtx.getServiceFilter()) && areParentsEqual(otherCtx.getParents()); } - private boolean areParentsEqual(IDMContext[] otherParents) { + private boolean areParentsEqual(IDMContext[] otherParents) { if ( !(fParents.length == otherParents.length) ) return false; for (int i = 0; i < fParents.length; i++) { if (!fParents[i].equals(otherParents[i])) { @@ -81,7 +81,7 @@ public class AbstractDMContext extends PlatformObject protected String baseToString() { StringBuffer retVal = new StringBuffer(); - for (IDMContext parent : fParents) { + for (IDMContext parent : fParents) { retVal.append(parent); } return retVal.toString(); @@ -89,7 +89,7 @@ public class AbstractDMContext extends PlatformObject public String getSessionId() { return fSessionId; } public String getServiceFilter() { return fServiceFilter; } - public IDMContext[] getParents() { return fParents; } + public IDMContext[] getParents() { return fParents; } /** * Overrides the standard platform getAdapter to provide session-specific @@ -106,6 +106,7 @@ public class AbstractDMContext extends PlatformObject * session is equally important. * @see org.eclipse.runtime.IAdapterManager */ + @SuppressWarnings("unchecked") public Object getAdapter(Class adapterType) { Object retVal = null; DsfSession session = DsfSession.getSession(fSessionId); diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMEvent.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMEvent.java index acb4b79ba70..68d2fc9842f 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMEvent.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/AbstractDMEvent.java @@ -17,7 +17,7 @@ import org.eclipse.dd.dsf.concurrent.Immutable; * required DM-Context reference. */ @Immutable -public class AbstractDMEvent implements IDMEvent { +public class AbstractDMEvent> implements IDMEvent { private final V fModelContext; public AbstractDMEvent(V context) { diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/DMContexts.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/DMContexts.java index c9aaf7bd339..6b7e0bd0e71 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/DMContexts.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/DMContexts.java @@ -56,16 +56,16 @@ public class DMContexts { * @return true if a match is found. */ @ThreadSafe - public static boolean isAncestorOf(IDMContext dmc, IDMContext potentialAncestor) { + public static boolean isAncestorOf(IDMContext dmc, IDMContext potentialAncestor) { // Check the direct parents for a match. - for (IDMContext parentDmc : dmc.getParents()) { + for (IDMContext parentDmc : dmc.getParents()) { if (potentialAncestor.equals(parentDmc)) { return true; } } // Recursively check the parents' parents for a match. - for (IDMContext parentDmc : dmc.getParents()) { + for (IDMContext parentDmc : dmc.getParents()) { if (isAncestorOf(parentDmc, potentialAncestor)) { return true; } @@ -80,15 +80,15 @@ public class DMContexts { * into a list. */ @ThreadSafe - public static List toList(IDMContext dmc) { + public static List> toList(IDMContext dmc) { /* * This method is implemented recursively, which is not necessarily * the most efficient way to do this. */ - List list = new ArrayList(); + List> list = new ArrayList>(); list.add(dmc); - for (IDMContext parentDmc : dmc.getParents()) { + for (IDMContext parentDmc : dmc.getParents()) { list.addAll(toList(parentDmc)); } return list; diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMContext.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMContext.java index b83ef7d325e..0fc319c2f64 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMContext.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMContext.java @@ -73,5 +73,5 @@ public interface IDMContext extends IAdaptable * the client. * @return parent context of this context. */ - public IDMContext[] getParents(); + public IDMContext[] getParents(); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMEvent.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMEvent.java index d73dd889864..373689b3877 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMEvent.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMEvent.java @@ -16,6 +16,6 @@ package org.eclipse.dd.dsf.datamodel; * this base class only identifies the DM Context that is affected. * @param Data Model context type that is affected by this event. */ -public interface IDMEvent { +public interface IDMEvent > { V getDMContext(); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMService.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMService.java index 59824a8c0e1..895dca5bbd0 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMService.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/datamodel/IDMService.java @@ -26,7 +26,7 @@ public interface IDMService extends IDsfService, IDMData { * usually used in events to indicate that lists of contexts in this * service are changed. */ - IDMContext getServiceContext(); + IDMContext getServiceContext(); /** * Retrieves model data object for given context. This method makes it diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java index 81595302280..b70e857ef65 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/AbstractDsfService.java @@ -42,6 +42,7 @@ abstract public class AbstractDsfService private DsfServicesTracker fTracker; /** Properties that this service was registered with */ + @SuppressWarnings("unchecked") private Dictionary fProperties; /** Properties that this service was registered with */ @@ -58,9 +59,14 @@ abstract public class AbstractDsfService } public DsfExecutor getExecutor() { return fSession.getExecutor(); } + + @SuppressWarnings("unchecked") public Dictionary getProperties() { return fProperties; } + public String getServiceFilter() { return fFilter; } + public int getStartupNumber() { return fStartupNumber; } + public void initialize(Done done) { fTracker = new DsfServicesTracker(getBundleContext(), fSession.getId()); fStartupNumber = fSession.getAndIncrementServiceStartupCounter(); @@ -136,9 +142,10 @@ abstract public class AbstractDsfService /** * Generates an LDAP filter to uniquely identify this service. */ + @SuppressWarnings("unchecked") private String generateFilter(Dictionary properties) { StringBuffer filter = new StringBuffer(); - filter.append("(&"); + filter.append("(&"); //$NON-NLS-1$ for (Enumeration keys = properties.keys(); keys.hasMoreElements();) { Object key = keys.nextElement(); @@ -151,7 +158,7 @@ abstract public class AbstractDsfService for (Object arrayValue : (Object[])value) { filter.append('('); filter.append(key.toString()); - filter.append("=*"); + filter.append("=*"); //$NON-NLS-1$ filter.append(arrayValue.toString()); filter.append(')'); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfServicesTracker.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfServicesTracker.java index 6c9b440e31c..7ea47d7af0b 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfServicesTracker.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfServicesTracker.java @@ -43,7 +43,7 @@ import org.osgi.framework.ServiceReference; public class DsfServicesTracker { 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 @@ -93,6 +93,7 @@ public class DsfServicesTracker { * session-ID * @return OSGI service reference object to the desired service, null if not found */ + @SuppressWarnings("unchecked") public ServiceReference getServiceReference(Class serviceClass, String filter) { ServiceKey key = new ServiceKey(serviceClass.getName().intern(), filter != null ? filter : fServiceFilter); if (fServiceReferences.containsKey(key)) { @@ -109,7 +110,7 @@ public class DsfServicesTracker { return references[0]; } } catch(InvalidSyntaxException e) { - assert false : "Invalid session ID syntax"; + assert false : "Invalid session ID syntax"; //$NON-NLS-1$ } return null; } @@ -154,8 +155,8 @@ public class DsfServicesTracker { * to avoid leaking OSGI service references. */ public void dispose() { - for (Iterator itr = fServices.keySet().iterator(); itr.hasNext();) { - fBundleContext.ungetService((ServiceReference)itr.next()); + for (Iterator itr = fServices.keySet().iterator(); itr.hasNext();) { + fBundleContext.ungetService(itr.next()); itr.remove(); } } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java index 807642efa87..b7eb38ad1d2 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/DsfSession.java @@ -49,7 +49,7 @@ import org.osgi.framework.Filter; * * @see org.eclipse.dd.dsf.concurrent.DsfExecutor */ -@ConfinedToDsfExecutor("getExecutor") +@ConfinedToDsfExecutor("getExecutor") public class DsfSession { /** @@ -222,6 +222,7 @@ public class DsfSession * IModelContext.getAdapter() method. * @see org.eclipse.dd.dsf.datamodel.AbstractDMContext#getAdapter */ + @SuppressWarnings("unchecked") private Map fAdapters = Collections.synchronizedMap(new HashMap()); /** 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 */ @ThreadSafe + @SuppressWarnings("unchecked") public void dispatchEvent(final Object event, final Dictionary serviceProperties) { getExecutor().submit(new DsfRunnable() { 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 */ @ThreadSafe + @SuppressWarnings("unchecked") public void registerModelAdapter(Class adapterType, Object adapter) { fAdapters.put(adapterType, adapter); } @@ -295,6 +298,7 @@ public class DsfSession * @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter */ @ThreadSafe + @SuppressWarnings("unchecked") public void unregisterModelAdapter(Class adapterType) { fAdapters.remove(adapterType); } @@ -306,6 +310,7 @@ public class DsfSession * @see org.eclipse.dsdp.model.AbstractDMContext#getAdapter */ @ThreadSafe + @SuppressWarnings("unchecked") public Object getModelAdapter(Class adapterType) { return fAdapters.get(adapterType); } @@ -318,6 +323,7 @@ public class DsfSession @ThreadSafe public int hashCode() { return fId.hashCode(); } + @SuppressWarnings("unchecked") private void doDispatchEvent(Object event, Dictionary serviceProperties) { // Build a list of listeners; SortedMap> listeners = new TreeMap>(new Comparator() { @@ -349,8 +355,8 @@ public class DsfSession Method[] allMethods = entry.getValue(); List matchingMethods = new ArrayList(); for (Method method : allMethods) { - assert method.getParameterTypes().length > 0 : eventClass.getName() + "." + method.getName() - + " signature contains zero parameters"; + assert method.getParameterTypes().length > 0 : eventClass.getName() + "." + method.getName() //$NON-NLS-1$ + + " signature contains zero parameters"; //$NON-NLS-1$ if ( method.getParameterTypes()[0].isAssignableFrom(eventClass) ) { matchingMethods.add(method); } @@ -368,13 +374,13 @@ public class DsfSession } catch (IllegalAccessException e) { DsfPlugin.getDefault().getLog().log(new Status( - IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Security exception when calling a service event handler method", e)); - assert false : "IServiceEventListener.ServiceHandlerMethod method not accessible, is listener declared public?"; + 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?"; //$NON-NLS-1$ } catch (InvocationTargetException e) { DsfPlugin.getDefault().getLog().log(new Status( - IStatus.ERROR, DsfPlugin.PLUGIN_ID, -1, "Invocation exception when calling a service event handler method", e)); - assert false : "Exception thrown by a IServiceEventListener.ServiceHandlerMethod method"; + 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"; //$NON-NLS-1$ } } } @@ -389,17 +395,17 @@ public class DsfSession if (method.isAnnotationPresent(DsfServiceEventHandler.class)) { Class[] paramTypes = method.getParameterTypes(); 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); } } } 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()) { - 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()]); } diff --git a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java index 5db2136b8b0..77bd7654078 100644 --- a/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java +++ b/plugins/org.eclipse.dd.dsf/src/org/eclipse/dd/dsf/service/IDsfService.java @@ -42,7 +42,7 @@ public interface IDsfService { * 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. */ - 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 @@ -84,6 +84,7 @@ public interface IDsfService { /** * Returns the map of properties that this service was registered with. */ + @SuppressWarnings("unchecked") Dictionary getProperties(); /**