summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHendrik Still2013-09-16 06:07:10 (EDT)
committer Hendrik Still2013-09-16 06:07:10 (EDT)
commit9d72bc856250759be2f645e2144d2b1527adc4c3 (patch)
treebaa50052e5124a682a7f3a25a30295d621c1ea44
parentc4d69dfb1433c698a532482c7c70d66cc06d4a6b (diff)
downloadeclipse.platform.ui-9d72bc856250759be2f645e2144d2b1527adc4c3.zip
eclipse.platform.ui-9d72bc856250759be2f645e2144d2b1527adc4c3.tar.gz
eclipse.platform.ui-9d72bc856250759be2f645e2144d2b1527adc4c3.tar.bz2
Bug 416339 - [JFace] The used input types for the generic JFace API arerefs/changes/09/16409/3
too restrictive! [JFace] added generics to the ArrayContetProvider Allows to set a contentprovider of a superset of the inputtype Also updated JUnit Tests and JFace Snipptes. Change-Id: Ic9b25517d81e78ed3c15576b4956b791278ca682 Signed-off-by: Hendrik Still <hendrik.still@gammas.de>
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTableViewer.java12
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java16
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ArrayContentProvider.java109
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java42
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IContentProvider.java10
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java4
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java2
-rw-r--r--bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java4
-rw-r--r--examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet063ComboViewer.java6
9 files changed, 143 insertions, 62 deletions
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTableViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTableViewer.java
index acf1eb1..e51759a 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTableViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTableViewer.java
@@ -87,10 +87,10 @@ public abstract class AbstractTableViewer<E,I> extends ColumnViewer<E,I> {
if (element == null) {
// Didn't find it so make a request
// Keep looking if it is not in the cache.
- IContentProvider<I> contentProvider = getContentProvider();
+ IContentProvider<? super I> contentProvider = getContentProvider();
// If we are building lazily then request lookup now
if (contentProvider instanceof ILazyContentProvider) {
- ILazyContentProvider<I> lazyContentProvider = ((ILazyContentProvider<I>) contentProvider);
+ ILazyContentProvider<? super I> lazyContentProvider = ((ILazyContentProvider<? super I>) contentProvider);
lazyContentProvider.updateElement(index);
return;
}
@@ -531,7 +531,7 @@ public abstract class AbstractTableViewer<E,I> extends ColumnViewer<E,I> {
List<E> result = new ArrayList<E>();
int[] selectionIndices = doGetSelectionIndices();
if (getContentProvider() instanceof ILazyContentProvider) {
- ILazyContentProvider<I> lazy = (ILazyContentProvider<I>) getContentProvider();
+ ILazyContentProvider<? super I> lazy = (ILazyContentProvider<? super I>) getContentProvider();
for (int i = 0; i < selectionIndices.length; i++) {
int selectionIndex = selectionIndices[i];
lazy.updateElement(selectionIndex);// Start the update
@@ -704,7 +704,7 @@ public abstract class AbstractTableViewer<E,I> extends ColumnViewer<E,I> {
private void internalVirtualRefreshAll() {
I root = getRoot();
- IContentProvider<I> contentProvider = getContentProvider();
+ IContentProvider<? super I> contentProvider = getContentProvider();
// Invalidate for lazy
if (!(contentProvider instanceof ILazyContentProvider)
@@ -1006,7 +1006,7 @@ public abstract class AbstractTableViewer<E,I> extends ColumnViewer<E,I> {
}
if (getContentProvider() instanceof ILazyContentProvider) {
- ILazyContentProvider<I> provider = (ILazyContentProvider<I>) getContentProvider();
+ ILazyContentProvider<? super I> provider = (ILazyContentProvider<? super I>) getContentProvider();
// Now go through it again until all is done or we are no longer
// virtual
@@ -1141,7 +1141,7 @@ public abstract class AbstractTableViewer<E,I> extends ColumnViewer<E,I> {
* @see org.eclipse.jface.viewers.StructuredViewer#assertContentProviderType(org.eclipse.jface.viewers.IContentProvider)
*/
@Override
- protected void assertContentProviderType(IContentProvider<I> provider) {
+ protected void assertContentProviderType(IContentProvider<? super I> provider) {
Assert.isTrue(provider instanceof IStructuredContentProvider
|| provider instanceof ILazyContentProvider);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
index 831406f..d2e0f1b 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/AbstractTreeViewer.java
@@ -1385,7 +1385,7 @@ public abstract class AbstractTreeViewer<E,I> extends ColumnViewer<E,I> {
I inputParent = (I) parent;
return super.getRawChildren(inputParent);
}
- IContentProvider<I> cp = getContentProvider();
+ IContentProvider<? super I> cp = getContentProvider();
if (cp instanceof ITreePathContentProvider) {
@SuppressWarnings("unchecked")
ITreePathContentProvider<E,I> tpcp = (ITreePathContentProvider<E,I>) cp;
@@ -1756,10 +1756,10 @@ public abstract class AbstractTreeViewer<E,I> extends ColumnViewer<E,I> {
TreePath<E> treePath = (TreePath<E>) elementOrTreePath;
return treePath.getParentPath();
}
- IContentProvider<I> cp = getContentProvider();
+ IContentProvider<? super I> cp = getContentProvider();
if (cp instanceof ITreePathContentProvider) {
@SuppressWarnings("unchecked")
- ITreePathContentProvider<E,I> tpcp = (ITreePathContentProvider<E,I>) cp;
+ ITreePathContentProvider<E,? super I> tpcp = (ITreePathContentProvider<E,? super I>) cp;
@SuppressWarnings("unchecked")
E element = (E) elementOrTreePath;
TreePath<E>[] paths = tpcp.getParents(element);
@@ -1772,7 +1772,7 @@ public abstract class AbstractTreeViewer<E,I> extends ColumnViewer<E,I> {
}
if (cp instanceof ITreeContentProvider) {
@SuppressWarnings("unchecked")
- ITreeContentProvider<E,I> tcp = (ITreeContentProvider<E,I>) cp;
+ ITreeContentProvider<E,? super I> tcp = (ITreeContentProvider<E,? super I>) cp;
@SuppressWarnings("unchecked")
E element = (E)elementOrTreePath;
return tcp.getParent(element);
@@ -2195,10 +2195,10 @@ public abstract class AbstractTreeViewer<E,I> extends ColumnViewer<E,I> {
element = castObjectToElement(elementOrTreePath);
path = null;
}
- IContentProvider<I> cp = getContentProvider();
+ IContentProvider<? super I> cp = getContentProvider();
if (cp instanceof ITreePathContentProvider) {
@SuppressWarnings("unchecked")
- ITreePathContentProvider<E,I> tpcp = (ITreePathContentProvider<E,I>) cp;
+ ITreePathContentProvider<E,? super I> tpcp = (ITreePathContentProvider<E,? super I>) cp;
if (path == null) {
// A path was not provided so try and find one
Widget w = findItem(element);
@@ -2468,13 +2468,13 @@ public abstract class AbstractTreeViewer<E,I> extends ColumnViewer<E,I> {
* <code>ITreeContentProvider</code>.
*/
@Override
- public void setContentProvider(IContentProvider<I> provider) {
+ public void setContentProvider(IContentProvider<? super I> provider) {
// the actual check is in assertContentProviderType
super.setContentProvider(provider);
}
@Override
- protected void assertContentProviderType(IContentProvider<I> provider) {
+ protected void assertContentProviderType(IContentProvider<? super I> provider) {
Assert.isTrue(provider instanceof ITreeContentProvider
|| provider instanceof ITreePathContentProvider);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ArrayContentProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ArrayContentProvider.java
index 83d762a..ebee2c2 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ArrayContentProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ArrayContentProvider.java
@@ -11,31 +11,71 @@
package org.eclipse.jface.viewers;
+import java.lang.reflect.Array;
import java.util.Collection;
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.Assert;
/**
* This implementation of <code>IStructuredContentProvider</code> handles
* the case where the viewer input is an unchanging array or collection of elements.
* <p>
* This class is not intended to be subclassed outside the viewer framework.
- * </p>
- *
+ * </p>
+ * @param <E> Type of an element of the model
+ *
* @since 2.1
* @noextend This class is not intended to be subclassed by clients.
*/
-public class ArrayContentProvider implements IStructuredContentProvider {
+public class ArrayContentProvider<E> implements IStructuredContentProvider<E,Object> {
+ private static HashMap<Class<?>,ArrayContentProvider<?>> instanceMap = new HashMap<Class<?>,ArrayContentProvider<?>>();
+ @SuppressWarnings("rawtypes")
private static ArrayContentProvider instance;
+ private Class<E> componentType;
+
+
+
+ /**
+ * Constructor for ArrayContentProvider
+ *
+ * <p>
+ * Only use this constructor if you are using rawtyped Viewers
+ * </p>
+ *
+ * @deprecated
+ */
+ public ArrayContentProvider(){
+
+ }
+
+ /**
+ * Constructor for ArrayContentProvider
+ *
+ * @param componentType The classtype of the used element e.g. MyElement.class
+ * @since 3.10
+ *
+ */
+ public ArrayContentProvider(Class<E> componentType) {
+ this.componentType = componentType;
+ }
/**
* Returns an instance of ArrayContentProvider. Since instances of this
* class do not maintain any state, they can be shared between multiple
* clients.
- *
+ *
+ * <p>
+ * Only use this method if you are using rawtyped Viewers
+ * </p>
+ *
* @return an instance of ArrayContentProvider
- *
+ *
* @since 3.5
+ * @deprecated
*/
+ @SuppressWarnings("rawtypes")
public static ArrayContentProvider getInstance() {
synchronized(ArrayContentProvider.class) {
if (instance == null) {
@@ -44,25 +84,66 @@ public class ArrayContentProvider implements IStructuredContentProvider {
return instance;
}
}
+
+ /**
+ * Returns an instance of ArrayContentProvider. Since instances of this
+ * class do not maintain any state, they can be shared between multiple
+ * clients.
+ * @param componentType The classtype of the used element e.g. MyElement.class
+ *
+ * @return an instance of ArrayContentProvider
+ *
+ * @since 3.10
+ */
+ public static <E> ArrayContentProvider<E> getInstance(Class<E> componentType) {
+
+ @SuppressWarnings("unchecked")
+ ArrayContentProvider<E> arrayContentProvider = (ArrayContentProvider<E>) instanceMap.get(componentType);
+ if (arrayContentProvider == null) {
+ synchronized (ArrayContentProvider.class) {
+ arrayContentProvider = new ArrayContentProvider<E>(
+ componentType);
+ instanceMap.put(componentType, arrayContentProvider);
+ }
+ }
+
+ return arrayContentProvider;
+ }
/**
* Returns the elements in the input, which must be either an array or a
- * <code>Collection</code>.
+ * <code>Collection</code> of the element type.
*/
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Object[]) {
- return (Object[]) inputElement;
+ @SuppressWarnings("unchecked")
+ public E[] getElements(Object inputElement) {
+ if (componentType != null) {
+ if (inputElement instanceof Object[]) {
+ Assert.isTrue(inputElement.getClass().getComponentType()
+ .isAssignableFrom(componentType),"The type of the input ("+inputElement.getClass().getComponentType()+") is not compatible to the ArrayContentProvider Type ("+componentType+")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return (E[]) inputElement;
+ }
+ if (inputElement instanceof Collection) {
+ E[] elementArray = (E[]) Array.newInstance(componentType,
+ ((Collection<E>) inputElement).size());
+ return ((Collection<E>) inputElement).toArray(elementArray);
+ }
+ return (E[]) Array.newInstance(componentType, 0);
+ }
+ //If the componentType is not given, the ArrayContentProvider should be an instance of a rawtype
+ if (inputElement instanceof Object[]) {
+ return (E[]) inputElement;
}
- if (inputElement instanceof Collection) {
- return ((Collection) inputElement).toArray();
+ if (inputElement instanceof Collection) {
+ @SuppressWarnings("rawtypes")
+ Collection collection = ((Collection) inputElement);
+ return (E[]) collection.toArray();
}
- return new Object[0];
+ return (E[]) new Object[0];
}
/**
* This implementation does nothing.
*/
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing.
+ public void inputChanged(Viewer<? extends Object> viewer, Object oldInput, Object newInput) {
}
/**
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
index 76b8f81..a4ce41f 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/ContentViewer.java
@@ -25,11 +25,11 @@ import org.eclipse.swt.widgets.Control;
* model by means of a content provider and a label provider.
* <p>
* A viewer's model consists of elements, represented by objects.
- * A viewer defines and implements generic infrastructure for handling model
+ * A viewer defines and implements generic infrastructure for handling model
* input, updates, and selections in terms of elements.
* Input is obtained by querying an <code>IContentProvider</code> which returns
* elements. The elements themselves are not displayed directly. They are
- * mapped to labels, containing text and/or an image, using the viewer's
+ * mapped to labels, containing text and/or an image, using the viewer's
* <code>ILabelProvider</code>.
* </p>
* <p>
@@ -56,7 +56,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
/**
* This viewer's content provider, or <code>null</code> if none.
*/
- private IContentProvider<I> contentProvider = null;
+ private IContentProvider<? super I> contentProvider = null;
/**
* This viewer's input, or <code>null</code> if none.
@@ -78,7 +78,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
*/
private final ILabelProviderListener labelProviderListener = new ILabelProviderListener() {
private boolean logWhenDisposed = true; // initially true, set to false
-
+
public void labelProviderChanged(LabelProviderChangedEvent event) {
Control control = getControl();
if (control == null || control.isDisposed()) {
@@ -109,25 +109,25 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
}
/**
- * Returns the content provider used by this viewer,
+ * Returns the content provider used by this viewer,
* or <code>null</code> if this view does not yet have a content
* provider.
* <p>
* The <code>ContentViewer</code> implementation of this method returns the content
- * provider recorded is an internal state variable.
- * Overriding this method is generally not required;
- * however, if overriding in a subclass,
+ * provider recorded is an internal state variable.
+ * Overriding this method is generally not required;
+ * however, if overriding in a subclass,
* <code>super.getContentProvider</code> must be invoked.
* </p>
*
* @return the content provider, or <code>null</code> if none
*/
- public IContentProvider<I> getContentProvider() {
+ public IContentProvider<? super I> getContentProvider() {
return contentProvider;
}
/**
- * The <code>ContentViewer</code> implementation of this <code>IInputProvider</code>
+ * The <code>ContentViewer</code> implementation of this <code>IInputProvider</code>
* method returns the current input of this viewer, or <code>null</code>
* if none. The viewer's input provides the "model" for the viewer's
* content.
@@ -144,7 +144,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* provider recorded in an internal state variable; if none has been
* set (with <code>setLabelProvider</code>) a default label provider
* will be created, remembered, and returned.
- * Overriding this method is generally not required;
+ * Overriding this method is generally not required;
* however, if overriding in a subclass,
* <code>super.getLabelProvider</code> must be invoked.
* </p>
@@ -189,7 +189,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* <p>
* The <code>ContentViewer</code> implementation of this method calls <code>labelProviderChanged()</code>
* to cause a complete refresh of the viewer.
- * Subclasses may reimplement or extend.
+ * Subclasses may reimplement or extend.
* </p>
* @param event the change event
*/
@@ -202,9 +202,9 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* <p>
* All subclasses must call this method when their control is
* first established.
- * </p>
+ * </p>
* <p>
- * The <code>ContentViewer</code> implementation of this method hooks
+ * The <code>ContentViewer</code> implementation of this method hooks
* dispose events for the given control.
* Subclasses may override if they need to add other control hooks;
* however, <code>super.hookControl</code> must be invoked.
@@ -234,9 +234,9 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
/**
* Sets the content provider used by this viewer.
* <p>
- * The <code>ContentViewer</code> implementation of this method records the
+ * The <code>ContentViewer</code> implementation of this method records the
* content provider in an internal state variable.
- * Overriding this method is generally not required;
+ * Overriding this method is generally not required;
* however, if overriding in a subclass,
* <code>super.setContentProvider</code> must be invoked.
* </p>
@@ -244,9 +244,9 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* @param contentProvider the content provider
* @see #getContentProvider
*/
- public void setContentProvider(IContentProvider<I> contentProvider) {
+ public void setContentProvider(IContentProvider<? super I> contentProvider) {
Assert.isNotNull(contentProvider);
- IContentProvider<I> oldContentProvider = this.contentProvider;
+ IContentProvider<? super I> oldContentProvider = this.contentProvider;
this.contentProvider = contentProvider;
if (oldContentProvider != null) {
I currentInput = getInput();
@@ -261,7 +261,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* The <code>ContentViewer</code> implementation of this <code>Viewer</code>
* method invokes <code>inputChanged</code> on the content provider and then the
* <code>inputChanged</code> hook method. This method fails if this viewer does
- * not have a content provider. Subclassers are advised to override
+ * not have a content provider. Subclassers are advised to override
* <code>inputChanged</code> rather than this method, but may extend this method
* if required.
*/
@@ -291,7 +291,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
* The <code>ContentViewer</code> implementation of this method ensures that the
* given label provider is connected to this viewer and the
* former label provider is disconnected from this viewer.
- * Overriding this method is generally not required;
+ * Overriding this method is generally not required;
* however, if overriding in a subclass,
* <code>super.setLabelProvider</code> must be invoked.
* </p>
@@ -323,7 +323,7 @@ public abstract class ContentViewer<E,I> extends Viewer<I>{
/**
* @param oldProvider
- *
+ *
* @since 3.4
*/
void internalDisposeLabelProvider(IBaseLabelProvider<E> oldProvider) {
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IContentProvider.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IContentProvider.java
index de6de53..197a088 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IContentProvider.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/IContentProvider.java
@@ -11,16 +11,16 @@
*******************************************************************************/
package org.eclipse.jface.viewers;
-/**
+/**
* A content provider mediates between the viewer's model
* and the viewer itself.
* @param <I> Type of the input for the view
- *
+ *
* @see org.eclipse.jface.viewers.ContentViewer#setContentProvider(IContentProvider)
*/
public interface IContentProvider<I> {
/**
- * Disposes of this content provider.
+ * Disposes of this content provider.
* This is called by the viewer when it is disposed.
* <p>
* The viewer should not be updated during this call, as it is in the process
@@ -34,7 +34,7 @@ public interface IContentProvider<I> {
* has been switched to a different element.
* <p>
* A typical use for this method is registering the content provider as a listener
- * to changes on the new input (using model-specific means), and deregistering the viewer
+ * to changes on the new input (using model-specific means), and deregistering the viewer
* from the old input. In response to these change notifications, the content provider
* should update the viewer (see the add, remove, update and refresh methods on the viewers).
* </p>
@@ -49,5 +49,5 @@ public interface IContentProvider<I> {
* @param newInput the new input element, or <code>null</code> if the viewer
* does not have an input
*/
- public void inputChanged(Viewer<I> viewer, I oldInput, I newInput);
+ public void inputChanged(Viewer<? extends I> viewer, I oldInput, I newInput);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
index 8385112..e691182 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/StructuredViewer.java
@@ -1691,7 +1691,7 @@ public abstract class StructuredViewer<E,I> extends ContentViewer<E,I> implement
* @see org.eclipse.jface.viewers.ContentViewer#setContentProvider(org.eclipse.jface.viewers.IContentProvider)
*/
@Override
- public void setContentProvider(IContentProvider<I> provider) {
+ public void setContentProvider(IContentProvider<? super I> provider) {
assertContentProviderType(provider);
super.setContentProvider(provider);
}
@@ -1701,7 +1701,7 @@ public abstract class StructuredViewer<E,I> extends ContentViewer<E,I> implement
* supported types.
* @param provider
*/
- protected void assertContentProviderType(IContentProvider<I> provider) {
+ protected void assertContentProviderType(IContentProvider<? super I> provider) {
Assert.isTrue(provider instanceof IStructuredContentProvider);
}
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
index 18116fa..7e43a54 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TableViewer.java
@@ -452,7 +452,7 @@ public class TableViewer<E,I> extends AbstractTableViewer<E,I> {
@Override
protected Widget doFindItem(E element) {
- IContentProvider<I> contentProvider = getContentProvider();
+ IContentProvider<? super I> contentProvider = getContentProvider();
if (contentProvider instanceof IIndexableLazyContentProvider) {
IIndexableLazyContentProvider indexable = (IIndexableLazyContentProvider) contentProvider;
int idx = indexable.findElement(element);
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
index fa399d2..d7b869c 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/viewers/TreeViewer.java
@@ -400,7 +400,7 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
}
@Override
- protected void assertContentProviderType(IContentProvider<I> provider) {
+ protected void assertContentProviderType(IContentProvider<? super I> provider) {
if (provider instanceof ILazyTreeContentProvider
|| provider instanceof ILazyTreePathContentProvider) {
return;
@@ -1020,7 +1020,7 @@ public class TreeViewer<E,I> extends AbstractTreeViewer<E, I> {
* @see org.eclipse.jface.viewers.AbstractTreeViewer#setContentProvider(org.eclipse.jface.viewers.IContentProvider)
*/
@Override
- public void setContentProvider(IContentProvider<I> provider) {
+ public void setContentProvider(IContentProvider<? super I> provider) {
contentProviderIsLazy = (provider instanceof ILazyTreeContentProvider)
|| (provider instanceof ILazyTreePathContentProvider);
contentProviderIsTreeBased = provider instanceof ILazyTreePathContentProvider;
diff --git a/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet063ComboViewer.java b/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet063ComboViewer.java
index 47cbe4e..c4bcde0 100644
--- a/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet063ComboViewer.java
+++ b/examples/org.eclipse.jface.snippets/Eclipse JFace Snippets/org/eclipse/jface/snippets/viewers/Snippet063ComboViewer.java
@@ -25,9 +25,9 @@ import org.eclipse.swt.widgets.Shell;
/**
* A simple ComboViewer to demonstrate usage
- *
+ *
* @author Hendrik Still <hendrik.still@gammas.de>
- *
+ *
*/
public class Snippet063ComboViewer {
private class MyContentProvider implements IStructuredContentProvider<MyModel,MyModel[]> {
@@ -36,7 +36,7 @@ public class Snippet063ComboViewer {
}
- public void inputChanged(Viewer<MyModel[]> viewer, MyModel[] oldInput,
+ public void inputChanged(Viewer<? extends MyModel[]> viewer, MyModel[] oldInput,
MyModel[] newInput) {
}