Skip to content

Commit 6810983

Browse files
SougandhSvogella
authored andcommitted
Add shortcut to rename breakpoints and select all text in inline editor
Improve usability of custom breakpoint label by mapping the F2 key to rename breakpoints, aligning with the standard convention for renaming items across platforms and select all texts in current breakpoint label on opening the inline editor
1 parent 11a1333 commit 6810983

File tree

4 files changed

+92
-2
lines changed

4 files changed

+92
-2
lines changed

debug/org.eclipse.debug.ui/plugin.properties

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,5 +418,7 @@ debug.core.component.label = Platform Debug Core
418418
GroupLaunch.description=Launch several other configurations sequentially
419419

420420
prototype.decorator.label = Prototype Decorator
421-
breakpointLabel.label=Label
422-
breakpointLabel.tooltip=Provide a custom label to quickly identify breakpoint
421+
breakpointLabel.label= Label
422+
breakpointLabel.tooltip= Provide a custom label to quickly identify breakpoint
423+
breakpointLabelCommand = EditBreakpointLabel
424+
breakpointLabelCommand.description = Opens inline editor to change breakpoint label

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,6 +2065,10 @@ M4 = Platform-specific fourth key
20652065
id="org.eclipse.debug.ui.commands.ToggleLineBreakpoint"
20662066
name="%ActionDefinition.toggleLineBreakpoint.name">
20672067
</command>
2068+
<command
2069+
id="org.eclipse.debug.ui.commands.BreakpointLabelCommand"
2070+
name="%breakpointLabelCommand"
2071+
description="%breakpointLabelCommand.description"/>
20682072
</extension>
20692073
<extension point="org.eclipse.ui.bindings">
20702074
<key
@@ -2250,6 +2254,11 @@ M4 = Platform-specific fourth key
22502254
contextId="org.eclipse.debug.ui.memory.abstractasynctablerendering"
22512255
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
22522256
sequence="M1+M2+,"/>
2257+
<key
2258+
commandId="org.eclipse.debug.ui.commands.BreakpointLabelCommand"
2259+
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
2260+
contextId="org.eclipse.ui.contexts.window"
2261+
sequence="F2"/>
22532262
</extension>
22542263

22552264
<extension point="org.eclipse.ui.commandImages">
@@ -3271,6 +3280,22 @@ M4 = Platform-specific fourth key
32713280
</iterate>
32723281
</activeWhen>
32733282
</handler>
3283+
<handler
3284+
commandId="org.eclipse.debug.ui.commands.BreakpointLabelCommand"
3285+
class="org.eclipse.debug.internal.ui.views.breakpoints.BreakpointLabelCommandHandler">
3286+
<enabledWhen>
3287+
<and>
3288+
<with variable="activePartId">
3289+
<equals value="org.eclipse.debug.ui.BreakpointView"/>
3290+
</with>
3291+
<with variable="selection">
3292+
<iterate ifEmpty="false">
3293+
<instanceof value="org.eclipse.debug.core.model.IBreakpoint"/>
3294+
</iterate>
3295+
</with>
3296+
</and>
3297+
</enabledWhen>
3298+
</handler>
32743299
</extension>
32753300
<extension
32763301
point="org.eclipse.ui.trace.traceComponents">

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/breakpoints/BreakpointLabelAction.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public void run(IAction action) {
8989
Text inlineEditor = new Text(tree.getParent(), SWT.BORDER);
9090
inlineEditor.setBounds(bounds.x, bounds.y, bounds.width, bounds.height);
9191
inlineEditor.setText(current);
92+
inlineEditor.selectAll();
9293
inlineEditor.setFocus();
9394

9495
inlineEditor.addListener(SWT.FocusOut, event -> {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025 IBM Corporation 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+
* IBM Corporation - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.debug.internal.ui.views.breakpoints;
15+
16+
import org.eclipse.core.commands.AbstractHandler;
17+
import org.eclipse.core.commands.ExecutionEvent;
18+
import org.eclipse.core.commands.ExecutionException;
19+
import org.eclipse.debug.core.model.IBreakpoint;
20+
import org.eclipse.debug.internal.ui.actions.breakpoints.BreakpointLabelAction;
21+
import org.eclipse.debug.ui.IDebugUIConstants;
22+
import org.eclipse.jface.viewers.ISelection;
23+
import org.eclipse.jface.viewers.IStructuredSelection;
24+
import org.eclipse.ui.IViewPart;
25+
import org.eclipse.ui.IWorkbenchPage;
26+
import org.eclipse.ui.PlatformUI;
27+
import org.eclipse.ui.handlers.HandlerUtil;
28+
29+
/**
30+
* Default handler for Custom Breakpoint Label action
31+
*
32+
*/
33+
public class BreakpointLabelCommandHandler extends AbstractHandler {
34+
35+
/*
36+
* (non-Javadoc)
37+
*
38+
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
39+
*/
40+
@Override
41+
public Object execute(ExecutionEvent event) throws ExecutionException {
42+
43+
ISelection rawSelection = HandlerUtil.getCurrentSelection(event);
44+
if (!(rawSelection instanceof IStructuredSelection selection)) {
45+
return null;
46+
}
47+
48+
Object element = selection.getFirstElement();
49+
if (!(element instanceof IBreakpoint)) {
50+
return null;
51+
}
52+
53+
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
54+
IViewPart view = page.findView(IDebugUIConstants.ID_BREAKPOINT_VIEW);
55+
if (view != null) {
56+
BreakpointLabelAction action = new BreakpointLabelAction();
57+
action.init(view);
58+
action.run(null);
59+
}
60+
return null;
61+
}
62+
}

0 commit comments

Comments
 (0)