diff options
author | Ken Ryall | 2007-04-25 15:21:36 +0000 |
---|---|---|
committer | Ken Ryall | 2007-04-25 15:21:36 +0000 |
commit | 07564ddb49884bb8629b542361c91b56d993ab2f (patch) | |
tree | af6126caca2e52dc4ea77d21b679f9f7bb7ec076 /debug | |
parent | 6405b3a3689d9b086d1bcb5eb3361a2d5a71ee1e (diff) | |
download | org.eclipse.cdt-07564ddb49884bb8629b542361c91b56d993ab2f.tar.gz org.eclipse.cdt-07564ddb49884bb8629b542361c91b56d993ab2f.tar.xz org.eclipse.cdt-07564ddb49884bb8629b542361c91b56d993ab2f.zip |
Bug 183291. ToggleBreakpointRulerAction should use the IToggleBreakpointTarget adapter based on editor file.
Diffstat (limited to 'debug')
4 files changed, 107 insertions, 13 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java index ac917f3ba4d..a114d04a09e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 QNX Software Systems and others. + * Copyright (c) 2004, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,16 +7,21 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) - bug 183291 *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.part.IContributedContentsView; /** * The delegate of the "Toggle Function Breakpoint" action. @@ -71,8 +76,35 @@ public class ManageFunctionBreakpointActionDelegate extends ActionDelegate imple return fSelection; } - private ToggleBreakpointAdapter getBreakpointAdapter() { - return fBreakpointAdapter; + private IToggleBreakpointsTarget getBreakpointAdapter() { + IToggleBreakpointsTarget targetAdapter = null; + if (fTargetPart != null) { + IResource resource = (IResource) fTargetPart.getAdapter(IResource.class); + if (resource == null && fTargetPart instanceof IEditorPart) { + resource = (IResource) ((IEditorPart)fTargetPart).getEditorInput().getAdapter(IResource.class); + } + if (resource == null) { + // in case of outline view + IContributedContentsView contentsView = (IContributedContentsView) fTargetPart.getAdapter(IContributedContentsView.class); + if (contentsView != null) { + IWorkbenchPart contributingPart = contentsView.getContributingPart(); + resource = (IResource) contributingPart.getAdapter(IResource.class); + if (resource == null && contributingPart instanceof IEditorPart) { + resource = (IResource) ((IEditorPart)contributingPart).getEditorInput().getAdapter(IResource.class); + } + } + } + if (resource != null) { + targetAdapter = (IToggleBreakpointsTarget)resource.getAdapter(IToggleBreakpointsTarget.class); + } + if (targetAdapter == null) { + targetAdapter = (IToggleBreakpointsTarget)fTargetPart.getAdapter(IToggleBreakpointsTarget.class); + } + } + if (targetAdapter == null) { + targetAdapter = fBreakpointAdapter; + } + return targetAdapter; } private void setSelection( ISelection selection ) { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java index 003eed48110..48ee44322a2 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargetAction.java @@ -1,15 +1,17 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2007 IBM Corporation 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: - * IBM Corporation - initial API and implementation + * IBM Corporation - initial API and implementation + * Anton Leherbauer (Wind River Systems) - bug 183291 *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdapterManager; @@ -19,6 +21,7 @@ import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPartService; import org.eclipse.ui.IWorkbenchPart; @@ -132,7 +135,16 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate, */ public void partActivated(IWorkbenchPart part) { fActivePart = part; - fTargetAdapter = getAdapter(part); + IResource resource = (IResource) part.getAdapter(IResource.class); + if (resource == null && part instanceof IEditorPart) { + resource = (IResource) ((IEditorPart)part).getEditorInput().getAdapter(IResource.class); + } + if (resource != null) { + fTargetAdapter = getAdapter(resource); + } + if (fTargetAdapter == null) { + fTargetAdapter = getAdapter(part); + } update(); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointRulerAction.java index 7db845fec30..5b908de41c4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointRulerAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 QNX Software Systems and others. + * Copyright (c) 2004, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,14 +7,17 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) - bug 183291 *******************************************************************************/ 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.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.BadLocationException; @@ -23,6 +26,7 @@ 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.IEditorPart; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; @@ -38,7 +42,7 @@ public class ToggleBreakpointRulerAction extends Action { private IVerticalRulerInfo fRuler; private IWorkbenchPart fTargetPart; - private ToggleBreakpointAdapter fBreakpointAdapter; + private IToggleBreakpointsTarget fTargetAdapter; private static final ISelection EMPTY_SELECTION = new EmptySelection(); /** @@ -51,7 +55,6 @@ public class ToggleBreakpointRulerAction extends Action { super( ActionMessages.getString( "ToggleBreakpointRulerAction.Toggle_Breakpoint_1" ) ); //$NON-NLS-1$ fRuler = ruler; setTargetPart( part ); - fBreakpointAdapter = new ToggleBreakpointAdapter(); part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.TOGGLE_BREAKPOINT_ACTION ); setId( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT ); } @@ -69,7 +72,7 @@ public class ToggleBreakpointRulerAction extends Action { */ public void run() { try { - fBreakpointAdapter.toggleLineBreakpoints( getTargetPart(), getTargetSelection() ); + fTargetAdapter.toggleLineBreakpoints( getTargetPart(), getTargetSelection() ); } catch( CoreException e ) { ErrorDialog.openError( getTargetPart().getSite().getShell(), @@ -94,6 +97,21 @@ public class ToggleBreakpointRulerAction extends Action { private void setTargetPart( IWorkbenchPart targetPart ) { this.fTargetPart = targetPart; + if (fTargetPart != null) { + IResource resource = (IResource) fTargetPart.getAdapter(IResource.class); + if (resource == null && fTargetPart instanceof IEditorPart) { + resource = (IResource) ((IEditorPart)fTargetPart).getEditorInput().getAdapter(IResource.class); + } + if (resource != null) { + fTargetAdapter = (IToggleBreakpointsTarget)resource.getAdapter(IToggleBreakpointsTarget.class); + } + if (fTargetAdapter == null) { + fTargetAdapter = (IToggleBreakpointsTarget)fTargetPart.getAdapter(IToggleBreakpointsTarget.class); + } + } + if (fTargetAdapter == null) { + fTargetAdapter = new ToggleBreakpointAdapter(); + } } /** diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleWatchpointActionDelegate.java index 21638332b84..b060da70f0b 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleWatchpointActionDelegate.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleWatchpointActionDelegate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 QNX Software Systems and others. + * Copyright (c) 2004, 2007 QNX Software Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -7,16 +7,21 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) - bug 183291 *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IObjectActionDelegate; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.part.IContributedContentsView; /** * The delegate of the "Toggle Watchpoint" action. @@ -74,8 +79,35 @@ public class ToggleWatchpointActionDelegate extends ActionDelegate implements IO return fSelection; } - private ToggleBreakpointAdapter getBreakpointAdapter() { - return fBreakpointAdapter; + private IToggleBreakpointsTarget getBreakpointAdapter() { + IToggleBreakpointsTarget targetAdapter = null; + if (fTargetPart != null) { + IResource resource = (IResource) fTargetPart.getAdapter(IResource.class); + if (resource == null && fTargetPart instanceof IEditorPart) { + resource = (IResource) ((IEditorPart)fTargetPart).getEditorInput().getAdapter(IResource.class); + } + if (resource == null) { + // in case of outline view + IContributedContentsView contentsView = (IContributedContentsView) fTargetPart.getAdapter(IContributedContentsView.class); + if (contentsView != null) { + IWorkbenchPart contributingPart = contentsView.getContributingPart(); + resource = (IResource) contributingPart.getAdapter(IResource.class); + if (resource == null && contributingPart instanceof IEditorPart) { + resource = (IResource) ((IEditorPart)contributingPart).getEditorInput().getAdapter(IResource.class); + } + } + } + if (resource != null) { + targetAdapter = (IToggleBreakpointsTarget)resource.getAdapter(IToggleBreakpointsTarget.class); + } + if (targetAdapter == null) { + targetAdapter = (IToggleBreakpointsTarget)fTargetPart.getAdapter(IToggleBreakpointsTarget.class); + } + } + if (targetAdapter == null) { + targetAdapter = fBreakpointAdapter; + } + return targetAdapter; } private void setSelection( ISelection selection ) { |