mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Fix for 183396: Open up breakpoint ruler actions for other debug models
This commit is contained in:
parent
6342a2854c
commit
987b06a53e
3 changed files with 95 additions and 113 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,123 +7,106 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 183397
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
|
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
|
||||||
|
import org.eclipse.core.resources.IMarker;
|
||||||
|
import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
import org.eclipse.debug.core.model.IBreakpoint;
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.jface.text.Position;
|
import org.eclipse.jface.text.Position;
|
||||||
import org.eclipse.jface.text.source.Annotation;
|
|
||||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
import org.eclipse.ui.ISaveablePart;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
import org.eclipse.ui.texteditor.IUpdate;
|
import org.eclipse.ui.texteditor.IUpdate;
|
||||||
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base implementation of the breakpoint ruler actions.
|
* Abstract base implementation of the breakpoint ruler actions.
|
||||||
|
*
|
||||||
|
* @see {@link RulerBreakpointAction}
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBreakpointRulerAction extends Action implements IUpdate {
|
public abstract class AbstractBreakpointRulerAction extends Action implements IUpdate {
|
||||||
|
|
||||||
private IVerticalRulerInfo fInfo;
|
private final IWorkbenchPart fTargetPart;
|
||||||
|
private final IVerticalRulerInfo fRulerInfo;
|
||||||
private IWorkbenchPart fTargetPart;
|
|
||||||
|
/**
|
||||||
private IBreakpoint fBreakpoint;
|
* Constructs an action to work on breakpoints in the specified
|
||||||
|
* part with the specified vertical ruler information.
|
||||||
protected IBreakpoint determineBreakpoint() {
|
*
|
||||||
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( CDebugCorePlugin.getUniqueIdentifier() );
|
* @param part a text editor or DisassemblyView
|
||||||
for( int i = 0; i < breakpoints.length; i++ ) {
|
* @param info vertical ruler information
|
||||||
IBreakpoint breakpoint = breakpoints[i];
|
*/
|
||||||
if ( breakpoint instanceof ILineBreakpoint ) {
|
public AbstractBreakpointRulerAction(IWorkbenchPart part, IVerticalRulerInfo info) {
|
||||||
ILineBreakpoint lineBreakpoint = (ILineBreakpoint)breakpoint;
|
Assert.isTrue(part instanceof ITextEditor || part instanceof DisassemblyView);
|
||||||
if ( breakpointAtRulerLine( lineBreakpoint ) ) {
|
fTargetPart = part;
|
||||||
return lineBreakpoint;
|
fRulerInfo = info;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IVerticalRulerInfo getInfo() {
|
|
||||||
return fInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setInfo( IVerticalRulerInfo info ) {
|
|
||||||
fInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IWorkbenchPart getTargetPart() {
|
|
||||||
return this.fTargetPart;
|
|
||||||
}
|
|
||||||
protected void setTargetPart( IWorkbenchPart targetPart ) {
|
|
||||||
this.fTargetPart = targetPart;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the breakpoint at the last line of mouse activity in the ruler
|
||||||
|
* or <code>null</code> if none.
|
||||||
|
*
|
||||||
|
* @return breakpoint associated with activity in the ruler or <code>null</code>
|
||||||
|
*/
|
||||||
protected IBreakpoint getBreakpoint() {
|
protected IBreakpoint getBreakpoint() {
|
||||||
return fBreakpoint;
|
IAnnotationModel annotationModel = getAnnotationModel();
|
||||||
}
|
IDocument document = getDocument();
|
||||||
|
if (annotationModel != null) {
|
||||||
protected void setBreakpoint( IBreakpoint breakpoint ) {
|
Iterator iterator = annotationModel.getAnnotationIterator();
|
||||||
fBreakpoint = breakpoint;
|
while (iterator.hasNext()) {
|
||||||
}
|
Object object = iterator.next();
|
||||||
|
if (object instanceof SimpleMarkerAnnotation) {
|
||||||
protected boolean breakpointAtRulerLine( ILineBreakpoint cBreakpoint ) {
|
SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object;
|
||||||
int lineNumber = getBreakpointLine( cBreakpoint );
|
IMarker marker = markerAnnotation.getMarker();
|
||||||
int rulerLine = getInfo().getLineOfLastMouseButtonActivity();
|
|
||||||
return ( rulerLine == lineNumber );
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getBreakpointLine( ILineBreakpoint breakpoint ) {
|
|
||||||
if ( getTargetPart() instanceof ISaveablePart && ((ISaveablePart)getTargetPart()).isDirty() ) {
|
|
||||||
try {
|
|
||||||
return breakpoint.getLineNumber();
|
|
||||||
}
|
|
||||||
catch( CoreException e ) {
|
|
||||||
DebugPlugin.log( e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Position position = getBreakpointPosition( breakpoint );
|
|
||||||
if ( position != null ) {
|
|
||||||
IDocument doc = getDocument();
|
|
||||||
if ( doc != null ) {
|
|
||||||
try {
|
try {
|
||||||
return doc.getLineOfOffset( position.getOffset() );
|
if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
|
||||||
|
Position position = annotationModel.getPosition(markerAnnotation);
|
||||||
|
int line = document.getLineOfOffset(position.getOffset());
|
||||||
|
if (line == fRulerInfo.getLineOfLastMouseButtonActivity()) {
|
||||||
|
IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
|
||||||
|
if (breakpoint != null) {
|
||||||
|
return breakpoint;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
} catch (BadLocationException e) {
|
||||||
}
|
}
|
||||||
catch ( BadLocationException x ) {
|
|
||||||
DebugPlugin.log( x );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Position getBreakpointPosition( ILineBreakpoint breakpoint ) {
|
|
||||||
IAnnotationModel model = getAnnotationModel();
|
|
||||||
if ( model != null ) {
|
|
||||||
Iterator it = model.getAnnotationIterator();
|
|
||||||
while( it.hasNext() ) {
|
|
||||||
Annotation ann = (Annotation)it.next();
|
|
||||||
if ( ann instanceof MarkerAnnotation && ((MarkerAnnotation)ann).getMarker().equals( breakpoint.getMarker() ) ) {
|
|
||||||
return model.getPosition( ann );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the workbench part this action was created for.
|
||||||
|
*
|
||||||
|
* @return workbench part, a text editor or a DisassemblyView
|
||||||
|
*/
|
||||||
|
protected IWorkbenchPart getTargetPart() {
|
||||||
|
return fTargetPart;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the vertical ruler information this action was created for.
|
||||||
|
*
|
||||||
|
* @return vertical ruler information
|
||||||
|
*/
|
||||||
|
protected IVerticalRulerInfo getVerticalRulerInfo() {
|
||||||
|
return fRulerInfo;
|
||||||
|
}
|
||||||
|
|
||||||
private IDocument getDocument() {
|
private IDocument getDocument() {
|
||||||
IWorkbenchPart targetPart = getTargetPart();
|
IWorkbenchPart targetPart = getTargetPart();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,12 +7,13 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 183397
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||||
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
@ -27,12 +28,13 @@ import org.eclipse.ui.dialogs.PropertyDialogAction;
|
||||||
*/
|
*/
|
||||||
public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction {
|
public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction {
|
||||||
|
|
||||||
|
private IBreakpoint fBreakpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the action to modify the breakpoint properties.
|
* Creates the action to modify the breakpoint properties.
|
||||||
*/
|
*/
|
||||||
public CBreakpointPropertiesRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) {
|
public CBreakpointPropertiesRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) {
|
||||||
setInfo( info );
|
super( part, info );
|
||||||
setTargetPart( part );
|
|
||||||
setText( ActionMessages.getString( "CBreakpointPropertiesRulerAction.Breakpoint_Properties" ) ); //$NON-NLS-1$
|
setText( ActionMessages.getString( "CBreakpointPropertiesRulerAction.Breakpoint_Properties" ) ); //$NON-NLS-1$
|
||||||
part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.BREAKPOINT_PROPERTIES_ACTION );
|
part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.BREAKPOINT_PROPERTIES_ACTION );
|
||||||
setId( IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES );
|
setId( IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES );
|
||||||
|
@ -42,14 +44,14 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct
|
||||||
* @see Action#run()
|
* @see Action#run()
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
if ( getBreakpoint() != null ) {
|
if ( fBreakpoint != null ) {
|
||||||
PropertyDialogAction action = new PropertyDialogAction( getTargetPart().getSite(), new ISelectionProvider() {
|
PropertyDialogAction action = new PropertyDialogAction( getTargetPart().getSite(), new ISelectionProvider() {
|
||||||
|
|
||||||
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
|
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISelection getSelection() {
|
public ISelection getSelection() {
|
||||||
return new StructuredSelection( getBreakpoint() );
|
return new StructuredSelection( fBreakpoint );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
|
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
|
||||||
|
@ -59,6 +61,7 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
action.run();
|
action.run();
|
||||||
|
action.dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,12 +69,7 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct
|
||||||
* @see IUpdate#update()
|
* @see IUpdate#update()
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
setBreakpoint( determineBreakpoint() );
|
fBreakpoint = getBreakpoint();
|
||||||
if ( getBreakpoint() == null || !(getBreakpoint() instanceof ICBreakpoint) ) {
|
setEnabled( fBreakpoint != null );
|
||||||
setBreakpoint( null );
|
|
||||||
setEnabled( false );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setEnabled( true );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 183397
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
|
@ -14,18 +15,20 @@ import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.model.IBreakpoint;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
|
||||||
public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction {
|
public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction {
|
||||||
|
|
||||||
|
private IBreakpoint fBreakpoint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the action to enable/disable breakpoints
|
* Creates the action to enable/disable breakpoints
|
||||||
*/
|
*/
|
||||||
public EnableDisableBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) {
|
public EnableDisableBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) {
|
||||||
setInfo( info );
|
super( part, info );
|
||||||
setTargetPart( part );
|
|
||||||
setText( ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$
|
setText( ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$
|
||||||
part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.ENABLE_DISABLE_BREAKPOINT_ACTION );
|
part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.ENABLE_DISABLE_BREAKPOINT_ACTION );
|
||||||
setId( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT );
|
setId( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT );
|
||||||
|
@ -51,18 +54,16 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA
|
||||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
setBreakpoint( determineBreakpoint() );
|
fBreakpoint = getBreakpoint();
|
||||||
if ( getBreakpoint() == null ) {
|
setEnabled( fBreakpoint != null );
|
||||||
setEnabled( false );
|
if ( isEnabled() ) {
|
||||||
return;
|
try {
|
||||||
}
|
boolean enabled = getBreakpoint().isEnabled();
|
||||||
setEnabled( true );
|
setText( enabled ? ActionMessages.getString( "EnableDisableBreakpointRulerAction.Disable_Breakpoint_1" ) : ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
try {
|
}
|
||||||
boolean enabled = getBreakpoint().isEnabled();
|
catch( CoreException e ) {
|
||||||
setText( enabled ? ActionMessages.getString( "EnableDisableBreakpointRulerAction.Disable_Breakpoint_1" ) : ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$ //$NON-NLS-2$
|
DebugPlugin.log( e );
|
||||||
}
|
}
|
||||||
catch( CoreException e ) {
|
|
||||||
DebugPlugin.log( e );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue