mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Implementation of the "Run To Line" retargettable action.
This commit is contained in:
parent
ead83ba6f7
commit
a1f408bc47
7 changed files with 85 additions and 411 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2004-04-11 Mikhail Khodjaiants
|
||||||
|
Implementation of the "Run To Line" retargettable action.
|
||||||
|
* plugin.xml
|
||||||
|
* RetargettableActionAdapterFactory.java
|
||||||
|
* RunToLineAdapter.java
|
||||||
|
* RunToLineRulerAction.java - deleted
|
||||||
|
* RunToLineRulerActionDelegate.java - deleted
|
||||||
|
* ActionMessages.properties
|
||||||
|
|
||||||
2004-04-08 Mikhail Khodjaiants
|
2004-04-08 Mikhail Khodjaiants
|
||||||
Implementing retargettable actions.
|
Implementing retargettable actions.
|
||||||
* plugin.xml
|
* plugin.xml
|
||||||
|
|
|
@ -160,23 +160,6 @@
|
||||||
</pluginState>
|
</pluginState>
|
||||||
</enablement>
|
</enablement>
|
||||||
</action>
|
</action>
|
||||||
<action
|
|
||||||
id="org.eclipse.cdt.debug.ui.internal.actions.RunToLineActionDelegate"
|
|
||||||
hoverIcon="icons/full/clcl16/runtoline_co.gif"
|
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineActionDelegate"
|
|
||||||
disabledIcon="icons/full/dlcl16/runtoline_co.gif"
|
|
||||||
enablesFor="1"
|
|
||||||
icon="icons/full/elcl16/runtoline_co.gif"
|
|
||||||
helpContextId="run_to_line_action_context"
|
|
||||||
label="%GlobalRunToLineAction.label"
|
|
||||||
menubarPath="org.eclipse.ui.run/stepGroup">
|
|
||||||
<enablement>
|
|
||||||
<pluginState
|
|
||||||
value="activated"
|
|
||||||
id="org.eclipse.cdt.debug.ui">
|
|
||||||
</pluginState>
|
|
||||||
</enablement>
|
|
||||||
</action>
|
|
||||||
<action
|
<action
|
||||||
id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
|
id="org.eclipse.cdt.debug.ui.internal.actions.RestartActionDelegate"
|
||||||
hoverIcon="icons/full/clcl16/restart.gif"
|
hoverIcon="icons/full/clcl16/restart.gif"
|
||||||
|
@ -312,16 +295,6 @@
|
||||||
<viewerContribution
|
<viewerContribution
|
||||||
targetID="#CEditorRulerContext"
|
targetID="#CEditorRulerContext"
|
||||||
id="org.eclipse.cdt.debug.ui.CEditorRulerActions">
|
id="org.eclipse.cdt.debug.ui.CEditorRulerActions">
|
||||||
<!--
|
|
||||||
<action
|
|
||||||
label="%RunToLineAction.label"
|
|
||||||
icon="icons/full/clcl16/runtoline_co.gif"
|
|
||||||
helpContextId="run_to_line_action_context"
|
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineRulerActionDelegate"
|
|
||||||
menubarPath="debug"
|
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.RunToLineRulerActionDelegate">
|
|
||||||
</action>
|
|
||||||
-->
|
|
||||||
<action
|
<action
|
||||||
label="%BreakpointProperties.label"
|
label="%BreakpointProperties.label"
|
||||||
helpContextId="breakpoint_properties_action_context"
|
helpContextId="breakpoint_properties_action_context"
|
||||||
|
@ -1120,9 +1093,6 @@
|
||||||
<action
|
<action
|
||||||
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
|
id="org.eclipse.cdt.debug.internal.ui.actions.JumpToLineActionDelegate">
|
||||||
</action>
|
</action>
|
||||||
<action
|
|
||||||
id="org.eclipse.cdt.debug.ui.internal.actions.RunToLineActionDelegate">
|
|
||||||
</action>
|
|
||||||
<action
|
<action
|
||||||
id="org.eclipse.cdt.debug.ui.internal.actions.ManageBreakpointActionDelegate">
|
id="org.eclipse.cdt.debug.ui.internal.actions.ManageBreakpointActionDelegate">
|
||||||
</action>
|
</action>
|
||||||
|
@ -1241,8 +1211,8 @@
|
||||||
</adapter>
|
</adapter>
|
||||||
</factory>
|
</factory>
|
||||||
<factory
|
<factory
|
||||||
adaptableType="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"
|
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
|
||||||
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory">
|
adaptableType="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor">
|
||||||
<adapter
|
<adapter
|
||||||
type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
|
type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
|
||||||
</adapter>
|
</adapter>
|
||||||
|
|
|
@ -10,3 +10,7 @@ SignalPropertiesDialog.Stop_label_1=Suspend the program when this signal happens
|
||||||
SignalPropertiesDialog.Pass_label_1=Pass this signal to the program.
|
SignalPropertiesDialog.Pass_label_1=Pass this signal to the program.
|
||||||
SignalPropertiesActionDelegate.Unable_to_change_signal_properties_1=Unable to change signal properties.
|
SignalPropertiesActionDelegate.Unable_to_change_signal_properties_1=Unable to change signal properties.
|
||||||
SignalPropertiesActionDelegate.Operation_failed_1=Operation failed.
|
SignalPropertiesActionDelegate.Operation_failed_1=Operation failed.
|
||||||
|
RunToLineActionDelegate.Error_1=Error
|
||||||
|
RunToLineActionDelegate.Operation_failed_1=Operation failed.
|
||||||
|
RunToLineAdapter.Empty_editor_1=Empty editor
|
||||||
|
RunToLineAdapter.Missing_document_1=Missing document
|
||||||
|
|
|
@ -1,135 +1,89 @@
|
||||||
/*
|
/*
|
||||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
* (c) Copyright QNX Software Systems Ltd. 2002. All Rights Reserved.
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.resources.FileStorage;
|
|
||||||
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
||||||
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
||||||
import org.eclipse.cdt.debug.core.sourcelookup.IDisassemblyStorage;
|
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.resources.IStorage;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
import org.eclipse.debug.core.model.IDebugElement;
|
||||||
import org.eclipse.debug.core.model.IDebugTarget;
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
|
import org.eclipse.debug.internal.ui.DebugUIPlugin;
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
|
import org.eclipse.debug.ui.actions.IRunToLineTarget;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.text.ITextSelection;
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.ui.IEditorInput;
|
|
||||||
import org.eclipse.ui.IFileEditorInput;
|
|
||||||
import org.eclipse.ui.IStorageEditorInput;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Run to line action of C editor popup menu.
|
||||||
* Enter type comment.
|
|
||||||
*
|
|
||||||
* @since Sep 19, 2002
|
|
||||||
*/
|
*/
|
||||||
public class RunToLineActionDelegate extends AbstractEditorActionDelegate
|
public class RunToLineActionDelegate extends AbstractEditorActionDelegate {
|
||||||
{
|
|
||||||
|
IRunToLineTarget fRunToLineTarget;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for RunToLineActionDelegate.
|
* Constructor for RunToLineActionDelegate.
|
||||||
*/
|
*/
|
||||||
public RunToLineActionDelegate()
|
public RunToLineActionDelegate() {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.ui.IActionDelegate#run(IAction)
|
* @see org.eclipse.ui.IActionDelegate#run(IAction)
|
||||||
*/
|
*/
|
||||||
public void run( IAction action )
|
public void run( IAction action ) {
|
||||||
{
|
if ( getTargetPart() instanceof ITextEditor ) {
|
||||||
if ( getTargetPart() != null && getTargetPart() instanceof ITextEditor )
|
|
||||||
{
|
|
||||||
IEditorInput input = ((ITextEditor)getTargetPart()).getEditorInput();
|
|
||||||
if ( input != null && input instanceof IFileEditorInput )
|
|
||||||
{
|
|
||||||
IFile file = ((IFileEditorInput)input).getFile();
|
|
||||||
if ( file != null )
|
|
||||||
{
|
|
||||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
||||||
int lineNumber = selection.getStartLine() + 1;
|
if ( getRunToLineTarget() != null ) {
|
||||||
runToLine( file, lineNumber );
|
try {
|
||||||
}
|
getRunToLineTarget().runToLine( getTargetPart(), selection, getDebugTarget() );
|
||||||
}
|
|
||||||
else if ( input != null && input instanceof IStorageEditorInput )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IStorage storage = ((IStorageEditorInput)input).getStorage();
|
|
||||||
if ( storage instanceof FileStorage )
|
|
||||||
{
|
|
||||||
IPath path = storage.getFullPath();
|
|
||||||
if ( path != null )
|
|
||||||
{
|
|
||||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
|
||||||
int lineNumber = selection.getStartLine() + 1;
|
|
||||||
runToLine( path.lastSegment(), lineNumber );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( storage != null && storage.getAdapter( IDisassemblyStorage.class ) != null )
|
|
||||||
{
|
|
||||||
IDisassemblyStorage disassemblyStorage = (IDisassemblyStorage)storage.getAdapter( IDisassemblyStorage.class );
|
|
||||||
ITextSelection selection = (ITextSelection)((ITextEditor)getTargetPart()).getSelectionProvider().getSelection();
|
|
||||||
int lineNumber = selection.getStartLine();
|
|
||||||
long address = disassemblyStorage.getAddress( lineNumber );
|
|
||||||
if ( address > 0 )
|
|
||||||
runToAddress( address );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch( CoreException e )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch( CoreException e ) {
|
||||||
|
DebugUIPlugin.errorDialog( getTargetPart().getSite().getShell(), ActionMessages.getString( "RunToLineActionDelegate.Error_1" ), ActionMessages.getString( "RunToLineActionDelegate.Operation_failed_1" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractEditorActionDelegate#initializeDebugTarget()
|
* @see org.eclipse.cdt.debug.internal.ui.actions.AbstractEditorActionDelegate#initializeDebugTarget()
|
||||||
*/
|
*/
|
||||||
protected void initializeDebugTarget()
|
protected void initializeDebugTarget() {
|
||||||
{
|
|
||||||
setDebugTarget( null );
|
setDebugTarget( null );
|
||||||
IAdaptable context = DebugUITools.getDebugContext();
|
IAdaptable context = DebugUITools.getDebugContext();
|
||||||
if ( context != null && context instanceof IDebugElement )
|
if ( context != null && context instanceof IDebugElement ) {
|
||||||
{
|
|
||||||
IDebugTarget target = ((IDebugElement)context).getDebugTarget();
|
IDebugTarget target = ((IDebugElement)context).getDebugTarget();
|
||||||
if ( target != null &&
|
if ( target != null && (target instanceof IRunToLine || target instanceof IRunToAddress) ) {
|
||||||
( target instanceof IRunToLine || target instanceof IRunToAddress ) )
|
|
||||||
{
|
|
||||||
setDebugTarget( target );
|
setDebugTarget( target );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart,
|
||||||
|
* ISelection)
|
||||||
*/
|
*/
|
||||||
public void selectionChanged( IWorkbenchPart part, ISelection selection )
|
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
|
||||||
{
|
|
||||||
IDebugTarget target = null;
|
IDebugTarget target = null;
|
||||||
if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
|
if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) {
|
||||||
{
|
if ( selection instanceof IStructuredSelection ) {
|
||||||
if ( selection instanceof IStructuredSelection )
|
|
||||||
{
|
|
||||||
Object element = ((IStructuredSelection)selection).getFirstElement();
|
Object element = ((IStructuredSelection)selection).getFirstElement();
|
||||||
if ( element != null && element instanceof IDebugElement )
|
if ( element != null && element instanceof IDebugElement ) {
|
||||||
{
|
|
||||||
IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
|
IDebugTarget target1 = ((IDebugElement)element).getDebugTarget();
|
||||||
if ( target1 != null &&
|
if ( target1 != null && (target1 instanceof IRunToLine || target1 instanceof IRunToAddress) ) {
|
||||||
( target1 instanceof IRunToLine || target1 instanceof IRunToAddress ) )
|
|
||||||
{
|
|
||||||
target = target1;
|
target = target1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,66 +93,10 @@ public class RunToLineActionDelegate extends AbstractEditorActionDelegate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void runToLine( IFile file, int lineNumber )
|
private IRunToLineTarget getRunToLineTarget() {
|
||||||
{
|
if ( fRunToLineTarget == null ) {
|
||||||
IRunToLine target = (IRunToLine)getDebugTarget().getAdapter( IRunToLine.class );
|
fRunToLineTarget = new RunToLineAdapter();
|
||||||
if ( target != null )
|
|
||||||
{
|
|
||||||
if ( !target.canRunToLine( file, lineNumber ) )
|
|
||||||
{
|
|
||||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
target.runToLine( file, lineNumber );
|
|
||||||
}
|
|
||||||
catch( DebugException e )
|
|
||||||
{
|
|
||||||
CDebugUIPlugin.errorDialog( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void runToLine( String fileName, int lineNumber )
|
|
||||||
{
|
|
||||||
IRunToLine target = (IRunToLine)getDebugTarget().getAdapter( IRunToLine.class );
|
|
||||||
if ( target != null )
|
|
||||||
{
|
|
||||||
if ( !target.canRunToLine( fileName, lineNumber ) )
|
|
||||||
{
|
|
||||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
target.runToLine( fileName, lineNumber );
|
|
||||||
}
|
|
||||||
catch( DebugException e )
|
|
||||||
{
|
|
||||||
CDebugUIPlugin.errorDialog( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void runToAddress( long address )
|
|
||||||
{
|
|
||||||
IRunToAddress target = (IRunToAddress)getDebugTarget().getAdapter( IRunToAddress.class );
|
|
||||||
if ( target != null )
|
|
||||||
{
|
|
||||||
if ( !target.canRunToAddress( address ) )
|
|
||||||
{
|
|
||||||
getTargetPart().getSite().getShell().getDisplay().beep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
target.runToAddress( address );
|
|
||||||
}
|
|
||||||
catch( DebugException e )
|
|
||||||
{
|
|
||||||
CDebugUIPlugin.errorDialog( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return fRunToLineTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,10 +11,11 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
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.core.model.IRunToLine;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
import org.eclipse.cdt.debug.ui.ICDebugUIConstants;
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.model.IDebugElement;
|
import org.eclipse.debug.core.model.IDebugElement;
|
||||||
|
@ -26,6 +27,7 @@ import org.eclipse.jface.viewers.ISelection;
|
||||||
import org.eclipse.ui.IEditorInput;
|
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.IStorageEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
|
@ -45,18 +47,24 @@ public class RunToLineAdapter implements IRunToLineTarget {
|
||||||
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( "RunToLineAdapter.Empty_editor_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final ITextEditor textEditor = (ITextEditor)editorPart;
|
final ITextEditor textEditor = (ITextEditor)editorPart;
|
||||||
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
|
final IDocument document = textEditor.getDocumentProvider().getDocument( input );
|
||||||
if ( document == null ) {
|
if ( document == null ) {
|
||||||
errorMessage = "Missing document";
|
errorMessage = ActionMessages.getString( "RunToLineAdapter.Missing_document_1" ); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
IFile file = getFile( input );
|
String fileName = getFileName( input );
|
||||||
ITextSelection textSelection = (ITextSelection)selection;
|
ITextSelection textSelection = (ITextSelection)selection;
|
||||||
int lineNumber = textSelection.getStartLine() + 1;
|
int lineNumber = textSelection.getStartLine() + 1;
|
||||||
|
if ( target instanceof IAdaptable ) {
|
||||||
|
IRunToLine runToLine = (IRunToLine)((IAdaptable)target).getAdapter( IRunToLine.class );
|
||||||
|
if ( runToLine != null && runToLine.canRunToLine( fileName, lineNumber ) )
|
||||||
|
runToLine.runToLine( fileName, lineNumber );
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
|
throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), ICDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
|
||||||
|
@ -72,9 +80,12 @@ public class RunToLineAdapter implements IRunToLineTarget {
|
||||||
return target instanceof IDebugElement && ((IDebugElement)target).getModelIdentifier().equals( CDIDebugModel.getPluginIdentifier() );
|
return target instanceof IDebugElement && ((IDebugElement)target).getModelIdentifier().equals( CDIDebugModel.getPluginIdentifier() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private IFile getFile( IEditorInput input ) {
|
private String getFileName( IEditorInput input ) throws CoreException {
|
||||||
if ( input instanceof IFileEditorInput ) {
|
if ( input instanceof IFileEditorInput ) {
|
||||||
return ((IFileEditorInput)input).getFile();
|
return ((IFileEditorInput)input).getFile().getName();
|
||||||
|
}
|
||||||
|
if ( input instanceof IStorageEditorInput ) {
|
||||||
|
return ((IStorageEditorInput)input).getStorage().getName();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,173 +0,0 @@
|
||||||
/*
|
|
||||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
|
||||||
import org.eclipse.debug.core.DebugException;
|
|
||||||
import org.eclipse.debug.ui.DebugUITools;
|
|
||||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
|
||||||
import org.eclipse.jface.action.Action;
|
|
||||||
import org.eclipse.jface.text.IDocument;
|
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.ui.IEditorInput;
|
|
||||||
import org.eclipse.ui.IFileEditorInput;
|
|
||||||
import org.eclipse.ui.INullSelectionListener;
|
|
||||||
import org.eclipse.ui.ISelectionListener;
|
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
|
||||||
import org.eclipse.ui.texteditor.IUpdate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Enter type comment.
|
|
||||||
*
|
|
||||||
* @since Sep 19, 2002
|
|
||||||
*/
|
|
||||||
public class RunToLineRulerAction extends Action
|
|
||||||
implements IUpdate,
|
|
||||||
ISelectionListener,
|
|
||||||
INullSelectionListener
|
|
||||||
{
|
|
||||||
private IVerticalRulerInfo fInfo;
|
|
||||||
private ITextEditor fTextEditor;
|
|
||||||
private IRunToLine fTarget = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for RunToLineRulerAction.
|
|
||||||
*/
|
|
||||||
public RunToLineRulerAction( IVerticalRulerInfo info, ITextEditor editor )
|
|
||||||
{
|
|
||||||
setInfo( info );
|
|
||||||
setTextEditor( editor );
|
|
||||||
setText( CDebugUIPlugin.getResourceString("internal.ui.actions.RunToLineRulerAction.Run_To_Line") ); //$NON-NLS-1$
|
|
||||||
initializeTarget();
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
|
||||||
*/
|
|
||||||
public void update()
|
|
||||||
{
|
|
||||||
boolean enabled = false;
|
|
||||||
IFile file = getFile();
|
|
||||||
int lineNumber = getLineNumber();
|
|
||||||
IDocumentProvider provider = getTextEditor().getDocumentProvider();
|
|
||||||
IDocument doc = provider.getDocument( getTextEditor().getEditorInput() );
|
|
||||||
if ( file != null && lineNumber <= doc.getNumberOfLines() && lineNumber > 0 )
|
|
||||||
{
|
|
||||||
enabled = ( getTarget() != null && getTarget().canRunToLine( file, lineNumber ) );
|
|
||||||
}
|
|
||||||
setEnabled( enabled );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see Action#run()
|
|
||||||
*/
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
runToLine( getFile(), getLineNumber() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
|
|
||||||
*/
|
|
||||||
public void selectionChanged( IWorkbenchPart part, ISelection selection )
|
|
||||||
{
|
|
||||||
IRunToLine target = null;
|
|
||||||
if ( part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) )
|
|
||||||
{
|
|
||||||
if ( selection != null && selection instanceof IStructuredSelection )
|
|
||||||
{
|
|
||||||
Object element = ((IStructuredSelection)selection).getFirstElement();
|
|
||||||
if ( element != null && element instanceof IRunToLine )
|
|
||||||
{
|
|
||||||
target = (IRunToLine)element;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setTarget( target );
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void initializeTarget()
|
|
||||||
{
|
|
||||||
setTarget( null );
|
|
||||||
IAdaptable context = DebugUITools.getDebugContext();
|
|
||||||
if ( context != null && context instanceof IRunToLine )
|
|
||||||
{
|
|
||||||
setTarget( (IRunToLine)context );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setTarget( IRunToLine target )
|
|
||||||
{
|
|
||||||
fTarget = target;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IRunToLine getTarget()
|
|
||||||
{
|
|
||||||
return fTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IVerticalRulerInfo getInfo()
|
|
||||||
{
|
|
||||||
return fInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setInfo( IVerticalRulerInfo info )
|
|
||||||
{
|
|
||||||
fInfo = info;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ITextEditor getTextEditor()
|
|
||||||
{
|
|
||||||
return fTextEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setTextEditor( ITextEditor textEditor )
|
|
||||||
{
|
|
||||||
fTextEditor = textEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected IFile getFile()
|
|
||||||
{
|
|
||||||
IEditorInput input = getTextEditor().getEditorInput();
|
|
||||||
if ( input != null && input instanceof IFileEditorInput )
|
|
||||||
{
|
|
||||||
return ((IFileEditorInput)input).getFile();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected int getLineNumber()
|
|
||||||
{
|
|
||||||
return getInfo().getLineOfLastMouseButtonActivity() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void runToLine( IFile file, int lineNumber )
|
|
||||||
{
|
|
||||||
if ( !getTarget().canRunToLine( file, lineNumber ) )
|
|
||||||
{
|
|
||||||
getTextEditor().getSite().getShell().getDisplay().beep();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
getTarget().runToLine( file, lineNumber );
|
|
||||||
}
|
|
||||||
catch( DebugException e )
|
|
||||||
{
|
|
||||||
CDebugUIPlugin.errorDialog( e.getMessage(), e );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,45 +0,0 @@
|
||||||
/*
|
|
||||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
|
||||||
* All Rights Reserved.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
|
||||||
|
|
||||||
import org.eclipse.jface.action.IAction;
|
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
|
||||||
import org.eclipse.ui.IEditorPart;
|
|
||||||
import org.eclipse.ui.texteditor.AbstractRulerActionDelegate;
|
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Enter type comment.
|
|
||||||
*
|
|
||||||
* @since Sep 19, 2002
|
|
||||||
*/
|
|
||||||
public class RunToLineRulerActionDelegate extends AbstractRulerActionDelegate
|
|
||||||
{
|
|
||||||
static final private String C_EDITOR_ID = "org.eclipse.cdt.ui.editor.CEditor"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see IEditorActionDelegate#setActiveEditor(IAction, IEditorPart)
|
|
||||||
*/
|
|
||||||
public void setActiveEditor( IAction callerAction, IEditorPart targetEditor )
|
|
||||||
{
|
|
||||||
if ( targetEditor != null )
|
|
||||||
{
|
|
||||||
String id = targetEditor.getSite().getId();
|
|
||||||
if ( !id.equals( C_EDITOR_ID ) )
|
|
||||||
targetEditor = null;
|
|
||||||
}
|
|
||||||
super.setActiveEditor( callerAction, targetEditor );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
|
|
||||||
*/
|
|
||||||
public IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo )
|
|
||||||
{
|
|
||||||
return new RunToLineRulerAction( rulerInfo, editor );
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Reference in a new issue