-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validation dialog - Edit launch configuration link
Introduced a new link in validation dialog to open the current launch configuration. Fixes: #305
- Loading branch information
1 parent
adb4cb4
commit 1d27d86
Showing
6 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/launcher/ValidationDialogTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -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; | ||
|
@@ -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); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters