Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorPawel Piech2009-04-27 14:44:31 -0400
committerPawel Piech2009-04-27 14:44:31 -0400
commit202474d90a65a36186e650c2012637e85d1beb65 (patch)
tree20d59545d86eff8fbe820400c1521d04b06b89a6 /debug
parent6423917e546cdcc2cede8df4117c8fe71e822f5c (diff)
downloadorg.eclipse.cdt-202474d90a65a36186e650c2012637e85d1beb65.tar.gz
org.eclipse.cdt-202474d90a65a36186e650c2012637e85d1beb65.tar.xz
org.eclipse.cdt-202474d90a65a36186e650c2012637e85d1beb65.zip
[273924] - [breakpoints] Use IToggleBreakpointsTargetFactory for CDT breakpoints
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml69
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java45
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java115
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java6
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointRulerAction.java168
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCBreakpointsTargetFactory.java89
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleWatchpointActionDelegate.java130
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditor.java13
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java13
10 files changed, 153 insertions, 497 deletions
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index bed9b43c6d..245224b5e9 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -420,9 +420,9 @@
<action
label="%AddBreakpoint.label"
helpContextId="manage_breakpoint_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"
+ class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
menubarPath="debug"
- id="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate">
+ id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction">
</action>
</viewerContribution>
<viewerContribution
@@ -525,9 +525,9 @@
<action
label="%AddBreakpoint.label"
helpContextId="manage_breakpoint_action_context"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"
+ class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
menubarPath="debug"
- id="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate">
+ id="org.eclipse.debug.ui.actions.RulerToggleBreakpointAction">
</action>
</viewerContribution>
<viewerContribution
@@ -689,10 +689,10 @@
icon="icons/elcl16/function_brkpt_co.gif"
helpContextId="manage_function_breakpoint_action_context"
tooltip="%ManageFunctionBreakpointAction.tooltip"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"
+ class="org.eclipse.debug.ui.actions.ToggleMethodBreakpointActionDelegate"
menubarPath="additions"
enablesFor="1"
- id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate">
+ id="org.eclipse.cdt.debug.ui.actions.function.ToggleMethodBreakpointAction">
</action>
</objectContribution>
<objectContribution
@@ -703,10 +703,10 @@
icon="icons/elcl16/function_brkpt_co.gif"
helpContextId="manage_function_breakpoint_action_context"
tooltip="%ManageFunctionBreakpointAction.tooltip"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate"
+ class="org.eclipse.debug.ui.actions.ToggleMethodBreakpointActionDelegate"
menubarPath="additions"
enablesFor="1"
- id="org.eclipse.cdt.debug.internal.ui.actions.ManageFunctionBreakpointActionDelegate">
+ id="org.eclipse.cdt.debug.ui.actions.method.ToggleMethodBreakpointAction">
</action>
</objectContribution>
<objectContribution
@@ -717,10 +717,10 @@
enablesFor="1"
label="%ToggleWatchpointAction.label"
icon="icons/elcl16/watchpoint_co.gif"
- class="org.eclipse.cdt.debug.internal.ui.actions.ToggleWatchpointActionDelegate"
+ class="org.eclipse.debug.ui.actions.ToggleWatchpointActionDelegate"
tooltip="%ToggleWatchpointAction.tooltip"
menubarPath="additions"
- id="org.eclipse.cdt.debug.internal.ui.actions.ToggleWatchpointActionDelegate"/>
+ id="org.eclipse.cdt.debug.ui.actions.ToggleWatchpointAction"/>
</objectContribution>
<viewerContribution
targetID="org.eclipse.debug.ui.VariableView"
@@ -1193,9 +1193,9 @@
id="org.eclipse.cdt.debug.ui.CEditor.BreakpointRulerActions">
<action
label="%Dummy.label"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"
+ class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
actionID="RulerDoubleClick"
- id="org.eclipse.cdt.debug.ui.CEditor.ManageBreakpointRulerAction">
+ id="org.eclipse.cdt.debug.ui.CEditor.RulerTobbleBreakpointAction">
</action>
</editorContribution>
<editorContribution
@@ -1203,9 +1203,9 @@
id="org.eclipse.cdt.ui.editor.asm.AsmEditor.BreakpointRulerActions">
<action
label="%Dummy.label"
- class="org.eclipse.cdt.debug.internal.ui.actions.ManageBreakpointRulerActionDelegate"
+ class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
actionID="RulerDoubleClick"
- id="org.eclipse.cdt.debug.ui.CEditor.ManageBreakpointRulerAction">
+ id="org.eclipse.cdt.debug.ui.CEditor.RulerTobbleBreakpointAction">
</action>
</editorContribution>
</extension>
@@ -1411,9 +1411,6 @@
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
adaptableType="org.eclipse.cdt.internal.ui.editor.CEditor">
<adapter
- type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
- </adapter>
- <adapter
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
@@ -1423,9 +1420,6 @@
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
adaptableType="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor">
<adapter
- type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
- </adapter>
- <adapter
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
@@ -1435,22 +1429,12 @@
class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
adaptableType="org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView">
<adapter
- type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
- </adapter>
- <adapter
type="org.eclipse.debug.ui.actions.IRunToLineTarget">
</adapter>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
</factory>
<factory
- class="org.eclipse.cdt.debug.internal.ui.actions.RetargettableActionAdapterFactory"
- adaptableType="org.eclipse.ui.views.contentoutline.ContentOutline">
- <adapter
- type="org.eclipse.debug.ui.actions.IToggleBreakpointsTarget">
- </adapter>
- </factory>
- <factory
class="org.eclipse.cdt.debug.internal.ui.CBreakpointWorkbenchAdapterFactory"
adaptableType="org.eclipse.cdt.debug.core.model.ICBreakpoint">
<adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
@@ -1904,4 +1888,29 @@
</breakpointLabels>
</extension>
+ <extension point="org.eclipse.debug.ui.toggleBreakpointsTargetFactories">
+ <toggleTargetFactory
+ id="org.eclipse.cdt.debug.ui.ToggleCBreakpointsTargetFactory"
+ class="org.eclipse.cdt.debug.internal.ui.actions.ToggleCBreakpointsTargetFactory">
+ <enablement>
+ <!-- Enable the breakpoint toggle for CDT's editors and model elements -->
+ <or>
+ <instanceof value="org.eclipse.cdt.internal.ui.editor.CEditor"/>
+ <instanceof value="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"/>
+ <instanceof value="org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView"/>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <or>
+ <instanceof value="org.eclipse.cdt.core.model.IFunction"/>
+ <instanceof value="org.eclipse.cdt.core.model.IMethod"/>
+ <instanceof value="org.eclipse.cdt.core.model.IVariable"/>
+ </or>
+ </iterate>
+ </with>
+ </or>
+ </enablement>
+ </toggleTargetFactory>
+ </extension>
+
</plugin>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties
index 9f490b25f2..750de55963 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties
@@ -125,3 +125,5 @@ AddRegisterGroupActionDelegate.1=Error(s) occurred adding register group.
EditRegisterGroupActionDelegate.0=Unable to edit register group.
AddEventBreakpointActionDelegate.0=Error adding Event Breakpoint
AddEventBreakpointActionDelegate.2=Action is not supported by installed debuggers
+ToggleCBreakpointsTargetFactory.CBreakpointDescription=Standard C/C++ breakpoint type.
+ToggleCBreakpointsTargetFactory.CBreakpointName=C/C++ Breakpoints
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java
deleted file mode 100644
index ed8c400afa..0000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageBreakpointRulerActionDelegate.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 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
- *******************************************************************************/
-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;
-
-public class ManageBreakpointRulerActionDelegate extends AbstractRulerActionDelegate {
-
- private ToggleBreakpointRulerAction fTargetAction;
- private IEditorPart fActiveEditor;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
- */
- public IAction createAction( ITextEditor editor, IVerticalRulerInfo rulerInfo ) {
- fTargetAction = new ToggleBreakpointRulerAction( editor, rulerInfo );
- return fTargetAction;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
- */
- public void setActiveEditor( IAction callerAction, IEditorPart targetEditor ) {
- if ( fActiveEditor != null ) {
- if ( fTargetAction != null ) {
- fTargetAction.dispose();
- fTargetAction = null;
- }
- }
- fActiveEditor = targetEditor;
- super.setActiveEditor( callerAction, targetEditor );
- }
-}
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
deleted file mode 100644
index fc6c868edb..0000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ManageFunctionBreakpointActionDelegate.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2008 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
- * 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.
- */
-public class ManageFunctionBreakpointActionDelegate extends ActionDelegate implements IObjectActionDelegate {
-
- private ToggleBreakpointAdapter fBreakpointAdapter;
-
- private IWorkbenchPart fTargetPart;
-
- private ISelection fSelection;
-
- public ManageFunctionBreakpointActionDelegate() {
- fBreakpointAdapter = new ToggleBreakpointAdapter();
- }
-
- /*(non-Javadoc)
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
- fTargetPart = targetPart;
- }
-
- /*(non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run( IAction action ) {
- try {
- getBreakpointAdapter().toggleMethodBreakpoints( getTargetPart(), getSelection() );
- }
- catch( CoreException e ) {
- ErrorDialog.openError( getTargetPart().getSite().getShell(),
- ActionMessages.getString( "ManageFunctionBreakpointActionDelegate.Error_1" ), //$NON-NLS-1$
- ActionMessages.getString( "ManageFunctionBreakpointActionDelegate.Operation_failed_1" ), //$NON-NLS-1$
- e.getStatus() );
- }
- }
-
- /*(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 ) {
- setSelection( selection );
- action.setEnabled( getBreakpointAdapter().canToggleMethodBreakpoints( getTargetPart(), getSelection() ) );
- }
-
- private IWorkbenchPart getTargetPart() {
- return fTargetPart;
- }
-
- private ISelection getSelection() {
- return fSelection;
- }
-
- 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();
- if (contributingPart != null) {
- 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 ) {
- fSelection = selection;
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
index e120bcae8a..ba6763faa8 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/RetargettableActionAdapterFactory.java
@@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.ui.actions.IRunToLineTarget;
-import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
/**
* Creates adapters for retargettable actions in debug platform.
@@ -25,9 +24,6 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
public Object getAdapter( Object adaptableObject, Class adapterType ) {
- if ( adapterType == IToggleBreakpointsTarget.class ) {
- return new ToggleBreakpointAdapter();
- }
if ( adapterType == IRunToLineTarget.class ) {
return new RunToLineAdapter();
}
@@ -44,6 +40,6 @@ public class RetargettableActionAdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
public Class[] getAdapterList() {
- return new Class[]{ IRunToLineTarget.class, IToggleBreakpointsTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class };
+ return new Class[]{ IRunToLineTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class };
}
}
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
deleted file mode 100644
index 7f6f584c69..0000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointRulerAction.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * 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.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.Platform;
-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;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class ToggleBreakpointRulerAction extends Action {
-
- static class EmptySelection implements ISelection {
-
- public boolean isEmpty() {
- return true;
- }
- }
-
- private IVerticalRulerInfo fRuler;
- private IWorkbenchPart fTargetPart;
- private IToggleBreakpointsTarget fTargetAdapter;
- private static final ISelection EMPTY_SELECTION = new EmptySelection();
-
- /**
- * Constructor for ToggleBreakpointRulerAction.
- *
- * @param ruler
- * @param editor
- */
- public ToggleBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo ruler ) {
- super( ActionMessages.getString( "ToggleBreakpointRulerAction.Toggle_Breakpoint_1" ) ); //$NON-NLS-1$
- fRuler = ruler;
- setTargetPart( part );
- part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.TOGGLE_BREAKPOINT_ACTION );
- setId( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT );
- }
-
- /**
- * Disposes this action
- */
- public void dispose() {
- setTargetPart( null );
- fRuler = null;
- }
-
- /**
- * @see Action#run()
- */
- public void run() {
- try {
- fTargetAdapter.toggleLineBreakpoints( getTargetPart(), getTargetSelection() );
- }
- catch( CoreException e ) {
- ErrorDialog.openError( getTargetPart().getSite().getShell(),
- ActionMessages.getString( "ToggleBreakpointRulerAction.Error_1" ), //$NON-NLS-1$
- ActionMessages.getString( "ToggleBreakpointRulerAction.Operation_failed_1" ), //$NON-NLS-1$
- e.getStatus() );
- }
- }
-
- /**
- * Returns this action's vertical ruler info.
- *
- * @return this action's vertical ruler
- */
- protected IVerticalRulerInfo getVerticalRulerInfo() {
- return fRuler;
- }
-
- private IWorkbenchPart getTargetPart() {
- return this.fTargetPart;
- }
-
- private void setTargetPart( IWorkbenchPart targetPart ) {
- this.fTargetPart = targetPart;
- 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 = getAdapter(resource);
- }
- if (fTargetAdapter == null) {
- fTargetAdapter = getAdapter(fTargetPart);
- }
- }
- if (fTargetAdapter == null) {
- fTargetAdapter = new ToggleBreakpointAdapter();
- }
- }
-
- private IToggleBreakpointsTarget getAdapter(IAdaptable adaptable) {
- IToggleBreakpointsTarget adapter= (IToggleBreakpointsTarget)adaptable.getAdapter(IToggleBreakpointsTarget.class);
- if (adapter == null) {
- IAdapterManager adapterManager= Platform.getAdapterManager();
- if (adapterManager.hasAdapter(adaptable, IToggleBreakpointsTarget.class.getName())) {
- adapter= (IToggleBreakpointsTarget)adapterManager.loadAdapter(adaptable, IToggleBreakpointsTarget.class.getName());
- }
- }
- return adapter;
- }
-
- /**
- * Returns the current selection in the active part, possibly
- * and empty selection, but never <code>null</code>.
- *
- * @return the selection in the active part, possibly empty
- */
- private ISelection getTargetSelection() {
- IDocument doc = getDocument();
- if ( doc != null ) {
- int line = getVerticalRulerInfo().getLineOfLastMouseButtonActivity();
- try {
- IRegion region = doc.getLineInformation( line );
- return new TextSelection( doc, region.getOffset(), region.getLength() );
- }
- catch( BadLocationException e ) {
- DebugPlugin.log( e );
- }
- }
- return EMPTY_SELECTION;
- }
-
- private IDocument getDocument() {
- IWorkbenchPart targetPart = getTargetPart();
- if ( targetPart instanceof ITextEditor ) {
- ITextEditor textEditor = (ITextEditor)targetPart;
- IDocumentProvider provider = textEditor.getDocumentProvider();
- if ( provider != null )
- return provider.getDocument( textEditor.getEditorInput() );
- }
- else if ( targetPart instanceof DisassemblyView ) {
- DisassemblyView dv = (DisassemblyView)targetPart;
- IDocumentProvider provider = dv.getDocumentProvider();
- if ( provider != null )
- return provider.getDocument( dv.getInput() );
- }
- return null;
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCBreakpointsTargetFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCBreakpointsTargetFactory.java
new file mode 100644
index 0000000000..ab6c490f0b
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCBreakpointsTargetFactory.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.model.IDebugModelProvider;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ *
+ */
+public class ToggleCBreakpointsTargetFactory implements IToggleBreakpointsTargetFactory {
+
+ public static String TOGGLE_C_BREAKPOINT_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + ".toggleCBreakpointTarget"; //$NON-NLS-1$
+
+ private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1);
+ static {
+ TOGGLE_TARGET_IDS.add(TOGGLE_C_BREAKPOINT_TARGET_ID);
+ }
+
+ private ToggleBreakpointAdapter fCToggleBreakpointTarget = new ToggleBreakpointAdapter();
+
+ public IToggleBreakpointsTarget createToggleTarget(String targetID) {
+ if (TOGGLE_C_BREAKPOINT_TARGET_ID.equals(targetID)) {
+ return fCToggleBreakpointTarget;
+ }
+ return null;
+ }
+
+ public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
+ // Return the debug context as a default if the currently selected context
+ // is a CDT element. Otherwise return null.
+ Object element = getDebugContext(part).getFirstElement();
+ if (element instanceof IAdaptable) {
+ IDebugModelProvider modelProvider =
+ (IDebugModelProvider)((IAdaptable)element).getAdapter(IDebugModelProvider.class);
+ if (modelProvider != null) {
+ String[] models = modelProvider.getModelIdentifiers();
+ if (Arrays.asList(models).contains(CDIDebugModel.getPluginIdentifier())) {
+ return TOGGLE_C_BREAKPOINT_TARGET_ID;
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getToggleTargetDescription(String targetID) {
+ return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CBreakpointDescription"); //$NON-NLS-1$
+ }
+
+ public String getToggleTargetName(String targetID) {
+ return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CBreakpointName"); //$NON-NLS-1$
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set getToggleTargets(IWorkbenchPart part, ISelection selection) {
+ return TOGGLE_TARGET_IDS;
+ }
+
+ private IStructuredSelection getDebugContext(IWorkbenchPart part) {
+ ISelection selection = DebugUITools.getDebugContextManager().
+ getContextService(part.getSite().getWorkbenchWindow()).getActiveContext();
+ if (selection instanceof IStructuredSelection) {
+ return (IStructuredSelection)selection;
+ }
+ return StructuredSelection.EMPTY;
+ }
+
+}
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
deleted file mode 100644
index 4b7ad2b04d..0000000000
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleWatchpointActionDelegate.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * 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.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.Platform;
-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.
- */
-public class ToggleWatchpointActionDelegate extends ActionDelegate implements IObjectActionDelegate {
-
- private ToggleBreakpointAdapter fBreakpointAdapter;
-
- private IWorkbenchPart fTargetPart;
-
- private ISelection fSelection;
-
- /**
- * Constructor for ToggleWatchpointActionDelegate.
- */
- public ToggleWatchpointActionDelegate() {
- fBreakpointAdapter = new ToggleBreakpointAdapter();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
- */
- public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
- fTargetPart = targetPart;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run( IAction action ) {
- try {
- getBreakpointAdapter().toggleWatchpoints( getTargetPart(), getSelection() );
- }
- catch( CoreException e ) {
- ErrorDialog.openError( getTargetPart().getSite().getShell(),
- ActionMessages.getString( "ToggleWatchpointActionDelegate.Error_1" ), //$NON-NLS-1$
- ActionMessages.getString( "ToggleWatchpointActionDelegate.Operation_failed_1" ), //$NON-NLS-1$
- e.getStatus() );
- }
- }
-
- /* (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 ) {
- setSelection( selection );
- action.setEnabled( getBreakpointAdapter().canToggleWatchpoints( getTargetPart(), getSelection() ) );
- }
-
- private IWorkbenchPart getTargetPart() {
- return fTargetPart;
- }
-
- private ISelection getSelection() {
- return fSelection;
- }
-
- 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 = getAdapter(resource);
- }
- if (targetAdapter == null) {
- targetAdapter = getAdapter(fTargetPart);
- }
- }
- if (targetAdapter == null) {
- targetAdapter = fBreakpointAdapter;
- }
- return targetAdapter;
- }
-
- private IToggleBreakpointsTarget getAdapter(IAdaptable adaptable) {
- IToggleBreakpointsTarget adapter= (IToggleBreakpointsTarget)adaptable.getAdapter(IToggleBreakpointsTarget.class);
- if (adapter == null) {
- IAdapterManager adapterManager= Platform.getAdapterManager();
- if (adapterManager.hasAdapter(adaptable, IToggleBreakpointsTarget.class.getName())) {
- adapter= (IToggleBreakpointsTarget)adapterManager.loadAdapter(adaptable, IToggleBreakpointsTarget.class.getName());
- }
- }
- return adapter;
- }
-
- private void setSelection( ISelection selection ) {
- fSelection = selection;
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditor.java
index fc7d99c582..3ce7f9074a 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditor.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/disassembly/editor/DisassemblyEditor.java
@@ -15,7 +15,6 @@ import org.eclipse.cdt.debug.core.disassembly.IDisassemblyContextProvider;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerAction;
import org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerAction;
-import org.eclipse.cdt.debug.internal.ui.actions.ToggleBreakpointRulerAction;
import org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyDocumentProvider;
import org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyPane;
import org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DocumentContentProvider;
@@ -26,9 +25,11 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IVerticalRuler;
@@ -338,7 +339,7 @@ public class DisassemblyEditor extends EditorPart implements ITextEditor, IReusa
protected void createActions() {
IVerticalRuler ruler = fDisassemblyPane.getVerticalRuler();
- IAction action= new ToggleBreakpointRulerAction( this, ruler );
+ IAction action= new ToggleBreakpointAction( this, null, ruler );
setAction( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT, action );
action= new EnableDisableBreakpointRulerAction( this, ruler );
setAction( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT, action );
@@ -352,4 +353,12 @@ public class DisassemblyEditor extends EditorPart implements ITextEditor, IReusa
public void propertyChange( PropertyChangeEvent event ) {
getViewer().refresh();
}
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (IDocument.class.equals(adapter)) {
+ return getDocumentProvider().getDocument(getEditorInput());
+ }
+ return super.getAdapter(adapter);
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java
index 5f73fc25e6..583da10569 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/disassembly/DisassemblyView.java
@@ -23,7 +23,6 @@ import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds;
import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
import org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesRulerAction;
import org.eclipse.cdt.debug.internal.ui.actions.EnableDisableBreakpointRulerAction;
-import org.eclipse.cdt.debug.internal.ui.actions.ToggleBreakpointRulerAction;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandler;
import org.eclipse.cdt.debug.internal.ui.views.AbstractDebugEventHandlerView;
import org.eclipse.cdt.debug.internal.ui.views.IDebugExceptionHandler;
@@ -37,6 +36,7 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IThread;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -46,6 +46,7 @@ import org.eclipse.jface.action.Separator;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextPresentation;
@@ -304,7 +305,7 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
protected void createActions() {
IAction action;
IVerticalRuler ruler = getVerticalRuler();
- action= new ToggleBreakpointRulerAction( this, ruler );
+ action= new ToggleBreakpointAction( this, null, ruler );
setAction( IInternalCDebugUIConstants.ACTION_TOGGLE_BREAKPOINT, action );
action= new EnableDisableBreakpointRulerAction( this, ruler );
setAction( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT, action );
@@ -962,4 +963,12 @@ public class DisassemblyView extends AbstractDebugEventHandlerView
}
super.partDeactivated( part );
}
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (IDocument.class.equals(adapter)) {
+ return getDocumentProvider().getDocument(getInput());
+ }
+ return super.getAdapter(adapter);
+ }
}

Back to the top