Skip to content

Commit

Permalink
Workaround for issue 194 ( fixes eclipse-pde#194) (eclipse-pde#200)
Browse files Browse the repository at this point in the history
Change-Id: Icfa7b40456e97444655aeec7aa6a8a4ac418e803
Signed-off-by: Vikas Chandra <Vikas.Chandra@in.ibm.com>
  • Loading branch information
vik-chand authored Jul 6, 2022
1 parent 5cbfbc9 commit c9e687a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -985,9 +985,10 @@ public void handleValidate() {
try {
LaunchValidationOperation fOperation = createValidationOperation();
fOperation.run(new NullProgressMonitor());

Map<Object, Object[]> 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();
Expand All @@ -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<String, IStatus> input = new HashMap<>(1);
input.put(PDEUIMessages.AbstractLauncherToolbar_noProblems, Status.OK_STATUS);
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, 2022 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 @@ -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;
Expand Down Expand Up @@ -90,6 +91,7 @@ public void showCancelButton(boolean showCancel) {
}

public void setInput(Map<?, ?> input) {
filterOutMissingConstraintJavaPackages(input);
fInput = input;
}

Expand Down Expand Up @@ -136,13 +138,39 @@ 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));

getShell().setText(PDEUIMessages.PluginStatusDialog_pluginValidation);
Dialog.applyDialogFont(container);
return container;
}
//workaround - filter out missing java package constraint validation error for M1
public static void filterOutMissingConstraintJavaPackages(Map<?, ?> fInput) {
Set<Object> 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() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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<Object, Object[]> input = op.getInput();
PluginStatusDialog.filterOutMissingConstraintJavaPackages(input);
if (input.size() == 0) {
dialog.close();
return;
}
dialog.setInput(op.getInput());
result[0] = dialog.open();
});
Expand Down

0 comments on commit c9e687a

Please sign in to comment.