Bug 373805 - ISelectionProvider of compat layer can lead to a selection
which can't be empty
diff --git a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/SelectionProviderContextFunction.java b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/SelectionProviderContextFunction.java
index 901627c..b77ed46 100644
--- a/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/SelectionProviderContextFunction.java
+++ b/bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/SelectionProviderContextFunction.java
@@ -15,10 +15,10 @@
 import org.eclipse.e4.core.contexts.ContextFunction;
 import org.eclipse.e4.core.contexts.IEclipseContext;
 import org.eclipse.e4.tools.services.ISelectionProviderService;
+import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
 
-
 public class SelectionProviderContextFunction extends ContextFunction {
 
 	@Override
@@ -27,12 +27,18 @@
 			public void setSelection(Object selection) {
 				ISelectionProvider pv = context.get(ISelectionProvider.class);
 				
-				if( selection instanceof List<?> ) {
-					pv.setSelection(new StructuredSelection((List<?>)selection));	
+				if( selection == null ) {
+					pv.setSelection(StructuredSelection.EMPTY);
+				} else if (selection instanceof ISelection) {
+					pv.setSelection((ISelection) selection);
+				} else if (selection instanceof List<?>) {
+					pv.setSelection(new StructuredSelection((List<?>) selection));
+				} else if (selection instanceof Object[]) {
+					pv.setSelection(new StructuredSelection(
+							(Object[]) selection));
 				} else {
 					pv.setSelection(new StructuredSelection(selection));
 				}
-				
 			}
 		};
 	}