Skip to content
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

Open edit launch dialog using correct mode #1300

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.pde.unittest.junit"
label="%featureName"
version="1.0.800.qualifier"
version="1.0.900.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
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 @@ -40,7 +40,11 @@ public class EclipsePluginValidationOperation extends LaunchValidationOperation
private final Map<Object, Object[]> fExtensionErrors = new HashMap<>(2);

public EclipsePluginValidationOperation(ILaunchConfiguration configuration, Set<IPluginModelBase> models) {
super(configuration, models);
this(configuration, models, null);
}

public EclipsePluginValidationOperation(ILaunchConfiguration configuration, Set<IPluginModelBase> models, String launchMode) {
super(configuration, models, launchMode);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ public class LaunchValidationOperation implements IWorkspaceRunnable {

private BundleValidationOperation fOperation;
public final ILaunchConfiguration fLaunchConfiguration;
public final String fLaunchMode;
protected final Set<IPluginModelBase> fModels;

public LaunchValidationOperation(ILaunchConfiguration configuration, Set<IPluginModelBase> models) {
this(configuration, models, null);
}

public LaunchValidationOperation(ILaunchConfiguration configuration, Set<IPluginModelBase> models, String launchMode) {
fLaunchConfiguration = configuration;
fModels = models;
fLaunchMode = launchMode;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.core.IStatusHandler;
Expand Down Expand Up @@ -80,11 +79,6 @@ private LauncherUtils() {
private static final String TIMESTAMP = "timestamp"; //$NON-NLS-1$
private static final String FILE_NAME = "dep-timestamp.properties"; //$NON-NLS-1$
private static Properties fLastRun;
/**
* Stores the last known launch mode so status handlers can open the correct launch configuration dialog
* @see LauncherUtils#setLastLaunchMode(String)
*/
private static String fLastLaunchMode;

/**
* Checks if the workspace being launched is already in use or needs to be cleared
Expand All @@ -98,7 +92,7 @@ private LauncherUtils() {
* @throws CoreException
* if unable to retrieve launch attribute values or the clear operation was cancelled
*/
public static void clearWorkspace(ILaunchConfiguration configuration, String workspace, IProgressMonitor monitor) throws CoreException {
public static void clearWorkspace(ILaunchConfiguration configuration, String workspace, String launchMode, IProgressMonitor monitor) throws CoreException {

SubMonitor subMon = SubMonitor.convert(monitor, 100);

Expand Down Expand Up @@ -136,7 +130,7 @@ public static void clearWorkspace(ILaunchConfiguration configuration, String wor
Status status = new Status(IStatus.ERROR, IPDEConstants.PLUGIN_ID, WORKSPACE_LOCKED, null, null);
IStatusHandler statusHandler = DebugPlugin.getDefault().getStatusHandler(status);
if (statusHandler != null)
statusHandler.handleStatus(status, new Object[] {workspace, configuration, fLastLaunchMode});
statusHandler.handleStatus(status, new Object[] {workspace, configuration, launchMode});
throw new CoreException(Status.CANCEL_STATUS);
}

Expand All @@ -156,7 +150,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 +327,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 @@ -381,13 +375,4 @@ public static boolean clearWorkspaceLog(String workspace) {
return true;
}

/**
* Updates the stores launch mode. This should be called on any PDE Eclipse launch. The launch mode
* is passed to the status handler so it can open the correct launch configuration dialog
*
* @param launchMode last known launch mode, see {@link ILaunch#getLaunchMode()}
*/
public static void setLastLaunchMode(String launchMode) {
fLastLaunchMode = launchMode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class ProductValidationOperation extends LaunchValidationOperation {

public ProductValidationOperation(Set<IPluginModelBase> models) {
super(null, models);
super(null, models, null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
public abstract class AbstractPDELaunchConfiguration extends LaunchConfigurationDelegate {

protected File fConfigDir = null;
String launchMode;

/**
* This field will control the addition of argument --add-modules=ALL-SYSTEM in the VM arguments
Expand Down Expand Up @@ -427,6 +428,7 @@ public String[] getProgramArguments(ILaunchConfiguration configuration) throws C
* from the launch configuration
*/
protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch, IProgressMonitor monitor) throws CoreException {
launchMode = launch.getLaunchMode();
String attribute = launch.getAttribute(PDE_LAUNCH_SHOW_COMMAND);
boolean isShowCommand = false;
if (attribute != null) {
Expand All @@ -439,7 +441,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 Expand Up @@ -556,7 +557,7 @@ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monito
*/
protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
Set<IPluginModelBase> models = BundleLauncherHelper.getMergedBundleMap(configuration, false).keySet();
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, models);
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, models, launchMode);
LaunchPluginValidator.runValidationOperation(op, monitor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monito
}

// Clear workspace and prompt, if necessary
LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, subMon.split(1));
LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, launchMode, subMon.split(1));

// clear config area, if necessary
if (configuration.getAttribute(IPDELauncherConstants.CONFIG_CLEAR_AREA, false)) {
Expand Down Expand Up @@ -238,7 +238,7 @@ private void validateConfigIni(ILaunchConfiguration configuration) throws CoreEx

@Override
protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet());
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet(), launchMode);
LaunchPluginValidator.runValidationOperation(op, monitor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch

@Override
protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
LaunchValidationOperation op = new LaunchValidationOperation(configuration, fModels.keySet());
LaunchValidationOperation op = new LaunchValidationOperation(configuration, fModels.keySet(), launchMode);
LaunchPluginValidator.runValidationOperation(op, monitor);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class JUnitLaunchConfigurationDelegate extends org.eclipse.jdt.junit.laun

// key is a model, value is startLevel:autoStart
private Map<IPluginModelBase, String> fModels;
private String launchMode;

private static final String PDE_JUNIT_SHOW_COMMAND = "pde.junit.showcommandline"; //$NON-NLS-1$

Expand Down Expand Up @@ -469,6 +470,7 @@ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch
fConfigDir = null;
fModels = BundleLauncherHelper.getMergedBundleMap(configuration, false);
fAllBundles = fModels.keySet().stream().collect(Collectors.groupingBy(m -> m.getPluginBase().getId(), LinkedHashMap::new, Collectors.toCollection(ArrayList::new)));
launchMode = launch.getLaunchMode();

// implicitly add the plug-ins required for JUnit testing if necessary
addRequiredJunitRuntimePlugins(configuration);
Expand All @@ -481,10 +483,10 @@ protected void preLaunchCheck(ILaunchConfiguration configuration, ILaunch launch
boolean autoValidate = configuration.getAttribute(IPDELauncherConstants.AUTOMATIC_VALIDATE, false);
SubMonitor subMonitor = SubMonitor.convert(monitor, autoValidate ? 3 : 4);
if (isShowCommand == false) {
if (autoValidate)
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 Expand Up @@ -580,7 +582,7 @@ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monito
SubMonitor subMon = SubMonitor.convert(monitor, 50);

// Clear workspace and prompt, if necessary
LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, subMon.split(25));
LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, launchMode, subMon.split(25));

subMon.setWorkRemaining(25);

Expand Down Expand Up @@ -615,7 +617,7 @@ protected void validateProjectDependencies(ILaunchConfiguration configuration, I
* a progress monitor
*/
protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet());
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet(), launchMode);
LaunchPluginValidator.runValidationOperation(op, monitor);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants;
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 @@ -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 @@ -92,6 +94,7 @@ public Object[] getElements(Object inputElement) {
private Map<?, ?> fInput;
private TreeViewer treeViewer;
private ILaunchConfiguration fLaunchConfiguration;
private String launchMode;

public PluginStatusDialog(Shell parentShell, int style) {
super(parentShell);
Expand All @@ -116,6 +119,7 @@ public void showLink(boolean showLink) {
public void setInput(LaunchValidationOperation operation) {
fInput = operation.getInput();
fLaunchConfiguration = operation.fLaunchConfiguration;
launchMode = operation.fLaunchMode;
}

@Override
Expand Down Expand Up @@ -154,8 +158,12 @@ private void createLink(Composite parent) {
// Closing the validation dialog to avoid cyclic dependency
setReturnCode(CANCEL);
close();
ILaunchGroup launchGroup = DebugUITools.getLaunchGroup(fLaunchConfiguration, launchMode);
String groupIdentifier = launchGroup != null //
? launchGroup.getIdentifier()
: IDebugUIConstants.ID_RUN_LAUNCH_GROUP;
DebugUITools.openLaunchConfigurationDialog(Display.getCurrent().getActiveShell(), fLaunchConfiguration,
"org.eclipse.debug.ui.launchGroup.run", null); //$NON-NLS-1$
groupIdentifier, null);
}));
}
}
Expand Down Expand Up @@ -195,12 +203,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 {
launchMode = 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 Expand Up @@ -1013,6 +1013,7 @@ protected void abort(String message, Throwable exception, int code) throws CoreE

// key is a model, value is startLevel:autoStart
private Map<IPluginModelBase, String> fModels;
private String launchMode;

private static final String PDE_JUNIT_SHOW_COMMAND = "pde.junit.showcommandline"; //$NON-NLS-1$

Expand Down Expand Up @@ -1234,7 +1235,7 @@ protected void clear(ILaunchConfiguration configuration, IProgressMonitor monito
SubMonitor subMon = SubMonitor.convert(monitor, 50);

// Clear workspace and prompt, if necessary
LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, subMon.split(25));
LauncherUtils.clearWorkspace(configuration, fWorkspaceLocation, launchMode, subMon.split(25));

subMon.setWorkRemaining(25);

Expand Down Expand Up @@ -1267,7 +1268,8 @@ protected void validateProjectDependencies(ILaunchConfiguration configuration, I
*/
protected void validatePluginDependencies(ILaunchConfiguration configuration, IProgressMonitor monitor)
throws CoreException {
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet());
EclipsePluginValidationOperation op = new EclipsePluginValidationOperation(configuration, fModels.keySet(),
launchMode);
LaunchPluginValidator.runValidationOperation(op, monitor);
}
}
Loading