summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Tepavich2012-04-30 13:51:21 (EDT)
committerPawel Piech2012-04-30 14:38:33 (EDT)
commit99b0e4643d8103ebd9789b79580cf4e3bbe0b695 (patch)
treecfd123f38398c7d44d19e9187ab3232fb93a5b6c
parent9ba6060632da13047dbd5763b0fe891a8768322b (diff)
downloadorg.eclipse.cdt-99b0e4643d8103ebd9789b79580cf4e3bbe0b695.zip
org.eclipse.cdt-99b0e4643d8103ebd9789b79580cf4e3bbe0b695.tar.gz
org.eclipse.cdt-99b0e4643d8103ebd9789b79580cf4e3bbe0b695.tar.bz2
Bug 376236 - [breakpoints] Create event breakpoints using breakpoint properties dialog
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java48
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java13
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java13
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties1
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java257
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java26
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java12
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java35
-rw-r--r--debug/org.eclipse.cdt.gdb.ui/plugin.xml1
-rw-r--r--dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java16
11 files changed, 396 insertions, 32 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java
index b959f77..36081a2 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddEventBreakpointActionDelegate.java
@@ -14,25 +14,30 @@ package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
-import org.eclipse.cdt.debug.internal.ui.dialogs.AddEventBreakpointDialog;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
-import org.eclipse.cdt.debug.ui.UIMessages;
+import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.window.Window;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.actions.ActionDelegate;
/**
* A delegate for the "Add Event Breakpoint" action.
*/
-public class AddEventBreakpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
+public class AddEventBreakpointActionDelegate extends ActionDelegate implements IViewActionDelegate, IObjectActionDelegate {
private IViewPart fView;
+ private IWorkbenchPart fPart;
+ private ISelection fSelection;
+ private ToggleBreakpointAdapter fDefaultToggleTarget = new ToggleBreakpointAdapter();
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
@@ -43,27 +48,35 @@ public class AddEventBreakpointActionDelegate extends ActionDelegate implements
}
private void setView(IViewPart view) {
- fView = view;
+ fPart = fView = view;
}
protected IViewPart getView() {
return fView;
}
+ @Override
+ public void selectionChanged(IAction action, ISelection selection) {
+ fSelection = selection;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
@Override
public void run(IAction action) {
- AddEventBreakpointDialog dlg = new AddEventBreakpointDialog(CDebugUIPlugin.getActiveWorkbenchShell());
- if (dlg.isActive() == false) {
- String message = ActionMessages.getString("AddEventBreakpointActionDelegate.2"); //$NON-NLS-1$
- MessageDialog.openError( getView().getSite().getShell(), UIMessages.getString( "CDebugUIPlugin.0" ), message); //$NON-NLS-1$
- } else {
- if (dlg.open() == Window.OK) {
- addEventBreakpoint(dlg.getEventTypeId(), dlg.getEventArgument());
- }
- }
+ IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fPart, fSelection);
+ IToggleBreakpointsTargetCExtension cToggleTarget = null;
+ if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
+ cToggleTarget = (IToggleBreakpointsTargetCExtension)toggleTarget;
+ } else {
+ cToggleTarget = fDefaultToggleTarget;
+ }
+ try {
+ cToggleTarget.createEventBreakpointsInteractive(fPart, fSelection);
+ } catch (CoreException e) {
+ CDebugUIPlugin.errorDialog( ActionMessages.getString("AddEventBreakpointActionDelegate.2"), e ); //$NON-NLS-1$
+ }
}
protected void addEventBreakpoint(String id, String arg) {
@@ -80,4 +93,9 @@ public class AddEventBreakpointActionDelegate extends ActionDelegate implements
return ResourcesPlugin.getWorkspace().getRoot();
}
+ @Override
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ fPart = targetPart;
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java
index c35d353..92888f2 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java
@@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
+import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
@@ -94,10 +95,20 @@ public class ToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter {
ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
Map<String, Object> attributes = new HashMap<String, Object>();
CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false,
- expression, memorySpace, new BigInteger(range), true, 0, ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expression, memorySpace, new BigInteger(range), true, 0, ""); //$NON-NLS-1$
openBreakpointPropertiesDialog(bp, part, resource, attributes);
}
+ @Override
+ protected void createEventBreakpoint( boolean interactive, IWorkbenchPart part, IResource resource, String type,
+ String arg ) throws CoreException
+ {
+ ICEventBreakpoint bp = CDIDebugModel.createBlankEventBreakpoint();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ CDIDebugModel.setEventBreakpointAttributes(attributes,type, arg);
+ openBreakpointPropertiesDialog(bp, part, resource, attributes);
+ }
+
protected int getBreakpointType() {
return ICBreakpointType.REGULAR;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java
index 0510d80..0408837 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleTracepointAdapter.java
@@ -84,6 +84,19 @@ public class ToggleTracepointAdapter extends AbstractToggleBreakpointAdapter {
int charStart, int charEnd, int lineNumber, String expression, String memorySpace, String range) throws CoreException
{
}
+
+ @Override
+ public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
+ return false;
+ }
+
+ @Override
+ protected void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource, String type,
+ String arg) throws CoreException {
+
+ }
+
+
protected int getBreakpointType() {
return ICBreakpointType.REGULAR;
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties
index 45819b0..90c7a30 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/BreakpointsMessages.properties
@@ -38,5 +38,6 @@ CBreakpointPropertyPage.condition_invalidValue_message=Invalid condition.
CBreakpointPropertyPage.ignoreCount_label=&Ignore count:
CBreakpointPropertyPage.breakpointType_label=Class:
CBreakpointPropertyPage.enabled_label=Enabled
+CBreakpointPropertyPage.eventType_label=Event Type
ThreadFilterEditor.0=&Restrict to Selected Targets and Threads:
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java
index 2262608..587af11 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/breakpoints/CBreakpointPropertyPage.java
@@ -12,16 +12,21 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.breakpoints;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
+import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
+import org.eclipse.cdt.debug.internal.core.breakpoints.CEventBreakpoint;
import org.eclipse.cdt.debug.internal.ui.preferences.ComboFieldEditor;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointUIContributionFactory;
@@ -34,10 +39,12 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugModelProvider;
import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
+import org.eclipse.jface.layout.GridDataFactory;
import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
@@ -49,8 +56,11 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
@@ -63,6 +73,10 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
*/
public class CBreakpointPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage {
+ private Composite fEventBPComposite;
+ private Composite fEventArgsComposite;
+ private List<FieldEditor> fEventArgsFEs = null;
+
class BreakpointIntegerFieldEditor extends IntegerFieldEditor {
public BreakpointIntegerFieldEditor( String name, String labelText, Composite parent ) {
@@ -384,6 +398,16 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
return array2d;
}
+ private String[][] joinToArray2D(String[] labels, String[] values) {
+ String[][] array2d = new String[labels.length][];
+ for (int i = 0; i < labels.length; i++) {
+ array2d[i] = new String[2];
+ array2d[i][0] = labels[i];
+ array2d[i][1] = values[i];
+ }
+ return array2d;
+ }
+
private ICDIMemorySpaceManagement getMemorySpaceManagement(){
Object debugViewElement = getDebugContext();
ICDIMemorySpaceManagement memMgr = null;
@@ -527,6 +551,9 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
createLineNumberEditor(getFieldEditorParent());
}
}
+ else if ( breakpoint instanceof CEventBreakpoint ) {
+ createEventBreakpointEditor( breakpoint, ICBreakpointsUIContribution.BREAKPOINT_LABELS);
+ }
}
private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
@@ -760,18 +787,77 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
fElement = element;
}
+ protected String[] getDebugModelIds() {
+ String[] debugModelIds = null;
+ Object debugContext = getDebugContext();
+ IDebugModelProvider debugModelProvider = (IDebugModelProvider)
+ DebugPlugin.getAdapter(debugContext, IDebugModelProvider.class);
+ if (debugModelProvider != null) {
+ debugModelIds = debugModelProvider.getModelIdentifiers();
+ } else if (debugContext instanceof IDebugElement) {
+ debugModelIds = new String[] { ((IDebugElement)debugContext).getModelIdentifier() };
+ }
+ return debugModelIds;
+ }
+
+ private void createEventBreakpointEditor( ICBreakpoint breakpoint, String conMainElement) {
+ boolean bAddEventType = true;
+ Composite parent = getFieldEditorParent();
+ String[] debugModelIds = getDebugModelIds();
+ try {
+ ICBreakpointsUIContribution[] cons;
+ CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
+ IPreferenceStore prefStore = getPreferenceStore();
+ if (prefStore instanceof CBreakpointPreferenceStore) {
+ cons = factory.getBreakpointUIContributions(
+ debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
+ } else {
+ cons = factory.getBreakpointUIContributions(breakpoint);
+ }
+
+ setupEventTypeFieldEditor(cons, breakpoint, conMainElement, parent);
+ for (ICBreakpointsUIContribution con : cons) {
+ if ( conMainElement.equals(con.getMainElement()) ) {
+ FieldEditor fieldEditor = null;
+ if (breakpoint.getMarker() == null && con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) {
+ continue;
+ }
+ else if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)) {
+ if ( breakpoint.getMarker() == null ) {
+ setupArgsComposite(parent);
+ fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", fEventArgsComposite); //$NON-NLS-1$
+ if ( fieldEditor != null ) {
+ addEditorToComposite(fieldEditor);
+ fEventArgsComposite.setVisible(true);
+ }
+ else {
+ fEventArgsComposite.setVisible(false);
+ }
+ }
+ else {
+ if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) {
+ if (bAddEventType == true) bAddEventType = false;
+ else continue;
+ }
+ fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
+ }
+ }
+
+ if (fieldEditor != null) {
+ addField(fieldEditor);
+ }
+ }
+ }
+ } catch (CoreException ce) {
+ CDebugUIPlugin.log(ce);
+ }
+ }
/**
* Creates field editors contributed using breakpointUIContribution extension point
*/
private void createContributedFieldEditors(ICBreakpoint breakpoint, String conMainElement) {
Composite parent = getFieldEditorParent();
- String[] debugModelIds = CBreakpointUIContributionFactory.DEBUG_MODEL_IDS_DEFAULT;
- IDebugModelProvider debugModelProvider = (IDebugModelProvider)DebugPlugin.getAdapter(
- getDebugContext(), IDebugModelProvider.class);
- if (debugModelProvider != null) {
- debugModelIds = debugModelProvider.getModelIdentifiers();
- }
-
+ String[] debugModelIds = getDebugModelIds();
try {
ICBreakpointsUIContribution[] cons;
CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
@@ -785,7 +871,10 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
for (ICBreakpointsUIContribution con : cons) {
if ( conMainElement.equals(con.getMainElement()) ) {
- FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
+ if (con.getMarkerType().equals(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)) {
+ continue;
+ }
+ FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", parent); //$NON-NLS-1$
if (fieldEditor != null) {
addField(fieldEditor);
}
@@ -794,7 +883,159 @@ public class CBreakpointPropertyPage extends FieldEditorPreferencePage implement
} catch (CoreException ce) {
CDebugUIPlugin.log(ce);
}
+ }
+
+ private void setupEventTypeFieldEditor(ICBreakpointsUIContribution[] cons, ICBreakpoint breakpoint, String conMainElement, Composite parent) {
+ String id = null;
+ ArrayList<String> eventTypeValueList = new ArrayList<String>();
+ ArrayList<String> eventTypeLabelList = new ArrayList<String>();
+
+ // The filter of the debugModelIds should already be done.
+ for (ICBreakpointsUIContribution con : cons) {
+ if ( conMainElement.equals(con.getMainElement()) ) {
+ if (breakpoint instanceof CEventBreakpoint && breakpoint.getMarker() == null &&
+ con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) {
+ id = con.getId();
+ for (String value : con.getPossibleValues()) {
+ eventTypeValueList.add(value);
+ eventTypeLabelList.add(con.getLabelForValue(value));
+ }
+ }
+ }
+ }
+ if (eventTypeValueList.size() != 0) {
+ EventTypeFieldEditor fieldEditor = new EventTypeFieldEditor(
+ id,
+ BreakpointsMessages.getString("CBreakpointPropertyPage.eventType_label"), //$NON-NLS-1$
+ eventTypeLabelList.toArray(new String[eventTypeLabelList.size()]),
+ eventTypeValueList.toArray(new String[eventTypeValueList.size()]),
+ parent,
+ breakpoint);
+ addField(fieldEditor);
+ setupArgsComposite(parent);
+ fieldEditor.initializeComboBox(getPreferenceStore(), this);
+ }
+ }
+
+ void addEditorToComposite(FieldEditor fieldEditor) {
+ if (fEventArgsFEs == null) {
+ fEventArgsFEs = new ArrayList<FieldEditor>();
+ }
+ fEventArgsFEs.add(fieldEditor);
+ }
+ void cleanEditorsFromComposite() {
+ if (fEventArgsFEs != null) {
+ for (FieldEditor editor : fEventArgsFEs){
+ editor.setPreferenceStore(null);
+ editor.setPage(null);
+ }
+ }
}
+ void setupArgsComposite(Composite parent) {
+ if (fEventArgsComposite != null) {
+ cleanEditorsFromComposite();
+ fEventArgsComposite.dispose();
+ fEventArgsComposite = null;
+ }
+ if (fEventBPComposite == null || fEventBPComposite.isDisposed()) {
+ fEventBPComposite = new Composite(parent,SWT.NONE);
+ fEventBPComposite.setLayout(parent.getLayout());
+ fEventBPComposite.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
+ GridDataFactory.defaultsFor(fEventBPComposite).grab(true, false).span(2, 1).applyTo(fEventBPComposite);
+ }
+ fEventArgsComposite = new Composite(fEventBPComposite,SWT.NONE);
+ fEventArgsComposite.setLayout(fEventBPComposite.getLayout());
+ GridDataFactory.defaultsFor(fEventArgsComposite).grab(true, false).span(2, 1).applyTo(fEventArgsComposite);
+ GridData gridData = (GridData)fEventArgsComposite.getLayoutData();
+ gridData.horizontalIndent = 10;
+ fEventArgsComposite.setLayoutData(gridData);
+ fEventArgsComposite.setVisible(false);
+ }
+
+ private void displayEventArgs(ICBreakpoint breakpoint, Composite parent) {
+ boolean result = false;
+ String[] debugModelIds = getDebugModelIds();
+
+ try {
+ ICBreakpointsUIContribution[] cons;
+ CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
+ IPreferenceStore prefStore = getPreferenceStore();
+ if (prefStore instanceof CBreakpointPreferenceStore) {
+ cons = factory.getBreakpointUIContributions(
+ debugModelIds, breakpoint, ((CBreakpointPreferenceStore) prefStore).getAttributes());
+ } else {
+ cons = factory.getBreakpointUIContributions(breakpoint);
+ }
+ for (ICBreakpointsUIContribution con : cons) {
+ if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER) &&
+ !con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) {
+ setupArgsComposite(parent);
+ FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", fEventArgsComposite); //$NON-NLS-1$
+ if ( fieldEditor != null ) {
+ fieldEditor.setPreferenceStore(getPreferenceStore());
+ fieldEditor.setPage(this);
+ addEditorToComposite(fieldEditor);
+ addField(fieldEditor);
+ result = true;
+ }
+ }
+ }
+ } catch (CoreException ce) {
+ CDebugUIPlugin.log(ce);
+ }
+
+ if (fEventArgsComposite != null && !fEventArgsComposite.isDisposed()) {
+ fEventArgsComposite.setVisible(result);
+ fEventArgsComposite.layout();
+ fEventBPComposite.layout();
+ }
+ }
+
+ class EventTypeFieldEditor extends ComboFieldEditor {
+
+ final Combo fCombo;
+ final Composite fParent;
+ final ICBreakpoint fBreakpoint;
+
+ class EventTypeSelectionListener implements SelectionListener {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ doStore();
+ displayEventArgs(fBreakpoint, fParent);
+ fParent.layout();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ widgetSelected(e);
+ }
+ }
+
+ public EventTypeFieldEditor( String name, String labelText, String[] eventTypesLabels, String[] eventTypesValues, Composite parent, ICBreakpoint breakpoint ) {
+ super( name, labelText, joinToArray2D(eventTypesLabels,eventTypesValues), parent);
+ fBreakpoint = breakpoint;
+ fParent = parent;
+ fCombo = this.getComboBoxControl();
+ fCombo.select(0);
+ fCombo.addSelectionListener(new EventTypeSelectionListener());
+ }
+
+ public void initializeComboBox(IPreferenceStore prefStore, CBreakpointPropertyPage page) {
+ if (getPage() == null) {
+ setPage(page);
+ }
+ if (getPreferenceStore() == null) {
+ setPreferenceStore(prefStore);
+ }
+ else
+ prefStore = getPreferenceStore();
+
+ String value = getValueForName(fCombo.getText());
+ if (prefStore instanceof CBreakpointPreferenceStore) {
+ prefStore.setValue(ICEventBreakpoint.EVENT_TYPE_ID, value);
+ }
+ displayEventArgs(fBreakpoint, fParent);
+ }
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java
index 5e5d2f3..2cf5525 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java
@@ -214,6 +214,18 @@ abstract public class AbstractToggleBreakpointAdapter
}
@Override
+ public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
+ return true;
+ }
+
+ @Override
+ public void createEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
+ String type = ""; //$NON-NLS-1$
+ String arg = ""; //$NON-NLS-1$
+ createEventBreakpoint( true, part, ResourcesPlugin.getWorkspace().getRoot(), type, arg );
+ }
+
+ @Override
public boolean canCreateFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) {
return true;
}
@@ -909,5 +921,17 @@ abstract public class AbstractToggleBreakpointAdapter
protected abstract void createWatchpoint(boolean interactive, IWorkbenchPart part, String sourceHandle,
IResource resource, int charStart, int charEnd, int lineNumber, String expression, String memorySpace,
String range) throws CoreException;
-
+
+ /**
+ * Creates an event breakpoint of the given type.
+ * @param interactive true if action should open a dialog to let user edit
+ * breakpoint properties prior to creation.
+ * @param part Workbench part where action was invoked.
+ * @param resource Resource to create breakpoint on.
+ * @param type Type of event breakpoint.
+ * @param arg Arugment of event breakpoint.
+ * @throws CoreException Exception while creating breakpoint.
+ */
+ protected abstract void createEventBreakpoint(boolean interactive, IWorkbenchPart part, IResource resource,
+ String type, String arg) throws CoreException;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java
index 118d1b4..bf68532 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CBreakpointUIContributionFactory.java
@@ -50,7 +50,7 @@ public class CBreakpointUIContributionFactory {
* @throws CoreException if cannot get marker attributes from bearkpoint
*/
public ICBreakpointsUIContribution[] getBreakpointUIContributions(IBreakpoint breakpoint) throws CoreException {
- String debugModelId = breakpoint.getModelIdentifier();
+ String debugModelId = null;
IMarker bmarker = breakpoint.getMarker();
Map<String, Object> attributes = Collections.emptyMap();
String markerType = CDIDebugModel.calculateMarkerType(breakpoint);
@@ -104,7 +104,7 @@ public class CBreakpointUIContributionFactory {
Map<String, Object> attributes)
{
return getBreakpointUIContributions(
- debugModelId != null ? new String[] { debugModelId } : DEBUG_MODEL_IDS_DEFAULT,
+ debugModelId != null ? new String[] { debugModelId } : null,
markerType,
attributes);
@@ -127,13 +127,15 @@ public class CBreakpointUIContributionFactory {
public ICBreakpointsUIContribution[] getBreakpointUIContributions(String[] debugModelIds, String markerType,
Map<String, Object> attributes)
{
- List<String> debugModelIdsList = Arrays.asList(debugModelIds);
+ List<String> debugModelIdsList = null;
+ if (debugModelIds != null ) {
+ debugModelIdsList = Arrays.asList(debugModelIds);
+ }
ArrayList<ICBreakpointsUIContribution> list = new ArrayList<ICBreakpointsUIContribution>();
for (ICBreakpointsUIContribution con : contributions) {
try {
if (con.getDebugModelId() == null ||
- con.getDebugModelId().equals(CDIDebugModel.getPluginIdentifier()) ||
- debugModelIdsList.contains(con.getDebugModelId()))
+ ((debugModelIdsList == null || debugModelIdsList.contains(con.getDebugModelId()))))
{
String contributedMarkerType = con.getMarkerType();
if (isMarkerSubtypeOf(markerType, contributedMarkerType)) {
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java
index 953ba4e..25512fd 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/CEventBreakpointsLabelProviderFactory.java
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.cdt.debug.ui.breakpoints;
+import java.util.Arrays;
+
import org.eclipse.cdt.debug.core.DebugCoreMessages;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
@@ -47,8 +49,10 @@ public class CEventBreakpointsLabelProviderFactory implements IAdapterFactory {
for (ICBreakpointsUIContribution con : bscs) {
Object attValue = breakpoint.getMarker().getAttribute(con.getId());
-
+
if (con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) {
+ if (!Arrays.asList(con.getPossibleValues()).contains(attValue))
+ continue;
buffer.append(con.getLabelForValue((String) attValue));
continue;
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java
index ed7fa04..a9ac185 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java
@@ -130,4 +130,39 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
* @throws CoreException if unable to perform the action
*/
public void createFunctionBreakpointInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
+
+ /**
+ * Returns whether the toggle target can create an event breakpoint at the
+ * given location. If the implementation does not support creating the
+ * breakpoint interactively then it should return <code>false</code>.
+ * <p>
+ * The selection varies depending on the given part. For example,
+ * a text selection is provided for text editors, and a structured
+ * selection is provided for tree views, and may be a multi-selection.
+ * </p>
+ * @param part the part on which the action has been invoked
+ * @param selection selection on which line breakpoints should be toggled
+ * @return Returns <code>true</code> if toggle target is able interactively
+ * create a breakpoint(s) at the given location.
+ */
+ public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection);
+
+ /**
+ * Creates a new event breakpoint interactively. The implementation should
+ * allows the user to edit all of the breakpoint's settings prior to
+ * creating the breakpoint. Unlike the
+ * {@link #toggleLineBreakpoints(IWorkbenchPart, ISelection)}
+ * method, this method does not remove the existing breakpoint at given
+ * location. It always creates a new breakpoint
+ * <p>
+ * The selection varies depending on the given part. For example,
+ * a text selection is provided for text editors, and a structured
+ * selection is provided for tree views, and may be a multi-selection.
+ * </p>
+ * @param part the part on which the action has been invoked
+ * @param selection selection on which line breakpoints should be toggled
+ * @throws CoreException if unable to perform the action
+ */
+ public void createEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
+
}
diff --git a/debug/org.eclipse.cdt.gdb.ui/plugin.xml b/debug/org.eclipse.cdt.gdb.ui/plugin.xml
index 47e02d6..95d3dfa 100644
--- a/debug/org.eclipse.cdt.gdb.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.gdb.ui/plugin.xml
@@ -3,6 +3,7 @@
<plugin>
<extension point="org.eclipse.cdt.debug.ui.breakpointContribution">
<breakpointLabels
+ debugModelId="org.eclipse.cdt.debug.core"
markerType="org.eclipse.cdt.debug.core.cEventBreakpointMarker">
<attribute name="org.eclipse.cdt.debug.core.eventbreakpoint_event_id" label="%catchType.label" type="string">
<value
diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java
index 7221649..91e9760 100644
--- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java
+++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/actions/AbstractDisassemblyBreakpointsTarget.java
@@ -226,7 +226,21 @@ public abstract class AbstractDisassemblyBreakpointsTarget
@Override
public void createWatchpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
}
-
+
+ /**
+ * @since 2.3
+ */
+ @Override
+ public boolean canCreateEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
+ return false;
+ }
+
+ /**
+ * @since 2.3
+ */
+ @Override
+ public void createEventBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
+ }
private void toggleBreakpointEnabled(IBreakpoint bp) {
try {