Skip to content

Commit

Permalink
Validation dialog - Edit launch configuration link
Browse files Browse the repository at this point in the history
Introduced a new link in validation dialog to open the current launch
configuration.

Fixes: #305
  • Loading branch information
Dinesh0723 authored and mickaelistria committed Dec 20, 2023
1 parent adb4cb4 commit 1d27d86
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
LaunchConfigurationHelperTestCase.class, //
LaunchConfigurationMigrationTest.class, //
ProductEditorLaunchingTest.class, //
ValidationDialogTest.class, //
})
public class AllLauncherTests {

Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,12 +11,18 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Lars Vogel <[email protected]> - 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;
Expand All @@ -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;

Expand Down Expand Up @@ -80,6 +91,7 @@ public Object[] getElements(Object inputElement) {
}

private boolean fShowCancelButton;
private boolean fShowLink;
private Map<?, ?> fInput;
private TreeViewer treeViewer;

Expand All @@ -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;
}
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=<A>Edit Launch Configuration</A>
PluginsView_openWith=Open &With
PluginsView_import=I&mport As
PluginsView_select=Se&lect
Expand Down

0 comments on commit 1d27d86

Please sign in to comment.