Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5e80761

Browse files
committedAug 12, 2024
Migrate ToggleInstructionStepModeAction to
ToggleInstructionStepModeCommand. All the contributions of the the action has been replaced ToggleInstructionStepModeCommand. Enabled when introduced. Which enabled the command only when C/CPP application is under debug in Debug View. see #865
1 parent 6ffa029 commit 5e80761

File tree

9 files changed

+305
-258
lines changed

9 files changed

+305
-258
lines changed
 

‎debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %pluginName
44
Bundle-SymbolicName: org.eclipse.cdt.debug.ui; singleton:=true
5-
Bundle-Version: 8.5.500.qualifier
5+
Bundle-Version: 8.5.600.qualifier
66
Bundle-Activator: org.eclipse.cdt.debug.ui.CDebugUIPlugin
77
Bundle-Vendor: %providerName
88
Bundle-Localization: plugin

‎debug/org.eclipse.cdt.debug.ui/plugin.xml

+99-58
Original file line numberDiff line numberDiff line change
@@ -280,17 +280,6 @@
280280
helpContextId="move_to_line_action_context"
281281
label="%GlobalMoveToLineAction.label"
282282
menubarPath="org.eclipse.ui.run/stepGroup"/>
283-
<action
284-
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
285-
helpContextId="toggle_instruction_step_mode_action_context"
286-
icon="icons/elcl16/instr_step.gif"
287-
id="org.eclipse.cdt.debug.ui.actions.ToggleInstructionStepMode"
288-
label="%ToggleInstructionStepModeAction.label"
289-
menubarPath="org.eclipse.ui.run/stepGroup"
290-
state="false"
291-
style="toggle"
292-
toolbarPath="org.eclipse.debug.ui.main.toolbar/renderGroup">
293-
</action>
294283
</actionSet>
295284
</extension>
296285
<extension
@@ -340,27 +329,6 @@
340329

341330
<extension
342331
point="org.eclipse.ui.popupMenus">
343-
<viewerContribution
344-
targetID="org.eclipse.debug.ui.DebugView"
345-
id="org.eclipse.cdt.debug.ui.debugview.popupMenu">
346-
<action
347-
state="false"
348-
style="toggle"
349-
id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
350-
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
351-
icon="icons/elcl16/instr_step.gif"
352-
helpContextId="toggle_instruction_step_mode_action_context"
353-
label="%ToggleInstructionStepModeAction.label"
354-
menubarPath="renderGroup"
355-
tooltip="%ToggleInstructionStepModeAction.tooltip">
356-
<enablement>
357-
<pluginState
358-
value="activated"
359-
id="org.eclipse.cdt.debug.ui">
360-
</pluginState>
361-
</enablement>
362-
</action>
363-
</viewerContribution>
364332
<viewerContribution
365333
targetID="#CEditorRulerContext"
366334
id="org.eclipse.cdt.debug.ui.CEditorRulerActions">
@@ -675,28 +643,6 @@
675643
</extension>
676644
<extension
677645
point="org.eclipse.ui.viewActions">
678-
<viewContribution
679-
targetID="org.eclipse.debug.ui.DebugView"
680-
id="org.eclipse.cdt.debug.ui.debugview.toolbar">
681-
<action
682-
state="false"
683-
style="toggle"
684-
id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
685-
toolbarPath="renderGroup"
686-
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
687-
disabledIcon="icons/dlcl16/instr_step.gif"
688-
icon="icons/elcl16/instr_step.gif"
689-
label="%ToggleInstructionStepModeAction.label"
690-
helpContextId="toggle_instruction_step_mode_action_context"
691-
tooltip="%ToggleInstructionStepModeAction.tooltip">
692-
<enablement>
693-
<pluginState
694-
value="activated"
695-
id="org.eclipse.cdt.debug.ui">
696-
</pluginState>
697-
</enablement>
698-
</action>
699-
</viewContribution>
700646
<viewContribution
701647
targetID="org.eclipse.debug.ui.DebugView"
702648
id="org.eclipse.cdt.debug.ui.debugView.menu">
@@ -1379,9 +1325,85 @@
13791325
id="org.eclipse.debug.ui.actions.BreakpointTypesContribution"
13801326
class="org.eclipse.debug.ui.actions.BreakpointTypesContribution">
13811327
</dynamic>
1382-
</menu>
1383-
</menuContribution>
1384-
1328+
</menu>
1329+
</menuContribution>
1330+
<menuContribution
1331+
allPopups="false"
1332+
locationURI="toolbar:org.eclipse.debug.ui.DebugView?after=additions">
1333+
<command
1334+
commandId="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand"
1335+
disabledIcon="icons/dlcl16/instr_step.gif"
1336+
helpContextId="toggle_instruction_step_mode_action_context"
1337+
icon="icons/elcl16/instr_step.gif"
1338+
label="%ToggleInstructionStepModeAction.label"
1339+
style="toggle"
1340+
tooltip="%ToggleInstructionStepModeAction.tooltip">
1341+
<visibleWhen
1342+
checkEnabled="false">
1343+
<test
1344+
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
1345+
</test>
1346+
</visibleWhen>
1347+
</command>
1348+
</menuContribution>
1349+
<menuContribution
1350+
allPopups="false"
1351+
locationURI="popup:org.eclipse.debug.ui.DebugView?after=renderGroup">
1352+
<command
1353+
commandId="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand"
1354+
disabledIcon="icons/dlcl16/instr_step.gif"
1355+
helpContextId="toggle_instruction_step_mode_action_context"
1356+
icon="icons/elcl16/instr_step.gif"
1357+
label="%ToggleInstructionStepModeAction.label"
1358+
style="toggle"
1359+
tooltip="%ToggleInstructionStepModeAction.tooltip">
1360+
<visibleWhen
1361+
checkEnabled="false">
1362+
<test
1363+
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
1364+
</test>
1365+
</visibleWhen>
1366+
</command>
1367+
</menuContribution>
1368+
<menuContribution
1369+
allPopups="false"
1370+
locationURI="menu:org.eclipse.ui.run?endof=stepGroup">
1371+
<command
1372+
commandId="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand"
1373+
disabledIcon="icons/dlcl16/instr_step.gif"
1374+
helpContextId="toggle_instruction_step_mode_action_context"
1375+
icon="icons/elcl16/instr_step.gif"
1376+
label="%ToggleInstructionStepModeAction.label"
1377+
style="toggle"
1378+
tooltip="%ToggleInstructionStepModeAction.tooltip">
1379+
<visibleWhen
1380+
checkEnabled="false">
1381+
<test
1382+
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
1383+
</test>
1384+
</visibleWhen>
1385+
</command>
1386+
</menuContribution>
1387+
<menuContribution
1388+
allPopups="false"
1389+
locationURI="toolbar:org.eclipse.debug.ui.main.toolbar?after=renderGroup">
1390+
<command
1391+
commandId="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand"
1392+
disabledIcon="icons/dlcl16/instr_step.gif"
1393+
helpContextId="toggle_instruction_step_mode_action_context"
1394+
icon="icons/elcl16/instr_step.gif"
1395+
label="%ToggleInstructionStepModeAction.label"
1396+
style="toggle"
1397+
tooltip="%ToggleInstructionStepModeAction.tooltip">
1398+
<visibleWhen
1399+
checkEnabled="false">
1400+
<test
1401+
property="org.eclipse.cdt.debug.ui.isCDTDebugging">
1402+
</test>
1403+
</visibleWhen>
1404+
</command>
1405+
</menuContribution>
1406+
13851407
</extension>
13861408
<extension
13871409
point="org.eclipse.core.runtime.adapters">
@@ -1660,6 +1682,14 @@
16601682
id="org.eclipse.cdt.debug.ui.command.loadAllSymbols"
16611683
name="%LoadSymbolsForAllAction.label">
16621684
</command>
1685+
<command
1686+
id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand"
1687+
name="%ToggleInstructionStepModeAction.label">
1688+
<state
1689+
class="org.eclipse.ui.handlers.RegistryToggleState:false"
1690+
id="org.eclipse.ui.commands.toggleState">
1691+
</state>
1692+
</command>
16631693
</extension>
16641694
<extension
16651695
point="org.eclipse.ui.handlers">
@@ -1737,7 +1767,11 @@
17371767
</with>
17381768
</and>
17391769
</enabledWhen>
1740-
</handler>
1770+
</handler>
1771+
<handler
1772+
class="org.eclipse.cdt.debug.internal.ui.commands.ToggleInstructionStepModeHandler"
1773+
commandId="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeCommand">
1774+
</handler>
17411775
</extension>
17421776
<extension
17431777
point="org.eclipse.core.expressions.definitions">
@@ -2564,6 +2598,13 @@
25642598
properties="createBreakpointAdapt"
25652599
type="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext">
25662600
</propertyTester>
2601+
<propertyTester
2602+
class="org.eclipse.cdt.debug.internal.ui.actions.CDTDebugPropertyTester"
2603+
id="org.eclipse.cdt.debug.CDTDebugPropertyTester"
2604+
namespace="org.eclipse.cdt.debug.ui"
2605+
properties="isCDTDebugging"
2606+
type="java.lang.Object">
2607+
</propertyTester>
25672608
</extension>
25682609
<extension
25692610
point="org.eclipse.launchbar.ui.launchBarUIContributions">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2024 Advantest Europe GmbH and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Raghunandana Murthappa
13+
*******************************************************************************/
14+
package org.eclipse.cdt.debug.internal.ui.actions;
15+
16+
import org.eclipse.cdt.debug.core.model.ISteppingModeTarget;
17+
import org.eclipse.core.expressions.PropertyTester;
18+
import org.eclipse.core.runtime.IAdaptable;
19+
import org.eclipse.debug.core.model.IDebugElement;
20+
import org.eclipse.debug.core.model.IDebugTarget;
21+
import org.eclipse.debug.ui.IDebugUIConstants;
22+
import org.eclipse.debug.ui.IDebugView;
23+
import org.eclipse.jface.viewers.ISelection;
24+
import org.eclipse.jface.viewers.TreeSelection;
25+
import org.eclipse.ui.IViewPart;
26+
import org.eclipse.ui.IWorkbenchPage;
27+
import org.eclipse.ui.IWorkbenchWindow;
28+
import org.eclipse.ui.PlatformUI;
29+
30+
/**
31+
* Tests whether an active C/C++ application is debugging. And selection inside Debug View is present on it.
32+
*
33+
* @author Raghunandana Murthappa
34+
*/
35+
public class CDTDebugPropertyTester extends PropertyTester {
36+
37+
public static final String IS_CDT_DEBUGGING = "isCDTDebugging"; //$NON-NLS-1$
38+
39+
@Override
40+
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
41+
if (IS_CDT_DEBUGGING.equals(property)) {
42+
return isCdtLaunchConfigDebugMode();
43+
}
44+
return false;
45+
}
46+
47+
private boolean isCdtLaunchConfigDebugMode() {
48+
ISteppingModeTarget gdbTarget = getSteppingModeTarget();
49+
return gdbTarget != null;
50+
}
51+
52+
/**
53+
* Debug View can contain many targets at given point of time. This will check if {@code ISteppingModeTarget} present and it is selected. If yes returns it.
54+
*
55+
* @return Instruction stepping mode target.
56+
*/
57+
public static ISteppingModeTarget getSteppingModeTarget() {
58+
IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
59+
if (workbenchWindow == null) {
60+
return null;
61+
}
62+
63+
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
64+
if (workbenchPage == null) {
65+
return null;
66+
}
67+
68+
IViewPart debugView = workbenchPage.findView(IDebugUIConstants.ID_DEBUG_VIEW);
69+
if (debugView == null) {
70+
return null;
71+
}
72+
73+
IDebugView debugViewClazz = debugView.getAdapter(IDebugView.class);
74+
ISelection selection = debugViewClazz.getViewer().getSelection();
75+
if (selection.isEmpty() || !(selection instanceof TreeSelection)) {
76+
return null;
77+
}
78+
79+
Object element = ((TreeSelection) selection).getFirstElement();
80+
ISteppingModeTarget target = null;
81+
if (element instanceof IDebugElement) {
82+
IDebugTarget debugTarget = ((IDebugElement) element).getDebugTarget();
83+
if (debugTarget instanceof ISteppingModeTarget) {
84+
target = (ISteppingModeTarget) debugTarget;
85+
}
86+
}
87+
if (target == null) {
88+
if (element instanceof IAdaptable) {
89+
target = ((IAdaptable) element).getAdapter(ISteppingModeTarget.class);
90+
}
91+
}
92+
return target;
93+
}
94+
}
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.