Skip to content

Commit

Permalink
Validation dialog - Fix edit launch configuration link
Browse files Browse the repository at this point in the history
Fix the link to open the validation dialog to open the current launch
configuration.

Fixes: #305
  • Loading branch information
Dinesh0723 authored and HannesWell committed Feb 14, 2024
1 parent 11023ed commit 72fa789
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
public class LaunchValidationOperation implements IWorkspaceRunnable {

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

public LaunchValidationOperation(ILaunchConfiguration configuration, Set<IPluginModelBase> models) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ public void handleValidate() {
if (fDialog == null) {
if (fOperation.hasErrors()) {
fDialog = new PluginStatusDialog(getShell(), SWT.MODELESS | SWT.CLOSE | SWT.BORDER | SWT.TITLE | SWT.RESIZE);
fDialog.setInput(fOperation.getInput());
fDialog.setInput(fOperation);
fDialog.open();
fDialog = null;
} else if (fOperation.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private void handleValidate() {
if (fDialog == null) {
if (fOperation.hasErrors()) {
fDialog = new PluginStatusDialog(getShell(), SWT.MODELESS | SWT.CLOSE | SWT.BORDER | SWT.TITLE | SWT.RESIZE);
fDialog.setInput(fOperation.getInput());
fDialog.setInput(fOperation);
fDialog.open();
fDialog = null;
} else if (fOperation.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
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;
Expand All @@ -31,12 +28,12 @@
import org.eclipse.jface.viewers.TreeViewer;
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.ui.IHelpContextIds;
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.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
Expand Down Expand Up @@ -94,6 +91,7 @@ public Object[] getElements(Object inputElement) {
private boolean fShowLink;
private Map<?, ?> fInput;
private TreeViewer treeViewer;
private ILaunchConfiguration fLaunchConfiguration;

public PluginStatusDialog(Shell parentShell, int style) {
super(parentShell);
Expand All @@ -115,8 +113,9 @@ public void showLink(boolean showLink) {
fShowLink = showLink;
}

public void setInput(Map<?, ?> input) {
fInput = input;
public void setInput(LaunchValidationOperation operation) {
fInput = operation.getInput();
fLaunchConfiguration = operation.fLaunchConfiguration;
}

@Override
Expand All @@ -136,36 +135,28 @@ protected int getDialogBoundsStrategy() {
@Override
protected void createButtonsForButtonBar(Composite parent) {
if (fShowLink) {
createLink(parent, IDialogConstants.YES_ID, PDEUIMessages.PluginStatusDialog_validationLink, true);
createLink(parent);
}
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) {
private void createLink(Composite parent) {
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$
}
});
if (fLaunchConfiguration != null) {
link.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
// Closing the validation dialog to avoid cyclic dependency
setReturnCode(CANCEL);
close();
DebugUITools.openLaunchConfigurationDialog(Display.getCurrent().getActiveShell(), fLaunchConfiguration,
"org.eclipse.debug.ui.launchGroup.run", null); //$NON-NLS-1$
}));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private void displayValidationError(final LaunchValidationOperation op) throws C
PluginStatusDialog dialog = new PluginStatusDialog(shellProvider.getShell());
dialog.showLink(true);
dialog.showCancelButton(true);
dialog.setInput(op.getInput());
dialog.setInput(op);
result[0] = dialog.open();
});
if (result[0] == IDialogConstants.CANCEL_ID)
Expand Down

0 comments on commit 72fa789

Please sign in to comment.