1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Implementation of watchpoints.

This commit is contained in:
Mikhail Khodjaiants 2002-09-04 22:36:23 +00:00
parent 42f2032ba8
commit cff216f9b7
4 changed files with 186 additions and 1 deletions

View file

@ -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

View file

@ -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.

View file

@ -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;
}
}

View file

@ -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)