Update breakpoint group actions to work on BreakpointGroupContainer
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 1c38162..8828f80 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml
@@ -1159,7 +1159,7 @@ id="org.eclipse.debug.ui.breakpointview.breakpointGroupActions"> <visibility> <objectClass - name="java.lang.String"> + name="org.eclipse.debug.internal.ui.views.breakpoints.BreakpointGroupContainer"> </objectClass> </visibility> <action
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AbstractBreakpointGroupAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AbstractBreakpointGroupAction.java index 8857a83..b68e15e 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AbstractBreakpointGroupAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/AbstractBreakpointGroupAction.java
@@ -10,22 +10,27 @@ *******************************************************************************/ package org.eclipse.debug.internal.ui.actions.breakpointGroups; +import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; +import java.util.List; +import java.util.Set; import org.eclipse.debug.core.model.IBreakpoint; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointGroupContainer; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; /** - * An action which acts on a selection of breakpoint groups + * An action which acts on a selection of breakpoint group containers */ public abstract class AbstractBreakpointGroupAction extends AbstractBreakpointsViewAction { /** - * The selected breakpoint groups. + * The selected breakpoint group containers. */ - protected String[] fGroups; + private List fGroupContainers= new ArrayList(); /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) @@ -33,23 +38,21 @@ public void selectionChanged(IAction action, ISelection sel) { IStructuredSelection selection= (IStructuredSelection) sel; int selectionSize= selection.size(); - if (selectionSize == 0) { - fGroups= new String[0]; - } else { - fGroups= new String[selection.size()]; + fGroupContainers.clear(); + if (selectionSize != 0) { Iterator iter = selection.iterator(); int index= 0; while (iter.hasNext()) { Object element= iter.next(); - if (element instanceof String) { - fGroups[index++]= (String) element; + if (element instanceof BreakpointGroupContainer) { + fGroupContainers.add(element); } else { - fGroups= new String[0]; + fGroupContainers.clear(); break; } } } - action.setEnabled(fGroups.length > 0); + action.setEnabled(fGroupContainers.size() > 0); } /** @@ -57,7 +60,13 @@ * @return the selected breakpoint groups */ public String[] getSelectedGroups() { - return fGroups; + List groupNames= new ArrayList(); + Iterator iter = fGroupContainers.iterator(); + while (iter.hasNext()) { + BreakpointGroupContainer container = (BreakpointGroupContainer) iter.next(); + groupNames.add(container.getName()); + } + return (String[]) groupNames.toArray(new String[0]); } /** @@ -66,12 +75,16 @@ * @return the breakpoints within the given group */ public IBreakpoint[] getBreakpoints(String group) { - Object[] children = fView.getTreeContentProvider().getChildren(group); - IBreakpoint[] breakpoints= new IBreakpoint[children.length]; - for (int i = 0; i < children.length; i++) { - breakpoints[i]= (IBreakpoint) children[i]; - } - return breakpoints; + Set breakpoints= new HashSet(); + Iterator iter = fGroupContainers.iterator(); + while (iter.hasNext()) { + BreakpointGroupContainer container = (BreakpointGroupContainer) iter.next(); + IBreakpoint[] children = container.getBreakpoints(); + for (int i = 0; i < children.length; i++) { + breakpoints.add(children[0]); + } + } + return (IBreakpoint[]) breakpoints.toArray(new IBreakpoint[0]); } }
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainer.java new file mode 100644 index 0000000..3539834 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainer.java
@@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.views.breakpoints; + +import org.eclipse.debug.core.model.IBreakpoint; + +/** + * Subclass of breakpoint container which exists to allow action contributions to + * breakpoint group containers + */ +public class BreakpointGroupContainer extends BreakpointContainer { + + /** + * @param breakpoints + * @param parentFactory + * @param name + * @param parentId + */ + public BreakpointGroupContainer(IBreakpoint[] breakpoints, IBreakpointContainerFactory parentFactory, String name, String parentId) { + super(breakpoints, parentFactory, name, parentId); + } + +}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainerFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainerFactory.java index a9f1bf0..68e5cd1 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainerFactory.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointGroupContainerFactory.java
@@ -60,7 +60,7 @@ while (iter.hasNext()) { String group= (String) iter.next(); List list= (List) map.get(group); - BreakpointContainer container= new BreakpointContainer( + BreakpointGroupContainer container= new BreakpointGroupContainer( (IBreakpoint[]) list.toArray(new IBreakpoint[0]), this, group, @@ -68,7 +68,7 @@ containers.add(container); } if (other.size() > 0) { - BreakpointContainer container= new BreakpointContainer( + BreakpointGroupContainer container= new BreakpointGroupContainer( (IBreakpoint[]) other.toArray(new IBreakpoint[0]), this, "(no group)",