mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Fixes in the breakpoint-related actions.
This commit is contained in:
parent
670e216592
commit
050a97e1c7
5 changed files with 70 additions and 32 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2004-04-12 Mikhail Khodjaiants
|
||||||
|
Fixes in the breakpoint-related actions.
|
||||||
|
* ActionMessages.properties
|
||||||
|
* AbstractListenerActionDelegate.java
|
||||||
|
* AddWatchpointActionDelegate.java
|
||||||
|
* ToggleBreakpointAdapter.java
|
||||||
|
|
||||||
2004-04-12 Mikhail Khodjaiants
|
2004-04-12 Mikhail Khodjaiants
|
||||||
Changed the labels of the ruler breakpoint actions.
|
Changed the labels of the ruler breakpoint actions.
|
||||||
* plugin.properties
|
* plugin.properties
|
||||||
|
|
|
@ -44,10 +44,6 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction
|
||||||
}
|
}
|
||||||
Runnable r= new Runnable() {
|
Runnable r= new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Shell shell= getWindow().getShell();
|
|
||||||
if (shell == null || shell.isDisposed()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (int i = 0; i < events.length; i++) {
|
for (int i = 0; i < events.length; i++) {
|
||||||
if (events[i].getSource() != null) {
|
if (events[i].getSource() != null) {
|
||||||
doHandleDebugEvent(events[i]);
|
doHandleDebugEvent(events[i]);
|
||||||
|
|
|
@ -14,3 +14,11 @@ RunToLineActionDelegate.Error_1=Error
|
||||||
RunToLineActionDelegate.Operation_failed_1=Operation failed.
|
RunToLineActionDelegate.Operation_failed_1=Operation failed.
|
||||||
RunToLineAdapter.Empty_editor_1=Empty editor
|
RunToLineAdapter.Empty_editor_1=Empty editor
|
||||||
RunToLineAdapter.Missing_document_1=Missing document
|
RunToLineAdapter.Missing_document_1=Missing document
|
||||||
|
ToggleBreakpointAdapter.Empty_editor_1=Empty editor
|
||||||
|
ToggleBreakpointAdapter.Missing_document_1=Missing document
|
||||||
|
ToggleBreakpointAdapter.Missing_resource_1=Missing resource
|
||||||
|
ToggleBreakpointAdapter.Invalid_line_1=Invalid line
|
||||||
|
ToggleBreakpointAdapter.Empty_editor_2=Empty editor
|
||||||
|
ToggleBreakpointAdapter.Missing_document_2=Missing document
|
||||||
|
ToggleBreakpointAdapter.Missing_resource_2=Missing resource
|
||||||
|
ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression:
|
||||||
|
|
|
@ -12,9 +12,10 @@ package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
|
@ -25,6 +26,7 @@ import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IFileEditorInput;
|
import org.eclipse.ui.IFileEditorInput;
|
||||||
import org.eclipse.ui.IPartListener;
|
import org.eclipse.ui.IPartListener;
|
||||||
|
import org.eclipse.ui.IStorageEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.IWorkbenchWindow;
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
|
@ -33,11 +35,8 @@ import org.eclipse.ui.actions.ActionDelegate;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Action for adding a watchpoint at a selection in the active
|
||||||
* Action for adding/removing watchpoints at a selection in the active
|
|
||||||
* C/C++ or assembly editor.
|
* C/C++ or assembly editor.
|
||||||
*
|
|
||||||
* @since Sep 4, 2002
|
|
||||||
*/
|
*/
|
||||||
public class AddWatchpointActionDelegate extends ActionDelegate implements IWorkbenchWindowActionDelegate, IPartListener {
|
public class AddWatchpointActionDelegate extends ActionDelegate implements IWorkbenchWindowActionDelegate, IPartListener {
|
||||||
|
|
||||||
|
@ -49,7 +48,9 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
|
||||||
|
|
||||||
private IWorkbenchWindow fWorkbenchWindow = null;
|
private IWorkbenchWindow fWorkbenchWindow = null;
|
||||||
|
|
||||||
private IProject fProject = null;
|
private IResource fResource = null;
|
||||||
|
|
||||||
|
private String fSourceHandle = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for AddWatchpointActionDelegate.
|
* Constructor for AddWatchpointActionDelegate.
|
||||||
|
@ -128,8 +129,8 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
|
||||||
fTextEditor = editor;
|
fTextEditor = editor;
|
||||||
if ( fTextEditor != null ) {
|
if ( fTextEditor != null ) {
|
||||||
IEditorInput input = fTextEditor.getEditorInput();
|
IEditorInput input = fTextEditor.getEditorInput();
|
||||||
IFile file = (input != null && input instanceof IFileEditorInput) ? ((IFileEditorInput)input).getFile() : null;
|
setSourceHandle( input );
|
||||||
setProject( (file != null) ? file.getProject() : null );
|
setResource( input );
|
||||||
}
|
}
|
||||||
setEnabledState( editor );
|
setEnabledState( editor );
|
||||||
}
|
}
|
||||||
|
@ -164,22 +165,27 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IProject getProject() {
|
protected IResource getResource() {
|
||||||
return fProject;
|
return fResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setProject( IProject project ) {
|
protected void setResource( IEditorInput input ) {
|
||||||
fProject = project;
|
if ( input instanceof IFileEditorInput ) {
|
||||||
|
fResource = ((IFileEditorInput)input).getFile().getProject();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fResource = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression ) {
|
protected void addWatchpoint( IEditorInput editorInput, boolean write, boolean read, String expression ) {
|
||||||
if ( getProject() == null )
|
if ( getResource() == null )
|
||||||
return;
|
return;
|
||||||
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
|
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
|
||||||
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
|
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
|
||||||
if ( wev.isValidExpression( document, expression ) ) {
|
if ( wev.isValidExpression( document, expression ) ) {
|
||||||
try {
|
try {
|
||||||
CDIDebugModel.createWatchpoint( "", getProject(), write, read, expression, true, 0, "", true ); //$NON-NLS-1$
|
CDIDebugModel.createWatchpoint( getSourceHandle(), getResource(), write, read, expression, true, 0, "", true ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
catch( CoreException ce ) {
|
catch( CoreException ce ) {
|
||||||
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString( "internal.ui.actions.AddWatchpointActionDelegate.Cannot_add_watchpoint" ), ce ); //$NON-NLS-1$
|
CDebugUIPlugin.errorDialog( CDebugUIPlugin.getResourceString( "internal.ui.actions.AddWatchpointActionDelegate.Cannot_add_watchpoint" ), ce ); //$NON-NLS-1$
|
||||||
|
@ -230,4 +236,24 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getSourceHandle() {
|
||||||
|
return fSourceHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSourceHandle( IEditorInput input ) {
|
||||||
|
fSourceHandle = ""; //$NON-NLS-1$
|
||||||
|
if ( input instanceof IFileEditorInput ) {
|
||||||
|
fSourceHandle = ((IFileEditorInput)input).getFile().getFullPath().toOSString();
|
||||||
|
}
|
||||||
|
else if ( input instanceof IStorageEditorInput ) {
|
||||||
|
try {
|
||||||
|
IPath path = ((IStorageEditorInput)input).getStorage().getFullPath();
|
||||||
|
if ( path != null )
|
||||||
|
fSourceHandle = path.toOSString();
|
||||||
|
}
|
||||||
|
catch( CoreException e ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -50,24 +50,24 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
IEditorInput input = editorPart.getEditorInput();
|
IEditorInput input = editorPart.getEditorInput();
|
||||||
String errorMessage = null;
|
String errorMessage = null;
|
||||||
if ( input == null ) {
|
if ( input == null ) {
|
||||||
errorMessage = "Empty editor";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final ITextEditor textEditor = (ITextEditor)editorPart;
|
ITextEditor textEditor = (ITextEditor)editorPart;
|
||||||
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
|
IDocument document = textEditor.getDocumentProvider().getDocument( input );
|
||||||
if ( document == null ) {
|
if ( document == null ) {
|
||||||
errorMessage = "Missing document";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IResource resource = getResource( textEditor );
|
IResource resource = getResource( textEditor );
|
||||||
if ( resource == null ) {
|
if ( resource == null ) {
|
||||||
errorMessage = "Missing resource";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
|
||||||
int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() );
|
int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() );
|
||||||
if ( lineNumber == -1 ) {
|
if ( lineNumber == -1 ) {
|
||||||
errorMessage = "Invalid line";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String sourceHandle = getSourceHandle( input );
|
String sourceHandle = getSourceHandle( input );
|
||||||
|
@ -121,18 +121,18 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
IEditorInput input = editorPart.getEditorInput();
|
IEditorInput input = editorPart.getEditorInput();
|
||||||
String errorMessage = null;
|
String errorMessage = null;
|
||||||
if ( input == null ) {
|
if ( input == null ) {
|
||||||
errorMessage = "Empty editor";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_2" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final ITextEditor textEditor = (ITextEditor)editorPart;
|
ITextEditor textEditor = (ITextEditor)editorPart;
|
||||||
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
|
IDocument document = textEditor.getDocumentProvider().getDocument( input );
|
||||||
if ( document == null ) {
|
if ( document == null ) {
|
||||||
errorMessage = "Missing document";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_2" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IResource resource = getResource( textEditor );
|
IResource resource = getResource( textEditor );
|
||||||
if ( resource == null ) {
|
if ( resource == null ) {
|
||||||
errorMessage = "Missing resource";
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_2" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( !(resource instanceof IWorkspaceRoot) )
|
if ( !(resource instanceof IWorkspaceRoot) )
|
||||||
|
@ -141,9 +141,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
AddWatchpointDialog dlg = new AddWatchpointDialog( textEditor.getSite().getShell(), true, false, expression );
|
AddWatchpointDialog dlg = new AddWatchpointDialog( textEditor.getSite().getShell(), true, false, expression );
|
||||||
if ( dlg.open() != Window.OK )
|
if ( dlg.open() != Window.OK )
|
||||||
return;
|
return;
|
||||||
|
expression = dlg.getExpression();
|
||||||
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
|
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
|
||||||
if ( !wev.isValidExpression( document, expression ) ) {
|
if ( !wev.isValidExpression( document, expression ) ) {
|
||||||
errorMessage = "Invalid expression: " + expression;
|
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_expression_1" ) + expression; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
String sourceHandle = getSourceHandle( input );
|
String sourceHandle = getSourceHandle( input );
|
||||||
|
@ -174,7 +175,7 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
|
||||||
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
* @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
||||||
*/
|
*/
|
||||||
public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) {
|
public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) {
|
||||||
return ( selection instanceof ITextSelection );
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void report( String message, IWorkbenchPart part ) {
|
protected void report( String message, IWorkbenchPart part ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue