Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorPawel Piech2012-02-29 14:40:29 -0500
committerPawel Piech2012-03-18 23:52:35 -0400
commitd76485935eae38374d7e233a6a0ab383957b0f8e (patch)
tree15ff0414aa0bf41b401a0c127a41aaacdaeea0cb /debug
parent8b6befdf03a49f4ee073b1aef05c7094d8f268da (diff)
downloadorg.eclipse.cdt-d76485935eae38374d7e233a6a0ab383957b0f8e.tar.gz
org.eclipse.cdt-d76485935eae38374d7e233a6a0ab383957b0f8e.tar.xz
org.eclipse.cdt-d76485935eae38374d7e233a6a0ab383957b0f8e.zip
Bug 360588 - [breakpoints] Allow user to edit all its properties prior to creating the breakpoint
Started refactoring toggle adapter to add watchpoint interactively
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java31
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/ToggleBreakpointAdapter.java55
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/AbstractToggleBreakpointAdapter.java10
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpoints/IToggleBreakpointsTargetCExtension.java5
4 files changed, 79 insertions, 22 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java
index 35d5cebe39..873b589803 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/AddWatchpointActionDelegate.java
@@ -19,13 +19,15 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+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.core.runtime.IAdaptable;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.window.Window;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
@@ -36,7 +38,9 @@ import org.eclipse.ui.actions.ActionDelegate;
public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
private IViewPart fView;
-
+ private ISelection fSelection;
+
+
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
@@ -53,15 +57,30 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView
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 ) {
- AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), getMemorySpaceManagement() );
- if ( dlg.open() == Window.OK ) {
- addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange() );
- }
+ IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection);
+ if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
+ try {
+ ((IToggleBreakpointsTargetCExtension)toggleTarget).createWatchpoingsInteractive(fView, fSelection);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+// AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), getMemorySpaceManagement() );
+// if ( dlg.open() == Window.OK ) {
+// addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange() );
+// }
}
protected void addWatchpoint(boolean write, boolean read, String expression, String memorySpace, BigInteger range) {
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 9a7a1c0315..ebee061e03 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
@@ -13,18 +13,23 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
+import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;
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.ICBreakpointType;
+import org.eclipse.cdt.debug.core.model.ICDebugTarget;
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.ui.breakpoints.AbstractToggleBreakpointAdapter;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.window.Window;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.ui.IWorkbenchPart;
/**
@@ -86,24 +91,42 @@ public class ToggleBreakpointAdapter extends AbstractToggleBreakpointAdapter {
protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource,
int charStart, int charEnd, int lineNumber, String expression) throws CoreException
{
- AddWatchpointDialog dlg = new AddWatchpointDialog(
- part.getSite().getShell(), AddWatchpointActionDelegate.getMemorySpaceManagement() );
- dlg.setExpression( expression );
- if ( dlg.open() != Window.OK )
- return;
- expression = dlg.getExpression();
- CDIDebugModel.createWatchpoint(sourceHandle, resource, charStart, charEnd, lineNumber, dlg.getWriteAccess(),
- dlg.getReadAccess(), expression, dlg.getMemorySpace(), dlg.getRange(), true, 0, "", true); //$NON-NLS-1$
-// if (interactive) {
-// ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
-// Map<String, Object> attributes = new HashMap<String, Object>();
-// CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess,
-// expression, memorySpace, range, true, 0, ""); //$NON-NLS-1$
-// openBreakpointPropertiesDialog(bp, part, resource, attributes);
-// }
+// AddWatchpointDialog dlg = new AddWatchpointDialog(part.getSite().getShell(), getMemorySpaceManagement() );
+// dlg.setExpression( expression );
+// if ( dlg.open() != Window.OK )
+// return;
+// expression = dlg.getExpression();
+// CDIDebugModel.createWatchpoint(sourceHandle, resource, charStart, charEnd, lineNumber, dlg.getWriteAccess(),
+// dlg.getReadAccess(), expression, dlg.getMemorySpace(), dlg.getRange(), true, 0, "", true); //$NON-NLS-1$
+ if (interactive) {
+ ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
+ Map<String, Object> attributes = new HashMap<String, Object>();
+ CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false,
+ expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$
+ openBreakpointPropertiesDialog(bp, part, resource, attributes);
+ }
}
protected int getBreakpointType() {
return ICBreakpointType.REGULAR;
}
+
+ public static ICDIMemorySpaceManagement getMemorySpaceManagement(){
+ IAdaptable debugViewElement = DebugUITools.getDebugContext();
+ ICDIMemorySpaceManagement memMgr = null;
+
+ if ( debugViewElement != null ) {
+ ICDebugTarget debugTarget = (ICDebugTarget)debugViewElement.getAdapter(ICDebugTarget.class);
+
+ if ( debugTarget != null ){
+ ICDITarget target = (ICDITarget)debugTarget.getAdapter(ICDITarget.class);
+
+ if (target instanceof ICDIMemorySpaceManagement)
+ memMgr = (ICDIMemorySpaceManagement)target;
+ }
+ }
+
+ return memMgr;
+ }
+
}
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 919609eeea..0c79dc3945 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
@@ -159,6 +159,16 @@ abstract public class AbstractToggleBreakpointAdapter
public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
updateBreakpoints(false, true, part, selection);
}
+
+ @Override
+ public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) {
+ return true;
+ }
+
+ @Override
+ public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException {
+ createWatchpoint(true, part, null, ResourcesPlugin.getWorkspace().getRoot(), -1, -1, -1, "");
+ }
/**
* Updates the breakpoint for given part and selection.
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 d01603cee5..3963ae4fb2 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
@@ -59,4 +59,9 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
* @throws CoreException if unable to perform the action
*/
public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
+
+ public boolean canCreateWatchpoingsInteractive(IWorkbenchPart part, ISelection selection);
+
+ public void createWatchpoingsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
+
}

Back to the top