mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Implementation of 'add watchpoint' action and watchpoint's properties.
This commit is contained in:
parent
eab4d5a0ad
commit
0ab86c77d5
15 changed files with 499 additions and 141 deletions
|
@ -231,6 +231,31 @@ public class CDebugModel
|
|||
return new CLineBreakpoint( resource, attributes, add );
|
||||
}
|
||||
|
||||
public static ICWatchpoint watchpointExists( IResource resource, boolean write, boolean read, String expression ) throws CoreException
|
||||
{
|
||||
String modelId = getPluginIdentifier();
|
||||
String markerType = CWatchpoint.getMarkerType();
|
||||
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
|
||||
IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
|
||||
for ( int i = 0; i < breakpoints.length; i++ )
|
||||
{
|
||||
if ( !( breakpoints[i] instanceof ICWatchpoint ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i];
|
||||
if ( breakpoint.getMarker().getType().equals( markerType )&&
|
||||
breakpoint.getMarker().getResource().equals( resource ) &&
|
||||
breakpoint.isWriteType() == write &&
|
||||
breakpoint.isReadType() == read &&
|
||||
breakpoint.getExpression().equals( expression ) )
|
||||
{
|
||||
return breakpoint;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ICWatchpoint createWatchpoint( IResource resource,
|
||||
boolean writeAccess,
|
||||
boolean readAccess,
|
||||
|
@ -245,6 +270,9 @@ public class CDebugModel
|
|||
attributes.put( ICBreakpoint.ENABLED, new Boolean( enabled ) );
|
||||
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
|
||||
attributes.put( ICBreakpoint.CONDITION, condition );
|
||||
attributes.put( ICWatchpoint.EXPRESSION, expression );
|
||||
attributes.put( ICWatchpoint.READ, new Boolean( readAccess ) );
|
||||
attributes.put( ICWatchpoint.WRITE, new Boolean( writeAccess ) );
|
||||
return new CWatchpoint( resource, attributes, add );
|
||||
}
|
||||
}
|
||||
|
|
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/read_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 156 B |
Binary file not shown.
After Width: | Height: | Size: 122 B |
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj.gif
Normal file
BIN
debug/org.eclipse.cdt.debug.ui/icons/full/obj16/write_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
Binary file not shown.
After Width: | Height: | Size: 125 B |
|
@ -12,6 +12,7 @@ MemoryView.name=Memory
|
|||
MemoryPreferencePage.name=Memory Views
|
||||
CDebuggerPage.name=C Debugger UI Page
|
||||
|
||||
RunMenu.label=&Run
|
||||
DebugActionSet.label=C/C++ Debug
|
||||
|
||||
RestartAction.label=Restart
|
||||
|
|
|
@ -80,6 +80,14 @@
|
|||
<actionSet
|
||||
label="%DebugActionSet.label"
|
||||
id="org.eclipse.cdt.debug.ui.debugActionSet">
|
||||
<menu
|
||||
label="%RunMenu.label"
|
||||
path="additions"
|
||||
id="org.eclipse.ui.run">
|
||||
<separator
|
||||
name="cBreakpointGroup">
|
||||
</separator>
|
||||
</menu>
|
||||
<action
|
||||
id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
|
||||
hoverIcon="icons/full/clcl16/restart.gif"
|
||||
|
@ -102,7 +110,7 @@
|
|||
icon="icons/full/obj16/brkpi_obj.gif"
|
||||
helpContextId="manage_breakpoint_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointActionDelegate"
|
||||
menubarPath="org.eclipse.ui.run/breakpointGroup"
|
||||
menubarPath="org.eclipse.ui.run/cBreakpointGroup"
|
||||
id="org.eclipse.cdt.debug.ui.internal.actions.ManageBreakpointActionDelegate">
|
||||
<enablement>
|
||||
<pluginState
|
||||
|
@ -115,8 +123,8 @@
|
|||
label="%ManageWatchpointAction.label"
|
||||
icon="icons/full/obj16/readwrite_obj.gif"
|
||||
helpContextId="manage_watchpoint_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ManageWatchpointActionDelegate"
|
||||
menubarPath="org.eclipse.ui.run/breakpointGroup"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointActionDelegate"
|
||||
menubarPath="org.eclipse.ui.run/cBreakpointGroup"
|
||||
disabledIcon="icons/full/obj16/readwrite_obj_disabled.gif"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.ManageWatchpointActionDelegate">
|
||||
<enablement>
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.eclipse.cdt.debug.core.ICAddressBreakpoint;
|
|||
import org.eclipse.cdt.debug.core.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.ICFunctionBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.core.IStackFrameInfo;
|
||||
import org.eclipse.cdt.debug.core.IState;
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
|
||||
|
@ -384,6 +385,10 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
{
|
||||
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
|
||||
}
|
||||
if ( breakpoint instanceof ICWatchpoint )
|
||||
{
|
||||
return getWatchpointImage( (ICWatchpoint)breakpoint );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -402,6 +407,31 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
return fDebugImageRegistry.get( descriptor );
|
||||
}
|
||||
|
||||
protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException
|
||||
{
|
||||
int flags = computeBreakpointAdornmentFlags( watchpoint );
|
||||
CImageDescriptor descriptor = null;
|
||||
if ( watchpoint.isEnabled() )
|
||||
{
|
||||
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
|
||||
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_READ_WATCHPOINT_ENABLED, flags );
|
||||
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
|
||||
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_ENABLED, flags );
|
||||
else
|
||||
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WATCHPOINT_ENABLED, flags );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
|
||||
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_READ_WATCHPOINT_DISABLED, flags );
|
||||
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
|
||||
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WRITE_WATCHPOINT_DISABLED, flags );
|
||||
else
|
||||
descriptor = new CImageDescriptor( CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED, flags );
|
||||
}
|
||||
return fDebugImageRegistry.get( descriptor );
|
||||
}
|
||||
|
||||
protected IBreakpoint getBreakpoint( IMarker marker )
|
||||
{
|
||||
return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker );
|
||||
|
@ -422,6 +452,10 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
{
|
||||
return getFunctionBreakpointText( (ICFunctionBreakpoint)breakpoint, qualified );
|
||||
}
|
||||
if ( breakpoint instanceof ICWatchpoint )
|
||||
{
|
||||
return getWatchpointText( (ICWatchpoint)breakpoint, qualified );
|
||||
}
|
||||
return ""; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
@ -435,6 +469,16 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
return label.toString();
|
||||
}
|
||||
|
||||
protected String getWatchpointText( ICWatchpoint watchpoint, boolean qualified ) throws CoreException
|
||||
{
|
||||
StringBuffer label = new StringBuffer();
|
||||
appendResourceName( watchpoint, label, qualified );
|
||||
appendWatchExpression( watchpoint, label );
|
||||
appendIgnoreCount( watchpoint, label );
|
||||
appendCondition( watchpoint, label );
|
||||
return label.toString();
|
||||
}
|
||||
|
||||
protected String getAddressBreakpointText( ICAddressBreakpoint breakpoint, boolean qualified ) throws CoreException
|
||||
{
|
||||
return null;
|
||||
|
@ -445,7 +489,7 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
return null;
|
||||
}
|
||||
|
||||
protected StringBuffer appendResourceName( ICLineBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException
|
||||
protected StringBuffer appendResourceName( ICBreakpoint breakpoint, StringBuffer label, boolean qualified ) throws CoreException
|
||||
{
|
||||
IPath path = breakpoint.getMarker().getResource().getLocation();
|
||||
if ( !path.isEmpty() )
|
||||
|
@ -481,7 +525,7 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
return label;
|
||||
}
|
||||
|
||||
protected void appendCondition( ICLineBreakpoint breakpoint, StringBuffer buffer ) throws CoreException
|
||||
protected void appendCondition( ICBreakpoint breakpoint, StringBuffer buffer ) throws CoreException
|
||||
{
|
||||
String condition = breakpoint.getCondition();
|
||||
if ( condition != null && condition.length() > 0 )
|
||||
|
@ -491,6 +535,17 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
}
|
||||
}
|
||||
|
||||
private void appendWatchExpression( ICWatchpoint watchpoint, StringBuffer label ) throws CoreException
|
||||
{
|
||||
String expression = watchpoint.getExpression();
|
||||
if ( expression != null && expression.length() > 0 )
|
||||
{
|
||||
label.append( " at \'" );
|
||||
label.append( expression );
|
||||
label.append( '\'' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the adornment flags for the given breakpoint.
|
||||
* These flags are used to render appropriate overlay
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.swt.graphics.Image;
|
|||
*/
|
||||
public class CDebugImages
|
||||
{
|
||||
private static final String NAME_PREFIX = "org.eclipse.jdt.debug.ui."; //$NON-NLS-1$
|
||||
private static final String NAME_PREFIX = "org.eclipse.cdt.debug.ui."; //$NON-NLS-1$
|
||||
private static final int NAME_PREFIX_LENGTH = NAME_PREFIX.length();
|
||||
|
||||
private static URL fgIconBaseURL = null;
|
||||
|
@ -50,6 +50,10 @@ public class CDebugImages
|
|||
public static final String IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED = NAME_PREFIX + "installed_ovr_disabled.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_READ_WATCHPOINT_DISABLED = NAME_PREFIX + "read_obj_disabled.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_WRITE_WATCHPOINT_ENABLED = NAME_PREFIX + "write_obj.gif"; //$NON-NLS-1$
|
||||
public static final String IMG_OBJS_WRITE_WATCHPOINT_DISABLED = NAME_PREFIX + "write_obj_disabled.gif"; //$NON-NLS-1$
|
||||
|
||||
/*
|
||||
* Set of predefined Image Descriptors.
|
||||
|
@ -67,6 +71,10 @@ public class CDebugImages
|
|||
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED_DISABLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED_DISABLED );
|
||||
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED );
|
||||
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED );
|
||||
public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED );
|
||||
public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_DISABLED );
|
||||
public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_ENABLED );
|
||||
public static final ImageDescriptor DESC_OBJS_WRITE_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WRITE_WATCHPOINT_DISABLED );
|
||||
|
||||
/**
|
||||
* Returns the image managed under the given key in this registry.
|
||||
|
|
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||
import org.eclipse.cdt.debug.core.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Action for adding/removing watchpoints at a selection in the active
|
||||
* C/C++ or assembly editor.
|
||||
*
|
||||
* @since Sep 4, 2002
|
||||
*/
|
||||
public class AddWatchpointActionDelegate implements IWorkbenchWindowActionDelegate,
|
||||
IPartListener
|
||||
{
|
||||
private boolean fInitialized = false;
|
||||
private IAction fAction = null;
|
||||
private ITextEditor fTextEditor = null;
|
||||
private IWorkbenchWindow fWorkbenchWindow = null;
|
||||
private IProject fProject = null;
|
||||
|
||||
/**
|
||||
* Constructor for AddWatchpointActionDelegate.
|
||||
*/
|
||||
public AddWatchpointActionDelegate()
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
|
||||
*/
|
||||
public void init( IWorkbenchWindow window )
|
||||
{
|
||||
setWorkbenchWindow( window );
|
||||
window.getPartService().addPartListener( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(IAction)
|
||||
*/
|
||||
public void run( IAction action )
|
||||
{
|
||||
String expression = getSelectedExpression();
|
||||
AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(),
|
||||
true,
|
||||
false,
|
||||
expression );
|
||||
if ( dlg.open() != Dialog.OK )
|
||||
return;
|
||||
if ( getTextEditor() != null )
|
||||
{
|
||||
update();
|
||||
addWatchpoint( getTextEditor().getEditorInput(),
|
||||
dlg.getWriteAccess(),
|
||||
dlg.getReadAccess(),
|
||||
dlg.getExpression() );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
|
||||
*/
|
||||
public void selectionChanged( IAction action, ISelection selection )
|
||||
{
|
||||
if ( !fInitialized )
|
||||
{
|
||||
setAction( action );
|
||||
if ( getWorkbenchWindow() != null )
|
||||
{
|
||||
IWorkbenchPage page = getWorkbenchWindow().getActivePage();
|
||||
if ( page != null )
|
||||
{
|
||||
IEditorPart part = page.getActiveEditor();
|
||||
if ( part instanceof ITextEditor )
|
||||
{
|
||||
setTextEditor( (ITextEditor)part );
|
||||
}
|
||||
}
|
||||
}
|
||||
fInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected IAction getAction()
|
||||
{
|
||||
return fAction;
|
||||
}
|
||||
|
||||
protected void setAction( IAction action )
|
||||
{
|
||||
fAction = action;
|
||||
}
|
||||
|
||||
protected IWorkbenchWindow getWorkbenchWindow()
|
||||
{
|
||||
return fWorkbenchWindow;
|
||||
}
|
||||
|
||||
protected void setWorkbenchWindow( IWorkbenchWindow workbenchWindow )
|
||||
{
|
||||
fWorkbenchWindow = workbenchWindow;
|
||||
}
|
||||
|
||||
protected ITextEditor getTextEditor()
|
||||
{
|
||||
return fTextEditor;
|
||||
}
|
||||
|
||||
protected void setTextEditor( ITextEditor editor )
|
||||
{
|
||||
fTextEditor = editor;
|
||||
if ( fTextEditor != null )
|
||||
{
|
||||
IEditorInput input = fTextEditor.getEditorInput();
|
||||
IFile file = ( input != null && input instanceof IFileEditorInput ) ? ((IFileEditorInput)input).getFile() : null;
|
||||
setProject( ( file != null ) ? file.getProject() : null );
|
||||
}
|
||||
setEnabledState( editor );
|
||||
}
|
||||
|
||||
protected String getSelectedExpression()
|
||||
{
|
||||
if ( getTextEditor() != null )
|
||||
{
|
||||
ISelectionProvider sp = getTextEditor().getSelectionProvider();
|
||||
if ( sp != null )
|
||||
{
|
||||
ISelection s = sp.getSelection();
|
||||
if ( s instanceof ITextSelection )
|
||||
{
|
||||
return ((ITextSelection)s).getText().trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
protected void update( ISelection selection )
|
||||
{
|
||||
setEnabledState( getTextEditor() );
|
||||
}
|
||||
|
||||
protected void update()
|
||||
{
|
||||
IAction action = getAction();
|
||||
if ( action != null )
|
||||
{
|
||||
action.setEnabled( getTextEditor() != null );
|
||||
}
|
||||
}
|
||||
|
||||
protected void setEnabledState( ITextEditor editor )
|
||||
{
|
||||
if ( getAction() != null )
|
||||
{
|
||||
getAction().setEnabled( editor != null );
|
||||
}
|
||||
}
|
||||
|
||||
protected IProject getProject()
|
||||
{
|
||||
return fProject;
|
||||
}
|
||||
|
||||
protected void setProject( IProject project )
|
||||
{
|
||||
fProject = project;
|
||||
}
|
||||
|
||||
protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression )
|
||||
{
|
||||
if ( getProject() == null )
|
||||
return;
|
||||
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
|
||||
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
|
||||
if ( wev.isValidExpression( document, expression ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
CDebugModel.createWatchpoint( getProject(),
|
||||
write,
|
||||
read,
|
||||
expression,
|
||||
true,
|
||||
0,
|
||||
"",
|
||||
true );
|
||||
}
|
||||
catch( CoreException ce )
|
||||
{
|
||||
CDebugUIPlugin.errorDialog( "Cannot add watchpoint", ce );
|
||||
}
|
||||
}
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
|
||||
*/
|
||||
public void partActivated( IWorkbenchPart part )
|
||||
{
|
||||
if ( part instanceof ITextEditor )
|
||||
{
|
||||
setTextEditor( (ITextEditor)part );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
|
||||
*/
|
||||
public void partBroughtToTop( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
|
||||
*/
|
||||
public void partClosed( IWorkbenchPart part )
|
||||
{
|
||||
if ( part == getTextEditor() )
|
||||
{
|
||||
setTextEditor( null );
|
||||
if ( getAction() != null )
|
||||
{
|
||||
getAction().setEnabled( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
|
||||
*/
|
||||
public void partDeactivated( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
|
||||
*/
|
||||
public void partOpened( IWorkbenchPart part )
|
||||
{
|
||||
if ( part instanceof ITextEditor )
|
||||
{
|
||||
if ( getTextEditor() == null )
|
||||
{
|
||||
setTextEditor( (ITextEditor)part );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,9 +45,13 @@ public class AddWatchpointDialog extends Dialog
|
|||
* Constructor for AddWatchpointDialog.
|
||||
* @param parentShell
|
||||
*/
|
||||
public AddWatchpointDialog( Shell parentShell )
|
||||
public AddWatchpointDialog( Shell parentShell, boolean write, boolean read, String expression )
|
||||
{
|
||||
super( parentShell );
|
||||
fWrite = write;
|
||||
fRead = read;
|
||||
if ( expression != null )
|
||||
fExpression = expression;
|
||||
}
|
||||
|
||||
protected void configureShell( Shell shell )
|
||||
|
@ -89,9 +93,9 @@ public class AddWatchpointDialog extends Dialog
|
|||
|
||||
private void initializeDataWidgets()
|
||||
{
|
||||
fTextExpression.setText( "" );
|
||||
fChkBtnRead.setSelection( false );
|
||||
fChkBtnWrite.setSelection( true );
|
||||
fTextExpression.setText( fExpression );
|
||||
fChkBtnRead.setSelection( fRead );
|
||||
fChkBtnWrite.setSelection( fWrite );
|
||||
setOkButtonState();
|
||||
}
|
||||
|
||||
|
@ -174,4 +178,13 @@ public class AddWatchpointDialog extends Dialog
|
|||
{
|
||||
return fRead;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.jface.dialogs.Dialog#okPressed()
|
||||
*/
|
||||
protected void okPressed()
|
||||
{
|
||||
storeData();
|
||||
super.okPressed();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.core.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -254,34 +255,9 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage
|
|||
protected void createFieldEditors()
|
||||
{
|
||||
ICBreakpoint breakpoint = getBreakpoint();
|
||||
String fileName = breakpoint.getMarker().getResource().getLocation().toOSString();
|
||||
if ( fileName != null )
|
||||
{
|
||||
addField( createLabelEditor( getFieldEditorParent(), "File: ", fileName ) );
|
||||
}
|
||||
|
||||
if ( breakpoint instanceof ILineBreakpoint )
|
||||
{
|
||||
setTitle( "C/C++ Line Breakpoint Properties" );
|
||||
ILineBreakpoint lBreakpoint = (ILineBreakpoint)breakpoint;
|
||||
StringBuffer lineNumber = new StringBuffer( 4 );
|
||||
try
|
||||
{
|
||||
int lNumber = lBreakpoint.getLineNumber();
|
||||
if ( lNumber > 0 )
|
||||
{
|
||||
lineNumber.append( lNumber );
|
||||
}
|
||||
}
|
||||
catch( CoreException ce )
|
||||
{
|
||||
CDebugUIPlugin.log( ce );
|
||||
}
|
||||
if ( lineNumber.length() > 0 )
|
||||
{
|
||||
addField( createLabelEditor( getFieldEditorParent(), "Line Number: ", lineNumber.toString() ) );
|
||||
}
|
||||
}
|
||||
createTypeSpecificLabelFieldEditors( breakpoint );
|
||||
|
||||
IPreferenceStore store = getPreferenceStore();
|
||||
|
||||
try
|
||||
|
@ -307,6 +283,68 @@ public class CBreakpointPreferencePage extends FieldEditorPreferencePage
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method createTypeSpecificLabelFieldEditors.
|
||||
* @param breakpoint
|
||||
*/
|
||||
private void createTypeSpecificLabelFieldEditors( ICBreakpoint breakpoint )
|
||||
{
|
||||
if ( breakpoint instanceof ILineBreakpoint )
|
||||
{
|
||||
String fileName = breakpoint.getMarker().getResource().getLocation().toOSString();
|
||||
if ( fileName != null )
|
||||
{
|
||||
addField( createLabelEditor( getFieldEditorParent(), "File: ", fileName ) );
|
||||
}
|
||||
setTitle( "C/C++ Line Breakpoint Properties" );
|
||||
ILineBreakpoint lBreakpoint = (ILineBreakpoint)breakpoint;
|
||||
StringBuffer lineNumber = new StringBuffer( 4 );
|
||||
try
|
||||
{
|
||||
int lNumber = lBreakpoint.getLineNumber();
|
||||
if ( lNumber > 0 )
|
||||
{
|
||||
lineNumber.append( lNumber );
|
||||
}
|
||||
}
|
||||
catch( CoreException ce )
|
||||
{
|
||||
CDebugUIPlugin.log( ce );
|
||||
}
|
||||
if ( lineNumber.length() > 0 )
|
||||
{
|
||||
addField( createLabelEditor( getFieldEditorParent(), "Line Number: ", lineNumber.toString() ) );
|
||||
}
|
||||
}
|
||||
else if ( breakpoint instanceof ICWatchpoint )
|
||||
{
|
||||
String projectName = breakpoint.getMarker().getResource().getLocation().toOSString();
|
||||
if ( projectName != null )
|
||||
{
|
||||
addField( createLabelEditor( getFieldEditorParent(), "Project: ", projectName ) );
|
||||
}
|
||||
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint;
|
||||
String title = "";
|
||||
String expression = "";
|
||||
try
|
||||
{
|
||||
if ( watchpoint.isReadType() && !watchpoint.isWriteType() )
|
||||
title = "C/C++ Read Watchpoint Properties";
|
||||
else if ( !watchpoint.isReadType() && watchpoint.isWriteType() )
|
||||
title = "C/C++ Watchpoint Properties";
|
||||
else
|
||||
title = "C/C++ Access Watchpoint Properties";
|
||||
expression = watchpoint.getExpression();
|
||||
}
|
||||
catch( CoreException ce )
|
||||
{
|
||||
CDebugUIPlugin.log( ce );
|
||||
}
|
||||
setTitle( title );
|
||||
addField( createLabelEditor( getFieldEditorParent(), "Expression To Watch: ", expression ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected void createConditionEditor( Composite parent )
|
||||
{
|
||||
fCondition = new BreakpointStringFieldEditor( CBreakpointPreferenceStore.CONDITION, "&Condition", parent );
|
||||
|
|
|
@ -5,9 +5,6 @@
|
|||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
||||
import org.eclipse.cdt.debug.core.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
|
@ -21,6 +18,7 @@ import org.eclipse.jface.viewers.ISelection;
|
|||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.ui.IEditorInput;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.IFileEditorInput;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
@ -263,8 +261,11 @@ public class ManageBreakpointActionDelegate implements IWorkbenchWindowActionDel
|
|||
protected void setTextEditor( ITextEditor editor )
|
||||
{
|
||||
fTextEditor = editor;
|
||||
IEditorInput input = fTextEditor.getEditorInput();
|
||||
fFile = (IFile)input.getAdapter( IFile.class );
|
||||
if ( fTextEditor != null )
|
||||
{
|
||||
IEditorInput input = fTextEditor.getEditorInput();
|
||||
setFile( ( input != null && input instanceof IFileEditorInput ) ? ((IFileEditorInput)input).getFile() : null );
|
||||
}
|
||||
setEnabledState( editor );
|
||||
}
|
||||
|
||||
|
|
|
@ -1,99 +0,0 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.Dialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
|
||||
|
||||
/**
|
||||
*
|
||||
* Action for adding/removing watchpoints at a selection in the active
|
||||
* C/C++ or assembly editor.
|
||||
*
|
||||
* @since Sep 4, 2002
|
||||
*/
|
||||
public class ManageWatchpointActionDelegate implements IWorkbenchWindowActionDelegate,
|
||||
IPartListener
|
||||
{
|
||||
/**
|
||||
* Constructor for ManageWatchpointActionDelegate.
|
||||
*/
|
||||
public ManageWatchpointActionDelegate()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
|
||||
*/
|
||||
public void dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(IWorkbenchWindow)
|
||||
*/
|
||||
public void init( IWorkbenchWindow window )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
|
||||
*/
|
||||
public void partActivated( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
|
||||
*/
|
||||
public void partBroughtToTop( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
|
||||
*/
|
||||
public void partClosed( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
|
||||
*/
|
||||
public void partDeactivated( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
|
||||
*/
|
||||
public void partOpened( IWorkbenchPart part )
|
||||
{
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(IAction)
|
||||
*/
|
||||
public void run( IAction action )
|
||||
{
|
||||
Dialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell() );
|
||||
dlg.open();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
|
||||
*/
|
||||
public void selectionChanged( IAction action, ISelection selection )
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.jface.text.IDocument;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Sep 5, 2002
|
||||
*/
|
||||
public class WatchpointExpressionVerifier
|
||||
{
|
||||
/**
|
||||
* Returns whether the specified expression is valid for a watchpoint.
|
||||
*/
|
||||
public boolean isValidExpression( IDocument doc, String expression )
|
||||
{
|
||||
// for now
|
||||
return expression.trim().length() > 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue