Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Schindl2012-03-09 10:16:41 -0500
committerTom Schindl2012-03-09 10:16:41 -0500
commit890a251b4a0514631c5565f41cfae6d954f0e367 (patch)
tree0fa54421e924579f3ba4ee59c9d1a1d1b8d70a60
parent7ce84a7ae5c1f58ddf9736f6528cc1bf59a08714 (diff)
downloadorg.eclipse.e4.tools-890a251b4a0514631c5565f41cfae6d954f0e367.tar.gz
org.eclipse.e4.tools-890a251b4a0514631c5565f41cfae6d954f0e367.tar.xz
org.eclipse.e4.tools-890a251b4a0514631c5565f41cfae6d954f0e367.zip
Bug 373805 - ISelectionProvider of compat layer can lead to a selectionv20120309-1516I20120312-0800I20120312-0100I20120310-2200I20120309-2200
which can't be empty
-rw-r--r--bundles/org.eclipse.e4.tools.compat/src/org/eclipse/e4/tools/compat/internal/SelectionProviderContextFunction.java14
1 files changed, 10 insertions, 4 deletions
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 901627cd..b77ed466 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 java.util.List;
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 class SelectionProviderContextFunction extends ContextFunction {
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));
}
-
}
};
}

Back to the top