mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
[303553]- [breakpoints] No property action in breakpoints view
This commit is contained in:
parent
428ad8d1f9
commit
a4a4038b86
4 changed files with 115 additions and 127 deletions
|
@ -42,6 +42,8 @@ ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection
|
|||
AddBreakpoint.label=Toggle &Breakpoint
|
||||
EnableBreakpoint.label=&Toggle Breakpoint Enabled
|
||||
BreakpointProperties.label=Breakpoint P&roperties...
|
||||
BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties
|
||||
BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint
|
||||
ManageFunctionBreakpointAction.label=Toggle Breakpoint
|
||||
ManageFunctionBreakpointAction.tooltip=Toggle Function/Method Breakpoint
|
||||
ToggleWatchpointAction.label=Toggle Watchpoint
|
||||
|
|
|
@ -485,31 +485,9 @@
|
|||
id="org.eclipse.cdt.debug.ui.actions.popup.RunToLine">
|
||||
</action>
|
||||
</viewerContribution>
|
||||
<objectContribution
|
||||
objectClass="org.eclipse.cdt.debug.core.model.ICBreakpoint"
|
||||
id="org.eclipse.cdt.debug.ui.CBreakpointActions">
|
||||
<action
|
||||
label="%BreakpointPropertiesAction.label"
|
||||
helpContextId="breakpoint_properties_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesAction"
|
||||
menubarPath="additions"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesAction">
|
||||
</action>
|
||||
</objectContribution>
|
||||
<viewerContribution
|
||||
targetID="#ASMEditorRulerContext"
|
||||
id="org.eclipse.cdt.debug.ui.AsmEditorRulerActions">
|
||||
<!--
|
||||
<action
|
||||
label="%RunToLineAction.label"
|
||||
icon="icons/elcl16/runtoline_co.gif"
|
||||
helpContextId="run_to_line_action_context"
|
||||
class="org.eclipse.cdt.debug.internal.ui.actions.RunToLineRulerActionDelegate"
|
||||
menubarPath="debug"
|
||||
id="org.eclipse.cdt.debug.internal.ui.actions.RunToLineRulerActionDelegate">
|
||||
</action>
|
||||
-->
|
||||
<action
|
||||
label="%BreakpointProperties.label"
|
||||
helpContextId="breakpoint_properties_action_context"
|
||||
|
@ -1833,6 +1811,14 @@
|
|||
optional="false">
|
||||
</commandParameter>
|
||||
</command>
|
||||
<command
|
||||
categoryId="org.eclipse.debug.ui.category.run"
|
||||
defaultHandler="org.eclipse.cdt.debug.internal.ui.actions.CBreakpointPropertiesHandler"
|
||||
description="%BreakpointPropertiesCommand.description"
|
||||
helpContextId="breakpoint_properties_action_context"
|
||||
id="org.eclipse.cdt.debug.command.breakpointProperties"
|
||||
name="%BreakpointPropertiesCommand.name">
|
||||
</command>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.ui.menus">
|
||||
|
@ -1886,7 +1872,19 @@
|
|||
</parameter>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<menuContribution
|
||||
locationURI="popup:org.eclipse.debug.ui.BreakpointView?after=additions">
|
||||
<command
|
||||
commandId="org.eclipse.cdt.debug.command.breakpointProperties"
|
||||
helpContextId="breakpoint_properties_action_context"
|
||||
id="org.eclipse.cdt.debug.menu.command.breakpointProperties"
|
||||
label="%BreakpointProperties.label"
|
||||
tooltip="%BreakpointProperties.label">
|
||||
<visibleWhen checkEnabled="true">
|
||||
</visibleWhen>
|
||||
</command>
|
||||
</menuContribution>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.adapters">
|
||||
<factory
|
||||
|
|
|
@ -1,104 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2005 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.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.internal.ui.CBreakpointContext;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.ui.IObjectActionDelegate;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
||||
|
||||
/**
|
||||
* Presents a custom properties dialog to configure the attibutes of a C/C++ breakpoint.
|
||||
*/
|
||||
public class CBreakpointPropertiesAction implements IObjectActionDelegate {
|
||||
|
||||
private IWorkbenchPart fPart;
|
||||
|
||||
private ICBreakpoint fContext;
|
||||
|
||||
/**
|
||||
* Constructor for CBreakpointPropertiesAction.
|
||||
*/
|
||||
public CBreakpointPropertiesAction() {
|
||||
super();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart)
|
||||
*/
|
||||
public void setActivePart( IAction action, IWorkbenchPart targetPart ) {
|
||||
fPart = targetPart;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
|
||||
*/
|
||||
public void run( IAction action ) {
|
||||
PropertyDialogAction propertyAction = new PropertyDialogAction( getActivePart().getSite(), new ISelectionProvider() {
|
||||
|
||||
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
|
||||
}
|
||||
|
||||
public ISelection getSelection() {
|
||||
return new StructuredSelection( new CBreakpointContext(getBreakpoint(), getDebugContext()) );
|
||||
}
|
||||
|
||||
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
|
||||
}
|
||||
|
||||
public void setSelection( ISelection selection ) {
|
||||
}
|
||||
} );
|
||||
propertyAction.run();
|
||||
}
|
||||
|
||||
/* (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 ) {
|
||||
if ( selection instanceof IStructuredSelection ) {
|
||||
IStructuredSelection ss = (IStructuredSelection)selection;
|
||||
if ( ss.isEmpty() || ss.size() > 1 ) {
|
||||
action.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
Object element = ss.getFirstElement();
|
||||
if ( element instanceof ICBreakpoint ) {
|
||||
action.setEnabled(true);
|
||||
setBreakpoint( (ICBreakpoint)element );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected IWorkbenchPart getActivePart() {
|
||||
return fPart;
|
||||
}
|
||||
|
||||
protected ICBreakpoint getBreakpoint() {
|
||||
return fContext;
|
||||
}
|
||||
|
||||
private ISelection getDebugContext() {
|
||||
return DebugUITools.getDebugContextManager().getContextService(fPart.getSite().getWorkbenchWindow()).getActiveContext();
|
||||
}
|
||||
|
||||
protected void setBreakpoint( ICBreakpoint breakpoint ) {
|
||||
fContext = breakpoint;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 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
|
||||
* Wind River Systems - Converted into a command
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.internal.ui.CBreakpointContext;
|
||||
import org.eclipse.core.commands.AbstractHandler;
|
||||
import org.eclipse.core.commands.ExecutionEvent;
|
||||
import org.eclipse.core.commands.ExecutionException;
|
||||
import org.eclipse.core.expressions.IEvaluationContext;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||
import org.eclipse.jface.viewers.ISelectionProvider;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.StructuredSelection;
|
||||
import org.eclipse.ui.ISources;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
import org.eclipse.ui.dialogs.PropertyDialogAction;
|
||||
import org.eclipse.ui.handlers.HandlerUtil;
|
||||
|
||||
/**
|
||||
* Presents a custom properties dialog to configure the attibutes of a C/C++ breakpoint.
|
||||
*/
|
||||
public class CBreakpointPropertiesHandler extends AbstractHandler {
|
||||
|
||||
/**
|
||||
* Constructor for CBreakpointPropertiesAction.
|
||||
*/
|
||||
public CBreakpointPropertiesHandler() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Object execute(ExecutionEvent event) throws ExecutionException {
|
||||
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
|
||||
ICBreakpoint bp = getBreakpoint(event.getApplicationContext());
|
||||
|
||||
if (part != null && bp != null) {
|
||||
ISelection debugContext = DebugUITools.getDebugContextManager().
|
||||
getContextService(part.getSite().getWorkbenchWindow()).getActiveContext();
|
||||
|
||||
final CBreakpointContext bpContext = new CBreakpointContext(bp, debugContext);
|
||||
|
||||
PropertyDialogAction propertyAction = new PropertyDialogAction( part.getSite(), new ISelectionProvider() {
|
||||
|
||||
public void addSelectionChangedListener( ISelectionChangedListener listener ) {
|
||||
}
|
||||
|
||||
public ISelection getSelection() {
|
||||
return new StructuredSelection( bpContext );
|
||||
}
|
||||
|
||||
public void removeSelectionChangedListener( ISelectionChangedListener listener ) {
|
||||
}
|
||||
|
||||
public void setSelection( ISelection selection ) {
|
||||
}
|
||||
} );
|
||||
propertyAction.run();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(Object evaluationContext) {
|
||||
setBaseEnabled( getBreakpoint(evaluationContext) != null );
|
||||
}
|
||||
|
||||
private ICBreakpoint getBreakpoint(Object evaluationContext) {
|
||||
if (evaluationContext instanceof IEvaluationContext) {
|
||||
Object s = ((IEvaluationContext) evaluationContext).getVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
|
||||
if (s instanceof IStructuredSelection) {
|
||||
IStructuredSelection ss = (IStructuredSelection)s;
|
||||
if (!ss.isEmpty()) {
|
||||
return (ICBreakpoint)DebugPlugin.getAdapter(ss.getFirstElement(), ICBreakpoint.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue