From cff216f9b73f50ea4b21e4af8cd97daa11f8953d Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Wed, 4 Sep 2002 22:36:23 +0000 Subject: [PATCH] Implementation of watchpoints. --- .../plugin.properties | 2 +- .../cdt/debug/internal/ui/CDebugImages.java | 4 + .../ui/actions/AddWatchpointDialog.java | 177 ++++++++++++++++++ .../ManageWatchpointActionDelegate.java | 4 + 4 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index 01ffc8ee816..74495492d02 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -21,4 +21,4 @@ EnableBreakpoint.label=T&oggle Breakpoint BreakpointProperties.label=Breakpoint P&roperties... ManageBreakpointAction.label=Add/Remove C/C++ Brea&kpoint BreakpointPropertiesAction.label=P&roperties... -ManageWatchpointAction.label=Add/Remove C/C++ &Watchpoint +ManageWatchpointAction.label=Add C/C++ &Watchpoint diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java index 391e6f5378f..74db72e0f96 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java @@ -48,6 +48,8 @@ public class CDebugImages */ public static final String IMG_OBJS_BREAKPOINT_INSTALLED = NAME_PREFIX + "installed_ovr.gif"; //$NON-NLS-1$ 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$ /* * Set of predefined Image Descriptors. @@ -63,6 +65,8 @@ public class CDebugImages public static final ImageDescriptor DESC_OBJS_BREAKPOINT_INSTALLED = createManaged( T_OVR, IMG_OBJS_BREAKPOINT_INSTALLED ); 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 ); /** * Returns the image managed under the given key in this registry. diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java new file mode 100644 index 00000000000..fecd440b916 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java @@ -0,0 +1,177 @@ +/* + *(c) Copyright QNX Software Systems Ltd. 2002. + * All Rights Reserved. + * + */ +package org.eclipse.cdt.debug.internal.ui.actions; + +import org.eclipse.cdt.debug.internal.ui.CDebugImages; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +/** + * + * Enter type comment. + * + * @since Sep 4, 2002 + */ +public class AddWatchpointDialog extends Dialog +{ + private Button fBtnOk = null; + private Button fBtnCancel = null; + private Text fTextExpression; + private Button fChkBtnWrite; + private Button fChkBtnRead; + + private boolean fWrite = true; + private boolean fRead = false; + private String fExpression = ""; + + /** + * Constructor for AddWatchpointDialog. + * @param parentShell + */ + public AddWatchpointDialog( Shell parentShell ) + { + super( parentShell ); + } + + protected void configureShell( Shell shell ) + { + super.configureShell( shell ); + shell.setText( "Add C/C++ Watchpoint" ); + shell.setImage( CDebugImages.get( CDebugImages.IMG_OBJS_WATCHPOINT_ENABLED ) ); + } + + protected Control createContents( Composite parent ) + { + Control control = super.createContents( parent ); + setOkButtonState(); + return control; + } + + protected Control createDialogArea( Composite parent ) + { + Composite composite = new Composite( parent, SWT.NONE ); + composite.setLayout( new GridLayout() ); + ((GridLayout)composite.getLayout()).marginWidth = 10; + composite.setLayoutData( new GridData( GridData.FILL_BOTH ) ); + createDataWidgets( composite ); + initializeDataWidgets(); + return composite; + } + + protected void createButtonsForButtonBar( Composite parent ) + { + fBtnOk = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true ); + fBtnCancel = createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false ); + } + + private void createDataWidgets( Composite parent ) + { + fTextExpression = createExpressionText( parent ); + createAccessWidgets( parent ); + } + + private void initializeDataWidgets() + { + fTextExpression.setText( "" ); + fChkBtnRead.setSelection( false ); + fChkBtnWrite.setSelection( true ); + setOkButtonState(); + } + + private Text createExpressionText( Composite parent ) + { + Label label = new Label( parent, SWT.RIGHT ); + label.setText( "Expression to watch:" ); + final Text text = new Text( parent, SWT.BORDER ); + GridData gridData = new GridData( GridData.FILL_HORIZONTAL ); + gridData.widthHint = 300; + text.setLayoutData( gridData ); + addModifyListener( text ); + return text; + } + + private void createAccessWidgets( Composite parent ) + { + Group group = new Group( parent, SWT.NONE ); + group.setLayout( new GridLayout() ); + group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) ); + group.setText( "Access" ); + fChkBtnWrite = new Button( group, SWT.CHECK ); + fChkBtnWrite.setText( "Write" ); + addSelectionListener( fChkBtnWrite ); + fChkBtnRead = new Button( group, SWT.CHECK ); + fChkBtnRead.setText( "Read" ); + addSelectionListener( fChkBtnRead ); + } + + private void addSelectionListener( Button button ) + { + button.addSelectionListener( + new SelectionAdapter() + { + public void widgetSelected( SelectionEvent e ) + { + setOkButtonState(); + } + } ); + } + + private void setOkButtonState() + { + if ( fBtnOk == null ) + return; + fBtnOk.setEnabled( (fChkBtnRead.getSelection() || fChkBtnWrite.getSelection()) && + fTextExpression.getText().trim().length() > 0 ); + } + + private void storeData() + { + fExpression = fTextExpression.getText().trim(); + fRead = fChkBtnRead.getSelection(); + fWrite = fChkBtnWrite.getSelection(); + } + + private void addModifyListener( Text text ) + { + text.addModifyListener( + new ModifyListener() + { + public void modifyText( ModifyEvent e ) + { + setOkButtonState(); + } + } ); + } + + public String getExpression() + { + return fExpression; + } + + public boolean getWriteAccess() + { + return fWrite; + } + + public boolean getReadAccess() + { + return fRead; + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java index b4ed2bbbd0a..63e71e4b748 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageWatchpointActionDelegate.java @@ -5,7 +5,9 @@ */ 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; @@ -84,6 +86,8 @@ public class ManageWatchpointActionDelegate implements IWorkbenchWindowActionDel */ public void run( IAction action ) { + Dialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell() ); + dlg.open(); } /* (non-Javadoc)