From d2a82cf88a0a26cb36f895ea89ee28bcdc7fc79d Mon Sep 17 00:00:00 2001 From: kysmith-csg Date: Thu, 13 Jun 2024 10:34:05 -0500 Subject: [PATCH] Open edit launch dialog using correct mode When a launch fails validation, the user is given a link to Edit Launch Configuration. Previously, this link always opened the Edit Run Configurations dialog in Run mode, even if the user initially attempted to Debug. This change ensures that the edit dialog is opening using the original mode. --- .../META-INF/MANIFEST.MF | 2 +- .../launching/launcher/LauncherUtils.java | 12 +++++++++-- .../AbstractPDELaunchConfiguration.java | 2 +- .../JUnitLaunchConfigurationDelegate.java | 2 +- .../ui/launcher/PluginStatusDialog.java | 20 +++++++++++++------ .../META-INF/MANIFEST.MF | 2 +- ...UnitPluginLaunchConfigurationDelegate.java | 2 +- 7 files changed, 29 insertions(+), 13 deletions(-) diff --git a/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF index 2d5329fca0..0f51b3f0c9 100644 --- a/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %name Bundle-SymbolicName: org.eclipse.pde.launching;singleton:=true -Bundle-Version: 3.13.0.qualifier +Bundle-Version: 3.13.100.qualifier Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-Vendor: %provider-name Require-Bundle: org.eclipse.jdt.junit.core;bundle-version="[3.6.0,4.0.0)", diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LauncherUtils.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LauncherUtils.java index 2c0c84d823..79c0c19514 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LauncherUtils.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/internal/launching/launcher/LauncherUtils.java @@ -156,7 +156,7 @@ public static void clearWorkspace(ILaunchConfiguration configuration, String wor result = ((Integer) statusHandler.handleStatus(status, workspaceFile.getPath())).intValue(); } - if (result == 2 /*Cancel Button*/|| result == -1 /*Dialog close button*/) { + if (result == 2 /*Cancel Button*/ || result == -1 /*Dialog close button*/) { throw new CoreException(Status.CANCEL_STATUS); } else if (result == 0) { if (configuration.getAttribute(IPDEConstants.DOCLEARLOG, false)) { @@ -333,7 +333,7 @@ private static Properties getLastRun() { File file = new File(getDirectory(), FILE_NAME); if (file.exists()) { try (FileInputStream fis = new FileInputStream(file)) { - fLastRun.load(fis); + fLastRun.load(fis); } } } catch (IOException e) { @@ -390,4 +390,12 @@ public static boolean clearWorkspaceLog(String workspace) { public static void setLastLaunchMode(String launchMode) { fLastLaunchMode = launchMode; } + + /** + * @return the last known launch mode + * @see #setLastLaunchMode(String) + */ + public static String getLastLaunchMode() { + return fLastLaunchMode; + } } diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java index 101c77019c..0e9b0ba8ce 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/AbstractPDELaunchConfiguration.java @@ -427,6 +427,7 @@ public String[] getProgramArguments(ILaunchConfiguration configuration) throws C * from the launch configuration */ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { + LauncherUtils.setLastLaunchMode(launch.getLaunchMode()); String attribute = launch.getAttribute(PDE_LAUNCH_SHOW_COMMAND); boolean isShowCommand = false; if (attribute != null) { @@ -439,7 +440,6 @@ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch validatePluginDependencies(configuration, subMonitor.split(10)); } validateProjectDependencies(configuration, subMonitor.split(10)); - LauncherUtils.setLastLaunchMode(launch.getLaunchMode()); clear(configuration, subMonitor.split(10)); } launch.setAttribute(PDE_LAUNCH_SHOW_COMMAND, "false"); //$NON-NLS-1$ diff --git a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java index eb2c7f5391..391dea195a 100644 --- a/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java +++ b/ui/org.eclipse.pde.launching/src/org/eclipse/pde/launching/JUnitLaunchConfigurationDelegate.java @@ -465,6 +465,7 @@ protected void manageLaunch(ILaunch launch) { @Override protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { + LauncherUtils.setLastLaunchMode(launch.getLaunchMode()); fWorkspaceLocation = null; fConfigDir = null; fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false); @@ -484,7 +485,6 @@ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch if (autoValidate) validatePluginDependencies(configuration, subMonitor.split(1)); validateProjectDependencies(configuration, subMonitor.split(1)); - LauncherUtils.setLastLaunchMode(launch.getLaunchMode()); clear(configuration, subMonitor.split(1)); } launch.setAttribute(PDE_JUNIT_SHOW_COMMAND, "false"); //$NON-NLS-1$ diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginStatusDialog.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginStatusDialog.java index ed498cd007..190e4d2a30 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginStatusDialog.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginStatusDialog.java @@ -20,6 +20,7 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.ILaunchGroup; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; @@ -29,6 +30,7 @@ import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.osgi.service.resolver.BundleDescription; import org.eclipse.pde.internal.launching.launcher.LaunchValidationOperation; +import org.eclipse.pde.internal.launching.launcher.LauncherUtils; import org.eclipse.pde.internal.ui.IHelpContextIds; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEUIMessages; @@ -45,9 +47,9 @@ import org.eclipse.ui.PlatformUI; /** - * Dialog that opens when plug-in validation fails during launching. Displays - * a list of problems discovered. Allows the user to continue the launch or - * cancel if @link {@link #showCancelButton(boolean)} is set to true. + * Dialog that opens when plug-in validation fails during launching. Displays a + * list of problems discovered. Allows the user to continue the launch or cancel + * if @link {@link #showCancelButton(boolean)} is set to true. */ public class PluginStatusDialog extends TrayDialog { @@ -154,8 +156,16 @@ private void createLink(Composite parent) { // Closing the validation dialog to avoid cyclic dependency setReturnCode(CANCEL); close(); + ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(fLaunchConfiguration, + LauncherUtils.getLastLaunchMode()); + String groupIdentifier = null; + if (launchGroup != null) { + groupIdentifier = launchGroup.getIdentifier(); + } else { + groupIdentifier = "org.eclipse.debug.ui.launchGroup.run"; //$NON-NLS-1$ + } DebugUITools.openLaunchConfigurationDialog(Display.getCurrent().getActiveShell(), fLaunchConfiguration, - "org.eclipse.debug.ui.launchGroup.run", null); //$NON-NLS-1$ + groupIdentifier, null); })); } } @@ -195,12 +205,10 @@ public boolean close() { return super.close(); } - protected String getDialogSectionName() { return PDEPlugin.getPluginId() + ".PLUGIN_STATUS_DIALOG"; //$NON-NLS-1$ } - public void refresh(Map input) { fInput = input; treeViewer.setInput(input); diff --git a/ui/org.eclipse.pde.unittest.junit/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.unittest.junit/META-INF/MANIFEST.MF index 3e125ccab3..1606ab427e 100644 --- a/ui/org.eclipse.pde.unittest.junit/META-INF/MANIFEST.MF +++ b/ui/org.eclipse.pde.unittest.junit/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.pde.unittest.junit Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.pde.unittest.junit;singleton:=true -Bundle-Version: 1.1.400.qualifier +Bundle-Version: 1.1.500.qualifier Bundle-Activator: org.eclipse.pde.unittest.junit.JUnitPluginTestPlugin Bundle-ActivationPolicy: lazy Bundle-Vendor: %providerName diff --git a/ui/org.eclipse.pde.unittest.junit/src/org/eclipse/pde/unittest/junit/launcher/JUnitPluginLaunchConfigurationDelegate.java b/ui/org.eclipse.pde.unittest.junit/src/org/eclipse/pde/unittest/junit/launcher/JUnitPluginLaunchConfigurationDelegate.java index 37f215263c..9d8489ab88 100644 --- a/ui/org.eclipse.pde.unittest.junit/src/org/eclipse/pde/unittest/junit/launcher/JUnitPluginLaunchConfigurationDelegate.java +++ b/ui/org.eclipse.pde.unittest.junit/src/org/eclipse/pde/unittest/junit/launcher/JUnitPluginLaunchConfigurationDelegate.java @@ -357,6 +357,7 @@ private int evaluatePort() throws CoreException { */ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException { + LauncherUtils.setLastLaunchMode(launch.getLaunchMode()); fWorkspaceLocation = null; fConfigDir = null; fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false); @@ -377,7 +378,6 @@ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch if (autoValidate) validatePluginDependencies(configuration, subMonitor.split(1)); validateProjectDependencies(configuration, subMonitor.split(1)); - LauncherUtils.setLastLaunchMode(launch.getLaunchMode()); clear(configuration, subMonitor.split(1)); } launch.setAttribute(PDE_JUNIT_SHOW_COMMAND, "false"); //$NON-NLS-1$