diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AllLauncherTests.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AllLauncherTests.java index 04e27a664d..6c13b5d43e 100644 --- a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AllLauncherTests.java +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/AllLauncherTests.java @@ -28,6 +28,7 @@ LaunchConfigurationHelperTestCase.class, // LaunchConfigurationMigrationTest.class, // ProductEditorLaunchingTest.class, // + ValidationDialogTest.class, // }) public class AllLauncherTests { diff --git a/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/ValidationDialogTest.java b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/ValidationDialogTest.java new file mode 100644 index 0000000000..294d04f377 --- /dev/null +++ b/ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/ValidationDialogTest.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2023 ETAS GmbH and others, all rights reserved. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * ETAS GmbH - initial API and implementation + *******************************************************************************/ + +package org.eclipse.pde.ui.tests.launcher; + +import static org.junit.Assert.assertNotNull; + +import org.eclipse.jface.window.IShellProvider; +import org.eclipse.pde.internal.ui.launcher.PluginStatusDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Link; +import org.eclipse.ui.PlatformUI; +import org.junit.Test; + +public class ValidationDialogTest { + PluginStatusDialog dialog; + + @Test + public void editLaunchConfigLink() { + Display.getDefault().syncExec(() -> { + IShellProvider shellProvider = PlatformUI.getWorkbench().getModalDialogShellProvider(); + dialog = new PluginStatusDialog(shellProvider.getShell()); + dialog.showLink(true); + dialog.showCancelButton(true); + // To make the dialogue close immediately + dialog.setBlockOnOpen(false); + dialog.open(); + Control[] children = dialog.buttonBar.getParent().getChildren(); + checkEditConfigurationLink(children); + dialog.close(); + }); + + } + + private void checkEditConfigurationLink(Control[] element) { + for (Control control : element) { + if (control instanceof Composite) { + Control[] children = ((Composite) control).getChildren(); + checkEditConfigurationLink(children); + } else if ((control instanceof Link)) { + isEditLaunchConfigurationLinkAvilable(element, control); + break; + } + } + } + + private void isEditLaunchConfigurationLinkAvilable(Control[] element, Control control) { + Control editConfigLink = element[0]; + ((Link) control).notifyListeners(SWT.Selection, new Event()); + assertNotNull(editConfigLink.isVisible()); + } +} \ No newline at end of file diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java index 5c9cde05db..fbf66eab27 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java @@ -1791,6 +1791,7 @@ public class PDEUIMessages extends NLS { public static String PluginWorkingSet_deselectAll_toolTip; public static String PluginWorkingSet_noPluginsChecked; public static String PluginStatusDialog_pluginValidation; + public static String PluginStatusDialog_validationLink; public static String PluginsView_openWith; public static String PluginsView_import; public static String PluginsView_select; 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 ca9bf56cd4..2b07f5f689 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2016 IBM Corporation and others. + * Copyright (c) 2005, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,12 +11,18 @@ * Contributors: * IBM Corporation - initial API and implementation * Lars Vogel - Bug 487943 + * Dinesh Palanisamy (ETAS GmbH) - Issue 305 *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; import java.util.Map; import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.DebugUITools; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogSettings; @@ -29,10 +35,15 @@ import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; @@ -80,6 +91,7 @@ public Object[] getElements(Object inputElement) { } private boolean fShowCancelButton; + private boolean fShowLink; private Map fInput; private TreeViewer treeViewer; @@ -99,6 +111,10 @@ public void showCancelButton(boolean showCancel) { fShowCancelButton = showCancel; } + public void showLink(boolean showLink) { + fShowLink = showLink; + } + public void setInput(Map input) { fInput = input; } @@ -119,12 +135,40 @@ protected int getDialogBoundsStrategy() { @Override protected void createButtonsForButtonBar(Composite parent) { + if (fShowLink) { + createLink(parent, IDialogConstants.YES_ID, PDEUIMessages.PluginStatusDialog_validationLink, true); + } createButton(parent, IDialogConstants.OK_ID, PDEUIMessages.PluginStatusDialog_continueButtonLabel, true); if (fShowCancelButton) { createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } } + private void createLink(Composite parent, int yesId, String pluginStatusDialog_validationLink, boolean b) { + GridLayout layout = (GridLayout) parent.getLayout(); + layout.numColumns = 2; + layout.makeColumnsEqualWidth = false; + Link link = new Link(parent, SWT.NONE); + link.setText(PDEUIMessages.PluginStatusDialog_validationLink); + ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); + ILaunch[] launches = manager.getLaunches(); + if (launches.length >= 1) { + ILaunch iLaunch = launches[launches.length - 1]; + ILaunchConfiguration launchConfiguration = iLaunch.getLaunchConfiguration(); + link.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + // Closing the validation dialog to avoid cyclic dependency + setReturnCode(CANCEL); + close(); + DebugUITools.openLaunchConfigurationDialog(Display.getCurrent().getActiveShell(), + launchConfiguration, + "org.eclipse.debug.ui.launchGroup.run", null); //$NON-NLS-1$ + } + }); + } + } + @Override protected void configureShell(Shell shell) { super.configureShell(shell); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java index e93dddb82f..fb7fa15f2e 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/PluginValidationStatusHandler.java @@ -57,6 +57,7 @@ private void displayValidationError(final LaunchValidationOperation op) throws C display.syncExec(() -> { IShellProvider shellProvider = PlatformUI.getWorkbench().getModalDialogShellProvider(); PluginStatusDialog dialog = new PluginStatusDialog(shellProvider.getShell()); + dialog.showLink(true); dialog.showCancelButton(true); dialog.setInput(op.getInput()); result[0] = dialog.open(); diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties index fb89d329ad..1e2ae5e188 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties @@ -1513,6 +1513,7 @@ PluginListPage_initializeFromPlugins=&Initialize from the plug-ins list: PluginEditor_exportTooltip=Export deployable plug-ins and fragments PluginWorkingSet_noPluginsChecked=At least one plug-in must be checked PluginStatusDialog_pluginValidation=Validation +PluginStatusDialog_validationLink=Edit Launch Configuration PluginsView_openWith=Open &With PluginsView_import=I&mport As PluginsView_select=Se&lect