diff options
author | Pawel Piech | 2012-05-04 04:11:32 +0000 |
---|---|---|
committer | Eugene Tarassov | 2012-05-18 21:06:07 +0000 |
commit | a2a04cd35bf629724d974c7aba2fdae3a6bb677e (patch) | |
tree | a2d1913ea2f8969b8f727a2611a68f71fae6475e /plugins/org.eclipse.tcf.cdt.ui | |
parent | 8c431ab5a53fad6fc763896da995015f67c17984 (diff) | |
download | org.eclipse.tcf-a2a04cd35bf629724d974c7aba2fdae3a6bb677e.tar.gz org.eclipse.tcf-a2a04cd35bf629724d974c7aba2fdae3a6bb677e.tar.xz org.eclipse.tcf-a2a04cd35bf629724d974c7aba2fdae3a6bb677e.zip |
US3739 - Grouping Breakpoints by Trigger Scope
Initial prototype.
Diffstat (limited to 'plugins/org.eclipse.tcf.cdt.ui')
4 files changed, 182 insertions, 0 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml index cde009c22..4df37c0ed 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml +++ b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml @@ -345,4 +345,12 @@ name="%editor.sourceNotFound.name"> </editor> </extension> + <extension + point="org.eclipse.debug.ui.breakpointOrganizers"> + <breakpointOrganizer + class="org.eclipse.tcf.internal.cdt.ui.breakpoints.BreakpointScopeOrganizer" + id="org.eclipse.tcf.cdt.ui.breakpointScopeGroup" + label="Scope"> + </breakpointOrganizer> + </extension> </plugin> diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/ImageCache.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/ImageCache.java index 1b0a785cc..0a9c138e5 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/ImageCache.java +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/ImageCache.java @@ -25,6 +25,9 @@ public class ImageCache { public static final String IMG_TARGET_TAB = "icons/target_tab.gif"; + + public static final String + IMG_BREAKPOINT_SCOPE = "icons/bp_scope.gif"; private static final Map<String,ImageDescriptor> desc_cache = new HashMap<String,ImageDescriptor>(); private static final Map<ImageDescriptor,Image> image_cache = new HashMap<ImageDescriptor,Image>(); diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeCategory.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeCategory.java new file mode 100644 index 000000000..2b57dff07 --- /dev/null +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeCategory.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2012 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.tcf.internal.cdt.ui.breakpoints; + +import org.eclipse.core.runtime.PlatformObject; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.tcf.internal.cdt.ui.ImageCache; +import org.eclipse.ui.model.IWorkbenchAdapter; + +/** + * + */ +public class BreakpointScopeCategory extends PlatformObject implements IWorkbenchAdapter { + + private static Object[] EMPTY_CHILDREN_ARRAY = new Object[0]; + + private final String fFilter; + + public BreakpointScopeCategory(String filter) { + fFilter = filter; + } + + public String getFilter() { + return fFilter; + } + + public String getLabel(Object o) { + return "Scope: " + getFilter(); + } + + public ImageDescriptor getImageDescriptor(Object object) { + return ImageCache.getImageDescriptor(ImageCache.IMG_BREAKPOINT_SCOPE); + } + + public Object[] getChildren(Object o) { + // Not used + return EMPTY_CHILDREN_ARRAY; + } + + public Object getParent(Object o) { + // Not used + return null; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof BreakpointScopeCategory && + ((BreakpointScopeCategory)obj).getFilter().equals(getFilter()); + } + + @Override + public int hashCode() { + return fFilter.hashCode(); + } +} 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 new file mode 100644 index 000000000..9a82deaf9 --- /dev/null +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/BreakpointScopeOrganizer.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2012 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.tcf.internal.cdt.ui.breakpoints; + +import org.eclipse.cdt.debug.core.model.ICBreakpoint; +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.debug.core.DebugPlugin; +import org.eclipse.debug.core.IBreakpointsListener; +import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.ui.AbstractBreakpointOrganizerDelegate; +import org.eclipse.tcf.internal.cdt.ui.Activator; +import org.eclipse.tcf.internal.debug.model.ITCFConstants; +import org.eclipse.tcf.internal.debug.model.TCFBreakpointsModel; + +/** + * + */ +public class BreakpointScopeOrganizer extends AbstractBreakpointOrganizerDelegate implements IBreakpointsListener { + + private static IAdaptable[] EMPTY_CATEGORY_ARRAY = new IAdaptable[0]; + + public BreakpointScopeOrganizer() { + DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener(this); + } + + public IAdaptable[] getCategories(IBreakpoint breakpoint) { + 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) }; + } + } + return EMPTY_CATEGORY_ARRAY; + } + + @Override + public void dispose() { + DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener(this); + super.dispose(); + } + + public void breakpointsAdded(IBreakpoint[] breakpoints) { + } + + 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); + } + } + + public void breakpointsRemoved(IBreakpoint[] breakpoints, IMarkerDelta[] deltas) { + } + + @Override + public void addBreakpoint(IBreakpoint breakpoint, IAdaptable category) { + if (category instanceof BreakpointScopeCategory && breakpoint instanceof ICBreakpoint) { + String filter = ((BreakpointScopeCategory)category).getFilter(); + ICBreakpoint cBreakpoint = (ICBreakpoint) breakpoint; + TCFBreakpointScopeExtension scopeExtension; + try { + scopeExtension = cBreakpoint.getExtension( + ITCFConstants.ID_TCF_DEBUG_MODEL, TCFBreakpointScopeExtension.class); + if (scopeExtension != null) { + scopeExtension.setPropertiesFilter(filter); + } + } + catch (CoreException e) { + Activator.log(e); + } + } + } + + @Override + public boolean canAdd(IBreakpoint breakpoint, IAdaptable category) { + return category instanceof BreakpointScopeCategory && breakpoint instanceof ICBreakpoint; + } + + @Override + public boolean canRemove(IBreakpoint breakpoint, IAdaptable category) { + return breakpoint instanceof ICBreakpoint; + } + + @Override + public void removeBreakpoint(IBreakpoint breakpoint, IAdaptable category) { + // Nothing to do, changes handled by add. + } +} |