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

Added ruler breakpoint actions to the Disassembly view.

This commit is contained in:
Mikhail Khodjaiants 2004-04-30 19:05:00 +00:00
parent 1d8bbf919e
commit 0a4a56f7b5
16 changed files with 551 additions and 488 deletions

View file

@ -1,3 +1,21 @@
2004-04-30 Mikhail Khodjaiants
Added ruler breakpoint actions to the Disassembly view.
* ICDebugHelpContextIds.java
* IInternalCDebugUIConstants.java
* ActionMessages.properties
* AbstractBreakpointRulerAction.java
* CBreakpointPropertiesRulerAction.java
* EnableDisableBreakpointRulerAction.java
* EnableDisableBreakpointRulerActionDelegate.java
* ManageBreakpointRulerActionDelegate.java
* ManageFunctionBreakpointActionDelegate.java
* ToggleBreakpointAdapter.java
* ManageBreakpointRulerAction.java: deleted
* ToggleBreakpointRulerAction.java: new
* DisassemblyAnnotationModel.java
* DisassemblyDocumentProvider.java
* DisassemblyView.java
2004-04-28 Mikhail Khodjaiants
Added support of context menu to the Disassembly view.
* DisassemblyView.java

View file

@ -6,7 +6,7 @@
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
/**
*
@ -20,7 +20,12 @@ import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
*/
public interface ICDebugHelpContextIds
{
public static final String PREFIX = ICDebugUIConstants.PLUGIN_ID + "."; //$NON-NLS-1$
/**
* C/C++ Debug UI plug-in identifier (value <code>"org.eclipse.cdt.debug.ui"</code>).
*/
public static final String PLUGIN_ID = CDebugUIPlugin.getUniqueIdentifier();
public static final String PREFIX = PLUGIN_ID + "."; //$NON-NLS-1$
// Actions
public static final String CHANGE_REGISTER_VALUE_ACTION = PREFIX + "change_register_value_action_context"; //$NON-NLS-1$
@ -35,6 +40,9 @@ public interface ICDebugHelpContextIds
public static final String LOAD_SYMBOLS_FOR_ALL = PREFIX + "load_symbols_for_all_action_context"; //$NON-NLS-1$
public static final String REFRESH_REGISTERS_ACTION = PREFIX + "refresh_registers_action_context"; //$NON-NLS-1$
public static final String AUTO_REFRESH_REGISTERS_ACTION = PREFIX + "auto_refresh_registers_action_context"; //$NON-NLS-1$
public static final String TOGGLE_BREAKPOINT_ACTION = PREFIX + "manage_breakpoint_action_context"; //$NON-NLS-1$
public static final String ENABLE_DISABLE_BREAKPOINT_ACTION = PREFIX + "enable_disable_breakpoint_action_context"; //$NON-NLS-1$
public static final String BREAKPOINT_PROPERTIES_ACTION = PREFIX + "breakpoint_properties_action_context"; //$NON-NLS-1$
// Views
public static final String MEMORY_VIEW = PREFIX + "memory_view_context"; //$NON-NLS-1$

View file

@ -10,26 +10,40 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
public interface IInternalCDebugUIConstants {
/**
* C/C++ Debug UI plug-in identifier (value <code>"org.eclipse.cdt.debug.ui"</code>).
*/
public static final String PLUGIN_ID = CDebugUIPlugin.getUniqueIdentifier();
public static final String PREFIX = PLUGIN_ID + "."; //$NON-NLS-1$
/**
* The name of the font to use for disassembly view. This font is managed via
* the workbench font preference page.
*/
public static final String DISASSEMBLY_FONT = "org.eclipse.cdt.debug.ui.DisassemblyFont"; //$NON-NLS-1$
public static final String DISASSEMBLY_FONT = PREFIX + "DisassemblyFont"; //$NON-NLS-1$
//Current stack frame instruction pointer
public static final String DISASM_INSTRUCTION_POINTER = "org.eclipse.cdt.debug.ui.disassemblyInstructionPointer"; //$NON-NLS-1$
public static final String DISASM_INSTRUCTION_POINTER = PREFIX + "disassemblyInstructionPointer"; //$NON-NLS-1$
// marker types for instruction pointer annotations - top stack frame, and secondary
public static final String DISASM_INSTRUCTION_POINTER_CURRENT = "org.eclipse.cdt.debug.ui.disassemblyInstructionPointer.current"; //$NON-NLS-1$
public static final String DISASM_INSTRUCTION_POINTER_SECONDARY = "org.eclipse.cdt.debug.ui.disassemblyInstructionPointer.secondary"; //$NON-NLS-1$
public static final String DISASM_INSTRUCTION_POINTER_CURRENT = PREFIX + "disassemblyInstructionPointer.current"; //$NON-NLS-1$
public static final String DISASM_INSTRUCTION_POINTER_SECONDARY = PREFIX + "disassemblyInstructionPointer.secondary"; //$NON-NLS-1$
// annotation types for instruction pointers
public static final String ANN_DISASM_INSTR_POINTER_CURRENT = "org.eclipse.cdt.debug.ui.currentDisassemblyIP"; //$NON-NLS-1$
public static final String ANN_DISASM_INSTR_POINTER_SECONDARY = "org.eclipse.cdt.debug.ui.secondaryDisassemblyIP"; //$NON-NLS-1$
public static final String ANN_DISASM_INSTR_POINTER_CURRENT = PREFIX + "currentDisassemblyIP"; //$NON-NLS-1$
public static final String ANN_DISASM_INSTR_POINTER_SECONDARY = PREFIX + "secondaryDisassemblyIP"; //$NON-NLS-1$
// object images
public static final String IMG_OBJS_DISASM_INSTRUCTION_POINTER_TOP = "IMG_OBJS_DISASM_INSTRUCTION_POINTER_TOP"; //$NON-NLS-1$
public static final String IMG_OBJS_DISASM_INSTRUCTION_POINTER = "IMG_OBJS_DISASM_INSTRUCTION_POINTER"; //$NON-NLS-1$
// action ids
public static final String ACTION_TOGGLE_BREAKPOINT = PREFIX + "toggleBreakpoint"; //$NON-NLS-1$
public static final String ACTION_ENABLE_DISABLE_BREAKPOINT = PREFIX + "enableDisableBreakpoint"; //$NON-NLS-1$
public static final String ACTION_BREAKPOINT_PROPERTIES = PREFIX + "breakpointProperties"; //$NON-NLS-1$
}

View file

@ -1,15 +1,20 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
*/
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IBreakpoint;
@ -17,147 +22,141 @@ import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
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.IVerticalRulerInfo;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.ISaveablePart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.IUpdate;
import org.eclipse.ui.texteditor.MarkerAnnotation;
/**
*
* Enter type comment.
*
* @since Aug 26, 2002
* Abstract base implementation of the breakpoint ruler actions.
*/
public abstract class AbstractBreakpointRulerAction extends Action implements IUpdate
{
public abstract class AbstractBreakpointRulerAction extends Action implements IUpdate {
private IVerticalRulerInfo fInfo;
private ITextEditor fTextEditor;
private IWorkbenchPart fTargetPart;
private IBreakpoint fBreakpoint;
protected IBreakpoint determineBreakpoint()
{
protected IBreakpoint determineBreakpoint() {
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints( CDebugCorePlugin.getUniqueIdentifier() );
for ( int i = 0; i < breakpoints.length; i++ )
{
for( int i = 0; i < breakpoints.length; i++ ) {
IBreakpoint breakpoint = breakpoints[i];
if ( breakpoint instanceof ICLineBreakpoint )
{
if ( breakpoint instanceof ICLineBreakpoint ) {
ICLineBreakpoint cBreakpoint = (ICLineBreakpoint)breakpoint;
try
{
if ( breakpointAtRulerLine( cBreakpoint ) )
{
return cBreakpoint;
}
}
catch( CoreException ce )
{
CDebugUIPlugin.log( ce );
continue;
if ( breakpointAtRulerLine( cBreakpoint ) ) {
return cBreakpoint;
}
}
}
return null;
}
protected IVerticalRulerInfo getInfo()
{
protected IVerticalRulerInfo getInfo() {
return fInfo;
}
protected void setInfo( IVerticalRulerInfo info )
{
protected void setInfo( IVerticalRulerInfo info ) {
fInfo = info;
}
protected ITextEditor getTextEditor()
{
return fTextEditor;
protected IWorkbenchPart getTargetPart() {
return this.fTargetPart;
}
protected void setTargetPart( IWorkbenchPart targetPart ) {
this.fTargetPart = targetPart;
}
protected void setTextEditor( ITextEditor textEditor )
{
fTextEditor = textEditor;
}
/**
* Returns the resource for which to create the marker,
* or <code>null</code> if there is no applicable resource.
*
* @return the resource for which to create the marker or <code>null</code>
*/
protected IResource getResource()
{
IEditorInput input = fTextEditor.getEditorInput();
IResource resource = (IResource)input.getAdapter( IFile.class );
if ( resource == null )
{
resource = (IResource)input.getAdapter( IResource.class );
}
return resource;
}
protected boolean breakpointAtRulerLine( ICLineBreakpoint cBreakpoint ) throws CoreException
{
AbstractMarkerAnnotationModel model = getAnnotationModel();
if ( model != null )
{
Position position = model.getMarkerPosition( cBreakpoint.getMarker() );
if ( position != null )
{
IDocumentProvider provider = getTextEditor().getDocumentProvider();
IDocument doc = provider.getDocument( getTextEditor().getEditorInput() );
try
{
int markerLineNumber = doc.getLineOfOffset( position.getOffset() );
int rulerLine = getInfo().getLineOfLastMouseButtonActivity();
if ( rulerLine == markerLineNumber )
{
if ( getTextEditor().isDirty() )
{
return cBreakpoint.getLineNumber() == markerLineNumber + 1;
}
return true;
}
}
catch ( BadLocationException x )
{
CDebugUIPlugin.log( x );
}
}
}
return false;
}
protected IBreakpoint getBreakpoint()
{
protected IBreakpoint getBreakpoint() {
return fBreakpoint;
}
protected void setBreakpoint( IBreakpoint breakpoint )
{
protected void setBreakpoint( IBreakpoint breakpoint ) {
fBreakpoint = breakpoint;
}
/**
* Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input.
*
* @return the marker annotation model
*/
protected AbstractMarkerAnnotationModel getAnnotationModel()
{
IDocumentProvider provider = fTextEditor.getDocumentProvider();
IAnnotationModel model = provider.getAnnotationModel( getTextEditor().getEditorInput() );
if ( model instanceof AbstractMarkerAnnotationModel )
{
return (AbstractMarkerAnnotationModel)model;
protected boolean breakpointAtRulerLine( ICLineBreakpoint cBreakpoint ) {
int lineNumber = getBreakpointLine( cBreakpoint );
int rulerLine = getInfo().getLineOfLastMouseButtonActivity();
return ( rulerLine == lineNumber );
}
private int getBreakpointLine( ICLineBreakpoint 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 {
return doc.getLineOfOffset( position.getOffset() );
}
catch ( BadLocationException x ) {
DebugPlugin.log( x );
}
}
}
}
return -1;
}
private Position getBreakpointPosition( ICLineBreakpoint 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;
}
}
private IDocument getDocument() {
IWorkbenchPart targetPart = getTargetPart();
if ( targetPart instanceof ITextEditor ) {
ITextEditor textEditor = (ITextEditor)targetPart;
IDocumentProvider provider = textEditor.getDocumentProvider();
if ( provider != null )
return provider.getDocument( textEditor.getEditorInput() );
}
else if ( targetPart instanceof DisassemblyView ) {
DisassemblyView dv = (DisassemblyView)targetPart;
IDocumentProvider provider = dv.getDocumentProvider();
if ( provider != null )
return provider.getDocument( dv.getInput() );
}
return null;
}
private IAnnotationModel getAnnotationModel() {
IWorkbenchPart targetPart = getTargetPart();
if ( targetPart instanceof ITextEditor ) {
ITextEditor textEditor = (ITextEditor)targetPart;
IDocumentProvider provider = textEditor.getDocumentProvider();
if ( provider != null )
return provider.getAnnotationModel( textEditor.getEditorInput() );
}
else if ( targetPart instanceof DisassemblyView ) {
DisassemblyView dv = (DisassemblyView)targetPart;
IDocumentProvider provider = dv.getDocumentProvider();
if ( provider != null )
return provider.getAnnotationModel( dv.getInput() );
}
return null;
}
}

View file

@ -23,3 +23,11 @@ ToggleBreakpointAdapter.Missing_document_2=Missing document
ToggleBreakpointAdapter.Missing_resource_2=Missing resource
ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression:
RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported.
EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint
EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1=Enabling/disabling breakpoints
EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1=Exceptions occurred enabling or disabling the breakpoint
EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint
ToggleBreakpointRulerAction.Toggle_Breakpoint_1=Toggle &Breakpoint
ToggleBreakpointRulerAction.Error_1=Error
ToggleBreakpointRulerAction.Operation_failed_1=Operation failed
CBreakpointPropertiesRulerAction.Breakpoint_Properties=Breakpoint &Properties...

View file

@ -1,59 +1,60 @@
/*
*(c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
*/
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
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.IInternalCDebugUIConstants;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.help.WorkbenchHelp;
/**
*
* Presents a custom properties dialog to configure the attibutes of
* a C/C++ breakpoint from the ruler popup menu of a text editor.
*
* @since Aug 29, 2002
* Opens a custom properties dialog to configure the attibutes of a C/C++ breakpoint
* from the ruler popup menu.
*/
public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction
{
/**
* Creates the action to enable/disable breakpoints
*/
public CBreakpointPropertiesRulerAction( ITextEditor editor, IVerticalRulerInfo info )
{
setInfo( info );
setTextEditor( editor );
setText( CDebugUIPlugin.getResourceString("internal.ui.actions.CBreakpointPropertiesRulerAction.Breakpoint_Properties") ); //$NON-NLS-1$
}
public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAction {
/**
* Creates the action to modify the breakpoint properties.
*/
public CBreakpointPropertiesRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) {
setInfo( info );
setTargetPart( part );
setText( ActionMessages.getString( "CBreakpointPropertiesRulerAction.Breakpoint_Properties" ) ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.BREAKPOINT_PROPERTIES_ACTION );
setId( IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES );
}
/* (non-Javadoc)
* @see Action#run()
*/
public void run()
{
if ( getBreakpoint() != null )
{
Dialog d = new CBreakpointPropertiesDialog( getTextEditor().getEditorSite().getShell(), (ICBreakpoint)getBreakpoint() );
public void run() {
if ( getBreakpoint() != null ) {
Dialog d = new CBreakpointPropertiesDialog( getTargetPart().getSite().getShell(), (ICBreakpoint)getBreakpoint() );
d.open();
}
}
/**
/* (non-Javadoc)
* @see IUpdate#update()
*/
public void update()
{
public void update() {
setBreakpoint( determineBreakpoint() );
if ( getBreakpoint() == null || !( getBreakpoint() instanceof ICBreakpoint ) )
{
if ( getBreakpoint() == null || !(getBreakpoint() instanceof ICBreakpoint) ) {
setBreakpoint( null );
setEnabled( false );
return;
}
setEnabled( true );
}
}
}

View file

@ -1,39 +1,50 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IUpdate;
public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction {
public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction
{
/**
* Creates the action to enable/disable breakpoints
*/
public EnableDisableBreakpointRulerAction( ITextEditor editor, IVerticalRulerInfo info )
{
public EnableDisableBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) {
setInfo( info );
setTextEditor( editor );
setText( CDebugUIPlugin.getResourceString("internal.ui.actions.EnableDisableBreakpointRulerAction.Enable_Breakpoint") ); //$NON-NLS-1$
setTargetPart( part );
setText( ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.ENABLE_DISABLE_BREAKPOINT_ACTION );
setId( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT );
}
/**
* @see Action#run()
*/
public void run()
{
if (getBreakpoint() != null)
{
try
{
public void run() {
if ( getBreakpoint() != null ) {
try {
getBreakpoint().setEnabled( !getBreakpoint().isEnabled() );
}
catch (CoreException e)
{
ErrorDialog.openError( getTextEditor().getEditorSite().getShell(),
CDebugUIPlugin.getResourceString("internal.ui.actions.EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints"), //$NON-NLS-1$
CDebugUIPlugin.getResourceString("internal.ui.actions.EnableDisableBreakpointRulerAction.Exceptions_occured_enabling_disabling_breakpoint"), //$NON-NLS-1$
catch( CoreException e ) {
ErrorDialog.openError( getTargetPart().getSite().getShell(), ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1" ), //$NON-NLS-1$
ActionMessages.getString( "EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1" ), //$NON-NLS-1$
e.getStatus() );
}
}
@ -42,24 +53,19 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA
/**
* @see IUpdate#update()
*/
public void update()
{
setBreakpoint(determineBreakpoint());
if ( getBreakpoint() == null )
{
public void update() {
setBreakpoint( determineBreakpoint() );
if ( getBreakpoint() == null ) {
setEnabled( false );
return;
}
setEnabled( true );
try
{
try {
boolean enabled = getBreakpoint().isEnabled();
setText( enabled ? CDebugUIPlugin.getResourceString("internal.ui.actions.EnableDisableBreakpointRulerAction.Disable_breakpoint") : //$NON-NLS-1$
CDebugUIPlugin.getResourceString("internal.ui.actions.EnableDisableBreakpointRulerAction.Enable_Breakpoint") ); //$NON-NLS-1$
setText( enabled ? ActionMessages.getString( "EnableDisableBreakpointRulerAction.Disable_Breakpoint_1" ) : ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
catch( CoreException ce )
{
CDebugUIPlugin.log( ce );
catch( CoreException e ) {
DebugPlugin.log( e );
}
}
}
}

View file

@ -1,3 +1,13 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.jface.action.IAction;
@ -5,13 +15,12 @@ import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
import org.eclipse.ui.texteditor.ITextEditor;
public class EnableDisableBreakpointRulerActionDelegate extends AbstractRulerActionDelegate
{
/**
public class EnableDisableBreakpointRulerActionDelegate extends AbstractRulerActionDelegate {
/*
* @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
*/
protected IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo )
{
protected IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) {
return new EnableDisableBreakpointRulerAction( editor, rulerInfo );
}
}
}

View file

@ -1,217 +0,0 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
public class ManageBreakpointRulerAction extends Action {
private IVerticalRulerInfo fRuler;
private ITextEditor fTextEditor;
private ToggleBreakpointAdapter fBreakpointAdapter;
/**
* Constructor for ManageBreakpointRulerAction.
*
* @param ruler
* @param editor
*/
public ManageBreakpointRulerAction( IVerticalRulerInfo ruler, ITextEditor editor ) {
super( "Toggle &Breakpoint" );
fRuler = ruler;
fTextEditor = editor;
fBreakpointAdapter = new ToggleBreakpointAdapter();
}
/**
* Disposes this action
*/
public void dispose() {
fTextEditor = null;
fRuler = null;
}
/**
* @see Action#run()
*/
public void run() {
try {
List list = getMarkers();
if ( list.isEmpty() ) {
// create new markers
IDocument document = getDocument();
int lineNumber = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
IRegion line = document.getLineInformation( lineNumber );
ITextSelection selection = new TextSelection( document, line.getOffset(), line.getLength() );
fBreakpointAdapter.toggleLineBreakpoints( fTextEditor, selection );
}
else {
// remove existing breakpoints of any type
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
Iterator iterator = list.iterator();
while( iterator.hasNext() ) {
IMarker marker = (IMarker)iterator.next();
IBreakpoint breakpoint = manager.getBreakpoint( marker );
if ( breakpoint != null ) {
breakpoint.delete();
}
}
}
}
catch( BadLocationException e ) {
DebugUIPlugin.errorDialog( getTextEditor().getSite().getShell(),
"Error",
"Operation failed",
e );
}
catch( CoreException e ) {
DebugUIPlugin.errorDialog( getTextEditor().getSite().getShell(),
"Error",
"Operation failed",
e.getStatus() );
}
}
protected List getMarkers() {
List breakpoints = new ArrayList();
IResource resource = ToggleBreakpointAdapter.getResource( fTextEditor );
IDocument document = getDocument();
AbstractMarkerAnnotationModel model = getAnnotationModel();
if ( model != null ) {
try {
IMarker[] markers = null;
if ( resource instanceof IFile )
markers = resource.findMarkers( IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE );
else {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
markers = root.findMarkers( IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_INFINITE );
}
if ( markers != null ) {
IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
for( int i = 0; i < markers.length; i++ ) {
IBreakpoint breakpoint = breakpointManager.getBreakpoint( markers[i] );
if ( breakpoint != null && breakpointManager.isRegistered( breakpoint ) && includesRulerLine( model.getMarkerPosition( markers[i] ), document ) )
breakpoints.add( markers[i] );
}
}
}
catch( CoreException x ) {
CDebugUIPlugin.log( x.getStatus() );
}
}
return breakpoints;
}
/**
* Returns the resource for which to create the marker,
* or <code>null</code> if there is no applicable resource.
*
* @return the resource for which to create the marker or <code>null</code>
*/
protected IResource getResource() {
IEditorInput input = fTextEditor.getEditorInput();
IResource resource = (IResource)input.getAdapter( IFile.class );
if ( resource == null )
resource = (IResource)input.getAdapter( IResource.class );
return resource;
}
/**
* Checks whether a position includes the ruler's line of activity.
*
* @param position the position to be checked
* @param document the document the position refers to
* @return <code>true</code> if the line is included by the given position
*/
protected boolean includesRulerLine( Position position, IDocument document ) {
if ( position != null ) {
try {
int markerLine = document.getLineOfOffset( position.getOffset() );
int line = fRuler.getLineOfLastMouseButtonActivity();
if ( line == markerLine ) {
return true;
}
}
catch( BadLocationException x ) {
}
}
return false;
}
/**
* Returns this action's vertical ruler info.
*
* @return this action's vertical ruler
*/
protected IVerticalRulerInfo getVerticalRulerInfo() {
return fRuler;
}
/**
* Returns this action's editor.
*
* @return this action's editor
*/
protected ITextEditor getTextEditor() {
return fTextEditor;
}
/**
* Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input.
*
* @return the marker annotation model
*/
protected AbstractMarkerAnnotationModel getAnnotationModel() {
IDocumentProvider provider = fTextEditor.getDocumentProvider();
IAnnotationModel model = provider.getAnnotationModel( fTextEditor.getEditorInput() );
if ( model instanceof AbstractMarkerAnnotationModel ) {
return (AbstractMarkerAnnotationModel)model;
}
return null;
}
/**
* Returns the <code>IDocument</code> of the editor's input.
*
* @return the document of the editor's input
*/
protected IDocument getDocument() {
IDocumentProvider provider = fTextEditor.getDocumentProvider();
return provider.getDocument( fTextEditor.getEditorInput() );
}
}

View file

@ -18,14 +18,14 @@ import org.eclipse.ui.texteditor.ITextEditor;
public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDelegate {
private ManageBreakpointRulerAction fTargetAction;
private ToggleBreakpointRulerAction fTargetAction;
private IEditorPart fActiveEditor;
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
*/
public IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) {
fTargetAction = new ManageBreakpointRulerAction( rulerInfo, editor );
fTargetAction = new ToggleBreakpointRulerAction( editor, rulerInfo );
return fTargetAction;
}

View file

@ -9,11 +9,6 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.IFunction;
import org.eclipse.cdt.core.model.IMethod;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;

View file

@ -233,16 +233,14 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
}
}
protected static IResource getResource( IEditorPart editor ) {
IResource resource;
IEditorInput editorInput = editor.getEditorInput();
if ( editorInput instanceof IFileEditorInput ) {
resource = ((IFileEditorInput)editorInput).getFile();
protected static IResource getResource( IWorkbenchPart part ) {
if ( part instanceof IEditorPart ) {
IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
if ( editorInput instanceof IFileEditorInput ) {
return ((IFileEditorInput)editorInput).getFile();
}
}
else {
resource = ResourcesPlugin.getWorkspace().getRoot();
}
return resource;
return ResourcesPlugin.getWorkspace().getRoot();
}
private String getSourceHandle( IEditorInput input ) throws CoreException {

View file

@ -0,0 +1,137 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
public class ToggleBreakpointRulerAction extends Action {
static class EmptySelection implements ISelection {
public boolean isEmpty() {
return true;
}
}
private IVerticalRulerInfo fRuler;
private IWorkbenchPart fTargetPart;
private ToggleBreakpointAdapter fBreakpointAdapter;
private static final ISelection EMPTY_SELECTION = new EmptySelection();
/**
* Constructor for ToggleBreakpointRulerAction.
*
* @param ruler
* @param editor
*/
public ToggleBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo ruler ) {
super( ActionMessages.getString( "ToggleBreakpointRulerAction.Toggle_Breakpoint_1" ) ); //$NON-NLS-1$
fRuler = ruler;
setTargetPart( part );
fBreakpointAdapter = new ToggleBreakpointAdapter();
WorkbenchHelp.setHelp( this, ICDebugHelpContextIds.TOGGLE_BREAKPOINT_ACTION );
setId( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT );
}
/**
* Disposes this action
*/
public void dispose() {
setTargetPart( null );
fRuler = null;
}
/**
* @see Action#run()
*/
public void run() {
try {
fBreakpointAdapter.toggleLineBreakpoints( getTargetPart(), getTargetSelection() );
}
catch( CoreException e ) {
DebugUIPlugin.errorDialog( getTargetPart().getSite().getShell(),
ActionMessages.getString( "ToggleBreakpointRulerAction.Error_1" ), //$NON-NLS-1$
ActionMessages.getString( "ToggleBreakpointRulerAction.Operation_failed_1" ), //$NON-NLS-1$
e.getStatus() );
}
}
/**
* Returns this action's vertical ruler info.
*
* @return this action's vertical ruler
*/
protected IVerticalRulerInfo getVerticalRulerInfo() {
return fRuler;
}
private IWorkbenchPart getTargetPart() {
return this.fTargetPart;
}
private void setTargetPart( IWorkbenchPart targetPart ) {
this.fTargetPart = targetPart;
}
/**
* Returns the current selection in the active part, possibly
* and empty selection, but never <code>null</code>.
*
* @return the selection in the active part, possibly empty
*/
private ISelection getTargetSelection() {
IDocument doc = getDocument();
if ( doc != null ) {
int line = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
try {
IRegion region = doc.getLineInformation( line );
return new TextSelection( doc, region.getOffset(), region.getLength() );
}
catch( BadLocationException e ) {
DebugPlugin.log( e );
}
}
return EMPTY_SELECTION;
}
private IDocument getDocument() {
IWorkbenchPart targetPart = getTargetPart();
if ( targetPart instanceof ITextEditor ) {
ITextEditor textEditor = (ITextEditor)targetPart;
IDocumentProvider provider = textEditor.getDocumentProvider();
if ( provider != null )
return provider.getDocument( textEditor.getEditorInput() );
}
else if ( targetPart instanceof DisassemblyView ) {
DisassemblyView dv = (DisassemblyView)targetPart;
IDocumentProvider provider = dv.getDocumentProvider();
if ( provider != null )
return provider.getDocument( dv.getInput() );
}
return null;
}
}

View file

@ -17,9 +17,7 @@ import java.util.List;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointsListener;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.jface.text.BadLocationException;
@ -33,77 +31,66 @@ import org.eclipse.ui.texteditor.MarkerAnnotation;
/**
* Annotation model for Disassembly view.
*/
public class DisassemblyAnnotationModel extends AnnotationModel implements IBreakpointsListener {
public class DisassemblyAnnotationModel extends AnnotationModel {
private DisassemblyEditorInput fInput;
private IDocument fDisassemblyDocument;
// private IDocument fDisassemblyDocument;
/**
* Constructor for DisassemblyAnnotationModel.
*/
public DisassemblyAnnotationModel( IDocument document ) {
public DisassemblyAnnotationModel() {
super();
fDisassemblyDocument = document;
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
*/
public void breakpointsAdded( final IBreakpoint[] breakpoints ) {
protected void breakpointsAdded( final IBreakpoint[] breakpoints, final IDocument document ) {
if ( getInput().equals( DisassemblyEditorInput.EMPTY_EDITOR_INPUT ) ||
getInput().equals( DisassemblyEditorInput.PENDING_EDITOR_INPUT ) )
return;
asyncExec( new Runnable() {
public void run() {
breakpointsAdded0( breakpoints );
breakpointsAdded0( breakpoints, document );
}
} );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
*/
public void breakpointsRemoved( final IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
protected void breakpointsRemoved( final IBreakpoint[] breakpoints, final IDocument document ) {
if ( getInput().equals( DisassemblyEditorInput.EMPTY_EDITOR_INPUT ) ||
getInput().equals( DisassemblyEditorInput.PENDING_EDITOR_INPUT ) )
return;
asyncExec( new Runnable() {
public void run() {
breakpointsRemoved0( breakpoints );
breakpointsRemoved0( breakpoints, document );
}
} );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
*/
public void breakpointsChanged( final IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
protected void breakpointsChanged( final IBreakpoint[] breakpoints, final IDocument document ) {
if ( getInput().equals( DisassemblyEditorInput.EMPTY_EDITOR_INPUT ) ||
getInput().equals( DisassemblyEditorInput.PENDING_EDITOR_INPUT ) )
return;
asyncExec( new Runnable() {
public void run() {
breakpointsChanged0( breakpoints );
breakpointsChanged0( breakpoints, document );
}
} );
}
protected void breakpointsAdded0( IBreakpoint[] breakpoints ) {
protected void breakpointsAdded0( IBreakpoint[] breakpoints, IDocument document ) {
for ( int i = 0; i < breakpoints.length; ++i ) {
if ( breakpoints[i] instanceof ICLineBreakpoint && isApplicable( breakpoints[i] ) ) {
addBreakpointAnnotation( (ICLineBreakpoint)breakpoints[i] );
addBreakpointAnnotation( (ICLineBreakpoint)breakpoints[i], document );
}
}
fireModelChanged();
}
protected void breakpointsRemoved0( IBreakpoint[] breakpoints ) {
protected void breakpointsRemoved0( IBreakpoint[] breakpoints, IDocument document ) {
removeAnnotations( findAnnotationsforBreakpoints( breakpoints ), true, false );
}
protected void breakpointsChanged0( IBreakpoint[] breakpoints ) {
protected void breakpointsChanged0( IBreakpoint[] breakpoints, IDocument document ) {
List annotations = findAnnotationsforBreakpoints( breakpoints );
List markers = new ArrayList( annotations.size() );
Iterator it = annotations.iterator();
@ -114,7 +101,7 @@ public class DisassemblyAnnotationModel extends AnnotationModel implements IBrea
}
for ( int i = 0; i < breakpoints.length; ++i ) {
if ( breakpoints[i] instanceof ICLineBreakpoint && !markers.contains( breakpoints[i].getMarker() ) ) {
addBreakpointAnnotation( (ICLineBreakpoint)breakpoints[i] );
addBreakpointAnnotation( (ICLineBreakpoint)breakpoints[i], document );
}
}
fireModelChanged();
@ -124,19 +111,19 @@ public class DisassemblyAnnotationModel extends AnnotationModel implements IBrea
return this.fInput;
}
protected void setInput( DisassemblyEditorInput input ) {
protected void setInput( DisassemblyEditorInput input, IDocument document ) {
DisassemblyEditorInput oldInput = this.fInput;
this.fInput = input;
if ( this.fInput != null && !this.fInput.equals( oldInput ) )
updateAnnotations();
updateAnnotations( document );
}
private boolean isApplicable( IBreakpoint breakpoint ) {
return true;
}
private void addBreakpointAnnotation( ICLineBreakpoint breakpoint ) {
Position position = createBreakpointPosition( breakpoint );
private void addBreakpointAnnotation( ICLineBreakpoint breakpoint, IDocument document ) {
Position position = createBreakpointPosition( breakpoint, document );
if ( position != null ) {
try {
addAnnotation( createMarkerAnnotation( breakpoint ), position, false );
@ -146,19 +133,19 @@ public class DisassemblyAnnotationModel extends AnnotationModel implements IBrea
}
}
private Position createBreakpointPosition( ICLineBreakpoint breakpoint ) {
private Position createBreakpointPosition( ICLineBreakpoint breakpoint, IDocument document ) {
Position position = null;
DisassemblyEditorInput input = getInput();
if ( input != null ) {
long address = input.getBreakpointAddress( breakpoint );
int start = -1;
if ( address > 0 && fDisassemblyDocument != null ) {
if ( address > 0 && document != null ) {
int instrNumber = input.getInstructionNumber( address );
if ( instrNumber > 0 ) {
try {
start = fDocument.getLineOffset( instrNumber - 1 );
if ( start > -1 ) {
return new Position( start, fDisassemblyDocument.getLineLength( instrNumber - 1 ) );
return new Position( start, document.getLineLength( instrNumber - 1 ) );
}
}
catch( BadLocationException e ) {
@ -174,7 +161,6 @@ public class DisassemblyAnnotationModel extends AnnotationModel implements IBrea
}
protected void dispose() {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
}
private List findAnnotationsforBreakpoints( IBreakpoint[] breakpoints ) {
@ -202,15 +188,15 @@ public class DisassemblyAnnotationModel extends AnnotationModel implements IBrea
display.asyncExec( r );
}
private void updateAnnotations() {
private void updateAnnotations( final IDocument document ) {
asyncExec( new Runnable() {
public void run() {
doUpdateAnnotations();
doUpdateAnnotations( document );
}
} );
}
protected void doUpdateAnnotations() {
breakpointsAdded0( DebugPlugin.getDefault().getBreakpointManager().getBreakpoints() );
protected void doUpdateAnnotations( IDocument document ) {
breakpointsAdded0( DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(), document );
}
}

View file

@ -10,8 +10,12 @@
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.views.disassembly;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointsListener;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IAnnotationModel;
@ -21,38 +25,24 @@ import org.eclipse.ui.texteditor.IElementStateListener;
/**
* Document provider for disassembly view.
*/
public class DisassemblyDocumentProvider implements IDocumentProvider {
public class DisassemblyDocumentProvider implements IDocumentProvider, IBreakpointsListener {
private IDocument fDocument;
// private DisassemblyMarkerAnnotationModel fAnnotationModel;
private DisassemblyAnnotationModel fAnnotationModel;
/**
* Constructor for DisassemblyDocumentProvider.
*/
public DisassemblyDocumentProvider() {
fDocument = new Document();
fAnnotationModel = new DisassemblyAnnotationModel();
DebugPlugin.getDefault().getBreakpointManager().addBreakpointListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IDocumentProvider#connect(java.lang.Object)
*/
public void connect( Object element ) throws CoreException {
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IDocumentProvider#disconnect(java.lang.Object)
*/
public void disconnect( Object element ) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IDocumentProvider#getDocument(java.lang.Object)
*/
public IDocument getDocument( Object element ) {
if ( fDocument == null ) {
fDocument = new Document();
}
if ( element instanceof DisassemblyEditorInput ) {
String contents = ((DisassemblyEditorInput)element).getContents();
fDocument.set( contents );
@ -60,6 +50,21 @@ public class DisassemblyDocumentProvider implements IDocumentProvider {
else {
fDocument.set( "" ); //$NON-NLS-1$
}
fAnnotationModel.setInput( ( element instanceof DisassemblyEditorInput ) ? (DisassemblyEditorInput)element : null, fDocument );
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IDocumentProvider#disconnect(java.lang.Object)
*/
public void disconnect( Object element ) {
fDocument.set( "" ); //$NON-NLS-1$
fAnnotationModel.setInput( null, fDocument );
}
/* (non-Javadoc)
* @see org.eclipse.ui.texteditor.IDocumentProvider#getDocument(java.lang.Object)
*/
public IDocument getDocument( Object element ) {
return fDocument;
}
@ -121,11 +126,6 @@ public class DisassemblyDocumentProvider implements IDocumentProvider {
* @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object)
*/
public IAnnotationModel getAnnotationModel( Object element ) {
if ( fAnnotationModel == null ) {
// fAnnotationModel = new DisassemblyMarkerAnnotationModel( getDocument( element ) );
fAnnotationModel = new DisassemblyAnnotationModel( getDocument( element ) );
}
fAnnotationModel.setInput( ( element instanceof DisassemblyEditorInput ) ? (DisassemblyEditorInput)element : null );
return fAnnotationModel;
}
@ -158,8 +158,32 @@ public class DisassemblyDocumentProvider implements IDocumentProvider {
}
protected void dispose() {
fDocument = null;
if ( fAnnotationModel != null ) {
fAnnotationModel.dispose();
fAnnotationModel = null;
}
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsAdded(org.eclipse.debug.core.model.IBreakpoint[])
*/
public void breakpointsAdded( IBreakpoint[] breakpoints ) {
fAnnotationModel.breakpointsAdded( breakpoints, fDocument );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsChanged(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
*/
public void breakpointsChanged( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
fAnnotationModel.breakpointsChanged( breakpoints, fDocument );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.IBreakpointsListener#breakpointsRemoved(org.eclipse.debug.core.model.IBreakpoint[], org.eclipse.core.resources.IMarkerDelta[])
*/
public void breakpointsRemoved( IBreakpoint[] breakpoints, IMarkerDelta[] deltas ) {
fAnnotationModel.breakpointsRemoved( breakpoints, fDocument );
}
}

View file

@ -11,16 +11,23 @@
package org.eclipse.cdt.debug.internal.ui.views.disassembly;
import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;
import org.eclipse.cdt.debug.core.model.IAsmInstruction;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.IDisassembly;
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerAction;
import org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerAction;
import org.eclipse.cdt.debug.internal.ui.actions.ToggleBreakpointRulerAction;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugException;
@ -43,6 +50,7 @@ import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.jface.text.source.OverviewRuler;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.text.source.VerticalRuler;
@ -143,7 +151,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
public void mouseDoubleClick( MouseEvent e ) {
if ( 1 == e.button ) {
fDoubleClicked = true;
triggerAction( ITextEditorActionConstants.RULER_DOUBLE_CLICK );
triggerAction( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT );
}
}
@ -246,6 +254,11 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
*/
private Menu fTextContextMenu;
/**
* The actions registered with the view.
*/
private Map fActions = new HashMap( 10 );
/**
* Constructor for DisassemblyView.
*/
@ -285,6 +298,17 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
* @see org.eclipse.debug.ui.AbstractDebugView#createActions()
*/
protected void createActions() {
IAction action;
IVerticalRuler ruler = getVerticalRuler();
if ( ruler instanceof IVerticalRulerInfo ) {
IVerticalRulerInfo info = (IVerticalRulerInfo)ruler;
action= new ToggleBreakpointRulerAction( this, info );
setAction( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT, action );
action= new EnableDisableBreakpointRulerAction( this, info );
setAction( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT, action );
action= new CBreakpointPropertiesRulerAction( this, info );
setAction( IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES, action );
}
}
/* (non-Javadoc)
@ -420,6 +444,12 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
setInput( input );
showViewer();
try {
getDocumentProvider().connect( input );
}
catch( CoreException e ) {
// never happens
}
getSourceViewer().setDocument( getDocumentProvider().getDocument( input ),
getDocumentProvider().getAnnotationModel( input ) );
updateObjects();
@ -443,6 +473,11 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
fDocumentProvider = null;
}
if ( fActions != null ) {
fActions.clear();
fActions = null;
}
super.dispose();
}
@ -627,7 +662,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
return EditorsPlugin.getDefault().getPreferenceStore();
}
protected DisassemblyDocumentProvider getDocumentProvider() {
public DisassemblyDocumentProvider getDocumentProvider() {
if ( this.fDocumentProvider == null )
this.fDocumentProvider = new DisassemblyDocumentProvider();
return this.fDocumentProvider;
@ -681,6 +716,12 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
IEditorInput input = DisassemblyEditorInput.EMPTY_EDITOR_INPUT;
setInput( input );
showViewer();
try {
getDocumentProvider().connect( input );
}
catch( CoreException e ) {
// never happens
}
IAnnotationModel model = getDocumentProvider().getAnnotationModel( input );
getSourceViewer().setDocument( getDocumentProvider().getDocument( input ), model );
removeCurrentInstructionPointer( model );
@ -745,6 +786,9 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
protected void rulerContextMenuAboutToShow( IMenuManager menu ) {
menu.add( new Separator( ITextEditorActionConstants.GROUP_REST ) );
menu.add( new Separator( IWorkbenchActionConstants.MB_ADDITIONS ) );
addAction( menu, IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT );
addAction( menu, IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT );
addAction( menu, IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES );
}
/**
@ -776,6 +820,20 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
}
}
/**
* Convenience method to add the action installed under the given action id to the given menu.
* @param menu the menu to add the action to
* @param actionId the id of the action to be added
*/
protected final void addAction( IMenuManager menu, String actionId ) {
IAction action = getAction( actionId );
if ( action != null ) {
if ( action instanceof IUpdate )
((IUpdate)action).update();
menu.add( action );
}
}
protected Menu getRulerContextMenu() {
return this.fRulerContextMenu;
}
@ -812,4 +870,23 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
private void setTextContextMenu( Menu textContextMenu ) {
this.fTextContextMenu = textContextMenu;
}
public void setAction( String actionID, IAction action ) {
Assert.isNotNull( actionID );
if ( action == null ) {
action = (IAction)fActions.remove( actionID );
}
else {
fActions.put( actionID, action );
}
}
public IAction getAction( String actionID ) {
Assert.isNotNull( actionID );
return (IAction)fActions.get( actionID );
}
private IVerticalRuler getVerticalRuler() {
return this.fVerticalRuler;
}
}