Added "Group By" actions
diff --git a/org.eclipse.debug.ui/plugin.properties b/org.eclipse.debug.ui/plugin.properties index 7415eb8..3ef5eb2 100644 --- a/org.eclipse.debug.ui/plugin.properties +++ b/org.eclipse.debug.ui/plugin.properties
@@ -287,4 +287,5 @@ addToGroup.label=&Add To Group removeFromGroup.label=&Remove From Group renameGroup.label=Re&name Group -dissolveGroup.label=&Ungroup \ No newline at end of file +dissolveGroup.label=&Ungroup +GroupBreakpointsByAction.label=Group By \ No newline at end of file
diff --git a/org.eclipse.debug.ui/plugin.xml b/org.eclipse.debug.ui/plugin.xml index 8828f80..f3b9cd6 100644 --- a/org.eclipse.debug.ui/plugin.xml +++ b/org.eclipse.debug.ui/plugin.xml
@@ -1077,6 +1077,14 @@ menubarPath="removeGroup" id="org.eclipse.debug.ui.actions.RemoveAllBreakpoints"> </action> + <action + label="%GroupBreakpointsByAction.label" + style="pulldown" + class="org.eclipse.debug.internal.ui.actions.breakpointGroups.GroupBreakpointsByAction" + menubarPath="additions" + enablesFor="*" + id="org.eclipse.debug.ui.actions.GroupBreakpointsByAction"> + </action> </viewerContribution> <!-- Breakpoint actions --> <viewerContribution
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java index 34e88f2..9b639cd 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java
@@ -17,8 +17,6 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.WorkbenchEncoding; -import org.eclipse.ui.internal.Workbench; public class DebugUIPreferenceInitializer extends AbstractPreferenceInitializer { @@ -62,7 +60,7 @@ prefs.setDefault(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK, 80000); prefs.setDefault(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK, 100000); prefs.setDefault(IDebugPreferenceConstants.CONSOLE_TAB_WIDTH, 8); - prefs.setDefault(IDebugPreferenceConstants.CONSOLE_ENCODING, WorkbenchEncoding.getWorkbenchDefaultEncoding()); +// prefs.setDefault(IDebugPreferenceConstants.CONSOLE_ENCODING, WorkbenchEncoding.getWorkbenchDefaultEncoding()); PreferenceConverter.setDefault(prefs, IDebugPreferenceConstants.CONSOLE_SYS_OUT_COLOR, new RGB(0, 0, 255)); PreferenceConverter.setDefault(prefs, IDebugPreferenceConstants.CONSOLE_SYS_IN_COLOR, new RGB(0, 200, 125));
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ShowBreakpointsByAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ShowBreakpointsByAction.java index d77f3de..4ee366f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ShowBreakpointsByAction.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ShowBreakpointsByAction.java
@@ -13,6 +13,7 @@ import java.util.List; import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView; +import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.viewers.ISelection; @@ -22,7 +23,7 @@ /** * */ -public class ShowBreakpointsByAction implements IViewActionDelegate { +public class ShowBreakpointsByAction extends Action implements IViewActionDelegate { private BreakpointsView fView; @@ -32,16 +33,23 @@ public void init(IViewPart view) { fView= (BreakpointsView) view; } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + public void run() { + ShowBreakpointsByDialog dialog = new ShowBreakpointsByDialog(fView); + if (dialog.open() == Dialog.OK) { + List selectedContainers = dialog.getSelectedContainers(); + fView.setBreakpointContainerFactories(selectedContainers); + } + } /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { - ShowBreakpointsByDialog dialog = new ShowBreakpointsByDialog(fView); - if (dialog.open() == Dialog.OK) { - List selectedContainers = dialog.getSelectedContainers(); - fView.setBreakpointContainerFactories(selectedContainers); - } + run(); } /* (non-Javadoc)
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java new file mode 100644 index 0000000..f3ca65c --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsAction.java
@@ -0,0 +1,42 @@ +/******************************************************************************* + * 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 implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.actions.breakpointGroups; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsView; +import org.eclipse.debug.internal.ui.views.breakpoints.IBreakpointContainerFactory; +import org.eclipse.jface.action.Action; + +/** + * + */ +public class GroupBreakpointsAction extends Action { + + private IBreakpointContainerFactory fFactory; + private BreakpointsView fView; + + public GroupBreakpointsAction(IBreakpointContainerFactory factory, BreakpointsView view) { + fFactory= factory; + fView= view; + setText(fFactory.getLabel()); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IAction#run() + */ + public void run() { + List list= new ArrayList(); + list.add(fFactory); + fView.setBreakpointContainerFactories(list); + } +}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByAction.java new file mode 100644 index 0000000..4563ab8 --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpointGroups/GroupBreakpointsByAction.java
@@ -0,0 +1,101 @@ +/******************************************************************************* + * 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 implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.actions.breakpointGroups; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.debug.internal.ui.actions.ShowBreakpointsByAction; +import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointContainerFactoryManager; +import org.eclipse.debug.internal.ui.views.breakpoints.IBreakpointContainerFactory; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; + +/** + * + */ +public class GroupBreakpointsByAction extends AbstractBreakpointsViewAction implements IMenuCreator { + + private boolean fFillMenu= true; + private IAction fAction= null; + + public GroupBreakpointsByAction() { + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + public void run(IAction action) { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#dispose() + */ + public void dispose() { + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control) + */ + public Menu getMenu(Control parent) { + // Never called + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu) + */ + public Menu getMenu(Menu parent) { + Menu menu = new Menu(parent); + fillMenu(menu); + return menu; + } + + /** + * Fill pull down menu with the "group by" options + */ + private void fillMenu(Menu menu) { + Iterator actionIter = getActions().iterator(); + while (actionIter.hasNext()) { + ActionContributionItem item= new ActionContributionItem((IAction) actionIter.next()); + item.fill(menu, -1); + } + } + + public List getActions() { + List actions= new ArrayList(); + IBreakpointContainerFactory[] factories = BreakpointContainerFactoryManager.getDefault().getFactories(); + for (int i = 0; i < factories.length; i++) { + IAction action = new GroupBreakpointsAction(factories[i], fView); + actions.add(action); + } + ShowBreakpointsByAction advancedAction = new ShowBreakpointsByAction(); + advancedAction.setText("Advanced..."); + advancedAction.init(fView); + actions.add(advancedAction); + return actions; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) + */ + public void selectionChanged(IAction action, ISelection selection) { + if (action != fAction) { + action.setMenuCreator(this); + fAction= action; + } + } +}
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewContentProvider.java index 7fb49da..066a8be 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewContentProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/views/breakpoints/BreakpointsViewContentProvider.java
@@ -38,7 +38,7 @@ children= breakpoints; } else if (parent instanceof IBreakpointManager) { IBreakpointContainerFactory factory = (IBreakpointContainerFactory) fBreakpointContainerFactories.get(0); - children= factory.getContainers(breakpoints, ""); + children= getFactoryChildren(factory, "", breakpoints); } else if (parent instanceof IBreakpointContainer) { IBreakpointContainer container = ((IBreakpointContainer) parent); IBreakpointContainerFactory parentFactory = container.getParentFactory(); @@ -50,10 +50,7 @@ children= container.getBreakpoints(); } else { IBreakpointContainerFactory nextFactory = (IBreakpointContainerFactory) fBreakpointContainerFactories.get(index + 1); - children= nextFactory.getContainers(container.getBreakpoints(), getParentId(container)); - if (children.length == 1) { - children= getElements(children[0]); - } + children= getFactoryChildren(nextFactory, getParentId(container), container.getBreakpoints()); } } else { children= new Object[0]; @@ -64,6 +61,14 @@ return children; } + public Object[] getFactoryChildren(IBreakpointContainerFactory factory, String parentId, IBreakpoint[] breakpoints) { + Object[] children= factory.getContainers(breakpoints, parentId); + if (children.length == 1) { + children= getElements(children[0]); + } + return children; + } + public String getParentId(IBreakpointContainer container) { Object parent= getParent(container); if (parent instanceof IBreakpointContainer) {