Skip to content

Commit

Permalink
Open edit launch dialog using correct mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kysmith-csg committed Jun 13, 2024
1 parent 0bcd422 commit d2a82cf
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.launching/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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 {

Expand Down Expand Up @@ -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);
}));
}
}
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ui/org.eclipse.pde.unittest.junit/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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$
Expand Down

0 comments on commit d2a82cf

Please sign in to comment.