mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 07:15:39 +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.core.model.ICDebugTarget;
|
||||||
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
|
import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
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.IResource;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||||
import org.eclipse.jface.action.IAction;
|
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.IViewActionDelegate;
|
||||||
import org.eclipse.ui.IViewPart;
|
import org.eclipse.ui.IViewPart;
|
||||||
import org.eclipse.ui.actions.ActionDelegate;
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
@ -36,6 +38,8 @@ import org.eclipse.ui.actions.ActionDelegate;
|
||||||
public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
|
public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
|
||||||
|
|
||||||
private IViewPart fView;
|
private IViewPart fView;
|
||||||
|
private ISelection fSelection;
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
||||||
|
@ -53,17 +57,32 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView
|
||||||
return fView;
|
return fView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
|
fSelection = selection;
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void run( IAction action ) {
|
public void run( IAction action ) {
|
||||||
AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), getMemorySpaceManagement() );
|
IToggleBreakpointsTarget toggleTarget = DebugUITools.getToggleBreakpointsTargetManager().getToggleBreakpointsTarget(fView, fSelection);
|
||||||
if ( dlg.open() == Window.OK ) {
|
if (toggleTarget instanceof IToggleBreakpointsTargetCExtension) {
|
||||||
addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange() );
|
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) {
|
protected void addWatchpoint(boolean write, boolean read, String expression, String memorySpace, BigInteger range) {
|
||||||
if ( getResource() == null )
|
if ( getResource() == null )
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -13,18 +13,23 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
|
package org.eclipse.cdt.debug.internal.ui.actions.breakpoints;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
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.ICBreakpointType;
|
||||||
|
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
|
||||||
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||||
import org.eclipse.cdt.debug.ui.breakpoints.AbstractToggleBreakpointAdapter;
|
import org.eclipse.cdt.debug.ui.breakpoints.AbstractToggleBreakpointAdapter;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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;
|
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,
|
protected void createWatchpoint( boolean interactive, IWorkbenchPart part, String sourceHandle, IResource resource,
|
||||||
int charStart, int charEnd, int lineNumber, String expression) throws CoreException
|
int charStart, int charEnd, int lineNumber, String expression) throws CoreException
|
||||||
{
|
{
|
||||||
AddWatchpointDialog dlg = new AddWatchpointDialog(
|
// AddWatchpointDialog dlg = new AddWatchpointDialog(part.getSite().getShell(), getMemorySpaceManagement() );
|
||||||
part.getSite().getShell(), AddWatchpointActionDelegate.getMemorySpaceManagement() );
|
// dlg.setExpression( expression );
|
||||||
dlg.setExpression( expression );
|
// if ( dlg.open() != Window.OK )
|
||||||
if ( dlg.open() != Window.OK )
|
// return;
|
||||||
return;
|
// expression = dlg.getExpression();
|
||||||
expression = dlg.getExpression();
|
// CDIDebugModel.createWatchpoint(sourceHandle, resource, charStart, charEnd, lineNumber, dlg.getWriteAccess(),
|
||||||
CDIDebugModel.createWatchpoint(sourceHandle, resource, charStart, charEnd, lineNumber, dlg.getWriteAccess(),
|
// dlg.getReadAccess(), expression, dlg.getMemorySpace(), dlg.getRange(), true, 0, "", true); //$NON-NLS-1$
|
||||||
dlg.getReadAccess(), expression, dlg.getMemorySpace(), dlg.getRange(), true, 0, "", true); //$NON-NLS-1$
|
if (interactive) {
|
||||||
// if (interactive) {
|
ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
|
||||||
// ICWatchpoint bp = CDIDebugModel.createBlankWatchpoint();
|
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||||
// Map<String, Object> attributes = new HashMap<String, Object>();
|
CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, true, false,
|
||||||
// CDIDebugModel.setWatchPointAttributes(attributes, sourceHandle, resource, writeAccess, readAccess,
|
expression, "", new BigInteger("0"), true, 0, ""); //$NON-NLS-1$
|
||||||
// expression, memorySpace, range, true, 0, ""); //$NON-NLS-1$
|
openBreakpointPropertiesDialog(bp, part, resource, attributes);
|
||||||
// openBreakpointPropertiesDialog(bp, part, resource, attributes);
|
}
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getBreakpointType() {
|
protected int getBreakpointType() {
|
||||||
return ICBreakpointType.REGULAR;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,6 +160,16 @@ abstract public class AbstractToggleBreakpointAdapter
|
||||||
updateBreakpoints(false, true, part, selection);
|
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.
|
* Updates the breakpoint for given part and selection.
|
||||||
* Depending on the flags and on whether a breakpoint exists, this method
|
* Depending on the flags and on whether a breakpoint exists, this method
|
||||||
|
|
|
@ -59,4 +59,9 @@ public interface IToggleBreakpointsTargetCExtension extends IToggleBreakpointsTa
|
||||||
* @throws CoreException if unable to perform the action
|
* @throws CoreException if unable to perform the action
|
||||||
*/
|
*/
|
||||||
public void createBreakpointsInteractive(IWorkbenchPart part, ISelection selection) throws CoreException;
|
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