1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Fixes in the breakpoint-related actions.

This commit is contained in:
Mikhail Khodjaiants 2004-04-13 03:17:06 +00:00
parent 670e216592
commit 050a97e1c7
5 changed files with 70 additions and 32 deletions

View file

@ -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
Changed the labels of the ruler breakpoint actions.
* plugin.properties

View file

@ -44,10 +44,6 @@ public abstract class AbstractListenerActionDelegate extends AbstractDebugAction
}
Runnable r= new Runnable() {
public void run() {
Shell shell= getWindow().getShell();
if (shell == null || shell.isDisposed()) {
return;
}
for (int i = 0; i < events.length; i++) {
if (events[i].getSource() != null) {
doHandleDebugEvent(events[i]);

View file

@ -14,3 +14,11 @@ RunToLineActionDelegate.Error_1=Error
RunToLineActionDelegate.Operation_failed_1=Operation failed.
RunToLineAdapter.Empty_editor_1=Empty editor
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:

View file

@ -12,9 +12,10 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
@ -25,6 +26,7 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IStorageEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
@ -33,11 +35,8 @@ import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.texteditor.ITextEditor;
/**
*
* Action for adding/removing watchpoints at a selection in the active
* Action for adding a watchpoint at a selection in the active
* C/C++ or assembly editor.
*
* @since Sep 4, 2002
*/
public class AddWatchpointActionDelegate extends ActionDelegate implements IWorkbenchWindowActionDelegate, IPartListener {
@ -49,7 +48,9 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
private IWorkbenchWindow fWorkbenchWindow = null;
private IProject fProject = null;
private IResource fResource = null;
private String fSourceHandle = ""; //$NON-NLS-1$
/**
* Constructor for AddWatchpointActionDelegate.
@ -128,8 +129,8 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
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 );
setSourceHandle( input );
setResource( input );
}
setEnabledState( editor );
}
@ -164,22 +165,27 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IWork
}
}
protected IProject getProject() {
return fProject;
protected IResource getResource() {
return fResource;
}
protected void setProject( IProject project ) {
fProject = project;
protected void setResource( IEditorInput input ) {
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 ) {
if ( getProject() == null )
if ( getResource() == null )
return;
IDocument document = getTextEditor().getDocumentProvider().getDocument( editorInput );
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
if ( wev.isValidExpression( document, expression ) ) {
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 ) {
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 ) {
}
}
}
}

View file

@ -50,24 +50,24 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
IEditorInput input = editorPart.getEditorInput();
String errorMessage = null;
if ( input == null ) {
errorMessage = "Empty editor";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_1" ); //$NON-NLS-1$
}
else {
final ITextEditor textEditor = (ITextEditor)editorPart;
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
ITextEditor textEditor = (ITextEditor)editorPart;
IDocument document = textEditor.getDocumentProvider().getDocument( input );
if ( document == null ) {
errorMessage = "Missing document";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_1" ); //$NON-NLS-1$
}
else {
IResource resource = getResource( textEditor );
if ( resource == null ) {
errorMessage = "Missing resource";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_1" ); //$NON-NLS-1$
}
else {
BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() );
if ( lineNumber == -1 ) {
errorMessage = "Invalid line";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
}
else {
String sourceHandle = getSourceHandle( input );
@ -121,18 +121,18 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
IEditorInput input = editorPart.getEditorInput();
String errorMessage = null;
if ( input == null ) {
errorMessage = "Empty editor";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_2" ); //$NON-NLS-1$
}
else {
final ITextEditor textEditor = (ITextEditor)editorPart;
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
ITextEditor textEditor = (ITextEditor)editorPart;
IDocument document = textEditor.getDocumentProvider().getDocument( input );
if ( document == null ) {
errorMessage = "Missing document";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_2" ); //$NON-NLS-1$
}
else {
IResource resource = getResource( textEditor );
if ( resource == null ) {
errorMessage = "Missing resource";
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_2" ); //$NON-NLS-1$
}
else {
if ( !(resource instanceof IWorkspaceRoot) )
@ -141,9 +141,10 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
AddWatchpointDialog dlg = new AddWatchpointDialog( textEditor.getSite().getShell(), true, false, expression );
if ( dlg.open() != Window.OK )
return;
expression = dlg.getExpression();
WatchpointExpressionVerifier wev = new WatchpointExpressionVerifier();
if ( !wev.isValidExpression( document, expression ) ) {
errorMessage = "Invalid expression: " + expression;
errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_expression_1" ) + expression; //$NON-NLS-1$
}
else {
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)
*/
public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) {
return ( selection instanceof ITextSelection );
return false;
}
protected void report( String message, IWorkbenchPart part ) {