From c9e687a44805f1fb26e422d25a1982f74291bffd Mon Sep 17 00:00:00 2001 From: Vikas Chandra <99390647+vik-chand@users.noreply.github.com> Date: Wed, 6 Jul 2022 14:54:14 +0530 Subject: [PATCH] Workaround for issue 194 ( fixes #194) (#200) Change-Id: Icfa7b40456e97444655aeec7aa6a8a4ac418e803 Signed-off-by: Vikas Chandra --- .../ui/launcher/AbstractPluginBlock.java | 9 ++--- .../ui/launcher/PluginStatusDialog.java | 34 +++++++++++++++++-- .../PluginValidationStatusHandler.java | 9 ++++- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java index a31ffb22cb..84461b1e85 100644 --- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java +++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/AbstractPluginBlock.java @@ -985,9 +985,10 @@ public void handleValidate() { try { LaunchValidationOperation fOperation = createValidationOperation(); fOperation.run(new NullProgressMonitor()); - + Map input2 = fOperation.getInput(); + PluginStatusDialog.filterOutMissingConstraintJavaPackages(input2); if (fDialog == null) { - if (fOperation.hasErrors()) { + if (fOperation.hasErrors() && input2.size() > 0) { fDialog = new PluginStatusDialog(getShell(), SWT.MODELESS | SWT.CLOSE | SWT.BORDER | SWT.TITLE | SWT.RESIZE); fDialog.setInput(fOperation.getInput()); fDialog.open(); @@ -1005,8 +1006,8 @@ public void handleValidate() { MessageDialog.openInformation(getShell(), PDEUIMessages.PluginStatusDialog_pluginValidation, PDEUIMessages.AbstractLauncherToolbar_noProblems); } } else { - if (fOperation.getInput().size() > 0) { - fDialog.refresh(fOperation.getInput()); + if (input2.size() > 0) { + fDialog.refresh(input2); } else { Map input = new HashMap<>(1); input.put(PDEUIMessages.AbstractLauncherToolbar_noProblems, Status.OK_STATUS); 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 c23dce33b0..db3c74c809 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, 2022 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -14,12 +14,13 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; -import java.util.Map; +import java.util.*; +import java.util.Map.Entry; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.jface.dialogs.*; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.viewers.*; -import org.eclipse.osgi.service.resolver.BundleDescription; +import org.eclipse.osgi.service.resolver.*; import org.eclipse.pde.internal.ui.*; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -90,6 +91,7 @@ public void showCancelButton(boolean showCancel) { } public void setInput(Map input) { + filterOutMissingConstraintJavaPackages(input); fInput = input; } @@ -136,6 +138,11 @@ protected Control createDialogArea(Composite parent) { treeViewer.setContentProvider(new ContentProvider()); treeViewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); treeViewer.setComparator(new ViewerComparator()); + filterOutMissingConstraintJavaPackages(fInput); + if (fInput.size() == 0) { + this.close(); + return container; + } treeViewer.setInput(fInput); treeViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -143,6 +150,27 @@ protected Control createDialogArea(Composite parent) { Dialog.applyDialogFont(container); return container; } + //workaround - filter out missing java package constraint validation error for M1 + public static void filterOutMissingConstraintJavaPackages(Map fInput) { + Set keySet = new HashSet<>(); // + for (Entry entry : fInput.entrySet()) { + Object key = entry.getKey(); + Object val = entry.getValue(); + if (val instanceof ResolverError[]) { + ResolverError[] re = (ResolverError[]) val; + int count = 0; + for (ResolverError resolverError : re) { + VersionConstraint unsatisfiedConstraint = resolverError.getUnsatisfiedConstraint(); + if (unsatisfiedConstraint instanceof ImportPackageSpecification && + unsatisfiedConstraint.getName().startsWith("java."))//$NON-NLS-1$ + count++; + } + if (re.length == count) + keySet.add(key); + } + } + fInput.keySet().removeAll(keySet); + } @Override public boolean close() { 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 bc2ee4d5e6..edd207fac6 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 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2015 eXXcellent solutions gmbh, EclipseSource Corporation + * Copyright (c) 2009, 2022 eXXcellent solutions gmbh, EclipseSource Corporation * and others. * * This program and the accompanying materials @@ -15,6 +15,7 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.launcher; +import java.util.Map; import org.eclipse.core.runtime.*; import org.eclipse.debug.core.IStatusHandler; import org.eclipse.jface.dialogs.IDialogConstants; @@ -52,6 +53,12 @@ private void displayValidationError(final LaunchValidationOperation op) throws C IShellProvider shellProvider = PlatformUI.getWorkbench().getModalDialogShellProvider(); PluginStatusDialog dialog = new PluginStatusDialog(shellProvider.getShell()); dialog.showCancelButton(true); + Map input = op.getInput(); + PluginStatusDialog.filterOutMissingConstraintJavaPackages(input); + if (input.size() == 0) { + dialog.close(); + return; + } dialog.setInput(op.getInput()); result[0] = dialog.open(); });