mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
Bug 183291. ToggleBreakpointRulerAction should use the IToggleBreakpointTarget adapter based on editor file.
This commit is contained in:
parent
6405b3a368
commit
07564ddb49
4 changed files with 107 additions and 13 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,16 +7,21 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 183291
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
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.CoreException;
|
||||||
|
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.actions.ActionDelegate;
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
import org.eclipse.ui.part.IContributedContentsView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The delegate of the "Toggle Function Breakpoint" action.
|
* The delegate of the "Toggle Function Breakpoint" action.
|
||||||
|
@ -71,8 +76,35 @@ public class ManageFunctionBreakpointActionDelegate extends ActionDelegate imple
|
||||||
return fSelection;
|
return fSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToggleBreakpointAdapter getBreakpointAdapter() {
|
private IToggleBreakpointsTarget getBreakpointAdapter() {
|
||||||
return fBreakpointAdapter;
|
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 ) {
|
private void setSelection( ISelection selection ) {
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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;
|
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.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
import org.eclipse.core.runtime.IAdapterManager;
|
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.ISelection;
|
||||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IPartListener;
|
import org.eclipse.ui.IPartListener;
|
||||||
import org.eclipse.ui.IPartService;
|
import org.eclipse.ui.IPartService;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
@ -132,7 +135,16 @@ public abstract class RetargetAction implements IWorkbenchWindowActionDelegate,
|
||||||
*/
|
*/
|
||||||
public void partActivated(IWorkbenchPart part) {
|
public void partActivated(IWorkbenchPart part) {
|
||||||
fActivePart = 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();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,14 +7,17 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 183291
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
|
||||||
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
|
||||||
import org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView;
|
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.core.runtime.CoreException;
|
||||||
import org.eclipse.debug.core.DebugPlugin;
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
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.TextSelection;
|
||||||
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
import org.eclipse.jface.text.source.IVerticalRulerInfo;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.texteditor.IDocumentProvider;
|
import org.eclipse.ui.texteditor.IDocumentProvider;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
@ -38,7 +42,7 @@ public class ToggleBreakpointRulerAction extends Action {
|
||||||
|
|
||||||
private IVerticalRulerInfo fRuler;
|
private IVerticalRulerInfo fRuler;
|
||||||
private IWorkbenchPart fTargetPart;
|
private IWorkbenchPart fTargetPart;
|
||||||
private ToggleBreakpointAdapter fBreakpointAdapter;
|
private IToggleBreakpointsTarget fTargetAdapter;
|
||||||
private static final ISelection EMPTY_SELECTION = new EmptySelection();
|
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$
|
super( ActionMessages.getString( "ToggleBreakpointRulerAction.Toggle_Breakpoint_1" ) ); //$NON-NLS-1$
|
||||||
fRuler = ruler;
|
fRuler = ruler;
|
||||||
setTargetPart( part );
|
setTargetPart( part );
|
||||||
fBreakpointAdapter = new ToggleBreakpointAdapter();
|
|
||||||
part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.TOGGLE_BREAKPOINT_ACTION );
|
part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.TOGGLE_BREAKPOINT_ACTION );
|
||||||
setId( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT );
|
setId( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT );
|
||||||
}
|
}
|
||||||
|
@ -69,7 +72,7 @@ public class ToggleBreakpointRulerAction extends Action {
|
||||||
*/
|
*/
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
fBreakpointAdapter.toggleLineBreakpoints( getTargetPart(), getTargetSelection() );
|
fTargetAdapter.toggleLineBreakpoints( getTargetPart(), getTargetSelection() );
|
||||||
}
|
}
|
||||||
catch( CoreException e ) {
|
catch( CoreException e ) {
|
||||||
ErrorDialog.openError( getTargetPart().getSite().getShell(),
|
ErrorDialog.openError( getTargetPart().getSite().getShell(),
|
||||||
|
@ -94,6 +97,21 @@ public class ToggleBreakpointRulerAction extends Action {
|
||||||
|
|
||||||
private void setTargetPart( IWorkbenchPart targetPart ) {
|
private void setTargetPart( IWorkbenchPart targetPart ) {
|
||||||
this.fTargetPart = 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2005 QNX Software Systems and others.
|
* Copyright (c) 2004, 2007 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,16 +7,21 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
* Anton Leherbauer (Wind River Systems) - bug 183291
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
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.CoreException;
|
||||||
|
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
|
||||||
import org.eclipse.jface.action.IAction;
|
import org.eclipse.jface.action.IAction;
|
||||||
import org.eclipse.jface.dialogs.ErrorDialog;
|
import org.eclipse.jface.dialogs.ErrorDialog;
|
||||||
import org.eclipse.jface.viewers.ISelection;
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IEditorPart;
|
||||||
import org.eclipse.ui.IObjectActionDelegate;
|
import org.eclipse.ui.IObjectActionDelegate;
|
||||||
import org.eclipse.ui.IWorkbenchPart;
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
import org.eclipse.ui.actions.ActionDelegate;
|
import org.eclipse.ui.actions.ActionDelegate;
|
||||||
|
import org.eclipse.ui.part.IContributedContentsView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The delegate of the "Toggle Watchpoint" action.
|
* The delegate of the "Toggle Watchpoint" action.
|
||||||
|
@ -74,8 +79,35 @@ public class ToggleWatchpointActionDelegate extends ActionDelegate implements IO
|
||||||
return fSelection;
|
return fSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ToggleBreakpointAdapter getBreakpointAdapter() {
|
private IToggleBreakpointsTarget getBreakpointAdapter() {
|
||||||
return fBreakpointAdapter;
|
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 ) {
|
private void setSelection( ISelection selection ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue