Skip to content

Commit 3bf4bf9

Browse files
committed
Improve Paste Expressions context
Enhance Expressions View paste functionality with context menu entry, multi-line paste prompt, and a Run/Debug preference for paste behavior
1 parent 6a25ff1 commit 3bf4bf9

File tree

11 files changed

+136
-18
lines changed

11 files changed

+136
-18
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,15 +1584,15 @@
15841584
icon="$nl$/icons/full/elcl16/rem_all_co.svg"
15851585
helpContextId="remove_all_expressions_action_context"
15861586
class="org.eclipse.debug.internal.ui.actions.expressions.RemoveAllExpressionsAction"
1587-
menubarPath="expressionGroup"
1587+
menubarPath="expressionRemoveGroup"
15881588
id="org.eclipse.debug.ui.debugview.popupMenu.removeAllExpressionsAction">
15891589
</action>
15901590
<action
15911591
label="%RemoveAction.label"
15921592
icon="$nl$/icons/full/elcl16/rem_co.svg"
15931593
helpContextId="remove_expression_action_context"
15941594
class="org.eclipse.debug.internal.ui.actions.expressions.RemoveExpressionAction"
1595-
menubarPath="expressionGroup"
1595+
menubarPath="expressionRemoveGroup"
15961596
id="org.eclipse.debug.ui.debugview.popupMenu.removeExpressionAction">
15971597
<selection
15981598
class="org.eclipse.debug.core.model.IExpression">

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public void initializeDefaultPreferences() {
5858
prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_DISABLE_ALL_BREAKPOINTS, true);
5959
prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_ENABLE_ALL_BREAKPOINTS, true);
6060
prefs.setDefault(IInternalDebugUIConstants.PREF_SKIP_ALL_BREAKPOINTS_PROMPT, true);
61+
prefs.setDefault(IDebugPreferenceConstants.PREF_PROMPT_PASTE_MULTILINE_EXPRESSIONS,
62+
IInternalDebugUIConstants.EXPRESSION_PASTE_PROMPT);
6163

6264
/**
6365
* Context launching preferences. Appear on the the Launching preference page

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/IInternalDebugUIConstants.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,22 @@ public interface IInternalDebugUIConstants {
465465
*/
466466
String PREF_SKIP_ALL_BREAKPOINTS_PROMPT = IDebugUIConstants.PLUGIN_ID + ".DisableSkipAllBreakpointsOnLaunch"; //$NON-NLS-1$
467467

468+
/**
469+
* String indicating always prompt on pasting multi-line expression
470+
*
471+
*/
472+
String EXPRESSION_PASTE_PROMPT = "org.eclipse.debug.ui.expression.paste.prompt"; //$NON-NLS-1$
473+
474+
/**
475+
* String indicating always paste as combined single expression
476+
*
477+
*/
478+
String EXPRESSION_PASTE_AS_SINGLE = "org.eclipse.debug.ui.expression.paste.single"; //$NON-NLS-1$
479+
480+
/**
481+
* String indicating always paste as multiple expressions
482+
*
483+
*/
484+
String EXPRESSION_PASTE_AS_MUTLY = "org.eclipse.debug.ui.expression.paste.multi"; //$NON-NLS-1$
485+
468486
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,5 +254,11 @@ public class ActionMessages extends NLS {
254254
public static String EnableAllBreakpointsAction_3;
255255
public static String BreakpointLabelDialog;
256256
public static String RemoveFromFavoritesAction;
257+
public static String PasteWatchExpressionsActionLabel;
258+
public static String ExpressionPasteTitle;
259+
public static String ExpressionPasteMultiButton;
260+
public static String ExpressionPasteSingleButton;
261+
public static String ExpressionPasteDialog;
262+
public static String ExpressionPasteRemember;
257263

258264
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/ActionMessages.properties

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# https://www.eclipse.org/legal/epl-2.0/
88
#
99
# SPDX-License-Identifier: EPL-2.0
10-
#
10+
#
1111
# Contributors:
1212
# IBM Corporation - initial API and implementation
1313
# Mike Morearty - Bug 271411
@@ -99,7 +99,7 @@ RelaunchLastAction_Error_encountered_attempting_to_relaunch_4=Error encountered
9999
# @see Bug 105733 TVT 3.1 - TCT 531 - Poor grammar in "Run Eclipse Application" and "Profile Eclipse Application"
100100
# - the following string is used to display the tooltip for run/debug/profile buttons and is
101101
# the concatenation of "{mode} {configuration name}", for example "Run HelloWorld". In some languages
102-
# this may need to be reversed to be translated properly.
102+
# this may need to be reversed to be translated properly.
103103
##
104104
AbstractLaunchHistoryAction_0={0} {1}
105105
AbstractLaunchHistoryAction_1=Run
@@ -164,8 +164,8 @@ ModifyWatchpointAction_0=Error
164164
ModifyWatchpointAction_1=Failed to modify watchpoint
165165
LaunchShortcutsAction_1=(none applicable)
166166
##
167-
# The following string is used to display launch histories using an integer mnemonic - i.e.
168-
# "{number} {configuration name}". For example "1 HelloWorld".
167+
# The following string is used to display launch histories using an integer mnemonic - i.e.
168+
# "{number} {configuration name}". For example "1 HelloWorld".
169169
##
170170
LaunchConfigurationAction_0=&{0} {1}
171171
FindDialog_1=&Specify an element to select (? = any character, * = any String):
@@ -227,8 +227,9 @@ RunLastAction_0=&Run Last Launched
227227
RunLastAction_1=&Run
228228
RunLastAction_2=Run the selected resource or active editor
229229
RunLastAction_3=Run the previously launched application
230+
PasteWatchExpressionsActionLabel=Paste Expressions
230231
##
231-
# The following string is used to display actions to open the launch dialog for
232+
# The following string is used to display actions to open the launch dialog for
232233
# a specific mode - for example "Debug Configurations..."
233234
##
234235
OpenLaunchDialogAction_1={0} Configurations...
@@ -237,4 +238,10 @@ VirtualFindAction_1=Unable to locate {0} in viewer
237238

238239
ToggleBreakpointsTargetManager_defaultToggleTarget_name = Default
239240
ToggleBreakpointsTargetManager_defaultToggleTarget_description = Default
240-
BreakpointLabelDialog=Provide a custom label, or blank for the default label
241+
BreakpointLabelDialog=Provide a custom label, or blank for the default label
242+
243+
ExpressionPasteMultiButton=Multiple Expressions
244+
ExpressionPasteSingleButton=Single Expression
245+
ExpressionPasteTitle=Paste Multiline Expression
246+
ExpressionPasteDialog=You are pasting a multiline expression. Choose whether to paste it as a single combined expression or as separate multiple expressions.
247+
ExpressionPasteRemember=Remember my preference next time

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/actions/expressions/PasteWatchExpressionsAction.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2009 Adobe Systems, Inc. and others.
2+
* Copyright (c) 2009, 2025 Adobe Systems, Inc. and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,6 +10,7 @@
1010
*
1111
* Contributors:
1212
* Adobe Systems, Inc. - initial API and implementation
13+
* IBM Corporation - Improve paste expressions
1314
*******************************************************************************/
1415
package org.eclipse.debug.internal.ui.actions.expressions;
1516

@@ -27,8 +28,6 @@ public class PasteWatchExpressionsAction extends SelectionListenerAction {
2728
public PasteWatchExpressionsAction(ExpressionView expressionView) {
2829
super(ActionMessages.PasteWatchExpressionsAction_0);
2930
fExpressionView = expressionView;
30-
// setToolTipText(BreakpointGroupMessages.PasteWatchExpressionsAction_1);
31-
// PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.PASTE_WATCH_EXPRESSIONS_ACTION);
3231
}
3332

3433
@Override
@@ -43,6 +42,10 @@ public boolean isEnabled() {
4342
return fExpressionView.canPaste();
4443
}
4544

45+
@Override
46+
public String getText() {
47+
return ActionMessages.PasteWatchExpressionsActionLabel;
48+
}
4649

4750

4851
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencePage.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,11 +17,14 @@
1717
import org.eclipse.debug.internal.ui.IDebugHelpContextIds;
1818
import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
1919
import org.eclipse.debug.internal.ui.SWTFactory;
20+
import org.eclipse.debug.internal.ui.actions.ActionMessages;
2021
import org.eclipse.debug.ui.IDebugUIConstants;
2122
import org.eclipse.jface.preference.BooleanFieldEditor;
2223
import org.eclipse.jface.preference.ColorFieldEditor;
24+
import org.eclipse.jface.preference.FieldEditor;
2325
import org.eclipse.jface.preference.FieldEditorPreferencePage;
2426
import org.eclipse.jface.preference.IPreferenceStore;
27+
import org.eclipse.jface.preference.RadioGroupFieldEditor;
2528
import org.eclipse.swt.SWT;
2629
import org.eclipse.swt.widgets.Composite;
2730
import org.eclipse.ui.IWorkbench;
@@ -70,6 +73,18 @@ protected void createFieldEditors() {
7073
addField(new BooleanFieldEditor(IInternalDebugUIConstants.PREF_SKIP_ALL_BREAKPOINTS_PROMPT,
7174
DebugPreferencesMessages.DebugPreferencePage_PromptSkipBreakpoints, SWT.NONE, getFieldEditorParent()));
7275

76+
FieldEditor edit = new RadioGroupFieldEditor(IDebugPreferenceConstants.PREF_PROMPT_PASTE_MULTILINE_EXPRESSIONS,
77+
DebugPreferencesMessages.DebugPreferencePage_PromptMultiExpressions, 3,
78+
new String[][] {
79+
{ ActionMessages.ExpressionPasteMultiButton,
80+
IInternalDebugUIConstants.EXPRESSION_PASTE_AS_MUTLY },
81+
{ ActionMessages.ExpressionPasteSingleButton,
82+
IInternalDebugUIConstants.EXPRESSION_PASTE_AS_SINGLE },
83+
{ DebugPreferencesMessages.LaunchingPreferencePage_5,
84+
IInternalDebugUIConstants.EXPRESSION_PASTE_PROMPT } },
85+
getFieldEditorParent(), true);
86+
addField(edit);
87+
7388
SWTFactory.createHorizontalSpacer(getFieldEditorParent(), 2);
7489
ColorFieldEditor mem= new ColorFieldEditor(IDebugUIConstants.PREF_CHANGED_DEBUG_ELEMENT_COLOR, DebugPreferencesMessages.DebugPreferencePage_4, getFieldEditorParent());
7590
addField(mem);

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,6 @@ public class DebugPreferencesMessages extends NLS {
230230

231231
public static Object ConsoleDisableElapsedTime;
232232

233+
public static String DebugPreferencePage_PromptMultiExpressions;
234+
233235
}

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/DebugPreferencesMessages.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ ConsolePreferencePage_12=Displayed &tab width:
3030
ConsolePreferencePage_13=Tab width must be between 1 and 100 inclusive.
3131
ConsolePreferencePage_11=Back&ground color:
3232
ConsolePreferencePage_Interpret_control_characters=Interpret ASCII &control characters
33-
ConsolePreferencePage_Interpret_cr_as_control_character=Interpret Carriage &Return (\\r) as control character
33+
ConsolePreferencePage_Interpret_cr_as_control_character=Interpret Carriage &Return (\\r) as control character
3434
ConsolePreferencePage_Enable_Word_Wrap_text=E&nable word wrap
3535
ConsoleElapsedTimeLabel=Elapsed Time Format (Choose 'None' to disable)
3636
ConsoleDefaultElapsedTimeFormat=%d:%02d:%02d
@@ -59,6 +59,7 @@ DebugPreferencePage_32=&Prompt for confirmation when disabling all breakpoints
5959
DebugPreferencePage_5=Prompt for confirmation when deleting all e&xpressions
6060
DebugPreferencePage_showValuesInline=Show debug values &inline on text editors (Experimental)
6161
DebugPreferencePage_PromptSkipBreakpoints=Prompt when launching application in debug mode with 'Skip Breakpoints' enabled
62+
DebugPreferencePage_PromptMultiExpressions=Select how multi-line expressions should be pasted in the 'Expressions View'
6263

6364
LaunchingPreferencePage_1=&Build (if required) before launching
6465
LaunchingPreferencePage_2=Save required dirty editors before launching

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/preferences/IDebugPreferenceConstants.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ public interface IDebugPreferenceConstants {
336336
*/
337337
String DEBUG_VIEW_TOOLBAR_HIDDEN_PERSPECTIVES = "org.eclipse.debug.ui.Debug_view.debug_toolbar_hidden_perspectives"; //$NON-NLS-1$
338338
String CONSOLE_ELAPSED_FORMAT = "org.eclipse.console.elapsedTimeFormat"; //$NON-NLS-1$
339+
340+
/**
341+
* Stores the boolean preference of whether to prompt when pasting multi-line
342+
* expressions
343+
*/
344+
String PREF_PROMPT_PASTE_MULTILINE_EXPRESSIONS = IDebugUIConstants.PLUGIN_ID + ".paste_multiline_exp_prompt"; //$NON-NLS-1$
339345
}
340346

341347

0 commit comments

Comments
 (0)