-
Notifications
You must be signed in to change notification settings - Fork 157
Improve No Recent Launch Dialog #2616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||
| ############################################################################### | ||||||||||
| # Copyright (c) 2007, 2012 IBM Corporation and others. | ||||||||||
| # Copyright (c) 2007, 2026 IBM Corporation and others. | ||||||||||
| # | ||||||||||
| # This program and the accompanying materials | ||||||||||
| # are made available under the terms of the Eclipse Public License 2.0 | ||||||||||
|
|
@@ -18,6 +18,8 @@ ContextRunner_13=The resource ''{0}'' is not accessible for launching | |||||||||
| ContextRunner_14=As... | ||||||||||
| ContextRunner_15=... | ||||||||||
| ContextRunner_1={0} Not Supported | ||||||||||
| OpenDebugConfigButton=Open Debug Config | ||||||||||
| OpenRunConfigButton=Open Run Config | ||||||||||
|
Comment on lines
+21
to
+22
|
||||||||||
| OpenDebugConfigButton=Open Debug Config | |
| OpenRunConfigButton=Open Run Config | |
| OpenDebugConfigButton=Open Debug Configurations... | |
| OpenRunConfigButton=Open Run Configurations... |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,5 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /******************************************************************************* | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright (c) 2007, 2025 IBM Corporation and others. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Copyright (c) 2007, 2026 IBM Corporation and others. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * This program and the accompanying materials | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * are made available under the terms of the Eclipse Public License 2.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -22,6 +22,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.core.runtime.CoreException; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.debug.core.DebugPlugin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.debug.core.ILaunchConfiguration; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.debug.core.ILaunchManager; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.debug.core.ILaunchMode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.debug.internal.ui.DebugUIPlugin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -38,6 +39,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.jface.viewers.IStructuredSelection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.jface.viewers.StructuredSelection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.jface.window.Window; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.swt.graphics.Image; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.swt.widgets.Shell; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.eclipse.ui.IEditorPart; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -153,7 +156,12 @@ else if(esize > 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else if(esize < 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IInternalDebugUIConstants.PREF_LAUNCH_LAST_IF_NOT_LAUNCHABLE)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!launchLast(group, isShift)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LaunchFailedDialog launchDialog = new LaunchFailedDialog(DebugUIPlugin.getShell(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContextMessages.ContextRunner_0, null, ContextMessages.ContextRunner_7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MessageDialog.INFORMATION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| new String[] { launchButtonName(mode), IDialogConstants.OK_LABEL }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group.getIdentifier()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| launchDialog.open(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+159
to
+164
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(resource != null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -166,12 +174,21 @@ else if(esize < 1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if(!resource.isAccessible()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| msg = MessageFormat.format(ContextMessages.ContextRunner_13, resource.getName()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, msg); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LaunchFailedDialog launchDialog = new LaunchFailedDialog(DebugUIPlugin.getShell(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContextMessages.ContextRunner_0, null, msg, MessageDialog.INFORMATION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| new String[] { launchButtonName(mode), IDialogConstants.OK_LABEL }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group.getIdentifier()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| launchDialog.open(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!launchLast(group, isShift)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MessageDialog.openInformation(DebugUIPlugin.getShell(), ContextMessages.ContextRunner_0, ContextMessages.ContextRunner_7); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LaunchFailedDialog launchDialog = new LaunchFailedDialog(DebugUIPlugin.getShell(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContextMessages.ContextRunner_0, null, ContextMessages.ContextRunner_7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MessageDialog.INFORMATION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| new String[] { launchButtonName(mode), IDialogConstants.OK_LABEL }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| group.getIdentifier()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| launchDialog.open(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -188,6 +205,46 @@ else if(csize > 1){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Returns the label for the launch configuration button based on the given | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * launch mode. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @param launchMode launch mode identifier (e.g., run or debug) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * @return the corresponding button label for opening the launch configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * dialog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private String launchButtonName(String launchMode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, if you have profiler installed, there will be "Profile" dialog, and if you have JaCoCo installed, there will be "Coverage" dialog and so on... BTW, by default there is also "External Tools Configuration" dialog. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (ILaunchManager.DEBUG_MODE.equals(launchMode)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ContextMessages.OpenDebugConfigButton; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | |
| } | |
| if (ILaunchManager.RUN_MODE.equals(launchMode)) { | |
| return ContextMessages.OpenRunConfigButton; | |
| } | |
| ILaunchMode mode = DebugPlugin.getDefault().getLaunchManager().getLaunchMode(launchMode); | |
| if (mode != null && mode.getLabel() != null && !mode.getLabel().isEmpty()) { | |
| return MessageFormat.format("{0} Configurations...", mode.getLabel()); | |
| } |
Copilot
AI
Apr 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LaunchFailedDialog is a non-static inner class with a mutable launchGroup field and package-default visibility. Since it’s only used within ContextRunner, making it private static and storing a final launchGroupIdentifier avoids capturing the outer instance and reduces unintended API surface.
| class LaunchFailedDialog extends MessageDialog { | |
| private String launchGroup; | |
| LaunchFailedDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, | |
| int dialogImageType, String[] dialogButtonLabels, String launchGroup) { | |
| super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, 1); | |
| this.launchGroup = launchGroup; | |
| } | |
| @Override | |
| protected void buttonPressed(int buttonId) { | |
| super.buttonPressed(buttonId); | |
| if (buttonId == 0) { | |
| DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), null, launchGroup); | |
| private static class LaunchFailedDialog extends MessageDialog { | |
| private final String launchGroupIdentifier; | |
| LaunchFailedDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, | |
| int dialogImageType, String[] dialogButtonLabels, String launchGroupIdentifier) { | |
| super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, 1); | |
| this.launchGroupIdentifier = launchGroupIdentifier; | |
| } | |
| @Override | |
| protected void buttonPressed(int buttonId) { | |
| super.buttonPressed(buttonId); | |
| if (buttonId == 0) { | |
| DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), null, launchGroupIdentifier); |
Copilot
AI
Apr 10, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buttonPressed calls super.buttonPressed(buttonId) before handling the custom action. In JFace dialogs this typically sets the return code and closes the dialog, which can dispose the shell; calling DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), ...) afterwards can then run with a disposed shell (and close() becomes redundant). Handle buttonId == 0 before calling super, or avoid calling super for that branch and explicitly set the return code + close after opening the launch configuration dialog.
| super.buttonPressed(buttonId); | |
| if (buttonId == 0) { | |
| DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), null, launchGroup); | |
| close(); | |
| } | |
| if (buttonId == 0) { | |
| DebugUITools.openLaunchConfigurationDialogOnGroup(getShell(), null, launchGroup); | |
| setReturnCode(buttonId); | |
| close(); | |
| return; | |
| } | |
| super.buttonPressed(buttonId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Open ... Config" is not correct wording.
"Open ... Configurations Dialog" is probably what we want.