mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Bug 360588 - [breakpoints] Allow user to edit all its properties prior to creating the breakpoint
Started refactoring toggle adapter to add watchpoint interactively
This commit is contained in:
parent
8b6befdf03
commit
d76485935e
4 changed files with 79 additions and 22 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue