diff options
Diffstat (limited to 'plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java')
-rw-r--r-- | plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java | 72 |
1 files changed, 55 insertions, 17 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java index 9a82deaf9..92b751372 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java @@ -15,21 +15,34 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IAdapterFactory; +import org.eclipse.core.runtime.Platform; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.IBreakpointsListener; import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.internal.ui.breakpoints.provisional.IBreakpointContainer; import org.eclipse.debug.ui.AbstractBreakpointOrganizerDelegate; +import org.eclipse.debug.ui.IBreakpointOrganizerDelegate; import org.eclipse.tcf.internal.cdt.ui.Activator; import org.eclipse.tcf.internal.debug.model.ITCFConstants; import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel; /** + * Breakpoint organizer which groups breakpoints according to their + * breakpoint scope attributes. * + * @see IBreakpointOrganizerDelegate */ +@SuppressWarnings("restriction") public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegate implements IBreakpointsListener { - private static IAdaptable[] EMPTY_CATEGORY_ARRAY = new IAdaptable[0]; + private static IAdaptable[] DEFAULT_CATEGORY_ARRAY = new IAdaptable[] { new BreakpointScopeCategory(null, null) }; + static + { + Platform.getAdapterManager().registerAdapters(new BreakpointScopeContainerAdapterFactory(), IBreakpointContainer.class); + } + public BreakpointScopeOrganizer() { DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); } @@ -38,11 +51,10 @@ public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegat IMarker marker = breakpoint.getMarker(); if (marker != null) { String filter = marker.getAttribute(TCFBreakpointsModel.ATTR_CONTEXT_QUERY, null); - if (filter != null) { - return new IAdaptable[] { new BreakpointScopeCategory(filter) }; - } + String contextIds = marker.getAttribute(TCFBreakpointsModel.ATTR_CONTEXTIDS, null); + return new IAdaptable[] { new BreakpointScopeCategory(filter, contextIds) }; } - return EMPTY_CATEGORY_ARRAY; + return DEFAULT_CATEGORY_ARRAY; } @Override @@ -55,18 +67,10 @@ public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegat } public void breakpointsChanged(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { - boolean changed = false; - - for (IBreakpoint breakpoint : breakpoints) { - IMarker marker = breakpoint.getMarker(); - if (marker != null && marker.getAttribute(TCFBreakpointsModel.ATTR_CONTEXT_QUERY, null) != null) { - changed = true; - break; - } - } - if (changed) { - fireCategoryChanged(null); - } + // Using delta's to see which attributes have changed is not reliable. + // Therefore we need to force a full refresh of scope categories whenever + // we get a breakpoints changed notiifcation. + fireCategoryChanged(null); } public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { @@ -76,6 +80,7 @@ public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegat public void addBreakpoint(IBreakpoint breakpoint, IAdaptable category) { if (category instanceof BreakpointScopeCategory && breakpoint instanceof ICBreakpoint) { String filter = ((BreakpointScopeCategory)category).getFilter(); + String contextIds = ((BreakpointScopeCategory)category).getContextIds(); ICBreakpoint cBreakpoint = (ICBreakpoint) breakpoint; TCFBreakpointScopeExtension scopeExtension; try { @@ -83,6 +88,7 @@ public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegat ITCFConstants.ID_TCF_DEBUG_MODEL, TCFBreakpointScopeExtension.class); if (scopeExtension != null) { scopeExtension.setPropertiesFilter(filter); + scopeExtension.setRawContextIds(contextIds); } } catch (CoreException e) { @@ -106,3 +112,35 @@ public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegat // Nothing to do, changes handled by add. } } + +/** + * Adapter factory which returns the breakpoint category for a given breakpoint + * container element that is shown in Breakpoints view. + */ +@SuppressWarnings("restriction") +class BreakpointScopeContainerAdapterFactory implements IAdapterFactory { + + private static final Class<?>[] fgAdapterList = new Class[] { + BreakpointScopeCategory.class + }; + + public Object getAdapter(Object obj, @SuppressWarnings("rawtypes") Class adapterType) { + if ( !(obj instanceof IBreakpointContainer) ) return null; + + + if ( BreakpointScopeCategory.class.equals(adapterType) ) { + IAdaptable category = ((IBreakpointContainer)obj).getCategory(); + if (category instanceof BreakpointScopeCategory) { + return category; + } + } + return null; + } + + @SuppressWarnings("rawtypes") + public Class[] getAdapterList() { + return fgAdapterList; + } +} + + |