mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-10 12:03:16 +02:00
[300096] Support for menu items "runToLine", "moveToLine" and "resumeAtLine" for DSF-GDB in the CEditor and DSF Disassembly view. Support for menu item "Add Watch Expression" for DSF-GDB in CEditor
This commit is contained in:
parent
c1c4444ee9
commit
4a593950ae
10 changed files with 606 additions and 257 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 Freescale Secmiconductor and others.
|
||||
* Copyright (c) 2008, 2010 Freescale Secmiconductor and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,14 +7,21 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Freescale Semiconductor - Initial API and implementation
|
||||
* Ericsson - Updated to latest platform code
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdapterManager;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.ISuspendResume;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextManager;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -24,146 +31,154 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.ui.IActionDelegate2;
|
||||
import org.eclipse.ui.IEditorActionDelegate;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchPartSite;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
||||
/**
|
||||
* A move to line action that can be contributed to a an editor. The action
|
||||
* will perform the "move to line" operation for editors that provide
|
||||
* an appropriate <code>IMoveToLineTarget</code> adapter.
|
||||
*/
|
||||
public class MoveToLineActionDelegate implements IEditorActionDelegate, IViewActionDelegate, IActionDelegate2 {
|
||||
|
||||
public class MoveToLineActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
|
||||
|
||||
private IWorkbenchPart fActivePart = null;
|
||||
|
||||
private IMoveToLineTarget fPartTarget = null;
|
||||
|
||||
private IAction fAction = null;
|
||||
private DebugContextListener fContextListener = new DebugContextListener();
|
||||
private ISuspendResume fTargetElement = null;
|
||||
|
||||
class DebugContextListener implements IDebugContextListener {
|
||||
|
||||
private ISelectionListener fSelectionListener = new DebugSelectionListener();
|
||||
|
||||
protected ISuspendResume fTargetElement = null;
|
||||
|
||||
class DebugSelectionListener implements ISelectionListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
|
||||
protected void contextActivated(ISelection selection) {
|
||||
fTargetElement = null;
|
||||
if ( selection instanceof IStructuredSelection ) {
|
||||
IStructuredSelection ss = (IStructuredSelection)selection;
|
||||
if ( ss.size() == 1 ) {
|
||||
Object object = ss.getFirstElement();
|
||||
if ( object instanceof ISuspendResume ) {
|
||||
fTargetElement = (ISuspendResume)object;
|
||||
}
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss = (IStructuredSelection) selection;
|
||||
if (ss.size() == 1) {
|
||||
fTargetElement = (ISuspendResume)
|
||||
DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
|
||||
*/
|
||||
public void setActiveEditor( IAction action, IEditorPart targetEditor ) {
|
||||
init( action );
|
||||
bindTo( targetEditor );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void init( IAction action ) {
|
||||
this.fAction = action;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
public void debugContextChanged(DebugContextEvent event) {
|
||||
contextActivated(event.getContext());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*(non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
fActivePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
|
||||
DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener);
|
||||
fActivePart = null;
|
||||
fPartTarget = null;
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
|
||||
*/
|
||||
public void runWithEvent( IAction action, Event event ) {
|
||||
run( action );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run( IAction action ) {
|
||||
if ( fPartTarget != null && fTargetElement != null ) {
|
||||
public void run(IAction action) {
|
||||
if (fPartTarget != null && fTargetElement != null) {
|
||||
try {
|
||||
fPartTarget.moveToLine( fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
fPartTarget.moveToLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement);
|
||||
} catch (CoreException e) {
|
||||
ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "MoveToLineActionDelegate.1" ), ActionMessages.getString( "MoveToLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged( IAction action, ISelection selection ) {
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
this.fAction = action;
|
||||
update();
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
if ( fAction == null ) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||
*/
|
||||
public void update() {
|
||||
if (fAction == null) {
|
||||
return;
|
||||
}
|
||||
boolean enabled = false;
|
||||
if ( fPartTarget != null && fTargetElement != null ) {
|
||||
IWorkbenchPartSite site = fActivePart.getSite();
|
||||
if ( site != null ) {
|
||||
ISelectionProvider selectionProvider = site.getSelectionProvider();
|
||||
if ( selectionProvider != null ) {
|
||||
ISelection selection = selectionProvider.getSelection();
|
||||
enabled = fTargetElement.isSuspended() && fPartTarget.canMoveToLine( fActivePart, selection, fTargetElement );
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
boolean enabled = false;
|
||||
if (fPartTarget != null && fTargetElement != null) {
|
||||
IWorkbenchPartSite site = fActivePart.getSite();
|
||||
if (site != null) {
|
||||
ISelectionProvider selectionProvider = site.getSelectionProvider();
|
||||
if (selectionProvider != null) {
|
||||
ISelection selection = selectionProvider.getSelection();
|
||||
enabled = fTargetElement.isSuspended() && fPartTarget.canMoveToLine(fActivePart, selection, fTargetElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
fAction.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
fAction.setEnabled( enabled );
|
||||
};
|
||||
CDebugUIPlugin.getStandardDisplay().asyncExec(r);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void init(IAction action) {
|
||||
this.fAction = action;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
|
||||
*/
|
||||
public void runWithEvent(IAction action, Event event) {
|
||||
run(action);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
|
||||
*/
|
||||
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
|
||||
init(action);
|
||||
bindTo(targetEditor);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
||||
*/
|
||||
public void init( IViewPart view ) {
|
||||
bindTo( view );
|
||||
public void init(IViewPart view) {
|
||||
bindTo(view);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Binds this action to operate on the given part's run to line adapter.
|
||||
*
|
||||
* @param part
|
||||
*/
|
||||
private void bindTo( IWorkbenchPart part ) {
|
||||
private void bindTo(IWorkbenchPart part) {
|
||||
IDebugContextManager manager = DebugUITools.getDebugContextManager();
|
||||
if (fActivePart != null && !fActivePart.equals(part)) {
|
||||
manager.getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener);
|
||||
}
|
||||
fPartTarget = null;
|
||||
fActivePart = part;
|
||||
if ( part != null ) {
|
||||
part.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
|
||||
fPartTarget = (IMoveToLineTarget)part.getAdapter( IMoveToLineTarget.class );
|
||||
if ( fPartTarget == null ) {
|
||||
if (part != null) {
|
||||
IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow();
|
||||
IDebugContextService service = manager.getContextService(workbenchWindow);
|
||||
service.addDebugContextListener(fContextListener);
|
||||
fPartTarget = (IMoveToLineTarget) part.getAdapter(IMoveToLineTarget.class);
|
||||
if (fPartTarget == null) {
|
||||
IAdapterManager adapterManager = Platform.getAdapterManager();
|
||||
// TODO: we could restrict loading to cases when the debugging context is on
|
||||
if ( adapterManager.hasAdapter( part, IMoveToLineTarget.class.getName() ) ) {
|
||||
fPartTarget = (IMoveToLineTarget)adapterManager.loadAdapter( part, IMoveToLineTarget.class.getName() );
|
||||
if (adapterManager.hasAdapter(part, IMoveToLineTarget.class.getName())) {
|
||||
fPartTarget = (IMoveToLineTarget) adapterManager.loadAdapter(part, IMoveToLineTarget.class.getName());
|
||||
}
|
||||
}
|
||||
// Force the selection update
|
||||
ISelection selection = part.getSite().getWorkbenchWindow().getSelectionService().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
|
||||
fSelectionListener.selectionChanged( part, selection );
|
||||
ISelection activeContext = service.getActiveContext();
|
||||
fContextListener.contextActivated(activeContext);
|
||||
}
|
||||
update();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,14 +7,21 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ericsson - Updated to latest platform code
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdapterManager;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.ISuspendResume;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.DebugContextEvent;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextListener;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextManager;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextService;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
|
@ -24,146 +31,154 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.ui.IActionDelegate2;
|
||||
import org.eclipse.ui.IEditorActionDelegate;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IViewActionDelegate;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchPartSite;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
|
||||
/**
|
||||
* A resume at line action that can be contributed to a an editor. The action
|
||||
* will perform the "resume at line" operation for editors that provide
|
||||
* an appropriate <code>IResumeAtLineTarget</code> adapter.
|
||||
*/
|
||||
public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IViewActionDelegate, IActionDelegate2 {
|
||||
|
||||
public class ResumeAtLineActionDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
|
||||
|
||||
private IWorkbenchPart fActivePart = null;
|
||||
|
||||
private IResumeAtLineTarget fPartTarget = null;
|
||||
|
||||
private IAction fAction = null;
|
||||
private DebugContextListener fContextListener = new DebugContextListener();
|
||||
private ISuspendResume fTargetElement = null;
|
||||
|
||||
class DebugContextListener implements IDebugContextListener {
|
||||
|
||||
private ISelectionListener fSelectionListener = new DebugSelectionListener();
|
||||
|
||||
protected ISuspendResume fTargetElement = null;
|
||||
|
||||
class DebugSelectionListener implements ISelectionListener {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
|
||||
protected void contextActivated(ISelection selection) {
|
||||
fTargetElement = null;
|
||||
if ( selection instanceof IStructuredSelection ) {
|
||||
IStructuredSelection ss = (IStructuredSelection)selection;
|
||||
if ( ss.size() == 1 ) {
|
||||
Object object = ss.getFirstElement();
|
||||
if ( object instanceof ISuspendResume ) {
|
||||
fTargetElement = (ISuspendResume)object;
|
||||
}
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss = (IStructuredSelection) selection;
|
||||
if (ss.size() == 1) {
|
||||
fTargetElement = (ISuspendResume)
|
||||
DebugPlugin.getAdapter(ss.getFirstElement(), ISuspendResume.class);
|
||||
}
|
||||
}
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
|
||||
*/
|
||||
public void setActiveEditor( IAction action, IEditorPart targetEditor ) {
|
||||
init( action );
|
||||
bindTo( targetEditor );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void init( IAction action ) {
|
||||
this.fAction = action;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
public void debugContextChanged(DebugContextEvent event) {
|
||||
contextActivated(event.getContext());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*(non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
fActivePart.getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
|
||||
DebugUITools.getDebugContextManager().getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener);
|
||||
fActivePart = null;
|
||||
fPartTarget = null;
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
|
||||
*/
|
||||
public void runWithEvent( IAction action, Event event ) {
|
||||
run( action );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run( IAction action ) {
|
||||
if ( fPartTarget != null && fTargetElement != null ) {
|
||||
public void run(IAction action) {
|
||||
if (fPartTarget != null && fTargetElement != null) {
|
||||
try {
|
||||
fPartTarget.resumeAtLine( fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement );
|
||||
}
|
||||
catch( CoreException e ) {
|
||||
fPartTarget.resumeAtLine(fActivePart, fActivePart.getSite().getSelectionProvider().getSelection(), fTargetElement);
|
||||
} catch (CoreException e) {
|
||||
ErrorDialog.openError( fActivePart.getSite().getWorkbenchWindow().getShell(), ActionMessages.getString( "ResumeAtLineActionDelegate.1" ), ActionMessages.getString( "ResumeAtLineActionDelegate.2" ), e.getStatus() ); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged( IAction action, ISelection selection ) {
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
this.fAction = action;
|
||||
update();
|
||||
}
|
||||
|
||||
protected void update() {
|
||||
if ( fAction == null ) {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.texteditor.IUpdate#update()
|
||||
*/
|
||||
public void update() {
|
||||
if (fAction == null) {
|
||||
return;
|
||||
}
|
||||
boolean enabled = false;
|
||||
if ( fPartTarget != null && fTargetElement != null ) {
|
||||
IWorkbenchPartSite site = fActivePart.getSite();
|
||||
if ( site != null ) {
|
||||
ISelectionProvider selectionProvider = site.getSelectionProvider();
|
||||
if ( selectionProvider != null ) {
|
||||
ISelection selection = selectionProvider.getSelection();
|
||||
enabled = fTargetElement.isSuspended() && fPartTarget.canResumeAtLine( fActivePart, selection, fTargetElement );
|
||||
Runnable r = new Runnable() {
|
||||
public void run() {
|
||||
boolean enabled = false;
|
||||
if (fPartTarget != null && fTargetElement != null) {
|
||||
IWorkbenchPartSite site = fActivePart.getSite();
|
||||
if (site != null) {
|
||||
ISelectionProvider selectionProvider = site.getSelectionProvider();
|
||||
if (selectionProvider != null) {
|
||||
ISelection selection = selectionProvider.getSelection();
|
||||
enabled = fTargetElement.isSuspended() && fPartTarget.canResumeAtLine(fActivePart, selection, fTargetElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
fAction.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
fAction.setEnabled( enabled );
|
||||
};
|
||||
CDebugUIPlugin.getStandardDisplay().asyncExec(r);
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void init(IAction action) {
|
||||
this.fAction = action;
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate2#runWithEvent(org.eclipse.jface.action.IAction, org.eclipse.swt.widgets.Event)
|
||||
*/
|
||||
public void runWithEvent(IAction action, Event event) {
|
||||
run(action);
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
|
||||
*/
|
||||
public void setActiveEditor(IAction action, IEditorPart targetEditor) {
|
||||
init(action);
|
||||
bindTo(targetEditor);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
|
||||
*/
|
||||
public void init( IViewPart view ) {
|
||||
bindTo( view );
|
||||
public void init(IViewPart view) {
|
||||
bindTo(view);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Binds this action to operate on the given part's run to line adapter.
|
||||
*
|
||||
* @param part
|
||||
*/
|
||||
private void bindTo( IWorkbenchPart part ) {
|
||||
private void bindTo(IWorkbenchPart part) {
|
||||
IDebugContextManager manager = DebugUITools.getDebugContextManager();
|
||||
if (fActivePart != null && !fActivePart.equals(part)) {
|
||||
manager.getContextService(fActivePart.getSite().getWorkbenchWindow()).removeDebugContextListener(fContextListener);
|
||||
}
|
||||
fPartTarget = null;
|
||||
fActivePart = part;
|
||||
if ( part != null ) {
|
||||
part.getSite().getWorkbenchWindow().getSelectionService().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, fSelectionListener );
|
||||
fPartTarget = (IResumeAtLineTarget)part.getAdapter( IResumeAtLineTarget.class );
|
||||
if ( fPartTarget == null ) {
|
||||
if (part != null) {
|
||||
IWorkbenchWindow workbenchWindow = part.getSite().getWorkbenchWindow();
|
||||
IDebugContextService service = manager.getContextService(workbenchWindow);
|
||||
service.addDebugContextListener(fContextListener);
|
||||
fPartTarget = (IResumeAtLineTarget) part.getAdapter(IResumeAtLineTarget.class);
|
||||
if (fPartTarget == null) {
|
||||
IAdapterManager adapterManager = Platform.getAdapterManager();
|
||||
// TODO: we could restrict loading to cases when the debugging context is on
|
||||
if ( adapterManager.hasAdapter( part, IResumeAtLineTarget.class.getName() ) ) {
|
||||
fPartTarget = (IResumeAtLineTarget)adapterManager.loadAdapter( part, IResumeAtLineTarget.class.getName() );
|
||||
if (adapterManager.hasAdapter(part, IResumeAtLineTarget.class.getName())) {
|
||||
fPartTarget = (IResumeAtLineTarget) adapterManager.loadAdapter(part, IResumeAtLineTarget.class.getName());
|
||||
}
|
||||
}
|
||||
// Force the selection update
|
||||
ISelection selection = part.getSite().getWorkbenchWindow().getSelectionService().getSelection( IDebugUIConstants.ID_DEBUG_VIEW );
|
||||
fSelectionListener.selectionChanged( part, selection );
|
||||
ISelection activeContext = service.getActiveContext();
|
||||
fContextListener.contextActivated(activeContext);
|
||||
}
|
||||
update();
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 140 B |
Binary file not shown.
After Width: | Height: | Size: 145 B |
Binary file not shown.
After Width: | Height: | Size: 125 B |
|
@ -30,6 +30,11 @@ breakpoints.property.filter=Filter
|
|||
tracepoints.property.common=Common
|
||||
tracepoints.property.actions=Actions
|
||||
|
||||
popup.addExpression.label=Add Watch Expression...
|
||||
popup.resumeAtLine.label=Resume At Li&ne
|
||||
popup.moveToLine.label=&Move To Line
|
||||
popup.runToLine.label=Run To &Line
|
||||
|
||||
# Tracepoints
|
||||
view.traceControl.name=Trace Control
|
||||
toolbar.startTracing.name=Start Tracing
|
||||
|
|
|
@ -414,4 +414,82 @@
|
|||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.popupMenus">
|
||||
<viewerContribution
|
||||
id="org.eclipse.cdt.debug.ui.editor.actions.popup"
|
||||
targetID="#CEditorContext">
|
||||
<visibility>
|
||||
<and>
|
||||
<systemProperty
|
||||
name="org.eclipse.cdt.dsf.gdb.ui.debuggerActive"
|
||||
value="true">
|
||||
</systemProperty>
|
||||
<objectClass
|
||||
name="org.eclipse.jface.text.ITextSelection">
|
||||
</objectClass>
|
||||
</and>
|
||||
</visibility>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.AddExpressionEditorActionDelegate"
|
||||
helpContextId="add_expression_action_context"
|
||||
icon="icons/full/obj16/watch_exp.gif"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.AddWathExpression"
|
||||
label="%popup.addExpression.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate"
|
||||
helpContextId="resume_at_line_action_context"
|
||||
icon="icons/full/obj16/resume_at_line.gif"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.ResumeAtLine"
|
||||
label="%popup.resumeAtLine.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate"
|
||||
helpContextId="move_to_line_action_context"
|
||||
icon="icons/full/obj16/move_to_line.gif"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.MoveToLine"
|
||||
label="%popup.moveToLine.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.debug.ui.actions.RunToLineActionDelegate"
|
||||
definitionId="org.eclipse.debug.ui.commands.RunToLine"
|
||||
helpContextId="run_to_line_action_context"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.RunToLine"
|
||||
label="%popup.runToLine.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<viewerContribution
|
||||
id="org.eclipse.cdt.debug.ui.disassembly.actions.popup"
|
||||
targetID="#DisassemblyPartContext">
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.ResumeAtLineActionDelegate"
|
||||
helpContextId="resume_at_line_action_context"
|
||||
icon="icons/full/obj16/resume_at_line.gif"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.ResumeAtLine"
|
||||
label="%popup.resumeAtLine.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.MoveToLineActionDelegate"
|
||||
helpContextId="move_to_line_action_context"
|
||||
icon="icons/full/obj16/move_to_line.gif"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.MoveToLine"
|
||||
label="%popup.moveToLine.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
<action
|
||||
class="org.eclipse.debug.ui.actions.RunToLineActionDelegate"
|
||||
definitionId="org.eclipse.debug.ui.commands.RunToLine"
|
||||
helpContextId="run_to_line_action_context"
|
||||
id="org.eclipse.cdt.dsf.gdb.ui.actions.popup.RunToLine"
|
||||
label="%popup.runToLine.label"
|
||||
menubarPath="additions">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
</extension>
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,231 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Ericsson - DSF-GDB version
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.IPageListener;
|
||||
import org.eclipse.ui.IPartListener2;
|
||||
import org.eclipse.ui.ISelectionListener;
|
||||
import org.eclipse.ui.IWindowListener;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.IWorkbenchPartReference;
|
||||
import org.eclipse.ui.IWorkbenchWindow;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
/**
|
||||
* Manages the current evaluation context (stack frame) for evaluation actions.
|
||||
* In each page, the selection is tracked in each debug view (if any). When a debug
|
||||
* target selection exists, the "debuggerActive" System property is set to true.
|
||||
* This property is used to make the "Run To Line", "Resume At Line",
|
||||
* "Move To Line" and "Add Watch Expression" actions
|
||||
* visible in editors only if there is a running debug session.
|
||||
*/
|
||||
public class EvaluationContextManager implements IWindowListener, IPageListener, ISelectionListener, IPartListener2 {
|
||||
|
||||
// Must use a different ID than for CDI
|
||||
private final static String DEBUGGER_ACTIVE = GdbUIPlugin.getUniqueIdentifier() + ".debuggerActive"; //$NON-NLS-1$
|
||||
|
||||
protected static EvaluationContextManager fgManager;
|
||||
|
||||
private Map<IWorkbenchPage,IDMVMContext> fContextsByPage = null;
|
||||
|
||||
protected EvaluationContextManager() {
|
||||
}
|
||||
|
||||
public static void startup() {
|
||||
Runnable r = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
if ( fgManager == null ) {
|
||||
fgManager = new EvaluationContextManager();
|
||||
IWorkbench workbench = PlatformUI.getWorkbench();
|
||||
IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
|
||||
for( int i = 0; i < windows.length; i++ ) {
|
||||
fgManager.windowOpened( windows[i] );
|
||||
}
|
||||
workbench.addWindowListener( fgManager );
|
||||
}
|
||||
}
|
||||
};
|
||||
Display display = Display.getCurrent();
|
||||
if ( display == null )
|
||||
display = Display.getDefault();
|
||||
display.asyncExec( r );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
public void windowActivated( IWorkbenchWindow window ) {
|
||||
windowOpened( window );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
public void windowDeactivated( IWorkbenchWindow window ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
public void windowClosed( IWorkbenchWindow window ) {
|
||||
window.removePageListener( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
public void windowOpened( IWorkbenchWindow window ) {
|
||||
IWorkbenchPage[] pages = window.getPages();
|
||||
for( int i = 0; i < pages.length; i++ ) {
|
||||
window.addPageListener( this );
|
||||
pageOpened( pages[i] );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPageListener#pageActivated(org.eclipse.ui.IWorkbenchPage)
|
||||
*/
|
||||
public void pageActivated( IWorkbenchPage page ) {
|
||||
pageOpened( page );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPageListener#pageClosed(org.eclipse.ui.IWorkbenchPage)
|
||||
*/
|
||||
public void pageClosed( IWorkbenchPage page ) {
|
||||
page.removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
page.removePartListener( this );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPageListener#pageOpened(org.eclipse.ui.IWorkbenchPage)
|
||||
*/
|
||||
public void pageOpened( IWorkbenchPage page ) {
|
||||
page.addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
|
||||
page.addPartListener( this );
|
||||
IWorkbenchPartReference ref = page.getActivePartReference();
|
||||
if ( ref != null ) {
|
||||
partActivated( ref );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
||||
*/
|
||||
public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
|
||||
IWorkbenchPage page = part.getSite().getPage();
|
||||
if ( selection instanceof IStructuredSelection ) {
|
||||
IStructuredSelection ss = (IStructuredSelection)selection;
|
||||
if ( ss.size() == 1 ) {
|
||||
Object element = ss.getFirstElement();
|
||||
if ( element instanceof IDMVMContext ) {
|
||||
setContext( page, (IDMVMContext)element );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// no context in the given view
|
||||
removeContext( page );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partActivated( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partBroughtToTop( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partClosed( IWorkbenchPartReference partRef ) {
|
||||
if ( IDebugUIConstants.ID_DEBUG_VIEW.equals( partRef.getId() ) ) {
|
||||
removeContext( partRef.getPage() );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partDeactivated( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partOpened( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partHidden( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partVisible( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference)
|
||||
*/
|
||||
public void partInputChanged( IWorkbenchPartReference partRef ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the evaluation context for the given page, and notes that
|
||||
* a valid execution context exists.
|
||||
*
|
||||
* @param page
|
||||
* @param frame
|
||||
*/
|
||||
private void setContext( IWorkbenchPage page, IDMVMContext target ) {
|
||||
if ( fContextsByPage == null ) {
|
||||
fContextsByPage = new HashMap<IWorkbenchPage,IDMVMContext>();
|
||||
}
|
||||
fContextsByPage.put( page, target );
|
||||
System.setProperty( DEBUGGER_ACTIVE, Boolean.TRUE.toString() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an evaluation context for the given page, and determines if
|
||||
* any valid execution context remain.
|
||||
*
|
||||
* @param page
|
||||
*/
|
||||
private void removeContext( IWorkbenchPage page ) {
|
||||
if ( fContextsByPage != null ) {
|
||||
fContextsByPage.remove( page );
|
||||
if ( fContextsByPage.isEmpty() ) {
|
||||
System.setProperty( DEBUGGER_ACTIVE, Boolean.FALSE.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,88 +1,91 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* Ericsson - Updated to support Move-To-Line
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbMoveToLine;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbResumeAtLine;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRunToLine;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.ISuspendResume;
|
||||
|
||||
/**
|
||||
* Adapter factory for Run-To-Line, Move-To-Line
|
||||
* and Resume-At-Line
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class GdbSuspendResumeAdapterFactory implements IAdapterFactory {
|
||||
|
||||
static class GdbSuspendResume implements ISuspendResume, IAdaptable {
|
||||
|
||||
private final GdbRunToLine fRunToLine;
|
||||
private final GdbMoveToLine fMoveToLine;
|
||||
private final GdbResumeAtLine fResumeAtLine;
|
||||
|
||||
GdbSuspendResume(IExecutionDMContext execCtx) {
|
||||
fRunToLine = new GdbRunToLine(execCtx);
|
||||
fMoveToLine = new GdbMoveToLine(execCtx);
|
||||
fResumeAtLine = new GdbResumeAtLine(execCtx);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter.isInstance(fRunToLine)) {
|
||||
return fRunToLine;
|
||||
}
|
||||
if (adapter.isInstance(fMoveToLine)) {
|
||||
return fMoveToLine;
|
||||
}
|
||||
if (adapter.isInstance(fResumeAtLine)) {
|
||||
return fResumeAtLine;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canResume() { return false; }
|
||||
public boolean canSuspend() { return false; }
|
||||
public boolean isSuspended() { return false; }
|
||||
public void resume() throws DebugException {}
|
||||
public void suspend() throws DebugException {}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
if (ISuspendResume.class.equals(adapterType)) {
|
||||
if (adaptableObject instanceof IDMVMContext) {
|
||||
IExecutionDMContext execDmc = DMContexts.getAncestorOfType(
|
||||
((IDMVMContext)adaptableObject).getDMContext(),
|
||||
IExecutionDMContext.class);
|
||||
// It only makes sense to RunToLine, MoveToLine or
|
||||
// ResumeAtLine if we are dealing with a thread, not a container
|
||||
if (execDmc != null && !(execDmc instanceof IContainerDMContext)) {
|
||||
return new GdbSuspendResume(execDmc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class[] getAdapterList() {
|
||||
return new Class[] { ISuspendResume.class };
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Wind River Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* Ericsson - Updated to support Move-To-Line
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui;
|
||||
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbMoveToLine;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbResumeAtLine;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.actions.GdbRunToLine;
|
||||
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.ISuspendResume;
|
||||
|
||||
/**
|
||||
* Adapter factory for Run-To-Line, Move-To-Line
|
||||
* and Resume-At-Line
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class GdbSuspendResumeAdapterFactory implements IAdapterFactory {
|
||||
|
||||
static class GdbSuspendResume implements ISuspendResume, IAdaptable {
|
||||
|
||||
private final GdbRunToLine fRunToLine;
|
||||
private final GdbMoveToLine fMoveToLine;
|
||||
private final GdbResumeAtLine fResumeAtLine;
|
||||
|
||||
GdbSuspendResume(IExecutionDMContext execCtx) {
|
||||
fRunToLine = new GdbRunToLine(execCtx);
|
||||
fMoveToLine = new GdbMoveToLine(execCtx);
|
||||
fResumeAtLine = new GdbResumeAtLine(execCtx);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter.isInstance(fRunToLine)) {
|
||||
return fRunToLine;
|
||||
}
|
||||
if (adapter.isInstance(fMoveToLine)) {
|
||||
return fMoveToLine;
|
||||
}
|
||||
if (adapter.isInstance(fResumeAtLine)) {
|
||||
return fResumeAtLine;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canResume() { return false; }
|
||||
public boolean canSuspend() { return false; }
|
||||
// This must return true because the platform
|
||||
// RunToLineActionDelegate will only enable the
|
||||
// action if we are suspended
|
||||
public boolean isSuspended() { return true; }
|
||||
public void resume() throws DebugException {}
|
||||
public void suspend() throws DebugException {}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
if (ISuspendResume.class.equals(adapterType)) {
|
||||
if (adaptableObject instanceof IDMVMContext) {
|
||||
IExecutionDMContext execDmc = DMContexts.getAncestorOfType(
|
||||
((IDMVMContext)adaptableObject).getDMContext(),
|
||||
IExecutionDMContext.class);
|
||||
// It only makes sense to RunToLine, MoveToLine or
|
||||
// ResumeAtLine if we are dealing with a thread, not a container
|
||||
if (execDmc != null && !(execDmc instanceof IContainerDMContext)) {
|
||||
return new GdbSuspendResume(execDmc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Class[] getAdapterList() {
|
||||
return new Class[] { ISuspendResume.class };
|
||||
}
|
||||
}
|
|
@ -55,6 +55,8 @@ public class GdbUIPlugin extends AbstractUIPlugin {
|
|||
super.start(context);
|
||||
plugin = this;
|
||||
|
||||
EvaluationContextManager.startup();
|
||||
|
||||
fTracingConsoleManager = new TracingConsoleManager();
|
||||
fTracingConsoleManager.startup();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue