summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorHendrik Still2013-09-11 07:24:26 (EDT)
committer Gerrit Code Review @ Eclipse.org2013-09-17 09:20:56 (EDT)
commit94afd5ca34dc66e7e60cb5af54c0b1af79bb8e7f (patch)
tree8e00d1b89e6f09606b9460aa9ffd201a2d1f50e4
parentd95f3516657cb987c46078778dcb69f673cab408 (diff)
downloadeclipse.platform.ui-94afd5ca34dc66e7e60cb5af54c0b1af79bb8e7f.zip
eclipse.platform.ui-94afd5ca34dc66e7e60cb5af54c0b1af79bb8e7f.tar.gz
eclipse.platform.ui-94afd5ca34dc66e7e60cb5af54c0b1af79bb8e7f.tar.bz2
Bug 417142 - [Viewers] Update Viewer JUnit tests to use genericsrefs/changes/98/16398/2
Updates the JUnittest for the JFace Viewer Change-Id: I767f9401ecf770e0844a4df03b44937374a2113c Signed-off-by: Hendrik Still <hendrik.still@gammas.de>
-rw-r--r--tests/org.eclipse.ui.tests/.settings/org.eclipse.jdt.core.prefs13
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontLabelProviderTest.java31
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontViewerLabelProviderTest.java35
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTableTest.java33
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTest.java36
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreePathTest.java31
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreeTest.java27
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java86
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/TestColorAndFontLabelProvider.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AbstractTreeViewerTest.java20
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java48
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TableViewerTest.java22
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TreeViewerTest.java35
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200337TableViewerTest.java24
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200558Test.java13
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TableViewerTest.java19
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java34
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java19
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java34
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java58
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java14
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java41
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug327004TreeViewerTest.java112
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CComboViewerTest.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java136
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerMissingTest.java10
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java160
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerTest.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java208
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerComparatorTest.java33
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java37
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java50
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/MultipleEqualElementsTreeViewerTest.java66
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTableViewerTest.java30
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTreeViewerTest.java66
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java53
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java8
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java92
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableColorProviderTest.java48
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableFontProviderTest.java50
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableTreeViewerTest.java12
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerComparatorTest.java34
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerTest.java50
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestComparator.java4
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestElement.java16
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLabelProvider.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java26
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModel.java11
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelContentProvider.java44
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelLazyTreeContentProvider.java24
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java218
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerColumnTest.java36
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerComparatorTest.java77
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerTest.java2
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerComparatorTest.java95
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTableViewerTest.java42
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java98
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTreeViewerTest.java2
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddElementAction.java2
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddFilterAction.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ChangeInputLabelAction.java2
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java64
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ExpandAllAction.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/Filter.java12
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyDeferredVirtualTableView.java14
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java18
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetFilterAction.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetSorterAction.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetLabelProviderAction.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetSorterAction.java5
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java64
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestBrowser.java14
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestLazyVirtualTree.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestList.java6
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTable.java8
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTree.java8
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestVirtualTree.java4
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java40
80 files changed, 1555 insertions, 1406 deletions
diff --git a/tests/org.eclipse.ui.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.ui.tests/.settings/org.eclipse.jdt.core.prefs
index 43b844a..541985d 100644
--- a/tests/org.eclipse.ui.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/tests/org.eclipse.ui.tests/.settings/org.eclipse.jdt.core.prefs
@@ -6,6 +6,8 @@ org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch
org.eclipse.jdt.core.circularClasspath=error
org.eclipse.jdt.core.classpath.exclusionPatterns=enabled
org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
+org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
@@ -50,7 +52,9 @@ org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=enabled
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=private
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=ignore
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
@@ -66,16 +70,19 @@ org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignor
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=error
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=error
org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
+org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=error
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
@@ -86,10 +93,11 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=enabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=error
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=ignore
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=ignore
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
@@ -110,6 +118,7 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.5
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontLabelProviderTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontLabelProviderTest.java
index bd21edc..0560f36 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontLabelProviderTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontLabelProviderTest.java
@@ -11,6 +11,7 @@
package org.eclipse.jface.tests.labelProviders;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.LabelProvider;
@@ -27,14 +28,14 @@ import org.eclipse.swt.widgets.TableItem;
/**
* ColorAndFontProviderTest is a test of a color and font provider but not an
* IViewerLabelProvider.
- *
+ *
* @since 3.3
- *
+ *
*/
public class ColorAndFontLabelProviderTest extends CompositeLabelProviderTest {
- class ColorAndFontProvider extends LabelProvider implements IColorProvider,
- IFontProvider {
+ class ColorAndFontProvider extends LabelProvider<TestElement> implements IColorProvider<TestElement>,
+ IFontProvider<TestElement> {
/**
* Create a new instance of the receiver.
@@ -45,28 +46,28 @@ public class ColorAndFontLabelProviderTest extends CompositeLabelProviderTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(TestElement element) {
return font;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return background;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return foreground;
}
@@ -75,7 +76,7 @@ public class ColorAndFontLabelProviderTest extends CompositeLabelProviderTest {
/**
* Create a new instance of the receiver.
- *
+ *
* @param name
*/
public ColorAndFontLabelProviderTest(String name) {
@@ -84,12 +85,12 @@ public class ColorAndFontLabelProviderTest extends CompositeLabelProviderTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
initializeColors(parent);
- final TableViewer v = new TableViewer(parent);
+ final TableViewer<TestElement,TestElement> v = new TableViewer<TestElement,TestElement>(parent);
v.setContentProvider(new LabelTableContentProvider());
v.setLabelProvider(new ColorAndFontProvider());
;
@@ -110,7 +111,7 @@ public class ColorAndFontLabelProviderTest extends CompositeLabelProviderTest {
assertTrue("Foreground was not set", item.getForeground(0).equals(
foreground));
assertTrue("Font was not set", item.getFont(0).equals(font));
-
+
Font oldFont = font;
clearColors();
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontViewerLabelProviderTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontViewerLabelProviderTest.java
index d88cc08..45baee4 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontViewerLabelProviderTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/ColorAndFontViewerLabelProviderTest.java
@@ -11,6 +11,7 @@
package org.eclipse.jface.tests.labelProviders;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IViewerLabelProvider;
@@ -29,14 +30,14 @@ import org.eclipse.swt.widgets.TableItem;
/**
* ColorAndFontProviderTest is a test of a color and font provider that is an
* IViewerLabelProvider.
- *
+ *
* @since 3.3
- *
+ *
*/
public class ColorAndFontViewerLabelProviderTest extends CompositeLabelProviderTest {
- class ColorAndFontProvider extends LabelProvider implements IColorProvider,
- IFontProvider, IViewerLabelProvider {
+ class ColorAndFontProvider extends LabelProvider<TestElement> implements IColorProvider<TestElement>,
+ IFontProvider<TestElement>, IViewerLabelProvider<TestElement> {
/**
* Create a new instance of the receiver.
@@ -47,38 +48,38 @@ public class ColorAndFontViewerLabelProviderTest extends CompositeLabelProviderT
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(TestElement element) {
return font;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return background;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return foreground;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IViewerLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel,
* java.lang.Object)
*/
- public void updateLabel(ViewerLabel label, Object element) {
+ public void updateLabel(ViewerLabel label, TestElement element) {
// Do nothing
}
@@ -87,7 +88,7 @@ public class ColorAndFontViewerLabelProviderTest extends CompositeLabelProviderT
/**
* Create a new instance of the receiver.
- *
+ *
* @param name
*/
public ColorAndFontViewerLabelProviderTest(String name) {
@@ -96,12 +97,12 @@ public class ColorAndFontViewerLabelProviderTest extends CompositeLabelProviderT
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
initializeColors(parent);
- final TableViewer v = new TableViewer(parent);
+ final TableViewer<TestElement,TestElement> v = new TableViewer<TestElement,TestElement>(parent);
v.setContentProvider(new LabelTableContentProvider());
v.setLabelProvider(new ColorAndFontProvider());
;
@@ -124,7 +125,7 @@ public class ColorAndFontViewerLabelProviderTest extends CompositeLabelProviderT
assertTrue("Font was not set", item.getFont(0).equals(font));
Font oldFont = font;
-
+
clearColors();
fViewer.refresh(item.getData());
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTableTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTableTest.java
index 00878c5..9d2d1e3 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTableTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTableTest.java
@@ -11,6 +11,7 @@
package org.eclipse.jface.tests.labelProviders;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.IViewerLabelProvider;
@@ -29,53 +30,53 @@ import org.eclipse.swt.widgets.TableItem;
* {@link IColorProvider}, {@link org.eclipse.jface.viewers.IColorProvider},
* {@link IFontProvider}
* @since 3.3
- *
+ *
*/
public class CompositeLabelProviderTableTest extends CompositeLabelProviderTest {
- class MyLabelProvider extends LabelProvider implements IColorProvider,
- IViewerLabelProvider, IFontProvider {
+ class MyLabelProvider extends LabelProvider<TestElement> implements IColorProvider<TestElement>,
+ IViewerLabelProvider<TestElement>, IFontProvider<TestElement> {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return foreground;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return background;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IViewerLabelProvider#updateLabel(org.eclipse.jface.viewers.ViewerLabel,
* java.lang.Object)
*/
- public void updateLabel(ViewerLabel label, Object element) {
+ public void updateLabel(ViewerLabel label, TestElement element) {
label.setText(getText(element));
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(TestElement element) {
return font;
}
}
/**
* Create a new instance of the recevier.
- *
+ *
* @param name
*/
public CompositeLabelProviderTableTest(String name) {
@@ -84,13 +85,13 @@ public class CompositeLabelProviderTableTest extends CompositeLabelProviderTest
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
-
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+
initializeColors(parent);
- final TableViewer v = new TableViewer(parent);
+ final TableViewer<TestElement,TestElement> v = new TableViewer<TestElement,TestElement> (parent);
v.setContentProvider(new LabelTableContentProvider());
v.setLabelProvider(new MyLabelProvider());
v.getTable().setLinesVisible(true);
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTest.java
index 5ff0690..bb52aab 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/CompositeLabelProviderTest.java
@@ -25,26 +25,26 @@ import org.eclipse.swt.widgets.Control;
/**
* CompositeLabelProviderTest is the abstract superclass of the LabelProvider
* tests that use multiple label provider suppliers.
- *
+ *
* @since 3.3
- *
+ *
*/
public abstract class CompositeLabelProviderTest extends ViewerTestCase {
- class LabelTableContentProvider implements IStructuredContentProvider {
+ class LabelTableContentProvider implements IStructuredContentProvider<TestElement,TestElement> {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
- public Object[] getElements(Object inputElement) {
+ public TestElement[] getElements(TestElement inputElement) {
return fRootElement.getChildren();
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
@@ -53,11 +53,11 @@ public abstract class CompositeLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<TestElement> viewer, TestElement oldInput, TestElement newInput) {
}
@@ -69,7 +69,7 @@ public abstract class CompositeLabelProviderTest extends ViewerTestCase {
/**
* Create a new instance of the receiver.
- *
+ *
* @param name
*/
public CompositeLabelProviderTest(String name) {
@@ -78,7 +78,7 @@ public abstract class CompositeLabelProviderTest extends ViewerTestCase {
/**
* Initialize the colors used by the receiver.
- *
+ *
* @param parent
*/
void initializeColors(Control parent) {
@@ -87,28 +87,28 @@ public abstract class CompositeLabelProviderTest extends ViewerTestCase {
font = JFaceResources.getBannerFont();
}
- class TestTreeContentProvider implements ITreeContentProvider {
+ class TestTreeContentProvider implements ITreeContentProvider<TestElement,TestElement> {
- public Object[] getChildren(Object parentElement) {
- return ((TestElement) parentElement).getChildren();
+ public TestElement[] getChildren(TestElement parentElement) {
+ return parentElement.getChildren();
}
- public Object getParent(Object element) {
- return ((TestElement) element).getContainer();
+ public TestElement getParent(TestElement element) {
+ return element.getContainer();
}
- public boolean hasChildren(Object element) {
+ public boolean hasChildren(TestElement element) {
return getChildren(element).length > 0;
}
- public Object[] getElements(Object inputElement) {
+ public TestElement[] getElements(TestElement inputElement) {
return fRootElement.getChildren();
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<TestElement> viewer, TestElement oldInput, TestElement newInput) {
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreePathTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreePathTest.java
index bdbfbe1..4ac18e8 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreePathTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreePathTest.java
@@ -11,6 +11,7 @@
package org.eclipse.jface.tests.labelProviders;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ITreePathLabelProvider;
@@ -28,50 +29,50 @@ import org.eclipse.swt.widgets.TreeItem;
/**
* DecoratingLabelProviderTreePathTest is the tree path version of the
* DecoratingLabelProviderTreeTest.
- *
+ *
* @since 3.3
- *
+ *
*/
public class DecoratingLabelProviderTreePathTest extends
CompositeLabelProviderTest {
- class TreePathTestLabelProvider extends LabelProvider implements
- IColorProvider, IFontProvider, ITreePathLabelProvider {
+ class TreePathTestLabelProvider extends LabelProvider<TestElement> implements
+ IColorProvider<TestElement>, IFontProvider<TestElement>, ITreePathLabelProvider<TestElement> {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return foreground;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return background;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(TestElement element) {
return font;
}
- public void updateLabel(ViewerLabel label, TreePath elementPath) {
+ public void updateLabel(ViewerLabel label, TreePath<TestElement> elementPath) {
label.setText(getText(elementPath.getLastSegment()));
}
}
/**
* Create a new instance of the receiver.
- *
+ *
* @param name
*/
public DecoratingLabelProviderTreePathTest(String name) {
@@ -81,13 +82,13 @@ public class DecoratingLabelProviderTreePathTest extends
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.labelProviders.DecoratingLabelProviderTreeTest#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
initializeColors(parent);
- final TreeViewer v = new TreeViewer(parent);
+ final TreeViewer<TestElement,TestElement> v = new TreeViewer<TestElement,TestElement>(parent);
v.setLabelProvider(new TreePathTestLabelProvider());
v.setContentProvider(new TestTreeContentProvider());
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreeTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreeTest.java
index da8669b..74ec6ba 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreeTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingLabelProviderTreeTest.java
@@ -11,6 +11,7 @@
package org.eclipse.jface.tests.labelProviders;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.DecoratingLabelProvider;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.IFontProvider;
@@ -25,40 +26,40 @@ import org.eclipse.swt.widgets.TreeItem;
/**
* @since 3.3
- *
+ *
*/
public class DecoratingLabelProviderTreeTest extends CompositeLabelProviderTest {
- class IntListLabelProvider extends LabelProvider implements IColorProvider,
- IFontProvider {
+ class IntListLabelProvider extends LabelProvider<TestElement> implements IColorProvider<TestElement>,
+ IFontProvider<TestElement> {
public IntListLabelProvider() {
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return background;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return foreground;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(TestElement element) {
return font;
}
}
@@ -72,20 +73,20 @@ public class DecoratingLabelProviderTreeTest extends CompositeLabelProviderTest
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
initializeColors(parent);
- StructuredViewer viewer = new TreeViewer(parent);
+ StructuredViewer<TestElement,TestElement> viewer = new TreeViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestTreeContentProvider());
viewer.setLabelProvider(new DecoratingLabelProvider(
new IntListLabelProvider(), null));
return viewer;
}
-
+
/**
* Test that all of the colours and fonts from the label provider are
* applied.
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java
index 3260a58..f11df84 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/DecoratingStyledCellLabelProviderTest.java
@@ -17,6 +17,7 @@ import org.eclipse.jface.tests.viewers.ViewerTestCase;
import org.eclipse.jface.viewers.CellLabelProvider;
import org.eclipse.jface.viewers.ColumnPixelData;
import org.eclipse.jface.viewers.DecoratingStyledCellLabelProvider;
+import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.IColorDecorator;
import org.eclipse.jface.viewers.IDecorationContext;
import org.eclipse.jface.viewers.IFontProvider;
@@ -30,7 +31,6 @@ import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TableLayout;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.ViewerCell;
-import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
@@ -48,19 +48,21 @@ import org.eclipse.swt.widgets.TableColumn;
/**
* Most of the setup has been taken from
* org.eclipse.jface.snippets.viewers.Snippet010OwnerDraw.java
- *
+ *
* @since 3.4
- *
+ *
*/
public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
+ private TableViewer<Object,Object> tableViewer;
+
// static ResourceManager resourceManager = PlatformUI.getWorkbench().
private class TestCellLabelProvider extends CellLabelProvider implements
IStyledLabelProvider, IFontProvider {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.CellLabelProvider#update(org.eclipse.jface.viewers.ViewerCell)
*/
public void update(ViewerCell cell) {
@@ -76,20 +78,20 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getImage(java.lang.Object)
*/
public Image getImage(Object element) {
// create a resource manager that holds onto images
// OR create image set, dispose in teardown
- return fViewer.getControl().getDisplay().getSystemImage(
+ return tableViewer.getControl().getDisplay().getSystemImage(
SWT.ICON_WARNING);
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider#getStyledText(java.lang.Object)
*/
public StyledString getStyledText(Object element) {
@@ -99,7 +101,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
public Font getFont(Object element) {
@@ -134,21 +136,21 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorDecorator#decorateBackground(java.lang.Object)
*/
public Color decorateBackground(Object element) {
- return fViewer.getControl().getDisplay().getSystemColor(
+ return tableViewer.getControl().getDisplay().getSystemColor(
SWT.COLOR_RED);
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IColorDecorator#decorateForeground(java.lang.Object)
*/
public Color decorateForeground(Object element) {
- return fViewer.getControl().getDisplay().getSystemColor(
+ return tableViewer.getControl().getDisplay().getSystemColor(
SWT.COLOR_BLUE);
}
}
@@ -166,12 +168,12 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- TableViewer viewer = new TableViewer(parent, SWT.FULL_SELECTION);
+ TableViewer<Object,Object> viewer = new TableViewer<Object,Object>(parent, SWT.FULL_SELECTION);
- viewer.setContentProvider(new IStructuredContentProvider() {
+ viewer.setContentProvider(new IStructuredContentProvider<Object,Object>() {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
@@ -179,7 +181,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
public Object[] getElements(Object inputElement) {
@@ -188,11 +190,11 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
- public void inputChanged(org.eclipse.jface.viewers.Viewer viewer,
+ public void inputChanged(org.eclipse.jface.viewers.Viewer<Object> viewer,
Object oldInput, Object newInput) {
}
@@ -205,7 +207,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
viewer.getControl().setLayoutData(data);
viewer.setSelection(new StructuredSelection(entries[1]));
-
+ tableViewer = viewer;
return viewer;
}
@@ -267,7 +269,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
}
protected void setInput() {
- fViewer.setInput(this);
+ tableViewer.setInput(this);
}
// the tests
@@ -285,10 +287,10 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
}
public void testUpdate() {
- Table table = ((TableViewer) fViewer).getTable();
+ Table table = ((TableViewer) tableViewer).getTable();
String before = table.getItem(0).toString();
entries[0].name = "Updated";
- fViewer.refresh();
+ tableViewer.refresh();
assertNotSame(before, table.getItem(0).toString());
}
@@ -333,7 +335,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
}
public void testGetImage() {
- Table table = ((TableViewer) fViewer).getTable();
+ Table table = ((TableViewer) tableViewer).getTable();
assertEquals(table.getItem(0).getImage(),
getDecoratingStyledLabelProvider().getImage(table.getItem(0)));
@@ -381,7 +383,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
public void testDispose() {
fShell.dispose();
- assertFalse(fViewer.getLabelProvider() instanceof DecoratingStyledCellLabelProvider);
+ assertFalse(tableViewer.getLabelProvider() instanceof DecoratingStyledCellLabelProvider);
// the viewer will return a new LabelProvider if the current is null
}
@@ -390,7 +392,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
* this test
*/
private DecoratingStyledCellLabelProvider getDecoratingStyledLabelProvider() {
- return ((DecoratingStyledCellLabelProvider) fViewer.getLabelProvider());
+ return ((DecoratingStyledCellLabelProvider) tableViewer.getLabelProvider());
}
class CountryEntry {
@@ -403,7 +405,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/**
* Create a new instance of the receiver.
- *
+ *
* @param countryName
* @param worldCupYear
*/
@@ -457,11 +459,11 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/**
* Draw the flag in bounds.
- *
+ *
* @param event
*/
protected void drawFlag(Event event) {
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_BLUE));
Rectangle bounds = event.getBounds();
@@ -471,7 +473,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/**
* Draw the cup year
- *
+ *
* @param event
*/
private void drawCupYear(Event event) {
@@ -481,14 +483,14 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/**
* Draw the name of the receiver.
- *
+ *
* @param event
*/
protected void drawName(Event event) {
StringBuffer buffer = getDisplayString();
- Display display = fViewer.getControl().getDisplay();
+ Display display = tableViewer.getControl().getDisplay();
TextLayout layout = new TextLayout(display);
layout.setText(buffer.toString());
@@ -506,7 +508,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
layout.setStyle(italic, name.length(), buffer.length() - 1);
layout.draw(event.gc, event.x, event.y);
-
+
layout.dispose();
}
@@ -554,7 +556,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.OwnerDrawExample.CountryEntry#drawFlag(org.eclipse.swt.widgets.Event)
*/
protected void drawFlag(Event event) {
@@ -565,19 +567,19 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
Rectangle stripe = new Rectangle(bounds.x, bounds.y, bounds.width,
stripeHeight);
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_BLACK));
event.gc.fillRectangle(stripe);
stripe.y += stripeHeight;
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_YELLOW));
event.gc.fillRectangle(stripe);
stripe.y += stripeHeight;
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_RED));
event.gc.fillRectangle(stripe);
@@ -593,7 +595,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.OwnerDrawExample.CountryEntry#drawFlag(org.eclipse.swt.widgets.Event)
*/
protected void drawFlag(Event event) {
@@ -604,19 +606,19 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
Rectangle stripe = new Rectangle(bounds.x, bounds.y, bounds.width,
stripeHeight);
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_RED));
event.gc.fillRectangle(stripe);
stripe.y += stripeHeight;
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_WHITE));
event.gc.fillRectangle(stripe);
stripe.y += stripeHeight;
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_RED));
event.gc.fillRectangle(stripe);
@@ -630,7 +632,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.OwnerDrawExample.CountryEntry#drawFlag(org.eclipse.swt.widgets.Event)
*/
protected void drawFlag(Event event) {
@@ -638,7 +640,7 @@ public class DecoratingStyledCellLabelProviderTest extends ViewerTestCase {
Rectangle bounds = event.getBounds();
bounds.width += 100;
- event.gc.setBackground(fViewer.getControl().getDisplay()
+ event.gc.setBackground(tableViewer.getControl().getDisplay()
.getSystemColor(SWT.COLOR_RED));
event.gc.fillRectangle(new Rectangle(bounds.width / 2 + bounds.x
- 5, bounds.y, 10, bounds.height));
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/TestColorAndFontLabelProvider.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/TestColorAndFontLabelProvider.java
index 3a36c3d..4505901 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/TestColorAndFontLabelProvider.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/labelProviders/TestColorAndFontLabelProvider.java
@@ -11,13 +11,13 @@
package org.eclipse.jface.tests.labelProviders;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.widgets.Display;
-
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
/**
* TestColorAndFontLabelProvider is a simple label provider that uses fonts and
@@ -25,19 +25,19 @@ import org.eclipse.jface.viewers.LabelProvider;
* @since 3.3
*
*/
-public class TestColorAndFontLabelProvider extends LabelProvider implements
- IColorProvider, ILabelProvider {
+public class TestColorAndFontLabelProvider extends LabelProvider<TestElement> implements
+ IColorProvider<TestElement>, ILabelProvider<TestElement> {
private final Display fDisplay;
public TestColorAndFontLabelProvider(Display display) {
fDisplay= display;
}
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return fDisplay.getSystemColor(SWT.COLOR_RED);
}
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return fDisplay.getSystemColor(SWT.COLOR_BLUE);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AbstractTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AbstractTreeViewerTest.java
index 83c99bf..5c9cc82 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AbstractTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/AbstractTreeViewerTest.java
@@ -21,7 +21,7 @@ import org.eclipse.swt.widgets.Widget;
public abstract class AbstractTreeViewerTest extends StructuredItemViewerTest {
- AbstractTreeViewer fTreeViewer;
+ AbstractTreeViewer<TestElement,TestElement> fTreeViewer;
public AbstractTreeViewerTest(String name) {
super(name);
@@ -39,7 +39,7 @@ public abstract class AbstractTreeViewerTest extends StructuredItemViewerTest {
protected void assertSelectionEquals(String message, TestElement expected) {
ISelection selection = fViewer.getSelection();
assertTrue(selection instanceof IStructuredSelection);
- List expectedList = new ArrayList();
+ List<TestElement> expectedList = new ArrayList<TestElement>();
expectedList.add(expected);
IStructuredSelection structuredSelection = (IStructuredSelection)selection;
assertEquals("selectionEquals - " + message, expectedList, (structuredSelection).toList());
@@ -171,17 +171,17 @@ public abstract class AbstractTreeViewerTest extends StructuredItemViewerTest {
public void testRefreshWithAddedChildren() {
TestElement parent = fRootElement.addChild(TestModelChange.INSERT);
TestElement child = parent.addChild(TestModelChange.INSERT);
- ((AbstractTreeViewer) fViewer).setExpandedState(parent, true);
+ ((AbstractTreeViewer<TestElement,TestElement>) fViewer).setExpandedState(parent, true);
parent.deleteChild(child);
child = parent.addChild(TestModelChange.STRUCTURE_CHANGE);
// On some platforms (namely GTK), removing all children causes the
// parent to collapse (actually it's worse than that: GTK doesn't
// allow there to be an empty expanded tree item, even if you do a
- // setExpanded(true)).
+ // setExpanded(true)).
// This behaviour makes it impossible to do this regression test.
// See bug 40797 for more details.
processEvents();
- if (((AbstractTreeViewer) fViewer).getExpandedState(parent)) {
+ if (((AbstractTreeViewer<TestElement,TestElement>) fViewer).getExpandedState(parent)) {
assertNotNull("new child is visible", fViewer.testFindItem(child));
}
}
@@ -206,7 +206,7 @@ public abstract class AbstractTreeViewerTest extends StructuredItemViewerTest {
/**
* Regression test for Bug 3840 [Viewers] free expansion of jar happening when deleting projects (1GEV2FL)
* Problem was:
- * - node has children A and B
+ * - node has children A and B
* - A is expanded, B is not
* - A gets deleted
* - B gets expanded because it reused A's item
@@ -243,19 +243,19 @@ public abstract class AbstractTreeViewerTest extends StructuredItemViewerTest {
* Regression test for Bug 26698 [Viewers] stack overflow during debug session, causing IDE to crash
* Problem was:
* - node A has child A
- * - setExpanded with A in the list caused an infinite recursion
+ * - setExpanded with A in the list caused an infinite recursion
*/
public void testSetExpandedWithCycle() {
TestElement first = fRootElement.getFirstChild();
first.addChild(first, new TestModelChange(TestModelChange.INSERT,
first, first));
- fTreeViewer.setExpandedElements(new Object[] { first });
+ fTreeViewer.setExpandedElements(new TestElement[] { first });
}
/**
* Test for Bug 41710 - assertion that an object may not be added to a given
- * TreeItem more than once.
+ * TreeItem more than once.
*/
public void testSetDuplicateChild() {
//Widget root = fViewer.testFindItem(fRootElement);
@@ -269,7 +269,7 @@ public abstract class AbstractTreeViewerTest extends StructuredItemViewerTest {
assertEquals("Same element added to a parent twice.", initialCount,
postCount);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#tearDown()
*/
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java
index da40a0b..04ebdc0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug138608Test.java
@@ -24,26 +24,27 @@ import org.eclipse.swt.widgets.Composite;
/**
* Description of the bug:
* Initially tree is populated by way shown below and is completely expanded.
- *
+ *
* root
* |-a
* |-c
* |-d
* |-b
* |-c
- *
+ *
* Then 'd' model element is added as child of 'b' in model and through
* add(parent,child) method of TreeViewer to tree.
- *
+ *
* The problem - It seems that calling add(parent,child) has no desired efect.
* 'd' model element is not shown as child of 'b'!
- *
+ *
* @since 3.2
- *
+ *
*/
public class Bug138608Test extends ViewerTestCase {
private TreeContentProvider contentProvider;
+ private TreeViewer<TreeNode<String>,TreeNode<String>> treeViewer;
/**
* @param name
@@ -53,12 +54,13 @@ public class Bug138608Test extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- final TreeViewer viewer = new TreeViewer(parent);
+ final TreeViewer<TreeNode<String>,TreeNode<String>> viewer = new TreeViewer<TreeNode<String>,TreeNode<String>>(parent);
viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
contentProvider = new TreeContentProvider();
- LabelProvider labelProvider = new LabelProvider();
+ LabelProvider<TreeNode<String>> labelProvider = new LabelProvider<TreeNode<String>>();
viewer.setContentProvider(contentProvider);
viewer.setLabelProvider(labelProvider);
+ treeViewer = viewer;
return viewer;
}
@@ -75,8 +77,8 @@ public class Bug138608Test extends ViewerTestCase {
/**
* @return
*/
- private TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ private TreeViewer<TreeNode<String>,TreeNode<String>> getTreeViewer() {
+ return treeViewer;
}
public void testBug138608() {
@@ -108,41 +110,41 @@ public class Bug138608Test extends ViewerTestCase {
super.tearDown();
}
- private static class TreeContentProvider implements ITreeContentProvider {
+ private static class TreeContentProvider implements ITreeContentProvider<TreeNode<String>,TreeNode<String>> {
- public TreeNode root = new TreeNode("root");
+ public TreeNode<String> root = new TreeNode<String>("root");
public TreeContentProvider() {
- TreeNode d = new TreeNode("d");
- TreeNode c = new TreeNode("c");
- TreeNode b = new TreeNode("b");
- TreeNode a = new TreeNode("a");
+ TreeNode<String> d = new TreeNode<String>("d");
+ TreeNode<String> c = new TreeNode<String>("c");
+ TreeNode<String> b = new TreeNode<String>("b");
+ TreeNode<String> a = new TreeNode<String>("a");
// build initial hierarchy
root.setChildren(new TreeNode[] { a, b });
a.setChildren(new TreeNode[] { c, d });
b.setChildren(new TreeNode[] { c });
}
- public Object[] getChildren(Object parentElement) {
- return ((TreeNode) parentElement).getChildren();
+ public TreeNode<String>[] getChildren(TreeNode<String> parentElement) {
+ return parentElement.getChildren();
}
- public Object getParent(Object element) {
- return ((TreeNode) element).getParent();
+ public TreeNode<String> getParent(TreeNode<String> element) {
+ return element.getParent();
}
- public boolean hasChildren(Object element) {
- return ((TreeNode) element).hasChildren();
+ public boolean hasChildren(TreeNode<String> element) {
+ return element.hasChildren();
}
- public Object[] getElements(Object inputElement) {
+ public TreeNode<String>[] getElements(TreeNode<String> inputElement) {
return getChildren(inputElement);
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<TreeNode<String>> viewer, TreeNode<String> oldInput, TreeNode<String> newInput) {
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TableViewerTest.java
index 057e980..83aeefc 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TableViewerTest.java
@@ -13,6 +13,8 @@ package org.eclipse.jface.tests.viewers;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
@@ -31,16 +33,16 @@ import org.eclipse.swt.widgets.TableColumn;
*/
public class Bug180504TableViewerTest extends ViewerTestCase {
+ private TableViewer<String,List<String>> tableViewer;
/**
* @param name
*/
public Bug180504TableViewerTest(String name) {
super(name);
- // TODO Auto-generated constructor stub
}
protected StructuredViewer createViewer(Composite parent) {
- final TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION);
+ tableViewer = new TableViewer<String,List<String>>(parent, SWT.FULL_SELECTION);
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
tableViewer.getTable()) });
@@ -61,7 +63,6 @@ public class Bug180504TableViewerTest extends ViewerTestCase {
});
new TableColumn(tableViewer.getTable(), SWT.NONE).setWidth(200);
-
return tableViewer;
}
@@ -71,19 +72,20 @@ public class Bug180504TableViewerTest extends ViewerTestCase {
}
protected void setInput() {
- String[] ar = new String[100];
- for( int i = 0; i < ar.length; i++ ) {
- ar[i] = i + "";
+ List<String> ar = new ArrayList<String>(100);
+// String[] ar = new String[100];
+ for( int i = 0; i < 100; i++ ) {
+ ar.add(i, i + "");
}
getTableViewer().setInput(ar);
}
- private TableViewer getTableViewer() {
- return (TableViewer) fViewer;
+ private TableViewer<String,List<String>> getTableViewer() {
+ return tableViewer;
}
public void testBug180504ApplyEditor() {
- getTableViewer().editElement(getTableViewer().getElementAt(0), 0);
+ getTableViewer().editElement((String)getTableViewer().getElementAt(0), 0);
Method m;
try {
m = ColumnViewer.class.getDeclaredMethod("applyEditorValue", new Class[0]);
@@ -109,7 +111,7 @@ public class Bug180504TableViewerTest extends ViewerTestCase {
}
public void testBug180504CancleEditor() {
- getTableViewer().editElement(getTableViewer().getElementAt(0), 0);
+ getTableViewer().editElement((String)getTableViewer().getElementAt(0), 0);
getTableViewer().cancelEditing();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TreeViewerTest.java
index cf194e9..dea8839 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug180504TreeViewerTest.java
@@ -32,10 +32,12 @@ import org.eclipse.swt.widgets.TreeColumn;
*
*/
public class Bug180504TreeViewerTest extends ViewerTestCase {
+
+ public TreeViewer<MyModel,MyModel> treeViewer;
public class MyModel {
public MyModel parent;
- public ArrayList child = new ArrayList();
+ public ArrayList<MyModel> child = new ArrayList<MyModel>();
public int counter;
@@ -64,37 +66,38 @@ public class Bug180504TreeViewerTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- final TreeViewer treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
+ treeViewer = new TreeViewer<MyModel,MyModel>(parent, SWT.FULL_SELECTION);
- treeViewer.setContentProvider(new ITreeContentProvider() {
+ treeViewer.setContentProvider(new ITreeContentProvider<MyModel,MyModel>() {
- public Object[] getElements(Object inputElement) {
- return ((MyModel) inputElement).child.toArray();
+ public MyModel[] getElements(MyModel inputElement) {
+ MyModel[] children = new MyModel[inputElement.child.size()];
+ return inputElement.child.toArray(children);
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
+ public void inputChanged(Viewer<MyModel> viewer, MyModel oldInput,
+ MyModel newInput) {
}
- public Object[] getChildren(Object parentElement) {
+ public MyModel[] getChildren(MyModel parentElement) {
return getElements(parentElement);
}
- public Object getParent(Object element) {
+ public MyModel getParent(MyModel element) {
if (element == null) {
return null;
}
- return ((MyModel) element).parent;
+ return element.parent;
}
- public boolean hasChildren(Object element) {
- return ((MyModel) element).child.size() > 0;
+ public boolean hasChildren(MyModel element) {
+ return element.child.size() > 0;
}
});
@@ -142,12 +145,12 @@ public class Bug180504TreeViewerTest extends ViewerTestCase {
getTreeViewer().setInput(root);
}
- private TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ private TreeViewer<MyModel,MyModel> getTreeViewer() {
+ return treeViewer;
}
public void testBug201002() {
- getTreeViewer().editElement(((MyModel)((MyModel)getTreeViewer().getInput()).child.get(90)).child.get(10), 0);
+ getTreeViewer().editElement(getTreeViewer().getInput().child.get(90).child.get(10), 0);
Method m;
try {
m = ColumnViewer.class.getDeclaredMethod("applyEditorValue", new Class[0]);
@@ -172,7 +175,7 @@ public class Bug180504TreeViewerTest extends ViewerTestCase {
}
public void testBug180504CancleEditor() {
- getTreeViewer().editElement(((MyModel)((MyModel)getTreeViewer().getInput()).child.get(90)).child.get(10), 0);
+ getTreeViewer().editElement(getTreeViewer().getInput().child.get(90).child.get(10), 0);
getTreeViewer().cancelEditing();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200337TableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200337TableViewerTest.java
index 007039c..89c10b7 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200337TableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200337TableViewerTest.java
@@ -11,6 +11,9 @@
package org.eclipse.jface.tests.viewers;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellModifier;
@@ -27,16 +30,17 @@ import org.eclipse.swt.widgets.TableColumn;
*/
public class Bug200337TableViewerTest extends ViewerTestCase {
+ TableViewer<String,List<String>> tableViewer;
+
/**
* @param name
*/
public Bug200337TableViewerTest(String name) {
super(name);
- // TODO Auto-generated constructor stub
}
protected StructuredViewer createViewer(Composite parent) {
- final TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION);
+ tableViewer = new TableViewer<String,List<String>>(parent, SWT.FULL_SELECTION);
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
tableViewer.getTable()) });
@@ -66,19 +70,21 @@ public class Bug200337TableViewerTest extends ViewerTestCase {
}
protected void setInput() {
- String[] ar = new String[100];
- for( int i = 0; i < ar.length; i++ ) {
- ar[i] = i + "";
+
+ ArrayList<String> ar = new ArrayList<String>(100);
+ for( int i = 0; i < 100; i++ ) {
+ ar.add(i, i + "");
}
+
getTableViewer().setInput(ar);
}
- private TableViewer getTableViewer() {
- return (TableViewer) fViewer;
+ private TableViewer<String,List<String>> getTableViewer() {
+ return tableViewer;
}
public void testBug200337() {
- getTableViewer().editElement(getTableViewer().getElementAt(0), 0);
- getTableViewer().editElement(getTableViewer().getElementAt(90), 0);
+ getTableViewer().editElement((String)getTableViewer().getElementAt(0), 0);
+ getTableViewer().editElement((String)getTableViewer().getElementAt(90), 0);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200558Test.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200558Test.java
index 1e9a245..a0030e3 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200558Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug200558Test.java
@@ -29,22 +29,23 @@ import org.eclipse.swt.widgets.TreeColumn;
*/
public class Bug200558Test extends ViewerTestCase {
+ private TreeViewer<Object,Object> treeViewer;
+
/**
* @param name
*/
public Bug200558Test(String name) {
super(name);
- // TODO Auto-generated constructor stub
}
protected StructuredViewer createViewer(Composite parent) {
- final TreeViewer treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
- treeViewer.setContentProvider(new ITreeContentProvider() {
+ treeViewer = new TreeViewer<Object,Object>(parent, SWT.FULL_SELECTION);
+ treeViewer.setContentProvider(new ITreeContentProvider<Object,Object>() {
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput,
+ public void inputChanged(Viewer<Object> viewer, Object oldInput,
Object newInput) {
}
@@ -98,8 +99,8 @@ public class Bug200558Test extends ViewerTestCase {
getTreeViewer().getTree().getColumn(0).dispose();
}
- private TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ private TreeViewer<Object,Object> getTreeViewer() {
+ return treeViewer;
}
public void testBug200558() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TableViewerTest.java
index 337883f..b8c8688 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TableViewerTest.java
@@ -11,6 +11,9 @@
package org.eclipse.jface.tests.viewers;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellModifier;
@@ -26,7 +29,7 @@ import org.eclipse.swt.widgets.TableColumn;
*
*/
public class Bug201002TableViewerTest extends ViewerTestCase {
-
+ private TableViewer<String,List<String>> tableViewer;
/**
* @param name
*/
@@ -36,7 +39,7 @@ public class Bug201002TableViewerTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- final TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION);
+ tableViewer = new TableViewer<String,List<String>>(parent, SWT.FULL_SELECTION);
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
tableViewer.getTable()) });
@@ -66,20 +69,20 @@ public class Bug201002TableViewerTest extends ViewerTestCase {
}
protected void setInput() {
- String[] ar = new String[100];
- for( int i = 0; i < ar.length; i++ ) {
- ar[i] = i + "";
+ ArrayList<String> ar = new ArrayList<String>(100);
+ for( int i = 0; i < 100; i++ ) {
+ ar.add(i, i + "");
}
getTableViewer().setInput(ar);
}
- private TableViewer getTableViewer() {
- return (TableViewer) fViewer;
+ private TableViewer<String,List<String>> getTableViewer() {
+ return tableViewer;
}
public void testBug201002() {
getTableViewer().getTable().setTopIndex(0);
- getTableViewer().editElement(getTableViewer().getElementAt(90), 0);
+ getTableViewer().editElement((String)getTableViewer().getElementAt(90), 0);
// GTK-Issue where call to getTopItem() immediately
// afterwards will fail
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java
index 2b57d5e..796c196 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug201002TreeViewerTest.java
@@ -29,10 +29,13 @@ import org.eclipse.swt.widgets.TreeColumn;
*
*/
public class Bug201002TreeViewerTest extends ViewerTestCase {
+
+ private TreeViewer<MyModel,MyModel> treeViewer;
+
public class MyModel {
public MyModel parent;
- public ArrayList child = new ArrayList();
+ public ArrayList<MyModel> child = new ArrayList<MyModel>();
public int counter;
@@ -61,37 +64,38 @@ public class Bug201002TreeViewerTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- final TreeViewer treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
+ treeViewer = new TreeViewer<MyModel,MyModel>(parent, SWT.FULL_SELECTION);
- treeViewer.setContentProvider(new ITreeContentProvider() {
+ treeViewer.setContentProvider(new ITreeContentProvider<MyModel,MyModel>() {
- public Object[] getElements(Object inputElement) {
- return ((MyModel) inputElement).child.toArray();
+ public MyModel[] getElements(MyModel inputElement) {
+ MyModel[] children = new MyModel[inputElement.child.size()];
+ return inputElement.child.toArray(children);
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
+ public void inputChanged(Viewer<MyModel> viewer, MyModel oldInput,
+ MyModel newInput) {
}
- public Object[] getChildren(Object parentElement) {
+ public MyModel[] getChildren(MyModel parentElement) {
return getElements(parentElement);
}
- public Object getParent(Object element) {
+ public MyModel getParent(MyModel element) {
if (element == null) {
return null;
}
- return ((MyModel) element).parent;
+ return element.parent;
}
- public boolean hasChildren(Object element) {
- return ((MyModel) element).child.size() > 0;
+ public boolean hasChildren(MyModel element) {
+ return element.child.size() > 0;
}
});
@@ -138,14 +142,14 @@ public class Bug201002TreeViewerTest extends ViewerTestCase {
getTreeViewer().setInput(root);
}
- private TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ private TreeViewer<MyModel,MyModel> getTreeViewer() {
+ return treeViewer;
}
public void testBug201002() {
getTreeViewer().getTree().setTopItem(
getTreeViewer().getTree().getItem(0));
- getTreeViewer().editElement(((MyModel)((MyModel)getTreeViewer().getInput()).child.get(90)).child.get(10), 0);
+ getTreeViewer().editElement(getTreeViewer().getInput().child.get(90).child.get(10), 0);
// GTK-Issue where call to getTopItem() immediately
// afterwards will fail
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java
index 5332a50..ed61cd7 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TableViewerTest.java
@@ -12,6 +12,8 @@
package org.eclipse.jface.tests.viewers;
import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CellEditor;
@@ -31,6 +33,8 @@ import org.eclipse.swt.widgets.TableColumn;
*/
public class Bug203657TableViewerTest extends ViewerTestCase {
+ private TableViewer<String,List<String>> tableViewer;
+
/**
* @param name
*/
@@ -40,7 +44,7 @@ public class Bug203657TableViewerTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- final TableViewer tableViewer = new TableViewer(parent, SWT.FULL_SELECTION);
+ tableViewer = new TableViewer<String,List<String>>(parent, SWT.FULL_SELECTION);
tableViewer.setContentProvider(new ArrayContentProvider());
tableViewer.setCellEditors(new CellEditor[] { new TextCellEditor(
tableViewer.getTable()) });
@@ -70,22 +74,23 @@ public class Bug203657TableViewerTest extends ViewerTestCase {
}
protected void setInput() {
- String[] ar = new String[100];
- for( int i = 0; i < ar.length; i++ ) {
- ar[i] = i + "";
+
+ ArrayList<String> ar = new ArrayList<String>(100);
+ for( int i = 0; i < 100; i++ ) {
+ ar.add(i, i + "");
}
getTableViewer().setInput(ar);
}
- private TableViewer getTableViewer() {
- return (TableViewer) fViewer;
+ private TableViewer<String,List<String>> getTableViewer() {
+ return tableViewer;
}
public void testBug203657() {
try {
Field f = ColumnViewer.class.getDeclaredField("cell");
f.setAccessible(true);
- ViewerCell cell = (ViewerCell) f.get(getTableViewer());
+ ViewerCell<String> cell = (ViewerCell<String>) f.get(getTableViewer());
assertNull(cell.getElement());
assertNull(cell.getViewerRow());
assertEquals(0, cell.getColumnIndex());
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java
index b5cab34..dac528d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug203657TreeViewerTest.java
@@ -32,10 +32,13 @@ import org.eclipse.swt.widgets.TreeColumn;
*
*/
public class Bug203657TreeViewerTest extends ViewerTestCase {
+
+ private TreeViewer<MyModel,MyModel> treeViewer;
+
public class MyModel {
public MyModel parent;
- public ArrayList child = new ArrayList();
+ public ArrayList<MyModel> child = new ArrayList<MyModel>();
public int counter;
@@ -64,37 +67,38 @@ public class Bug203657TreeViewerTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- final TreeViewer treeViewer = new TreeViewer(parent, SWT.FULL_SELECTION);
+ treeViewer = new TreeViewer<MyModel,MyModel>(parent, SWT.FULL_SELECTION);
- treeViewer.setContentProvider(new ITreeContentProvider() {
+ treeViewer.setContentProvider(new ITreeContentProvider<MyModel,MyModel>() {
- public Object[] getElements(Object inputElement) {
- return ((MyModel) inputElement).child.toArray();
+ public MyModel[] getElements(MyModel inputElement) {
+ MyModel[] children = new MyModel[inputElement.child.size()];
+ return inputElement.child.toArray(children);
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
+ public void inputChanged(Viewer<MyModel> viewer, MyModel oldInput,
+ MyModel newInput) {
}
- public Object[] getChildren(Object parentElement) {
+ public MyModel[] getChildren(MyModel parentElement) {
return getElements(parentElement);
}
- public Object getParent(Object element) {
+ public MyModel getParent(MyModel element) {
if (element == null) {
return null;
}
- return ((MyModel) element).parent;
+ return element.parent;
}
- public boolean hasChildren(Object element) {
- return ((MyModel) element).child.size() > 0;
+ public boolean hasChildren(MyModel element) {
+ return element.child.size() > 0;
}
});
@@ -141,15 +145,15 @@ public class Bug203657TreeViewerTest extends ViewerTestCase {
getTreeViewer().setInput(root);
}
- private TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ private TreeViewer<MyModel,MyModel> getTreeViewer() {
+ return treeViewer;
}
public void testBug203657() {
try {
Field f = ColumnViewer.class.getDeclaredField("cell");
f.setAccessible(true);
- ViewerCell cell = (ViewerCell) f.get(getTreeViewer());
+ ViewerCell<MyModel> cell = (ViewerCell<MyModel>) f.get(getTreeViewer());
assertNull(cell.getElement());
assertNull(cell.getViewerRow());
assertEquals(0, cell.getColumnIndex());
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java
index bfcdd8d..9cbe754 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug205700TreeViewerTest.java
@@ -28,7 +28,7 @@ public class Bug205700TreeViewerTest extends TestCase {
private Shell shell;
- private TreeViewer viewer;
+ private TreeViewer<TreeNode,TreeNode> viewer;
private TreeNode rootNode;
@@ -40,13 +40,13 @@ public class Bug205700TreeViewerTest extends TestCase {
/*
* (non-Javadoc)
- *
+ *
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
shell = new Shell();
- viewer = new TreeViewer(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer = new TreeViewer<TreeNode,TreeNode>(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new InternalContentProvider());
viewer.setLabelProvider(new InternalLabelProvider());
@@ -58,7 +58,7 @@ public class Bug205700TreeViewerTest extends TestCase {
/*
* (non-Javadoc)
- *
+ *
* @see junit.framework.TestCase#tearDown()
*/
protected void tearDown() throws Exception {
@@ -76,7 +76,8 @@ public class Bug205700TreeViewerTest extends TestCase {
rootNode.add(new TreeNode("Child8"));
rootNode.add(new TreeNode("Child9"));
- viewer.add(rootNode, rootNode.getChildren().toArray());
+ TreeNode[] children = new TreeNode[rootNode.getChildren().size()];
+ viewer.add(rootNode, rootNode.getChildren().toArray(children));
assertItemNames(new String[] { "Child1", "Child5", "Child10", "Child2",
"Child3", "Child4", "Child6", "Child7", "Child8", "Child9" });
@@ -113,7 +114,8 @@ public class Bug205700TreeViewerTest extends TestCase {
rootNode.add(new TreeNode("Child8"));
rootNode.add(new TreeNode("Child9"));
- viewer.add(rootNode, rootNode.getChildren().toArray());
+ TreeNode[] children = new TreeNode[rootNode.getChildren().size()];
+ viewer.add(rootNode, rootNode.getChildren().toArray(children));
assertItemNames(new String[] { "Child1", "Child10", "Child2", "Child3",
"Child4", "Child5", "Child6", "Child7", "Child8", "Child9" });
@@ -127,13 +129,14 @@ public class Bug205700TreeViewerTest extends TestCase {
// add before the existing "Child1" node
rootNode.getChildren().add(0, new TreeNode("Child1"));
- viewer.add(rootNode, rootNode.getChildren().toArray());
+ TreeNode[] children = new TreeNode[rootNode.getChildren().size()];
+ viewer.add(rootNode, rootNode.getChildren().toArray(children));
assertItemNames(new String[] { "Child1", "Child1", "Child10",
"Child5" });
}
- private Object createInput() {
+ private TreeNode createInput() {
rootNode = new TreeNode("Root");
rootNode.add(child1);
@@ -149,7 +152,7 @@ public class Bug205700TreeViewerTest extends TestCase {
private TreeNode parent = null;
- private final List children = new ArrayList();
+ private final List<TreeNode> children = new ArrayList<TreeNode>();
public TreeNode(String name) {
this.name = name;
@@ -161,7 +164,7 @@ public class Bug205700TreeViewerTest extends TestCase {
}
}
- public List getChildren() {
+ public List<TreeNode> getChildren() {
return children;
}
@@ -178,38 +181,39 @@ public class Bug205700TreeViewerTest extends TestCase {
}
}
- private class InternalLabelProvider extends LabelProvider {
- public String getText(Object element) {
- if (element instanceof TreeNode) {
- return ((TreeNode) element).getName();
+ private class InternalLabelProvider extends LabelProvider<TreeNode> {
+ public String getText(TreeNode element) {
+ if (element != null) {
+ return element.getName();
}
return null;
}
}
- private class InternalContentProvider implements ITreeContentProvider {
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof TreeNode) {
- return ((TreeNode) parentElement).getChildren().toArray();
+ private class InternalContentProvider implements ITreeContentProvider<TreeNode,TreeNode> {
+ public TreeNode[] getChildren(TreeNode parentElement) {
+ if (parentElement != null) {
+ TreeNode[] children = new TreeNode[parentElement.getChildren().size()];
+ return parentElement.getChildren().toArray(children);
}
- return new Object[0];
+ return new TreeNode[0];
}
- public Object getParent(Object element) {
- if (element instanceof TreeNode) {
- return ((TreeNode) element).getParent();
+ public TreeNode getParent(TreeNode element) {
+ if (element != null) {
+ return element.getParent();
}
return null;
}
- public boolean hasChildren(Object element) {
- if (element instanceof TreeNode) {
- return !((TreeNode) element).getChildren().isEmpty();
+ public boolean hasChildren(TreeNode element) {
+ if (element != null) {
+ return !element.getChildren().isEmpty();
}
return false;
}
- public Object[] getElements(Object inputElement) {
+ public TreeNode[] getElements(TreeNode inputElement) {
return getChildren(inputElement);
}
@@ -217,7 +221,7 @@ public class Bug205700TreeViewerTest extends TestCase {
// nothing
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<TreeNode> viewer, TreeNode oldInput, TreeNode newInput) {
// nothing
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java
index 4a91b3d..7317609 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug256889TableViewerTest.java
@@ -30,9 +30,9 @@ public class Bug256889TableViewerTest extends ViewerTestCase {
private int rowcounter = 0;
- private List model = new ArrayList();
+ private List<String> model = new ArrayList<String>();
private Table table;
- private TableViewer tableViewer;
+ private TableViewer<String,List<String>> tableViewer;
/**
* @param name
@@ -43,9 +43,9 @@ public class Bug256889TableViewerTest extends ViewerTestCase {
}
protected StructuredViewer createViewer(Composite parent) {
- tableViewer = new TableViewer(parent, SWT.VIRTUAL | SWT.BORDER
+ tableViewer = new TableViewer<String,List<String>>(parent, SWT.VIRTUAL | SWT.BORDER
| SWT.MULTI);
- tableViewer.setContentProvider(new ILazyContentProvider() {
+ tableViewer.setContentProvider(new ILazyContentProvider<List<String>>() {
public void updateElement(int index) {
if (index >= 0 && index < tableViewer.getTable().getItemCount()) {
@@ -74,7 +74,7 @@ public class Bug256889TableViewerTest extends ViewerTestCase {
public void dispose() {
}
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+ public void inputChanged(Viewer<List<String>> arg0, List<String> arg1, List<String> arg2) {
}
});
@@ -102,7 +102,7 @@ public class Bug256889TableViewerTest extends ViewerTestCase {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#setInput()
*/
protected void setInput() {
@@ -146,7 +146,7 @@ public class Bug256889TableViewerTest extends ViewerTestCase {
return approxRecordCount;
}
- private List getModel() {
+ private List<String> getModel() {
return this.model;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java
index 889ef5a..1887c47 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug287765Test.java
@@ -29,10 +29,10 @@ import org.eclipse.swt.widgets.Shell;
/**
* @since 3.4
- *
+ *
*/
public class Bug287765Test extends TestCase {
- private TreeViewer treeViewer;
+ private TreeViewer<Node,Node> treeViewer;
private Node root;
/**
@@ -40,7 +40,7 @@ public class Bug287765Test extends TestCase {
*/
private static class Node {
private final Node parent;
- private final List children = new ArrayList();
+ private final List<Node> children = new ArrayList<Node>();
private final int level;
private Node(Node parentNode, int nodeLevel) {
@@ -54,39 +54,40 @@ public class Bug287765Test extends TestCase {
}
private final class SimpleTreeContentProvider implements
- ITreeContentProvider, ILabelProvider {
+ ITreeContentProvider<Node,Node>, ILabelProvider<Node> {
- public Image getImage(Object element) {
+ public Image getImage(Node element) {
// TODO Auto-generated method stub
return null;
}
- public String getText(Object element) {
- Node node = (Node) element;
+ public String getText(Node element) {
+ Node node = element;
return Integer.toString(node.level);
}
public void addListener(ILabelProviderListener listener) {
}
- public boolean isLabelProperty(Object element, String property) {
+ public boolean isLabelProperty(Node element, String property) {
return false;
}
public void removeListener(ILabelProviderListener listener) {
}
- public Object[] getChildren(Object parentElement) {
- Node node = (Node) parentElement;
- return node.children.toArray();
+ public Node[] getChildren(Node parentElement) {
+ Node node = parentElement;
+ Node[] children = new Node[node.children.size()];
+ return node.children.toArray(children);
}
- public boolean hasChildren(Object element) {
- Node node = (Node) element;
+ public boolean hasChildren(Node element) {
+ Node node = element;
return node.children.size() > 0;
}
- public Object[] getElements(Object inputElement) {
+ public Node[] getElements(Node inputElement) {
int depth = 4;
Node node = new Node(root, 1);
@@ -97,19 +98,17 @@ public class Bug287765Test extends TestCase {
parentNode = newNode;
}
- return new Object[] { node };
+ return new Node[] { node };
}
- public Object getParent(Object element) {
- Node node = (Node) element;
-
- return node.parent;
+ public Node getParent(Node element) {
+ return element.parent;
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<Node> viewer, Node oldInput, Node newInput) {
}
}
@@ -120,7 +119,7 @@ public class Bug287765Test extends TestCase {
shell.setLayout(new GridLayout());
shell.setSize(new Point(500, 200));
- treeViewer = new TreeViewer(shell);
+ treeViewer = new TreeViewer<Node,Node>(shell);
treeViewer.getControl().setLayoutData(
new GridData(SWT.FILL, SWT.FILL, true, true));
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug327004TreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug327004TreeViewerTest.java
new file mode 100644
index 0000000..cabaf86
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/Bug327004TreeViewerTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Copyright (c) 2006, 2011 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.jface.tests.viewers;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TreeNode;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @since 3.2
+ *
+ */
+public class Bug327004TreeViewerTest extends ViewerTestCase {
+
+ private TreeViewer<TreeNode<String>,TreeNode<String>[]> treeViewer;
+ private TreeNode<String>[] rootElements;
+
+
+ /**
+ * @param name
+ */
+ public Bug327004TreeViewerTest(String name) {
+ super(name);
+ }
+
+ protected StructuredViewer createViewer(Composite parent) {
+ treeViewer = new TreeViewer<TreeNode<String>,TreeNode<String>[]>(parent);
+ treeViewer.setContentProvider(new ITreeContentProvider<TreeNode<String>, TreeNode<String>[]>() {
+
+ public void dispose() {
+ // Do nothing
+
+ }
+
+ public void inputChanged(Viewer<TreeNode<String>[]> viewer,
+ TreeNode<String>[] oldInput, TreeNode<String>[] newInput) {
+ // Do nothing
+
+ }
+
+ public TreeNode<String>[] getElements(
+ TreeNode<String>[] inputElement) {
+ return inputElement;
+ }
+
+ public TreeNode<String>[] getChildren(TreeNode<String> parentElement) {
+ return parentElement.getChildren();
+ }
+
+ public TreeNode<String> getParent(TreeNode<String> element) {
+ return element.getParent();
+ }
+
+ public boolean hasChildren(TreeNode<String> element) {
+ return element.hasChildren();
+ }
+ });
+ return treeViewer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.viewers.ViewerTestCase#setUpModel()
+ */
+ @Override
+ protected void setUpModel() {
+ rootElements= new TreeNode[5];
+ rootElements[0]= new TreeNode<String>("0");
+ rootElements[1]= new TreeNode<String>("1");
+ rootElements[2]= new TreeNode<String>("1");
+ rootElements[3]= new TreeNode<String>("1");
+ rootElements[4]= new TreeNode<String>("1");
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.tests.viewers.ViewerTestCase#setInput()
+ */
+ @Override
+ protected void setInput() {
+ treeViewer.setInput(rootElements);
+ }
+
+ public void test327004() {
+
+
+ ViewerFilter<TreeNode<String>,TreeNode<String>[]> filter= new ViewerFilter<TreeNode<String>,TreeNode<String>[]>() {
+ public boolean select(Viewer<TreeNode<String>[]> viewer, Object parentElement, TreeNode<String> element) {
+ if (element == rootElements[0] || element == rootElements[1] || element == rootElements[2] || element == rootElements[4])
+ return false;
+ return true;
+ }
+ };
+ treeViewer.addFilter(filter);
+ int i= treeViewer.getTree().getItemCount();
+
+ assertEquals(4, i); // 4 because the filter doesn't work due to equal nodes
+ }
+
+}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CComboViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CComboViewerTest.java
index fe7b581..9c48aec 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CComboViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CComboViewerTest.java
@@ -24,9 +24,9 @@ public class CComboViewerTest extends StructuredViewerTest {
super(name);
}
- protected StructuredViewer createViewer(Composite parent) {
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
CCombo cCombo = new CCombo(parent, SWT.READ_ONLY | SWT.BORDER);
- ComboViewer viewer = new ComboViewer(cCombo);
+ ComboViewer<TestElement,TestElement> viewer = new ComboViewer<TestElement,TestElement>(cCombo);
viewer.setContentProvider(new TestModelContentProvider());
return viewer;
}
@@ -47,7 +47,7 @@ public class CComboViewerTest extends StructuredViewerTest {
}
/**
- * TODO: Determine if this test is applicable to ComboViewer
+ * TODO: Determine if this test is applicable to ComboViewer
*/
public void testInsertChild() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java
index bae8bbf..2346b39 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTableViewerTest.java
@@ -33,23 +33,23 @@ import org.eclipse.swt.widgets.TableItem;
public class CheckboxTableViewerTest extends TableViewerTest {
public static class CheckboxTableTestLabelProvider extends
- TestLabelProvider implements ITableLabelProvider {
+ TestLabelProvider implements ITableLabelProvider<TestElement> {
public boolean fExtended = false;
- public String getText(Object element) {
+ public String getText(TestElement element) {
if (fExtended)
- return providedString((String) element);
+ return providedString(element);
return element.toString();
}
- public String getColumnText(Object element, int index) {
+ public String getColumnText(TestElement element, int index) {
if (fExtended)
- return providedString((TestElement) element);
+ return providedString(element);
return element.toString();
}
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
}
@@ -57,10 +57,10 @@ public class CheckboxTableViewerTest extends TableViewerTest {
public DeprecatedConstructor(String name) {
super(name);
}
-
- protected StructuredViewer createViewer(Composite parent) {
+
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
TableViewer viewer = new CheckboxTableViewer(parent);
-
+
Table table = viewer.getTable();
table.setLinesVisible(true);
TableLayout layout = new TableLayout();
@@ -86,7 +86,7 @@ public class CheckboxTableViewerTest extends TableViewerTest {
viewer.setLabelProvider(new TableTestLabelProvider());
return viewer;
}
-
+
public void testViewerColumn() {
assertNull(getViewerColumn((TableViewer) fViewer, -1));
assertNotNull(getViewerColumn((TableViewer) fViewer, 0));
@@ -97,15 +97,15 @@ public class CheckboxTableViewerTest extends TableViewerTest {
assertNull(getViewerColumn((TableViewer) fViewer, 3));
}
}
-
+
public static class FactoryMethod extends CheckboxTableViewerTest {
public FactoryMethod(String name) {
super(name);
}
-
+
protected StructuredViewer createViewer(Composite parent) {
TableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.NONE);
-
+
Table table = viewer.getTable();
table.setLinesVisible(true);
TableLayout layout = new TableLayout();
@@ -230,20 +230,20 @@ public class CheckboxTableViewerTest extends TableViewerTest {
ctv.setAllGrayed(false);
}
-
+
public void testWithoutCheckProvider() {
//Check that without a provider, no exceptions are thrown
CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
ctv.refresh();
}
-
+
public void testCheckProviderInvoked() {
//Check that a refresh successfully causes the provider's
//setChecked and setGrayed methods to be invoked.
CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();
-
+
ctv.setCheckStateProvider(provider);
assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
@@ -253,109 +253,109 @@ public class CheckboxTableViewerTest extends TableViewerTest {
assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
}
-
+
public void testCheckedFalseGrayedFalse() {
testSpecificState(false, false);
}
-
+
public void testCheckedFalseGrayedTrue() {
testSpecificState(false, true);
}
-
+
public void testCheckedTrueGrayedFalse() {
testSpecificState(true, false);
}
-
+
public void testCheckedTrueGrayedTrue() {
testSpecificState(true, true);
}
-
+
private void testSpecificState(final boolean isChecked, final boolean isGrayed) {
CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
-
+
ctv.setCheckStateProvider(new ICheckStateProvider() {
public boolean isChecked(Object element) { return isChecked; }
public boolean isGrayed(Object element) { return isGrayed; }
});
-
+
TableItem item = ctv.getTable().getItem(0);
-
+
assertEquals(item.getChecked(), isChecked);
assertEquals(item.getGrayed(), isGrayed);
}
-
+
public void testSetCheckProviderRefreshesItems() {
CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
-
+
//First provider
//Should cause visible items' check state to adhere to provider
ctv.setCheckStateProvider(new TestCheckStateProvider(0));
-
+
//Check that all states are properly set
checkAllStates("Testing checkbox state after refresh", ctv, 0);
-
+
//Remove the check state provider
ctv.setCheckStateProvider(null);
-
+
//Test that an update doesn't fail
TestElement update = fRootElement.getChildAt(5);
ctv.update(update, null);
-
+
//Test that a refresh doesn't fail
ctv.refresh();
}
-
+
public void testCheckProviderWithSorter() {
CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
-
+
ctv.setSorter(new CheckStateProviderTestsUtil.Sorter());
-
+
//First provider
//Should cause visible items' check state adhere to provider
ctv.setCheckStateProvider(new TestCheckStateProvider(0));
-
+
//Check that all states are properly set
checkAllStates("Testing checkbox state with a sorter", ctv, 0);
}
-
+
public void testCheckProviderWithFilter() {
CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
-
+
final CheckStateProviderTestsUtil.Filter filter = new CheckStateProviderTestsUtil.Filter();
ctv.addFilter(filter);
-
+
//First provider
//Should cause visible items' check state adhere to provider
final TestCheckStateProvider checkStateProvider = new TestCheckStateProvider(0);
ctv.setCheckStateProvider(checkStateProvider);
-
+
//Check that all states are properly set
checkAllStates("Testing checkbox state with a sorter", ctv, 0);
-
+
//Check that the provider is only invoked on elements which pass the filter
for (Iterator i = checkStateProvider.isCheckedInvokedOn.iterator(); i.hasNext();) {
TestElement element = (TestElement) i.next();
assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
}
-
+
for (Iterator i = checkStateProvider.isGrayedInvokedOn.iterator(); i.hasNext();) {
TestElement element = (TestElement) i.next();
assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
}
}
-
+
public void testCheckProviderUpdate() {
CheckboxTableViewer ctv = (CheckboxTableViewer)fViewer;
-
+
//First provider
//Should cause visible items' check state to adhere to provider
ctv.setCheckStateProvider(new TestCheckStateProvider(0));
-
+
checkAllStates("Testing checkbox state after refresh", ctv, 0);
-
+
//Put in a new check state provider
ctv.setCheckStateProvider(new TestCheckStateProvider(1));
-
+
//Check that setting a new check provider caused a refresh,
//and thus all the items have their new appropriate check
//states.
@@ -364,17 +364,17 @@ public class CheckboxTableViewerTest extends TableViewerTest {
private void checkAllStates(String comment, CheckboxTableViewer ctv, int shift) {
TableItem[] items = ctv.getTable().getItems();
-
+
//Check that actual states were set properly
for (int i = 0; i < items.length; i++) {
TableItem item = items[i];
TestElement element = (TestElement)items[i].getData();
-
+
checkState(comment, element, item, shift); //check in Table
checkState(comment, element, ctv, shift); //check in Viewer
}
}
-
+
/**
* Invokes the appropriate asserts to verify the state
* of a TestElement.
@@ -386,7 +386,7 @@ public class CheckboxTableViewerTest extends TableViewerTest {
assertEquals(comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), viewer.getChecked(te));
assertEquals(comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), viewer.getGrayed(te));
}
-
+
/**
* Invokes the appropriate asserts to verify the state
* of a TestElement's associated TableItem
@@ -398,41 +398,41 @@ public class CheckboxTableViewerTest extends TableViewerTest {
assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), item.getChecked());
assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), item.getGrayed());
}
-
+
public void testGetCheckedElements() {
CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
List checked = new ArrayList((children.length + 1) / 2);
-
+
for (int i = 0; i < children.length; i+=2) {
ctv.setChecked(children[i], true);
checked.add(children[i]);
}
-
+
Object[] actuallyChecked = ctv.getCheckedElements();
-
+
for (int i = 0; i < actuallyChecked.length; i++) {
assertTrue("getCheckedElements should include all checked elements", checked.remove(actuallyChecked[i]));
}
-
+
assertTrue("getCheckedElements should not include any unchecked elements", checked.isEmpty());
}
-
+
public void testSetCheckedElements() {
CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
List toCheck = new ArrayList((children.length + 1) / 2);
-
+
for (int i = 0; i < children.length; i+=2) {
toCheck.add(children[i]);
}
-
+
ctv.setCheckedElements(toCheck.toArray());
-
+
for (int i = 0; i < children.length; i++) {
if(i % 2 == 0) {
assertTrue("an element passed through setCheckedElements should be checked", ctv.getChecked(children[i]));
@@ -441,20 +441,20 @@ public class CheckboxTableViewerTest extends TableViewerTest {
}
}
}
-
+
public void testSetGrayedElements() {
CheckboxTableViewer ctv = (CheckboxTableViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
List toGray = new ArrayList((children.length + 1) / 2);
-
+
for (int i = 0; i < children.length; i+=2) {
toGray.add(children[i]);
}
-
+
ctv.setGrayedElements(toGray.toArray());
-
+
for (int i = 0; i < children.length; i++) {
if(i % 2 == 0) {
assertTrue("an element passed through setGrayedElements should be grayed", ctv.getGrayed(children[i]));
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerMissingTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerMissingTest.java
index a49f3c5..57ccea8 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerMissingTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerMissingTest.java
@@ -30,13 +30,13 @@ public class CheckboxTreeViewerMissingTest extends CheckboxTreeViewerTest {
public static class CheckboxMissingTableTestLabelProvider extends
CheckboxTreeViewerTest.CheckboxTableTestLabelProvider implements
- ITableLabelProvider {
+ ITableLabelProvider<TestElement> {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest.TestLabelProvider#getImage(java.lang.Object)
*/
- public Image getImage(Object element) {
+ public Image getImage(TestElement element) {
return getMissingImage();
}
@@ -50,13 +50,13 @@ public class CheckboxTreeViewerMissingTest extends CheckboxTreeViewerTest {
* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#getTestLabelProvider()
*/
- public IBaseLabelProvider getTestLabelProvider() {
+ public IBaseLabelProvider<TestElement> getTestLabelProvider() {
return new CheckboxMissingTableTestLabelProvider();
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#tearDown()
*/
public void tearDown() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java
index e3d2b58..dee3ca0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/CheckboxTreeViewerTest.java
@@ -27,23 +27,23 @@ import org.eclipse.swt.widgets.TreeItem;
public class CheckboxTreeViewerTest extends TreeViewerTest {
public static class CheckboxTableTestLabelProvider extends
- TestLabelProvider implements ITableLabelProvider {
+ TestLabelProvider implements ITableLabelProvider<TestElement> {
public boolean fExtended = false;
- public String getText(Object element) {
+ public String getText(TestElement element) {
if (fExtended)
- return providedString((String) element);
+ return providedString(element);
return element.toString();
}
- public String getColumnText(Object element, int index) {
+ public String getColumnText(TestElement element, int index) {
if (fExtended)
return providedString((TestElement) element);
return element.toString();
}
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
}
@@ -114,44 +114,44 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
assertTrue(elements[2] == firstfirstfirst);
ctv.setParentsGrayed(firstfirstfirst, false);
}
-
+
public void testWithoutCheckProvider() {
//Check that without a provider, no exceptions are thrown
CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
ctv.expandAll();
ctv.refresh();
}
-
+
public void testCheckProviderInvoked() {
//Check that a refresh successfully causes the provider's
//setChecked and setGrayed methods to be invoked.
CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
-
+
TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();
-
+
ctv.setCheckStateProvider(provider);
assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
-
+
provider.reset();
ctv.refresh();
assertTrue("isChecked should be invoked on a refresh", (!provider.isCheckedInvokedOn.isEmpty()));
assertTrue("isGrayed should be invoked on a refresh", (!provider.isGrayedInvokedOn.isEmpty()));
}
-
+
public void testCheckProviderLazilyInvoked() {
//Check that a refresh successfully causes the provider's
//setChecked and setGrayed methods to be invoked.
CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
-
+
TestMethodsInvokedCheckStateProvider provider = new TestMethodsInvokedCheckStateProvider();
-
+
ctv.setCheckStateProvider(provider);
ctv.refresh();
-
+
TestElement[] expected = fRootElement.getChildren();
-
+
for (Iterator i = provider.isCheckedInvokedOn.iterator(); i.hasNext();) {
TestElement element = (TestElement) i.next();
boolean firstLevelElement = false;
@@ -160,7 +160,7 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
}
assertTrue("The check provider should only be invoked with visible elements", firstLevelElement);
}
-
+
for (Iterator i = provider.isGrayedInvokedOn.iterator(); i.hasNext();) {
TestElement element = (TestElement) i.next();
boolean firstLevelElement = false;
@@ -170,95 +170,95 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
assertTrue("The check provider should only be invoked with visible elements", firstLevelElement);
}
}
-
+
public void testCheckedFalseGrayedFalse() {
testSpecificState(false, false);
}
-
+
public void testCheckedFalseGrayedTrue() {
testSpecificState(false, true);
}
-
+
public void testCheckedTrueGrayedFalse() {
testSpecificState(true, false);
}
-
+
public void testCheckedTrueGrayedTrue() {
testSpecificState(true, true);
}
-
+
private void testSpecificState(final boolean isChecked, final boolean isGrayed) {
CheckboxTreeViewer ctv = (CheckboxTreeViewer)fViewer;
-
+
ctv.setCheckStateProvider(new ICheckStateProvider() {
public boolean isChecked(Object element) { return isChecked; }
public boolean isGrayed(Object element) { return isGrayed; }
});
-
+
TreeItem item = ctv.getTree().getItem(0);
-
+
assertEquals(item.getChecked(), isChecked);
assertEquals(item.getGrayed(), isGrayed);
}
-
+
public void testSetCheckProviderRefreshesItems() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
//First provider
//Should cause visible items' check state adhere to provider
ctv.setCheckStateProvider(new TestCheckStateProvider(0));
-
+
ctv.expandAll();
-
+
//Check that all states are properly set
checkAllStates("Testing checkbox state after refresh", ctv, 0);
-
+
//Remove the check state provider
ctv.setCheckStateProvider(null);
-
+
//Test that an update doesn't fail
TestElement update = fRootElement.getFirstChild().getChildAt(5);
ctv.update(update, null);
-
+
//Test that a refresh doesn't fail
ctv.refresh();
}
-
+
public void testCheckProviderWithSorter() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
ctv.setSorter(new CheckStateProviderTestsUtil.Sorter());
-
+
//First provider
//Should cause visible items' check state adhere to provider
ctv.setCheckStateProvider(new TestCheckStateProvider(0));
ctv.expandAll();
-
+
//Check that all states are properly set
checkAllStates("Testing checkbox state with a sorter", ctv, 0);
}
-
+
public void testCheckProviderWithFilter() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
final CheckStateProviderTestsUtil.Filter filter = new CheckStateProviderTestsUtil.Filter();
ctv.addFilter(filter);
-
+
//First provider
//Should cause visible items' check state adhere to provider
final TestCheckStateProvider checkStateProvider = new TestCheckStateProvider(0);
ctv.setCheckStateProvider(checkStateProvider);
ctv.expandAll();
-
+
//Check that all states are properly set
checkAllStates("Testing checkbox state with a sorter", ctv, 0);
-
+
//Check that the provider is only invoked on elements which pass the filter
for (Iterator i = checkStateProvider.isCheckedInvokedOn.iterator(); i.hasNext();) {
TestElement element = (TestElement) i.next();
assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
}
-
+
for (Iterator i = checkStateProvider.isGrayedInvokedOn.iterator(); i.hasNext();) {
TestElement element = (TestElement) i.next();
assertTrue("The check provider should not be invoked on elements which did not get through the filter", filter.select(ctv, null, element));
@@ -267,23 +267,23 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
public void testSetNewCheckProvider() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
//First provider
//Should cause visible items' check state to adhere to provider
ctv.setCheckStateProvider(new TestCheckStateProvider(0));
ctv.expandAll();
-
+
checkAllStates("Testing checkbox state after first refresh", ctv, 0);
-
+
//Put in a new check state provider
ctv.setCheckStateProvider(new TestCheckStateProvider(1));
-
+
//Check that setting a new check provider caused a refresh,
//and thus all the items have their new appropriate check
//states.
checkAllStates("Testing checkbox state after setting new check provider", ctv, 1);
}
-
+
private void collectElementsInBranch(TreeItem item, Collection treeItems, Collection testElements) {
treeItems.add(item);
testElements.add(item.getData());
@@ -292,22 +292,22 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
collectElementsInBranch(children[i], treeItems, testElements);
}
}
-
+
private void checkAllStates(String comment, CheckboxTreeViewer ctv, int shift) {
List items = new ArrayList();
List elements = new ArrayList();
collectElementsInBranch(ctv.getTree().getItem(0), items, elements);
-
+
//Check that actual states were set properly
for (Iterator i = items.iterator(), j = elements.iterator(); i.hasNext();) {
TreeItem item = (TreeItem)i.next();
TestElement element = (TestElement)j.next();
-
+
checkState(comment, element, item, shift); //check in Tree
checkState(comment, element, ctv, shift); //check in Viewer
}
}
-
+
/**
* Invokes the appropriate asserts to verify the state
* of a TestElement.
@@ -319,7 +319,7 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
assertEquals(comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), viewer.getChecked(te));
assertEquals(comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), viewer.getGrayed(te));
}
-
+
/**
* Invokes the appropriate asserts to verify the state
* of a TestElement's associated TreeItem
@@ -331,41 +331,41 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeChecked(te, shift), item.getChecked());
assertEquals("Wrong checkstate: " + comment, CheckStateProviderTestsUtil.shouldBeGrayed(te, shift), item.getGrayed());
}
-
+
public void testGetCheckedElements() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
List checked = new ArrayList((children.length + 1) / 2);
-
+
for (int i = 0; i < children.length; i+=2) {
ctv.setChecked(children[i], true);
checked.add(children[i]);
}
-
+
Object[] actuallyChecked = ctv.getCheckedElements();
-
+
for (int i = 0; i < actuallyChecked.length; i++) {
assertTrue("getCheckedElements should include all checked elements", checked.remove(actuallyChecked[i]));
}
-
+
assertTrue("getCheckedElements should not include any unchecked elements", checked.isEmpty());
}
public void testSetCheckedElements() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
List toCheck = new ArrayList((children.length + 1) / 2);
-
+
for (int i = 0; i < children.length; i+=2) {
toCheck.add(children[i]);
}
-
+
ctv.setCheckedElements(toCheck.toArray());
-
+
for (int i = 0; i < children.length; i++) {
if(i % 2 == 0) {
assertTrue("an element passed through setCheckedElements should be checked", ctv.getChecked(children[i]));
@@ -374,20 +374,20 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
}
}
}
-
+
public void testSetGrayedElements() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
List toGray = new ArrayList((children.length + 1) / 2);
-
+
for (int i = 0; i < children.length; i+=2) {
toGray.add(children[i]);
}
-
+
ctv.setGrayedElements(toGray.toArray());
-
+
for (int i = 0; i < children.length; i++) {
if(i % 2 == 0) {
assertTrue("an element passed through setGrayedElements should be grayed", ctv.getGrayed(children[i]));
@@ -396,37 +396,37 @@ public class CheckboxTreeViewerTest extends TreeViewerTest {
}
}
}
-
+
public void testSetAllChecked() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
ctv.expandToLevel(2);
-
+
ctv.setAllChecked(true);
Object[] expandedElements = ctv.getExpandedElements();
-
+
for (int i = 0; i < expandedElements.length; i++) {
assertTrue("all expanded items should be checked", ctv.getChecked(expandedElements[i]));
}
-
+
ctv.setAllChecked(false);
-
+
for (int i = 0; i < expandedElements.length; i++) {
assertFalse("all expanded items should be unchecked", ctv.getChecked(expandedElements[i]));
}
}
-
+
public void testSetGrayChecked() {
CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer;
-
+
TestElement[] children = fRootElement.getChildren();
-
+
ctv.setGrayChecked(children[0], true);
ctv.setGrayChecked(children[1], false);
-
+
assertTrue("an item invoked with setGrayChecked(true) should be checked", ctv.getChecked(children[0]));
assertTrue("an item invoked with setGrayChecked(true) should be grayed", ctv.getGrayed(children[0]));
-
+
assertFalse("an item invoked with setGrayChecked(false) should be unchecked", ctv.getChecked(children[1]));
assertFalse("an item invoked with setGrayChecked(false) should not be grayed", ctv.getGrayed(children[1]));
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java
index c45cc99..c191335 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerComparerTest.java
@@ -32,7 +32,7 @@ public class ComboViewerComparerTest extends TestCase {
private Shell shell;
- private StructuredViewer viewer;
+ private StructuredViewer<TestElement,TestElement[]> viewer;
private static final class TestElement {
@@ -107,8 +107,8 @@ public class ComboViewerComparerTest extends TestCase {
}
}
- protected StructuredViewer createViewer(final Shell parent) {
- return new ComboViewer(parent, SWT.NONE);
+ protected StructuredViewer<TestElement,TestElement[]> createViewer(final Shell parent) {
+ return new ComboViewer<TestElement,TestElement[]>(parent, SWT.NONE);
}
private void processEvents() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerTest.java
index c2a5cb1..a7af5af 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ComboViewerTest.java
@@ -23,8 +23,8 @@ public class ComboViewerTest extends StructuredViewerTest {
super(name);
}
- protected StructuredViewer createViewer(Composite parent) {
- ComboViewer viewer = new ComboViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ ComboViewer<TestElement,TestElement> viewer = new ComboViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
return viewer;
}
@@ -45,7 +45,7 @@ public class ComboViewerTest extends StructuredViewerTest {
}
/**
- * TODO: Determine if this test is applicable to ComboViewer
+ * TODO: Determine if this test is applicable to ComboViewer
*/
public void testInsertChild() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java
index efdc29b..5740cfe 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/LazySortedCollectionTest.java
@@ -25,22 +25,22 @@ import org.eclipse.jface.viewers.deferred.LazySortedCollection;
* @since 3.1
*/
public class LazySortedCollectionTest extends TestCase {
-
+
public static void main(String[] args) {
junit.textui.TestRunner.run(LazySortedCollectionTest.class);
}
-
+
public static Test suite() {
return new TestSuite(LazySortedCollectionTest.class);
}
-
+
private TestComparator comparator;
private TestComparator comparisonComparator;
-
+
// All operations will be done on both collections -- after each operation, the result
// will be compared
private LazySortedCollection collection;
- private TreeSet comparisonCollection;
+ private TreeSet<Object> comparisonCollection;
/**
* Please don't add or remove from this set -- we rely on the exact insertion order
@@ -75,9 +75,9 @@ public class LazySortedCollectionTest extends TestCase {
"v25 yellow",
"v26 zero"
};
-
+
/**
- * Please don't mess with the insertion order here or add or remove from this set --
+ * Please don't mess with the insertion order here or add or remove from this set --
* we rely on the exact order in order to get full coverage for the removal tests.
*/
private String[] elements = new String[] {
@@ -107,35 +107,35 @@ public class LazySortedCollectionTest extends TestCase {
se[12],
se[13],
se[14],
- se[2]
+ se[2]
};
-
+
public static void printArray(Object[] array) {
for (int i = 0; i < array.length; i++) {
System.out.println("[" + i + "] = " + array[i]);
}
}
-
+
/* (non-Javadoc)
* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
System.out.println("--- " + getName());
-
+
comparator = new TestComparator();
collection = new LazySortedCollection(comparator);
// Ensure a predictable tree structure
collection.enableDebug = true;
-
+
comparisonComparator = new TestComparator();
- comparisonCollection = new TreeSet(comparisonComparator);
-
+ comparisonCollection = new TreeSet<Object>(comparisonComparator);
+
addAll(elements);
-
+
super.setUp();
}
-
+
/* (non-Javadoc)
* @see junit.framework.TestCase#tearDown()
*/
@@ -143,14 +143,14 @@ public class LazySortedCollectionTest extends TestCase {
System.out.println("Comparisons required by lazy collection: " + comparator.comparisons);
System.out.println("Comparisons required by reference implementation: " + comparisonComparator.comparisons);
System.out.println("");
-
+
super.tearDown();
}
-
+
/**
* Computes the entries that are expected to lie in the given range. The result
* is sorted.
- *
+ *
* @param start
* @param length
* @return
@@ -158,18 +158,18 @@ public class LazySortedCollectionTest extends TestCase {
*/
private Object[] computeExpectedElementsInRange(int start, int length) {
int counter = 0;
-
- Iterator iter = comparisonCollection.iterator();
+
+ Iterator<Object> iter = comparisonCollection.iterator();
while(iter.hasNext() && counter < start) {
iter.next();
counter++;
}
-
+
Object[] result = new Object[length];
for (int i = 0; i < result.length; i++) {
- result[i] = iter.next();
+ result[i] = iter.next();
}
-
+
return result;
}
@@ -177,20 +177,20 @@ public class LazySortedCollectionTest extends TestCase {
collection.addAll(elements);
comparisonCollection.addAll(Arrays.asList(elements));
}
-
+
private void add(Object toAdd) {
collection.add(toAdd);
comparisonCollection.add(toAdd);
}
-
+
private void remove(Object toRemove) {
collection.remove(toRemove);
comparisonCollection.remove(toRemove);
}
-
+
private void removeRange(int start, int length) {
collection.removeRange(start, length);
-
+
Object[] expected = computeExpectedElementsInRange(start, length);
// Alternative remove implementation that removes one-at-a-time
@@ -198,44 +198,44 @@ public class LazySortedCollectionTest extends TestCase {
comparisonCollection.remove(expected[i]);
}
}
-
+
private void clear() {
collection.clear();
comparisonCollection.clear();
}
-
+
/**
* Force the collection to sort all elements immediately.
- *
+ *
* @since 3.1
*/
private void forceFullSort() {
queryRange(0, elements.length, true);
}
-
+
private void assertContentsValid() {
queryRange(0, comparisonCollection.size(), false);
Assert.assertEquals(comparisonCollection.size(), collection.size());
Assert.assertEquals(comparisonCollection.isEmpty(), collection.isEmpty());
}
-
+
private void assertIsPermutation(Object[] array1, Object[] array2) {
Object[] sorted1 = new Object[array1.length];
System.arraycopy(array1, 0, sorted1, 0, array1.length);
Arrays.sort(sorted1, new TestComparator());
-
+
Object[] sorted2 = new Object[array2.length];
System.arraycopy(array2, 0, sorted2, 0, array2.length);
Arrays.sort(sorted2, new TestComparator());
-
+
assertArrayEquals(sorted1, sorted2);
}
/**
- * Queries the collection for the given range, and throws an assertation failure if the
+ * Queries the collection for the given range, and throws an assertation failure if the
* result was unexpected. Assumes that the "elements" array was initially added and that nothing
* has been added or removed since.
- *
+ *
* @param start
* @param length
* @param sorted
@@ -243,13 +243,13 @@ public class LazySortedCollectionTest extends TestCase {
*/
private Object[] queryRange(int start, int length, boolean sorted) {
Object[] result = new Object[length];
-
+
int returnValue = collection.getRange(result, start, sorted);
-
+
Assert.assertEquals(returnValue, length);
-
+
Object[] expectedResult = computeExpectedElementsInRange(start, length);
-
+
if (sorted) {
// If the result is supposed to be sorted, it will match the expected
// result exactly
@@ -259,46 +259,46 @@ public class LazySortedCollectionTest extends TestCase {
// expected result.
assertIsPermutation(result, expectedResult);
}
-
+
collection.testInvariants();
-
+
return result;
}
-
+
private void assertArrayEquals(Object[] array1, Object[] array2) {
for (int i = 0; i < array1.length; i++) {
Assert.assertEquals(array1[i], array2[i]);
- }
+ }
}
-
+
public void testComparisonCount() {
Assert.assertTrue("additions should not require any comparisons", comparator.comparisons == 0);
-
+
queryRange(0, elements.length, false);
Assert.assertTrue("requesting the complete set of unsorted elements should not require any comparisons", comparator.comparisons == 0);
}
-
+
/**
* Ensure that no comparisons are required for range queries once the collection is fully sorted
- *
+ *
* @since 3.1
*/
public void testSortAll() {
// Test that sorting the entire array works
queryRange(0, elements.length, true);
-
+
int comparisons = comparator.comparisons;
-
+
// Ensure that subsequent operations require no comparisons
queryRange(elements.length - 10, 10, true);
queryRange(0, 10, false);
-
- Assert.assertEquals("Once the lazy collection is fully sorted, it should not require further comparisons",
+
+ Assert.assertEquals("Once the lazy collection is fully sorted, it should not require further comparisons",
comparisons, comparator.comparisons);
}
-
+
/**
* Tests LazySortedCollection.removeNode(int) when removing a leaf node
*/
@@ -319,7 +319,7 @@ public class LazySortedCollectionTest extends TestCase {
/**
* Tests LazySortedCollection.removeNode(int) when removing a node with no right child
- *
+ *
* @since 3.1
*/
public void testRemoveNodeWithNoRightChild() {
@@ -327,10 +327,10 @@ public class LazySortedCollectionTest extends TestCase {
remove(se[13]);
assertContentsValid();
}
-
+
/**
* Tests LazySortedCollection.remove when removing the root node
- *
+ *
* @since 3.1
*/
public void testRemoveRootNode() {
@@ -343,7 +343,7 @@ public class LazySortedCollectionTest extends TestCase {
* Tests LazySortedCollection.remove when the removal
* will require swapping with a non-leaf node. (The descendent with the closest value
* in the largest subtree has at least 1 child).
- *
+ *
* @since 3.1
*/
public void testRemoveWhereSwappedNodeIsntLeaf() {
@@ -351,74 +351,74 @@ public class LazySortedCollectionTest extends TestCase {
remove(se[14]);
assertContentsValid();
}
-
+
/**
* Tests LazySortedCollection.remove when the removal
* will require swapping with a non-leaf node, and both the removed node and the swapped
* node contain unsorted children.
- *
+ *
* @since 3.1
*/
public void testRemoveWithUnsortedSwap() {
- // Ensure that we've sorted nodes 13 and 14
+ // Ensure that we've sorted nodes 13 and 14
queryRange(14, 1, true);
queryRange(13, 1, true);
-
+
// Add some unsorted nodes that will become children of the node with value "v13 mongoose"
addAll(new String[] {"v13 n", "v13 l"});
// Ensure that the new nodes are pushed down to node 14 by querying its parent (currently at position 8)
queryRange(8, 1, true);
-
- // Add some unsorted nodes that will become children of the node with value "v14 noodle"
+
+ // Add some unsorted nodes that will become children of the node with value "v14 noodle"
addAll(new String[] {"v14 m", "v14 o"});
- // Push down the unsorted nodes by querying for the parent of "v14 noodle"
- // (the parent is currently at position 7)
+ // Push down the unsorted nodes by querying for the parent of "v14 noodle"
+ // (the parent is currently at position 7)
queryRange(7, 1, true);
-
+
// Now remove node with value "v14 noodle" -- this should swap it with the node "v13 mongoose", requiring
// both sets of unsorted children to be dealt with
-
+
remove(se[14]);
assertContentsValid();
}
-
+
/**
* Remove an element from an initially unsorted collection
- *
+ *
* @since 3.1
*/
public void testRemoveFromUnsorted() {
remove(se[10]);
assertContentsValid();
}
-
+
/**
* Remove the root from an initially-unsorted collection
- *
+ *
* @since 3.1
*/
public void testRemoveRootFromUnsorted() {
remove(se[19]);
assertContentsValid();
}
-
+
/**
* Ensure that removing an element that isn't in the collection is a no-op
- *
+ *
* @since 3.1
*/
public void testRemoveUnknown() {
remove("some unknown element");
assertContentsValid();
}
-
+
/**
* Tests that the swaps during removal don't mess up the internal hashmap.
* Perform a removal that will require a swap, add a new item, then
* remove the item that was previously swapped. If the hashmap was not updated,
- * then the removed item may still be pointing to its old index and the
- * new item will be removed instead.
- *
+ * then the removed item may still be pointing to its old index and the
+ * new item will be removed instead.
+ *
* @since 3.1
*/
public void testRemovePreviouslySwappedNode() {
@@ -430,30 +430,30 @@ public class LazySortedCollectionTest extends TestCase {
remove(se[13]);
assertContentsValid();
}
-
+
/**
* Remove all nodes using removeRange
- *
+ *
* @since 3.1
*/
public void testRemoveFullRange() {
removeRange(0, se.length);
assertContentsValid();
}
-
+
/**
* Remove a range that includes the start
- *
+ *
* @since 3.1
*/
public void testRemoveFromStart() {
removeRange(0, se.length / 2);
assertContentsValid();
}
-
+
/**
* Remove a range that includes the last node
- *
+ *
* @since 3.1
*/
public void testRemoveFromEnd() {
@@ -461,20 +461,20 @@ public class LazySortedCollectionTest extends TestCase {
removeRange(start, se.length - start);
assertContentsValid();
}
-
+
/**
* Remove a range that includes the root, but leaves nodes in both subtrees intact.
- *
+ *
* @since 3.1
*/
public void testRemoveIncludingRoot() {
removeRange(14, 6);
assertContentsValid();
}
-
+
/**
- * Test boundary conditions:
- *
+ * Test boundary conditions:
+ *
* Tests moving an entire right subtree, and a left subtree including the tree itself
*/
public void testRemoveRightSubtree() {
@@ -497,29 +497,29 @@ public class LazySortedCollectionTest extends TestCase {
removeRange(3, 5);
assertContentsValid();
}
-
+
public void testClear() {
clear();
assertContentsValid();
}
-
+
public void testClearSorted() {
forceFullSort();
clear();
assertContentsValid();
}
-
- //
-//
+
+ //
+//
// public static void testAdditions() {
// TestComparator comparator = new TestComparator();
// LazySortedCollection collection = new LazySortedCollection(comparator);
//
// addSomeElements(collection);
-//
+//
// System.out.println("comparisons after add = " + comparator.comparisons);
// comparator.comparisons = 0;
-//
+//
// // Getfirst10Elements
// Object[] first10Elements = new Object[10];
// collection.getFirst(first10Elements, false);
@@ -527,23 +527,23 @@ public class LazySortedCollectionTest extends TestCase {
// printArray(first10Elements);
// System.out.println("comparisons after getFirst = " + comparator.comparisons);
// comparator.comparisons = 0;
-//
+//
// collection.print();
-//
+//
// // remove the 10th element
// collection.remove(first10Elements[9]);
-//
+//
// collection.print();
//
-////
+////
//// collection.getFirst(first10Elements, true);
//// System.out.println("first 10 elements (sorted):");
//// printArray(first10Elements);
//// System.out.println("comparisons after getFirst = " + comparator.comparisons);
//// comparator.comparisons = 0;
-////
-////
-////
+////
+////
+////
//// // get elements 8-13
//// Object[] eightThrough14 = new Object[7];
//// collection.getRange(eightThrough14, 8, false);
@@ -551,7 +551,7 @@ public class LazySortedCollectionTest extends TestCase {
//// printArray(eightThrough14);
//// System.out.println("comparisons after 8-14 query = " + comparator.comparisons);
//// comparator.comparisons = 0;
-//
+//
// collection.print();
// }
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerComparatorTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerComparatorTest.java
index cf6b29b..d3b1e2d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerComparatorTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerComparatorTest.java
@@ -34,34 +34,35 @@ public class ListViewerComparatorTest extends ViewerComparatorTest {
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#createViewer(org.eclipse.swt.widgets.Composite)
*/
protected StructuredViewer createViewer(Composite parent) {
- ListViewer viewer = new ListViewer(parent);
+ ListViewer<Object,Object> viewer = new ListViewer<Object,Object>(parent);
viewer.setContentProvider(new TeamModelContentProvider());
viewer.setLabelProvider(new TeamModelLabelProvider());
+ comparatorTestViewer = viewer;
return viewer;
}
-
+
public void testViewerSorter(){
- fViewer.setSorter(new ViewerSorter());
+ comparatorTestViewer.setSorter(new ViewerSorter());
assertSortedResult(TEAM1_SORTED);
}
-
+
public void testViewerSorterInsertElement(){
- fViewer.setSorter(new ViewerSorter());
+ comparatorTestViewer.setSorter(new ViewerSorter());
team1.addMember("Duong");
assertSortedResult(TEAM1_SORTED_WITH_INSERT);
}
-
+
public void testViewerComparator(){
- fViewer.setComparator(new ViewerComparator());
+ comparatorTestViewer.setComparator(new ViewerComparator<Object,Object>());
assertSortedResult(TEAM1_SORTED);
}
-
+
public void testViewerComparatorInsertElement(){
- fViewer.setComparator(new ViewerComparator());
+ comparatorTestViewer.setComparator(new ViewerComparator<Object,Object>());
team1.addMember("Duong");
assertSortedResult(TEAM1_SORTED_WITH_INSERT);
}
-
+
private void assertSortedResult(String[] expected){
String[] items = getListViewer().getList().getItems();
for (int i = 0; i < items.length; i++){
@@ -69,15 +70,15 @@ public class ListViewerComparatorTest extends ViewerComparatorTest {
assertEquals("Item not expected. actual=" + item + " expected=", expected[i], item);
}
}
-
+
protected void setInput() {
- fViewer.setInput(team1);
+ comparatorTestViewer.setInput(team1);
}
-
- protected ListViewer getListViewer(){
- return (ListViewer)fViewer;
+
+ protected ListViewer<Object,Object> getListViewer(){
+ return (ListViewer<Object,Object>)comparatorTestViewer;
}
-
+
/**
* @param args
*/
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
index 332ee15..f845918 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerRefreshTest.java
@@ -35,17 +35,17 @@ public class ListViewerRefreshTest extends TestCase {
private Label label = null;
- private ListViewer viewer = null;
+ private ListViewer<String,List<String>> viewer = null;
- private ArrayList input = null;
+ private ArrayList<String> input = null;
protected void setUp() throws Exception {
shell = new Shell();
shell.setSize(400, 200);
shell.setLayout(new FillLayout());
label = new Label(shell, SWT.WRAP);
- viewer = new ListViewer(shell);
- input = new ArrayList();
+ viewer = new ListViewer<String,List<String>>(shell);
+ input = new ArrayList<String>();
for (int i = 0; i < 50; i++) {
input.add("item " + i); //$NON-NLS-1$
@@ -56,7 +56,7 @@ public class ListViewerRefreshTest extends TestCase {
shell.layout();
shell.open();
}
-
+
protected void tearDown() throws Exception {
shell.dispose();
shell = null;
@@ -65,7 +65,7 @@ public class ListViewerRefreshTest extends TestCase {
/**
* Asserts the ability to refresh without a selection and preserve the
* scrolled to position.
- *
+ *
* @throws Exception
*/
public void testNoSelectionRefresh() throws Exception {
@@ -91,7 +91,7 @@ public class ListViewerRefreshTest extends TestCase {
/**
* Asserts the ability to refresh with a selection and preserve the scrolled
* to position.
- *
+ *
* @throws Exception
*/
public void testSelectionRefresh() throws Exception {
@@ -104,27 +104,27 @@ public class ListViewerRefreshTest extends TestCase {
.get(30)));
}
});
-
+
// Ensure that to index is 0
viewer.getList().setTopIndex(0);
-
+
run("Refreshed viewer with selection.", new Runnable() { //$NON-NLS-1$
public void run() {
viewer.refresh();
}
});
-
+
// Checking that the viewer is not scrolling
assertTrue(viewer.getList().getTopIndex() == 0);
-
+
viewer.getList().showSelection();
-
+
assertTrue(viewer.getList().getTopIndex() != 0);
}
-
+
/**
* Runs the runnable and displays the description.
- *
+ *
* @param description
* @param runnable
*/
@@ -149,16 +149,17 @@ public class ListViewerRefreshTest extends TestCase {
}
}
- private class ContentProvider implements IStructuredContentProvider {
+ private class ContentProvider implements IStructuredContentProvider<String,List<String>> {
- public Object[] getElements(Object inputElement) {
- return ((List) inputElement).toArray();
+ public String[] getElements(List<String> inputElement) {
+ String[] results = new String[inputElement.size()];
+ return inputElement.toArray(results);
}
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<List<String>> viewer, List<String> oldInput, List<String> newInput) {
}
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
index 2a4dc93..0cbbcec 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ListViewerTest.java
@@ -27,8 +27,8 @@ public class ListViewerTest extends StructuredViewerTest {
super(name);
}
- protected StructuredViewer createViewer(Composite parent) {
- ListViewer viewer = new ListViewer(parent);
+ protected StructuredViewer<TestElement,TestElement>createViewer(Composite parent) {
+ ListViewer<TestElement,TestElement> viewer = new ListViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
return viewer;
}
@@ -47,30 +47,30 @@ public class ListViewerTest extends StructuredViewerTest {
public static void main(String args[]) {
junit.textui.TestRunner.run(ListViewerTest.class);
}
-
+
public void testInsert() {
- ListViewer v = ((ListViewer)fViewer);
+ ListViewer<TestElement,TestElement> v = ((ListViewer<TestElement,TestElement>)fViewer);
TestElement element = new TestElement(fModel, fRootElement);
v.insert(element, 1);
assertSame("test insert", element, v.getElementAt(1));
assertEquals("test insert", element.toString(), v.getList().getItem(1));
-
+
v.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
return true;
}
});
-
+
TestElement element1 = new TestElement(fModel, fRootElement);
v.insert(element1, 1);
assertNotSame("test insert", element1, v.getElementAt(1));
-
+
v.setFilters(new ViewerFilter[0]);
v.remove(element);
v.remove(element1);
}
-
+
public void testRevealBug69076() {
// TODO remove the Mac OS check when SWT has fixed the bug in List.java
// see bug 116105
@@ -92,7 +92,7 @@ public class ListViewerTest extends StructuredViewerTest {
.getFirstChild()), true);
TestElement child = fRootElement.getChildAt(j);
fViewer.reveal(child);
- List list = ((ListViewer) fViewer).getList();
+ List list = ((ListViewer<TestElement,TestElement>) fViewer).getList();
int topIndex = list.getTopIndex();
// even though we pass in reveal=false, SWT still scrolls to show the selection (since 20020815)
fViewer.setSelection(new StructuredSelection(child), false);
@@ -104,10 +104,10 @@ public class ListViewerTest extends StructuredViewerTest {
}
}
}
-
+
/**
* Asserts the ability to refresh a List that contains no selection without losing vertically scrolled state.
- *
+ *
* @throws Exception
*/
public void testRefreshBug141435() throws Exception {
@@ -119,43 +119,43 @@ public class ListViewerTest extends StructuredViewerTest {
openBrowser();
TestElement model = TestElement.createModel(1, 50);
fViewer.setInput(model);
-
+
int lastIndex = model.getChildCount() - 1;
-
+
//Scroll...
fViewer.reveal(model.getChildAt(lastIndex));
List list = (List) fViewer.getControl();
int topIndex = list.getTopIndex();
-
+
assertTrue("Top item should not be the first item.", topIndex != 0);
fViewer.refresh();
processEvents();
assertEquals("Top index was not preserved after refresh.", topIndex, list.getTopIndex());
-
+
//Assert that when the previous top index after refresh is invalid no exceptions are thrown.
model.deleteChildren();
-
+
try {
fViewer.refresh();
assertEquals(0, list.getTopIndex());
} catch (Exception e) {
fail("Refresh failure when refreshing with an empty model.");
- }
+ }
}
-
+
public void testSelectionRevealBug177619() throws Exception {
TestElement model = TestElement.createModel(1, 100);
fViewer.setInput(model);
-
- fViewer.setSelection(new StructuredSelection(((ListViewer)fViewer).getElementAt(50)),true);
- assertTrue(((ListViewer)fViewer).getList().getTopIndex() != 0);
+
+ fViewer.setSelection(new StructuredSelection(((ListViewer<TestElement,TestElement>)fViewer).getElementAt(50)),true);
+ assertTrue(((ListViewer<TestElement,TestElement>)fViewer).getList().getTopIndex() != 0);
}
-
+
public void testSelectionNoRevealBug177619() throws Exception {
TestElement model = TestElement.createModel(1, 100);
fViewer.setInput(model);
-
- fViewer.setSelection(new StructuredSelection(((ListViewer)fViewer).getElementAt(50)),false);
- assertTrue(((ListViewer)fViewer).getList().getTopIndex() == 0);
+
+ fViewer.setSelection(new StructuredSelection(((ListViewer<TestElement,TestElement>)fViewer).getElementAt(50)),false);
+ assertTrue(((ListViewer<TestElement,TestElement>)fViewer).getList().getTopIndex() == 0);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/MultipleEqualElementsTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/MultipleEqualElementsTreeViewerTest.java
index b02adc6..108311d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/MultipleEqualElementsTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/MultipleEqualElementsTreeViewerTest.java
@@ -25,11 +25,11 @@ import org.eclipse.swt.widgets.Widget;
/**
* Tests TreeViewer's support for multiple equal elements ().
- *
+ *
* @since 3.2
*/
public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
-
+
private TestElement element_2;
private TestElement element_2_1;
@@ -40,32 +40,32 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
private TestElement element_1_3;
- private TreePath treePath_1_2_21_212;
+ private TreePath<TestElement> treePath_1_2_21_212;
- private TreePath treePath_1_21_212;
+ private TreePath<TestElement> treePath_1_21_212;
- private TreePath treePath_1_212;
+ private TreePath<TestElement> treePath_1_212;
- private TreePath treePath_2_21_212;
+ private TreePath<TestElement> treePath_2_21_212;
- private TreePath treePath_1;
+ private TreePath<TestElement> treePath_1;
- private TreePath treePath_1_21;
+ private TreePath<TestElement> treePath_1_21;
- private TreePath treePath_2_21;
+ private TreePath<TestElement> treePath_2_21;
- private TreePath treePath_1_2_21;
+ private TreePath<TestElement> treePath_1_2_21;
- private TreePath treePath_1_2;
+ private TreePath<TestElement> treePath_1_2;
- private TreePath treePath_2;
+ private TreePath<TestElement> treePath_2;
public MultipleEqualElementsTreeViewerTest(String name) {
super(name);
}
- public TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ public TreeViewer<TestElement,TestElement> getTreeViewer() {
+ return (TreeViewer<TestElement, TestElement>) fTreeViewer;
}
protected void setUpModel() {
@@ -125,20 +125,20 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
element_1.addChild(element_2, null);
element_1.addChild(element_2_1, null);
element_1.addChild(element_2_1_2, null);
- treePath_1_2_21_212 = new TreePath(new Object[] { element_1, element_2,
+ treePath_1_2_21_212 = new TreePath<TestElement>(new TestElement[] { element_1, element_2,
element_2_1, element_2_1_2 });
- treePath_1_2_21 = new TreePath(new Object[] { element_1, element_2,
+ treePath_1_2_21 = new TreePath<TestElement>(new TestElement[] { element_1, element_2,
element_2_1 });
- treePath_1 = new TreePath(new Object[] { element_1 });
- treePath_2 = new TreePath(new Object[] { element_2 });
- treePath_1_2 = new TreePath(new Object[] { element_1, element_2 });
- treePath_1_21 = new TreePath(new Object[] { element_1, element_2_1 });
- treePath_1_21_212 = new TreePath(new Object[] { element_1, element_2_1,
+ treePath_1 = new TreePath<TestElement>(new TestElement[] { element_1 });
+ treePath_2 = new TreePath<TestElement>(new TestElement[] { element_2 });
+ treePath_1_2 = new TreePath<TestElement>(new TestElement[] { element_1, element_2 });
+ treePath_1_21 = new TreePath<TestElement>(new TestElement[] { element_1, element_2_1 });
+ treePath_1_21_212 = new TreePath<TestElement>(new TestElement[] { element_1, element_2_1,
element_2_1_2 });
- treePath_1_212 = new TreePath(new Object[] { element_1, element_2_1_2 });
- treePath_2_21_212 = new TreePath(new Object[] { element_2, element_2_1,
+ treePath_1_212 = new TreePath<TestElement>(new TestElement[] { element_1, element_2_1_2 });
+ treePath_2_21_212 = new TreePath<TestElement>(new TestElement[] { element_2, element_2_1,
element_2_1_2 });
- treePath_2_21 = new TreePath(new Object[] { element_2, element_2_1 });
+ treePath_2_21 = new TreePath<TestElement>(new TestElement[] { element_2, element_2_1 });
fModel = fRootElement.getModel();
}
@@ -158,7 +158,7 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
ISelection selection = getTreeViewer().getSelection();
assertTrue(selection instanceof ITreeSelection);
ITreeSelection treeSelection = (ITreeSelection) selection;
- assertEquals(new TreeSelection(new TreePath(new Object[] { element_1,
+ assertEquals(new TreeSelection(new TreePath<TestElement>(new TestElement[] { element_1,
element_1_3 }), null), treeSelection);
Widget[] items = getTreeViewer().testFindItems(element_2_1_2);
TreeItem[] treeItems = new TreeItem[items.length];
@@ -169,7 +169,7 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
}
getTreeViewer().getTree().setSelection(treeItems);
treeSelection = (ITreeSelection) getTreeViewer().getSelection();
- List paths = Arrays.asList(treeSelection.getPaths());
+ List<TreePath> paths = Arrays.asList(treeSelection.getPaths());
assertEquals(4, paths.size());
assertTrue(paths.contains(treePath_1_2_21_212));
assertTrue(paths.contains(treePath_1_21_212));
@@ -193,7 +193,7 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
assertEqualsArray("path expansion", new Object[] { treePath_1, treePath_1_2, treePath_1_2_21, treePath_2, treePath_2_21 }, getTreeViewer().getExpandedTreePaths());
}
- private void assertMatchingPath(TreePath expectedPath, TreeItem item) {
+ private void assertMatchingPath(TreePath<TestElement> expectedPath, TreeItem item) {
for (int i = expectedPath.getSegmentCount() - 1; i >= 0; i--) {
assertNotNull(item);
assertEquals(expectedPath.getSegment(i), item.getData());
@@ -217,7 +217,7 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
assertEquals("0-2-1 billy", ((TreeItem) items[i]).getText());
}
}
-
+
public void testAddWithoutMaterialize() {
TestElement newElement = element_2.addChild(TestModelChange.INSERT);
getTreeViewer().setExpandedTreePaths(
@@ -225,7 +225,7 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
Widget[] items = getTreeViewer().testFindItems(newElement);
assertEquals(2, items.length);
}
-
+
public void testAddAfterMaterialize() {
// materialize before adding
getTreeViewer().setExpandedTreePaths(
@@ -236,13 +236,13 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
Widget[] items = getTreeViewer().testFindItems(newElement);
assertEquals(2, items.length);
}
-
+
public void testRemoveWithParentAfterMaterialize() {
// materialize
getTreeViewer().expandToLevel(element_1, AbstractTreeViewer.ALL_LEVELS);
getTreeViewer().expandToLevel(element_2, AbstractTreeViewer.ALL_LEVELS);
element_2.basicDeleteChild(element_2_1);
- getTreeViewer().remove(element_2, new Object[]{element_2_1});
+ getTreeViewer().remove(element_2, new TestElement[]{element_2_1});
assertEquals(2, getTreeViewer().testFindItems(element_2).length);
assertEquals(1, getTreeViewer().testFindItems(element_2_1).length);
assertEquals(2, getTreeViewer().testFindItems(element_2_1_2).length);
@@ -250,7 +250,7 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
public void testRemoveWithParentBeforeMaterialize() {
element_2.basicDeleteChild(element_2_1);
- getTreeViewer().remove(element_2, new Object[]{element_2_1});
+ getTreeViewer().remove(element_2, new TestElement[]{element_2_1});
// materialize
getTreeViewer().expandToLevel(element_1, AbstractTreeViewer.ALL_LEVELS);
getTreeViewer().expandToLevel(element_2, AbstractTreeViewer.ALL_LEVELS);
@@ -258,5 +258,5 @@ public class MultipleEqualElementsTreeViewerTest extends TreeViewerTest {
assertEquals(1, getTreeViewer().testFindItems(element_2_1).length);
assertEquals(2, getTreeViewer().testFindItems(element_2_1_2).length);
}
-
+
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTableViewerTest.java
index 4a8a251..30bf4b9 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTableViewerTest.java
@@ -28,11 +28,11 @@ import org.eclipse.ui.tests.harness.util.Mocks;
/**
* @since 3.2
- *
+ *
*/
public class SimpleTableViewerTest extends ViewerTestCase {
- private TableViewer tableViewer;
+ private TableViewer<TestElement,TestElement> tableViewer;
/**
* @param name
@@ -41,20 +41,20 @@ public class SimpleTableViewerTest extends ViewerTestCase {
super(name);
}
- protected StructuredViewer createViewer(Composite parent) {
- tableViewer = new TableViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ tableViewer = new TableViewer<TestElement,TestElement>(parent);
tableViewer.setContentProvider(new TestModelContentProvider());
return tableViewer;
}
public void testNullLabel() {
- tableViewer.setLabelProvider(new ITableLabelProvider() {
+ tableViewer.setLabelProvider(new ITableLabelProvider<TestElement>() {
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
- public String getColumnText(Object element, int columnIndex) {
+ public String getColumnText(TestElement element, int columnIndex) {
return null;
}
@@ -64,7 +64,7 @@ public class SimpleTableViewerTest extends ViewerTestCase {
public void dispose() {
}
- public boolean isLabelProperty(Object element, String property) {
+ public boolean isLabelProperty(TestElement element, String property) {
return false;
}
@@ -77,7 +77,7 @@ public class SimpleTableViewerTest extends ViewerTestCase {
Table table = tableViewer.getTable();
new TableColumn(table, SWT.NONE);
new TableColumn(table, SWT.NONE);
- ILabelProvider mockLabelProvider = (ILabelProvider) Mocks
+ ILabelProvider<TestElement> mockLabelProvider = (ILabelProvider<TestElement>) Mocks
.createOrderedMock(ILabelProvider.class);
// setLabelProvider will cause the addListener and does a refresh,
// so getText and getImage will be called for each element and both
@@ -105,10 +105,10 @@ public class SimpleTableViewerTest extends ViewerTestCase {
public void testLabelProviderListenersWithColumn() {
Table table = tableViewer.getTable();
new TableColumn(table, SWT.NONE);
- new TableViewerColumn(tableViewer, SWT.NONE);
+ new TableViewerColumn<TestElement,TestElement>(tableViewer, SWT.NONE);
final int[] disposeCounter = { 0 };
final int[] listenerCounter = { 0 };
- tableViewer.setLabelProvider(new LabelProvider() {
+ tableViewer.setLabelProvider(new LabelProvider<TestElement>() {
public void addListener(ILabelProviderListener listener) {
listenerCounter[0]++;
super.addListener(listener);
@@ -129,10 +129,10 @@ public class SimpleTableViewerTest extends ViewerTestCase {
public void testColumnLabelProviderListeners() {
Table table = tableViewer.getTable();
new TableColumn(table, SWT.NONE);
- TableViewerColumn tvc = new TableViewerColumn(tableViewer, SWT.NONE);
+ TableViewerColumn<TestElement,TestElement> tvc = new TableViewerColumn<TestElement,TestElement>(tableViewer, SWT.NONE);
final int[] disposeCounter = { 0 };
final int[] listenerCounter = { 0 };
- tvc.setLabelProvider(new ColumnLabelProvider() {
+ tvc.setLabelProvider(new ColumnLabelProvider<TestElement,TestElement>() {
public void addListener(ILabelProviderListener listener) {
listenerCounter[0]++;
super.addListener(listener);
@@ -149,10 +149,10 @@ public class SimpleTableViewerTest extends ViewerTestCase {
assertEquals(0, listenerCounter[0]);
assertEquals(1, disposeCounter[0]);
}
-
+
public void testCellLabelProviderDispose() {
final int[] disposeCounter = { 0 };
- tableViewer.setLabelProvider(new ColumnLabelProvider() {
+ tableViewer.setLabelProvider(new ColumnLabelProvider<TestElement,TestElement>() {
public void dispose() {
disposeCounter[0]++;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTreeViewerTest.java
index 09a0cf8..8e49762 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleTreeViewerTest.java
@@ -11,9 +11,6 @@
package org.eclipse.jface.tests.viewers;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
@@ -22,21 +19,20 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.TreeNode;
-import org.eclipse.jface.viewers.TreeNodeContentProvider;
import org.eclipse.jface.viewers.TreePathViewerSorter;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
/**
* @since 3.2
- *
+ *
*/
public class SimpleTreeViewerTest extends ViewerTestCase {
- private TreeViewer treeViewer;
+ private TreeViewer<TestElement,TestElement> treeViewer;
/**
* @param name
@@ -45,8 +41,8 @@ public class SimpleTreeViewerTest extends ViewerTestCase {
super(name);
}
- protected StructuredViewer createViewer(Composite parent) {
- treeViewer = new TreeViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ treeViewer = new TreeViewer<TestElement,TestElement>(parent);
treeViewer.setContentProvider(new TestModelContentProvider());
return treeViewer;
}
@@ -55,15 +51,15 @@ public class SimpleTreeViewerTest extends ViewerTestCase {
treeViewer.setInput(null);
treeViewer.setSorter(new TreePathViewerSorter());
}
-
+
public void testNullLabel() {
- treeViewer.setLabelProvider(new ITableLabelProvider(){
+ treeViewer.setLabelProvider(new ITableLabelProvider<TestElement>(){
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
- public String getColumnText(Object element, int columnIndex) {
+ public String getColumnText(TestElement element, int columnIndex) {
return null;
}
@@ -73,7 +69,7 @@ public class SimpleTreeViewerTest extends ViewerTestCase {
public void dispose() {
}
- public boolean isLabelProperty(Object element, String property) {
+ public boolean isLabelProperty(TestElement element, String property) {
return false;
}
@@ -95,10 +91,10 @@ public class SimpleTreeViewerTest extends ViewerTestCase {
public void testBug184441() {
MyViewerSorter sorter = new MyViewerSorter();
treeViewer.setSorter(sorter);
- ITreeContentProvider contentProvider = (ITreeContentProvider) treeViewer
+ ITreeContentProvider<TestElement,TestElement> contentProvider = (ITreeContentProvider<TestElement,TestElement>) treeViewer
.getContentProvider();
- Object firstRoot = contentProvider.getElements(treeViewer.getInput())[0];
- Object childOfFirstRoot = contentProvider.getChildren(firstRoot)[0];
+ TestElement firstRoot = contentProvider.getElements(treeViewer.getInput())[0];
+ TestElement childOfFirstRoot = contentProvider.getChildren(firstRoot)[0];
treeViewer.setSelection(new StructuredSelection(childOfFirstRoot), true);
final ISelectionChangedListener listener = new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
@@ -112,46 +108,20 @@ public class SimpleTreeViewerTest extends ViewerTestCase {
}
public void testBug184712() {
- class TableAndTreeLabelProvider extends LabelProvider implements ITableLabelProvider {
- public Image getColumnImage(Object element, int columnIndex) {
+ class TableAndTreeLabelProvider extends LabelProvider<TestElement> implements ITableLabelProvider<TestElement> {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
- public String getColumnText(Object element, int columnIndex) {
+ public String getColumnText(TestElement element, int columnIndex) {
return "wrong";
}
- public String getText(Object element) {
+ public String getText(TestElement element) {
return "right";
}
}
treeViewer.setLabelProvider(new TableAndTreeLabelProvider());
assertEquals("right", treeViewer.getTree().getItem(0).getText());
}
-
- public void test327004() {
- treeViewer.setInput(null);
- treeViewer.setContentProvider(new TreeNodeContentProvider());
-
- final TreeNode[] children= new TreeNode[5];
- children[0]= new TreeNode("0");
- children[1]= new TreeNode("1");
- children[2]= new TreeNode("1");
- children[3]= new TreeNode("1");
- children[4]= new TreeNode("1");
- treeViewer.setInput(children);
-
- ViewerFilter filter= new ViewerFilter() {
- public boolean select(Viewer viewer, Object parentElement, Object element) {
- if (element == children[0] || element == children[1] || element == children[2] || element == children[4])
- return false;
- return true;
- }
- };
- treeViewer.setFilters(new ViewerFilter[] { filter });
- int i= treeViewer.getTree().getItemCount();
-
- assertEquals(4, i); // 4 because the filter doesn't work due to equal nodes
- }
-
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
index e05a072..e13e3f0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/SimpleVirtualLazyTreeViewerTest.java
@@ -27,7 +27,7 @@ import org.eclipse.swt.widgets.TreeItem;
/**
* Tests TreeViewer's VIRTUAL support with a lazy content provider.
- *
+ *
* @since 3.2
*/
public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
@@ -40,16 +40,18 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
private int updateElementCallCount = 0;
- private class LazyTreeContentProvider implements ILazyTreeContentProvider {
+ private TreeViewer<String,String> treeViewer;
+
+ private class LazyTreeContentProvider implements ILazyTreeContentProvider<String,String> {
/**
- *
+ *
*/
- private Object input;
+ private String input;
- public void updateElement(Object parent, int index) {
+ public void updateElement(String parent, int index) {
updateElementCallCount++;
- String parentString = (String) parent;
- Object childElement = parentString + "-" + (index+offset);
+ String parentString = parent;
+ String childElement = parentString + "-" + (index+offset);
if (printCallbacks)
System.out.println("updateElement called for " + parent + " at " + index);
if (callbacksEnabled) {
@@ -62,18 +64,18 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
// do nothing
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<String> viewer, String oldInput, String newInput) {
this.input = newInput;
}
- public Object getParent(Object element) {
+ public String getParent(String element) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILazyTreeContentProvider#updateChildCount(java.lang.Object, int)
*/
- public void updateChildCount(Object element, int currentChildCount) {
+ public void updateChildCount(String element, int currentChildCount) {
if (printCallbacks)
System.out.println("updateChildCount called for " + element + " with " + currentChildCount);
if (callbacksEnabled) {
@@ -86,17 +88,17 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
super(name);
}
- public TreeViewer getTreeViewer() {
- return (TreeViewer) fViewer;
+ public TreeViewer<String,String> getTreeViewer() {
+ return treeViewer;
}
-
+
/**
* Checks if the virtual tree / table functionality can be tested in the current settings.
* The virtual trees and tables rely on SWT.SetData event which is only sent if OS requests
* information about the tree / table. If the window is not visible (obscured by another window,
* outside of visible area, or OS determined that it can skip drawing), then OS request won't
- * be send, causing automated tests to fail.
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=118919 .
+ * be send, causing automated tests to fail.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=118919 .
*/
protected boolean setDataCalled = false;
@@ -104,7 +106,7 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
super.setUp();
processEvents(); // run events for SetData precondition test
}
-
+
protected void setInput() {
String letterR = "R";
getTreeViewer().setInput(letterR);
@@ -112,7 +114,7 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
protected StructuredViewer createViewer(Composite parent) {
Tree tree = new Tree(fShell, SWT.VIRTUAL | SWT.MULTI);
- TreeViewer treeViewer = new TreeViewer(tree);
+ treeViewer = new TreeViewer<String,String>(tree);
treeViewer.setContentProvider(new LazyTreeContentProvider());
tree.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
@@ -170,18 +172,18 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
tree.setRedraw(true);
}
}
-
+
public void testSetSorterOnNullInput() {
- fViewer.setInput(null);
- fViewer.setSorter(new ViewerSorter());
+ treeViewer.setInput(null);
+ treeViewer.setSorter(new ViewerSorter());
}
-
+
public void testSetComparatorOnNullInput(){
- fViewer.setInput(null);
- fViewer.setComparator(new ViewerComparator());
+ treeViewer.setInput(null);
+ treeViewer.setComparator(new ViewerComparator<String,String>());
}
-
- /* test TreeViewer.remove(parent, index) */
+
+ /* test TreeViewer.remove(parent, index) */
public void testRemoveAt() {
if (disableTestsBug347491)
return;
@@ -189,7 +191,6 @@ public class SimpleVirtualLazyTreeViewerTest extends ViewerTestCase {
System.err.println("SWT.SetData is not received. Cancelled test " + getName());
return;
}
- TreeViewer treeViewer = (TreeViewer) fViewer;
// correct what the content provider is answering with
treeViewer.getTree().update();
offset = 1;
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java
index 64af9d7..0e8b5f6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredSelectionTest.java
@@ -60,11 +60,11 @@ public class StructuredSelectionTest extends TestCase {
}
public void testEquals5() { // equality is order-dependent
- List l1 = new ArrayList();
+ List<String> l1 = new ArrayList<String>();
l1.add("element 1");
l1.add("element 2");
- List l2 = new ArrayList();
+ List<String> l2 = new ArrayList<String>();
l2.add("element 2");
l2.add("element 1");
@@ -75,11 +75,11 @@ public class StructuredSelectionTest extends TestCase {
}
public void testEquals6() { // different selections
- List l1 = new ArrayList();
+ List<String> l1 = new ArrayList<String>();
l1.add("element 1");
l1.add("element 2");
- List l2 = new ArrayList();
+ List<String> l2 = new ArrayList<String>();
l2.add("element 2");
l2.add("element 3");
l2.add("element 1");
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
index 180887b..db8ab2b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/StructuredViewerTest.java
@@ -27,9 +27,9 @@ import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.swt.graphics.Image;
public abstract class StructuredViewerTest extends ViewerTestCase {
- public static class TestLabelFilter extends ViewerFilter {
- public boolean select(Viewer viewer, Object parent, Object element) {
- String label = ((TestElement) element).getLabel();
+ public static class TestLabelFilter extends ViewerFilter<TestElement,TestElement> {
+ public boolean select(Viewer<TestElement> viewer, Object parent, TestElement element) {
+ String label = element.getLabel();
int count = label.indexOf("-");
if (count < 0)
return false;
@@ -37,14 +37,14 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
return ((Integer.parseInt(number) % 2) == 0);
}
- public boolean isFilterProperty(Object element, String property) {
+ public boolean isFilterProperty(TestElement element, String property) {
return property.equals(IBasicPropertyConstants.P_TEXT);
}
}
- public static class TestLabelFilter2 extends ViewerFilter {
- public boolean select(Viewer viewer, Object parent, Object element) {
- String label = ((TestElement) element).getLabel();
+ public static class TestLabelFilter2 extends ViewerFilter<TestElement,TestElement> {
+ public boolean select(Viewer<TestElement> viewer, Object parent, TestElement element) {
+ String label = element.getLabel();
int count = label.indexOf("-");
if (count < 0)
return false;
@@ -52,11 +52,11 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
return Integer.parseInt(number) == 0;
}
- public boolean isFilterProperty(Object element, String property) {
+ public boolean isFilterProperty(TestElement element, String property) {
return property.equals(IBasicPropertyConstants.P_TEXT);
}
}
-
+
public static class TestLabelSorter extends ViewerSorter {
public int compare(Viewer v, Object e1, Object e2) {
// put greater labels first
@@ -70,17 +70,17 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
}
}
- public static class TestLabelProvider extends LabelProvider {
+ public static class TestLabelProvider extends LabelProvider<TestElement> {
public static String fgSuffix = "";
static Image fgImage = ImageDescriptor.createFromFile(
TestLabelProvider.class, "images/java.gif").createImage();
- public String getText(Object element) {
- return providedString((TestElement) element);
+ public String getText(TestElement element) {
+ return providedString(element);
}
- public Image getImage(Object element) {
+ public Image getImage(TestElement element) {
return fgImage;
}
@@ -150,17 +150,17 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
fRootElement.deleteChild(first);
assertNull("first child is not visible", fViewer.testFindItem(first));
}
-
+
/**
* Tests to ensure that the viewer is properly diposed. Includes:
* removal of filters
*/
public void testDispose() {
assertEquals(0, fViewer.getFilters().length);
- fViewer.addFilter(new ViewerFilter() {
+ fViewer.addFilter(new ViewerFilter<TestElement,TestElement>() {
- public boolean select(Viewer viewer, Object parentElement,
- Object element) {
+ public boolean select(Viewer<TestElement> viewer, Object parentElement,
+ TestElement element) {
return false;
}});
assertEquals(1, fViewer.getFilters().length);
@@ -169,7 +169,7 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
}
public void testFilter() {
- ViewerFilter filter = new TestLabelFilter();
+ ViewerFilter<TestElement,TestElement> filter = new TestLabelFilter();
fViewer.addFilter(filter);
assertTrue("filtered count", getItemCount() == 5);
fViewer.removeFilter(filter);
@@ -178,74 +178,74 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
}
public void testSetFilters() {
- ViewerFilter filter = new TestLabelFilter();
+ ViewerFilter<TestElement,TestElement> filter = new TestLabelFilter();
fViewer.setFilters(new ViewerFilter[] { filter, new TestLabelFilter2() });
// System.err.println("Item: " + getItemCount() );
assertTrue("2 filters count", getItemCount() == 1);
-
+
fViewer.setFilters(new ViewerFilter[] { filter });
assertTrue("1 filtered count", getItemCount() == 5);
-
+
fViewer.setFilters(new ViewerFilter[0]);
assertTrue("unfiltered count", getItemCount() == 10);
}
-
+
public void testSetAndGetData() {
-
+
//get with no data
assertNull("get with no data", fViewer.getData("foo"));
-
+
//remove with no data
fViewer.setData("foo", null);
-
+
//get with no data after remove
assertNull("get with no data after remove", fViewer.getData("foo"));
-
+
//set
fViewer.setData("foo", "bar");
-
+
//remove key which does not exist
fViewer.setData("baz", null);
-
+
//get key which does not exist
assertNull("get key which does not exist", fViewer.getData("baz"));
-
+
//get value instead of key
assertNull("get value instead of key", fViewer.getData("bar"));
-
+
//get single value
assertEquals("get single value", "bar", fViewer.getData("foo"));
-
+
//set new value
fViewer.setData("foo", "baz");
-
+
//get overridden value
assertEquals("get overridden value", "baz", fViewer.getData("foo"));
-
+
//add more values
fViewer.setData("alpha", "1");
fViewer.setData("beta", "2");
fViewer.setData("delta", "3");
-
+
//get multiple values
assertEquals("get multiple values", "baz", fViewer.getData("foo"));
assertEquals("get multiple values", "1", fViewer.getData("alpha"));
assertEquals("get multiple values", "2", fViewer.getData("beta"));
assertEquals("get multiple values", "3", fViewer.getData("delta"));
-
+
//override with multiple values
fViewer.setData("alpha", "10");
-
+
//get overridden value
assertEquals("get overridden value", "10", fViewer.getData("alpha"));
-
+
//add more values
fViewer.setData("gamma", "4");
fViewer.setData("epsilon", "5");
-
+
//remove first value
fViewer.setData("foo", null);
-
+
//check remaining values
assertEquals("get after remove", null, fViewer.getData("foo"));
assertEquals("get after remove", "10", fViewer.getData("alpha"));
@@ -253,10 +253,10 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
assertEquals("get after remove", "3", fViewer.getData("delta"));
assertEquals("get after remove", "4", fViewer.getData("gamma"));
assertEquals("get after remove", "5", fViewer.getData("epsilon"));
-
+
//remove middle value
fViewer.setData("delta", null);
-
+
//check remaining values
assertEquals("get after remove", null, fViewer.getData("foo"));
assertEquals("get after remove", "10", fViewer.getData("alpha"));
@@ -264,10 +264,10 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
assertEquals("get after remove", null, fViewer.getData("delta"));
assertEquals("get after remove", "4", fViewer.getData("gamma"));
assertEquals("get after remove", "5", fViewer.getData("epsilon"));
-
+
//remove last value
fViewer.setData("epsilon", null);
-
+
//check remaining values
assertEquals("get after remove", null, fViewer.getData("foo"));
assertEquals("get after remove", "10", fViewer.getData("alpha"));
@@ -275,12 +275,12 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
assertEquals("get after remove", null, fViewer.getData("delta"));
assertEquals("get after remove", "4", fViewer.getData("gamma"));
assertEquals("get after remove", null, fViewer.getData("epsilon"));
-
+
//remove remaining values
fViewer.setData("alpha", null);
fViewer.setData("beta", null);
fViewer.setData("gamma", null);
-
+
//check final values
assertEquals("get after remove", null, fViewer.getData("foo"));
assertEquals("get after remove", null, fViewer.getData("alpha"));
@@ -289,7 +289,7 @@ public abstract class StructuredViewerTest extends ViewerTestCase {
assertEquals("get after remove", null, fViewer.getData("gamma"));
assertEquals("get after remove", null, fViewer.getData("epsilon"));
}
-
+
public void testInsertChild() {
TestElement first = fRootElement.getFirstChild();
TestElement newElement = first.addChild(TestModelChange.INSERT);
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableColorProviderTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableColorProviderTest.java
index 70b8e32..2ecc617 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableColorProviderTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableColorProviderTest.java
@@ -30,7 +30,7 @@ import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
/**
- * The TableColorProviderTest is a test suite designed to test
+ * The TableColorProviderTest is a test suite designed to test
* ITableColorProviders.
*/
public class TableColorProviderTest extends StructuredViewerTest {
@@ -50,9 +50,9 @@ public class TableColorProviderTest extends StructuredViewerTest {
* Test with a standard color provider.
*/
public void testColorProviderForeground() {
- TableViewer viewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
ColorViewLabelProvider provider = new ColorViewLabelProvider();
-
+
viewer.setLabelProvider(provider);
//refresh so that the colors are set
@@ -69,11 +69,11 @@ public class TableColorProviderTest extends StructuredViewerTest {
* Test that the backgrounds are being set.
*/
public void testColorProviderBackground() {
- TableViewer viewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
ColorViewLabelProvider provider = new ColorViewLabelProvider();
-
+
viewer.setLabelProvider(provider);
-
+
fViewer.refresh();
assertEquals("background 1 red", viewer.getTable().getItem(0).getBackground(0), red);//$NON-NLS-1$
@@ -88,9 +88,9 @@ public class TableColorProviderTest extends StructuredViewerTest {
*
*/
public void testTableItemsColorProviderForeground() {
- TableViewer viewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
TableColorViewLabelProvider provider = new TableColorViewLabelProvider();
-
+
viewer.setLabelProvider(provider);
Table table = viewer.getTable();
@@ -107,11 +107,11 @@ public class TableColorProviderTest extends StructuredViewerTest {
*
*/
public void testTableItemsColorProviderBackground() {
- TableViewer viewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
TableColorViewLabelProvider provider = new TableColorViewLabelProvider();
-
+
viewer.setLabelProvider(provider);
-
+
Table table = viewer.getTable();
fViewer.refresh();
@@ -150,10 +150,10 @@ public class TableColorProviderTest extends StructuredViewerTest {
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
- TableViewer viewer = new TableViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ TableViewer<TestElement,TestElement> viewer = new TableViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
-
+
viewer.getTable().setLinesVisible(true);
TableLayout layout = new TableLayout();
@@ -189,16 +189,16 @@ public class TableColorProviderTest extends StructuredViewerTest {
}
class TableColorViewLabelProvider extends TableTestLabelProvider implements
- ITableColorProvider {
+ ITableColorProvider<TestElement> {
- public Image getColumnImage(Object obj, int index) {
+ public Image getColumnImage(TestElement obj, int index) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableColorProvider#getForeground(java.lang.Object, int)
*/
- public Color getForeground(Object element, int columnIndex) {
+ public Color getForeground(TestElement element, int columnIndex) {
switch (columnIndex) {
case 0:
return green;
@@ -207,13 +207,13 @@ public class TableColorProviderTest extends StructuredViewerTest {
return red;
}
}
-
-
+
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableColorProvider#getBackground(java.lang.Object, int)
*/
- public Color getBackground(Object element, int columnIndex) {
+ public Color getBackground(TestElement element, int columnIndex) {
switch (columnIndex) {
case 0:
return red;
@@ -227,18 +227,18 @@ public class TableColorProviderTest extends StructuredViewerTest {
/**
* A class to test color providing without coloured columns.
*/
- class ColorViewLabelProvider extends TableTestLabelProvider implements IColorProvider{
+ class ColorViewLabelProvider extends TableTestLabelProvider implements IColorProvider<TestElement>{
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
- public Color getBackground(Object element) {
+ public Color getBackground(TestElement element) {
return red;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
- public Color getForeground(Object element) {
+ public Color getForeground(TestElement element) {
return green;
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableFontProviderTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableFontProviderTest.java
index 7bfd819..7bbcff0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableFontProviderTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableFontProviderTest.java
@@ -37,11 +37,11 @@ public class TableFontProviderTest extends StructuredViewerTest {
Font font1;
Font font2;
-
+
/**
* Create a new instance of the receiver
- *
+ *
* @param name
*/
public TableFontProviderTest(String name) {
@@ -52,8 +52,8 @@ public class TableFontProviderTest extends StructuredViewerTest {
* Test the general font provider.
*/
public void testFontProvider() {
- TableViewer viewer = (TableViewer) fViewer;
-
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
+
FontViewLabelProvider provider = new FontViewLabelProvider();
viewer.setLabelProvider(provider);
@@ -63,7 +63,7 @@ public class TableFontProviderTest extends StructuredViewerTest {
compareFontDatas(viewer.getTable().getItem(0).getFont(0), font1);//$NON-NLS-1$
compareFontDatas(viewer.getTable().getItem(0).getFont(1), font1);//$NON-NLS-1$
-
+
provider.fExtended = false;
@@ -71,10 +71,10 @@ public class TableFontProviderTest extends StructuredViewerTest {
/**
* Test that the fonts are being set.
- *
+ *
*/
public void testTableItemsFontProvider() {
- TableViewer viewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
TableFontViewLabelProvider provider = new TableFontViewLabelProvider();
viewer.setLabelProvider(provider);
@@ -91,19 +91,19 @@ public class TableFontProviderTest extends StructuredViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#setUp()
*/
public void setUp() {
super.setUp();
font1 = JFaceResources.getFont(JFaceResources.BANNER_FONT);
font2 = JFaceResources.getFont(JFaceResources.HEADER_FONT);
-
+
}
/**
* Run as a stand alone test
- *
+ *
* @param args
*/
public static void main(String[] args) {
@@ -112,11 +112,11 @@ public class TableFontProviderTest extends StructuredViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#createViewer(org.eclipse.swt.widgets.Composite)
*/
- protected StructuredViewer createViewer(Composite parent) {
- TableViewer viewer = new TableViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ TableViewer<TestElement,TestElement> viewer = new TableViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
viewer.getTable().setLinesVisible(true);
@@ -151,34 +151,34 @@ public class TableFontProviderTest extends StructuredViewerTest {
Table table = (Table) fViewer.getControl();
return table.getItem(at).getText();
}
-
+
private void compareFontDatas(Font font1, Font font2){
-
+
FontData[] font1Data = font1.getFontData();
FontData[] font2Data = font2.getFontData();
-
+
assertTrue("Mismatched sizes",font1Data.length == font2Data.length);
for (int a = 0; a < font2Data.length; a++) {
assertTrue("Mismatched fontData",font1Data[a].equals(font2Data[a]));
}
-
-
+
+
}
class TableFontViewLabelProvider extends TableTestLabelProvider implements
- ITableFontProvider {
+ ITableFontProvider<TestElement> {
- public Image getColumnImage(Object obj, int index) {
+ public Image getColumnImage(TestElement obj, int index) {
return null;
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.ITableFontProvider#getFont(java.lang.Object,
* int)
*/
- public Font getFont(Object element, int columnIndex) {
+ public Font getFont(TestElement element, int columnIndex) {
switch (columnIndex) {
case 0:
return font1;
@@ -194,13 +194,13 @@ public class TableFontProviderTest extends StructuredViewerTest {
* A label provider that does not provide font support entry by entry.
*/
class FontViewLabelProvider extends TableTestLabelProvider implements
- IFontProvider {
+ IFontProvider<TestElement> {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
*/
- public Font getFont(Object element) {
+ public Font getFont(TestElement element) {
return font1;
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableTreeViewerTest.java
index 7985c18..d106517 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableTreeViewerTest.java
@@ -26,23 +26,23 @@ import org.eclipse.swt.widgets.TableColumn;
public class TableTreeViewerTest extends AbstractTreeViewerTest {
public static class TableTreeTestLabelProvider extends TestLabelProvider
- implements ITableLabelProvider {
+ implements ITableLabelProvider<TestElement> {
public boolean fExtended = false;
- public String getText(Object element) {
+ public String getText(TestElement element) {
if (fExtended)
- return providedString((String) element);
+ return providedString(element);
return element.toString();
}
- public String getColumnText(Object element, int index) {
+ public String getColumnText(TestElement element, int index) {
if (fExtended)
- return providedString((TestElement) element);
+ return providedString(element);
return element.toString();
}
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerComparatorTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerComparatorTest.java
index 57d68a6..f7ebcc4 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerComparatorTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerComparatorTest.java
@@ -40,7 +40,7 @@ public class TableViewerComparatorTest extends ViewerComparatorTest {
* @see org.eclipse.jface.tests.viewers.ViewerTestCase#createViewer(org.eclipse.swt.widgets.Composite)
*/
protected StructuredViewer createViewer(Composite parent) {
- TableViewer viewer = new TableViewer(parent);
+ TableViewer<Object,Object> viewer = new TableViewer<Object,Object>(parent);
viewer.setContentProvider(new TeamModelContentProvider());
viewer.setLabelProvider(new TeamModelLabelProvider());
viewer.getTable().setLinesVisible(true);
@@ -62,32 +62,32 @@ public class TableViewerComparatorTest extends ViewerComparatorTest {
tc.setText(headers[i]);
columns[i] = tc;
}
-
+ comparatorTestViewer = viewer;
return viewer;
}
-
+
public void testViewerSorter(){
- fViewer.setSorter(new ViewerSorter());
+ comparatorTestViewer.setSorter(new ViewerSorter());
assertSortedResult(TEAM1_SORTED);
}
-
+
public void testViewerSorterInsertElement(){
- fViewer.setSorter(new ViewerSorter());
+ comparatorTestViewer.setSorter(new ViewerSorter());
team1.addMember("Duong");
assertSortedResult(TEAM1_SORTED_WITH_INSERT);
}
-
+
public void testViewerComparator(){
- fViewer.setComparator(new ViewerComparator());
+ comparatorTestViewer.setComparator(new ViewerComparator<Object,Object>());
assertSortedResult(TEAM1_SORTED);
}
-
+
public void testViewerComparatorInsertElement(){
- fViewer.setComparator(new ViewerComparator());
+ comparatorTestViewer.setComparator(new ViewerComparator<Object,Object>());
team1.addMember("Duong");
assertSortedResult(TEAM1_SORTED_WITH_INSERT);
}
-
+
private void assertSortedResult(String[] expected){
TableItem[] items = getTableViewer().getTable().getItems();
for (int i = 0; i < items.length; i++){
@@ -95,15 +95,15 @@ public class TableViewerComparatorTest extends ViewerComparatorTest {
assertEquals("Item not expected. actual=" + item.getText() + " expected=", expected[i], item.getText());
}
}
-
+
protected void setInput() {
- fViewer.setInput(team1);
+ comparatorTestViewer.setInput(team1);
}
-
- protected TableViewer getTableViewer(){
- return (TableViewer)fViewer;
+
+ protected TableViewer<Object,Object> getTableViewer(){
+ return (TableViewer<Object,Object>)comparatorTestViewer;
}
-
+
/**
* @param args
*/
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerTest.java
index a146c43..b5ff783 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TableViewerTest.java
@@ -29,22 +29,22 @@ import org.eclipse.swt.widgets.TableItem;
public class TableViewerTest extends StructuredItemViewerTest {
public static class TableTestLabelProvider extends TestLabelProvider
- implements ITableLabelProvider {
+ implements ITableLabelProvider<TestElement> {
public boolean fExtended = false;
- public String getText(Object element) {
+ public String getText(TestElement element) {
if (fExtended)
- return providedString((String) element);
+ return providedString(element.toString());
return element.toString();
}
- public String getColumnText(Object element, int index) {
+ public String getColumnText(TestElement element, int index) {
if (fExtended)
- return providedString((TestElement) element);
+ return providedString(element);
return element.toString();
}
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
}
@@ -56,8 +56,8 @@ public class TableViewerTest extends StructuredItemViewerTest {
/**
* Creates the viewer used by this test, under the given parent widget.
*/
- protected StructuredViewer createViewer(Composite parent) {
- TableViewer viewer = createTableViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ TableViewer<TestElement,TestElement> viewer = createTableViewer(parent);
viewer.setContentProvider(getContentProvider());
viewer.setLabelProvider(new TableTestLabelProvider());
viewer.getTable().setLinesVisible(true);
@@ -82,28 +82,28 @@ public class TableViewerTest extends StructuredItemViewerTest {
return viewer;
}
-
- ViewerColumn getViewerColumn(ColumnViewer viewer, int index) {
+
+ ViewerColumn<TestElement,TestElement> getViewerColumn(ColumnViewer<TestElement,TestElement> viewer, int index) {
Method method;
try {
method = ColumnViewer.class.getDeclaredMethod("getViewerColumn", new Class[]{int.class});
method.setAccessible(true);
- return (ViewerColumn) method.invoke(viewer, new Object[]{new Integer(index)});
+ return (ViewerColumn<TestElement,TestElement>) method.invoke(viewer, new Object[]{new Integer(index)});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void testViewerColumn() {
- assertNull(getViewerColumn((TableViewer) fViewer, -1));
- assertNotNull(getViewerColumn((TableViewer) fViewer, 0));
- assertNotNull(getViewerColumn((TableViewer) fViewer, 1));
- assertNull(getViewerColumn((TableViewer) fViewer, 2));
+ assertNull(getViewerColumn((TableViewer<TestElement,TestElement>) fViewer, -1));
+ assertNotNull(getViewerColumn((TableViewer<TestElement,TestElement>) fViewer, 0));
+ assertNotNull(getViewerColumn((TableViewer<TestElement,TestElement>) fViewer, 1));
+ assertNull(getViewerColumn((TableViewer<TestElement,TestElement>) fViewer, 2));
}
-
+
/**
* Get the content provider for the viewer.
- *
+ *
* @return IContentProvider
*/
protected TestModelContentProvider getContentProvider() {
@@ -112,12 +112,12 @@ public class TableViewerTest extends StructuredItemViewerTest {
/**
* Create the table viewer for the test
- *
+ *
* @param parent
* @return
*/
- protected TableViewer createTableViewer(Composite parent) {
- return new TableViewer(parent);
+ protected TableViewer<TestElement,TestElement> createTableViewer(Composite parent) {
+ return new TableViewer<TestElement,TestElement>(parent);
}
protected int getItemCount() {
@@ -138,7 +138,7 @@ public class TableViewerTest extends StructuredItemViewerTest {
public void testLabelProvider() {
- TableViewer viewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> viewer = (TableViewer<TestElement,TestElement>) fViewer;
TableTestLabelProvider provider = (TableTestLabelProvider) viewer
.getLabelProvider();
@@ -155,7 +155,7 @@ public class TableViewerTest extends StructuredItemViewerTest {
}
public void testLabelProviderStateChange() {
- TableViewer tableviewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> tableviewer = (TableViewer<TestElement,TestElement>) fViewer;
TableTestLabelProvider provider = (TableTestLabelProvider) tableviewer
.getLabelProvider();
@@ -174,15 +174,15 @@ public class TableViewerTest extends StructuredItemViewerTest {
}
public void testRemove() {
- TableViewer tableviewer = (TableViewer) fViewer;
+ TableViewer<TestElement,TestElement> tableviewer = (TableViewer<TestElement,TestElement>) fViewer;
TestElement first = fRootElement.getFirstChild();
- ((TestElement) fViewer.getInput()).deleteChild(first);
+ fViewer.getInput().deleteChild(first);
tableviewer.remove(first);
assertTrue("Removed item still exists",
fViewer.testFindItem(first) == null);
}
-
+
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestComparator.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestComparator.java
index 1814fce..45eb7d6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestComparator.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestComparator.java
@@ -15,10 +15,10 @@ import java.util.Comparator;
/**
* @since 3.1
*/
-public class TestComparator implements Comparator {
+public class TestComparator implements Comparator<Object> {
public volatile int comparisons = 0;
-
+
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestElement.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestElement.java
index 882549a..eaec07b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestElement.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestElement.java
@@ -21,7 +21,7 @@ public class TestElement implements Cloneable {
String fId;
- Vector fChildren = new Vector();
+ Vector<TestElement> fChildren = new Vector<TestElement>();
boolean fIsDeleted = false;
@@ -131,7 +131,7 @@ public class TestElement implements Cloneable {
public void deleteChildren() {
for (int i = fChildren.size() - 1; i >= 0; i--) {
- TestElement te = (TestElement) fChildren.elementAt(i);
+ TestElement te = fChildren.elementAt(i);
fChildren.remove(te);
te.fIsDeleted = true;
}
@@ -141,7 +141,7 @@ public class TestElement implements Cloneable {
public void deleteSomeChildren() {
for (int i = fChildren.size() - 1; i >= 0; i -= 2) {
- TestElement te = (TestElement) fChildren.elementAt(i);
+ TestElement te = fChildren.elementAt(i);
fChildren.remove(te);
te.fIsDeleted = true;
}
@@ -157,13 +157,13 @@ public class TestElement implements Cloneable {
}
public TestElement getChildAt(int i) {
- return (TestElement) fChildren.elementAt(i);
+ return fChildren.elementAt(i);
}
public int getChildCount() {
return fChildren.size();
}
-
+
/**
* Get the children of the receiver.
* @return TestElement[]
@@ -171,7 +171,7 @@ public class TestElement implements Cloneable {
public TestElement[] getChildren(){
TestElement[] result = new TestElement[fChildren.size()];
fChildren.toArray(result);
- return result;
+ return result;
}
public TestElement getContainer() {
@@ -180,7 +180,7 @@ public class TestElement implements Cloneable {
public TestElement getFirstChild() {
if (fChildren.size() > 0)
- return (TestElement) fChildren.elementAt(0);
+ return fChildren.elementAt(0);
return null;
}
@@ -195,7 +195,7 @@ public class TestElement implements Cloneable {
public TestElement getLastChild() {
int size = fChildren.size();
if (size > 0)
- return (TestElement) fChildren.elementAt(size - 1);
+ return fChildren.elementAt(size - 1);
return null;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLabelProvider.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLabelProvider.java
index 711b5b2..c726d88 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLabelProvider.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLabelProvider.java
@@ -14,7 +14,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-public class TestLabelProvider extends LabelProvider {
+public class TestLabelProvider<E> extends LabelProvider<E> {
static Image fgImage = null;
@@ -28,11 +28,11 @@ public class TestLabelProvider extends LabelProvider {
return fgImage;
}
- public Image getImage(Object element) {
+ public Image getImage(E element) {
return getImage();
}
- public String getText(Object element) {
+ public String getText(E element) {
String label = element.toString();
return label + " <rendered>";
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java
index 4cb3f2b..7bb83c5 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestLazyModelContentProvider.java
@@ -22,29 +22,29 @@ import org.eclipse.jface.viewers.Viewer;
* The TestLazyModelContentProvider is the lazy version
* of the model content provider.
*/
-public class TestLazyModelContentProvider extends TestModelContentProvider implements ILazyContentProvider, IContentProvider {
-
+public class TestLazyModelContentProvider extends TestModelContentProvider implements ILazyContentProvider<TestElement>, IContentProvider<TestElement> {
+
TableViewerTest test;
TestElement input;
-
+
TestLazyModelContentProvider(TableViewerTest testObject){
test = testObject;
if(!(testObject instanceof VirtualLazyTableViewerTest)) {
throw new AssertionFailedError("TestLazyModelContentProvider only works with VirtualLazyTableViewerTest");
}
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILazyContentProvider#updateElements(int, int)
*/
public void updateElement(int index) {
-
+
((VirtualLazyTableViewerTest)test).updateElementCalled(index);
if(input == null)
return; //Nothing to update yet
-
- ((TableViewer) test.fViewer).replace(input.getChildAt(index), index);
+
+ ((TableViewer<TestElement,TestElement>) test.fViewer).replace(input.getChildAt(index), index);
}
@@ -54,20 +54,20 @@ public class TestLazyModelContentProvider extends TestModelContentProvider imple
public void dispose() {
super.dispose();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.TestModelContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- input = (TestElement) newInput;
- ((TableViewer)viewer).setItemCount(input==null?0:input.getChildCount());
+ public void inputChanged(Viewer<TestElement> viewer, TestElement oldInput, TestElement newInput) {
+ input = newInput;
+ ((TableViewer<TestElement,TestElement>)viewer).setItemCount(input==null?0:input.getChildCount());
super.inputChanged(viewer, oldInput, newInput);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.TestModelContentProvider#getElements(java.lang.Object)
*/
- public Object[] getElements(Object element) {
+ public TestElement[] getElements(TestElement element) {
Assert.isTrue(false,"Should not ever call getElements if lazy");
return super.getElements(element);
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModel.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModel.java
index 21a8f34..3f31380 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModel.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModel.java
@@ -13,7 +13,7 @@ package org.eclipse.jface.tests.viewers;
import java.util.Vector;
public class TestModel {
- Vector fListeners = new Vector();
+ Vector<ITestModelListener> fListeners = new Vector<ITestModelListener>();
int fNumLevels;
@@ -32,11 +32,10 @@ public class TestModel {
* Fires a model changed event to all listeners.
*/
public void fireModelChanged(TestModelChange change) {
- for (int i = 0; i < fListeners.size(); ++i) {
- ITestModelListener listener = (ITestModelListener) fListeners
- .get(i);
- listener.testModelChanged(change);
- }
+ for (int i = 0; i < fListeners.size(); ++i) {
+ ITestModelListener listener = fListeners.get(i);
+ listener.testModelChanged(change);
+ }
}
public int getNumChildren() {
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelContentProvider.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelContentProvider.java
index 3928e64..c174c8e 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelContentProvider.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelContentProvider.java
@@ -23,8 +23,8 @@ import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
public class TestModelContentProvider implements ITestModelListener,
- IStructuredContentProvider, ITreeContentProvider {
- Viewer fViewer;
+ IStructuredContentProvider<TestElement,TestElement>, ITreeContentProvider<TestElement,TestElement> {
+ Viewer<TestElement> fViewer;
public void dispose() {
}
@@ -33,18 +33,18 @@ public class TestModelContentProvider implements ITestModelListener,
if (fViewer instanceof ListViewer) {
if (change.getParent() != null
&& change.getParent().equals(fViewer.getInput())) {
- ((ListViewer) fViewer).add(change.getChildren());
+ ((ListViewer<TestElement,TestElement>) fViewer).add(change.getChildren());
}
} else if (fViewer instanceof TableViewer) {
if (change.getParent() != null
&& change.getParent().equals(fViewer.getInput())) {
- ((TableViewer) fViewer).add(change.getChildren());
+ ((TableViewer<TestElement,TestElement>) fViewer).add(change.getChildren());
}
} else if (fViewer instanceof AbstractTreeViewer) {
- ((AbstractTreeViewer) fViewer).add(change.getParent(), change
+ ((AbstractTreeViewer<TestElement,TestElement>) fViewer).add(change.getParent(), change
.getChildren());
} else if (fViewer instanceof ComboViewer) {
- ((ComboViewer) fViewer).add(change.getChildren());
+ ((ComboViewer<TestElement,TestElement>) fViewer).add(change.getChildren());
} else {
Assert.isTrue(false, "Unknown kind of viewer");
}
@@ -52,7 +52,7 @@ public class TestModelContentProvider implements ITestModelListener,
protected void doNonStructureChange(TestModelChange change) {
if (fViewer instanceof StructuredViewer) {
- ((StructuredViewer) fViewer).update(change.getParent(),
+ ((StructuredViewer<TestElement,TestElement>) fViewer).update(change.getParent(),
new String[] { IBasicPropertyConstants.P_TEXT });
} else {
Assert.isTrue(false, "Unknown kind of viewer");
@@ -61,13 +61,13 @@ public class TestModelContentProvider implements ITestModelListener,
protected void doRemove(TestModelChange change) {
if (fViewer instanceof ListViewer) {
- ((ListViewer) fViewer).remove(change.getChildren());
+ ((ListViewer<TestElement,TestElement>) fViewer).remove(change.getChildren());
} else if (fViewer instanceof TableViewer) {
- ((TableViewer) fViewer).remove(change.getChildren());
+ ((TableViewer<TestElement,TestElement>) fViewer).remove(change.getChildren());
} else if (fViewer instanceof AbstractTreeViewer) {
- ((AbstractTreeViewer) fViewer).remove(change.getChildren());
+ ((AbstractTreeViewer<TestElement,TestElement>) fViewer).remove(change.getChildren());
} else if (fViewer instanceof ComboViewer) {
- ((ComboViewer) fViewer).remove(change.getChildren());
+ ((ComboViewer<TestElement,TestElement>) fViewer).remove(change.getChildren());
} else {
Assert.isTrue(false, "Unknown kind of viewer");
}
@@ -75,14 +75,14 @@ public class TestModelContentProvider implements ITestModelListener,
protected void doStructureChange(TestModelChange change) {
if (fViewer instanceof StructuredViewer) {
- ((StructuredViewer) fViewer).refresh(change.getParent());
+ ((StructuredViewer<TestElement,TestElement>) fViewer).refresh(change.getParent());
} else {
Assert.isTrue(false, "Unknown kind of viewer");
}
}
- public Object[] getChildren(Object element) {
- TestElement testElement = (TestElement) element;
+ public TestElement[] getChildren(TestElement element) {
+ TestElement testElement = element;
int count = testElement.getChildCount();
TestElement[] children = new TestElement[count];
for (int i = 0; i < count; ++i)
@@ -90,25 +90,25 @@ public class TestModelContentProvider implements ITestModelListener,
return children;
}
- public Object[] getElements(Object element) {
+ public TestElement[] getElements(TestElement element) {
return getChildren(element);
}
- public Object getParent(Object element) {
- return ((TestElement) element).getContainer();
+ public TestElement getParent(TestElement element) {
+ return element.getContainer();
}
- public boolean hasChildren(Object element) {
- return ((TestElement) element).getChildCount() > 0;
+ public boolean hasChildren(TestElement element) {
+ return element.getChildCount() > 0;
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<TestElement> viewer, TestElement oldInput, TestElement newInput) {
fViewer = viewer;
- TestElement oldElement = (TestElement) oldInput;
+ TestElement oldElement = oldInput;
if (oldElement != null) {
oldElement.getModel().removeListener(this);
}
- TestElement newElement = (TestElement) newInput;
+ TestElement newElement = newInput;
if (newElement != null) {
newElement.getModel().addListener(this);
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelLazyTreeContentProvider.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelLazyTreeContentProvider.java
index 6d64b60..dd514d0 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelLazyTreeContentProvider.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TestModelLazyTreeContentProvider.java
@@ -17,16 +17,16 @@ import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
public class TestModelLazyTreeContentProvider extends TestModelContentProvider
- implements ILazyTreeContentProvider {
+ implements ILazyTreeContentProvider<TestElement,TestElement> {
- private final TreeViewer treeViewer;
+ private final TreeViewer<TestElement,TestElement> treeViewer;
- public TestModelLazyTreeContentProvider(TreeViewer treeViewer) {
+ public TestModelLazyTreeContentProvider(TreeViewer<TestElement,TestElement> treeViewer) {
this.treeViewer = treeViewer;
}
- public void updateElement(Object parent, int index) {
- TestElement parentElement = (TestElement) parent;
+ public void updateElement(TestElement parent, int index) {
+ TestElement parentElement = parent;
if(parentElement.getChildCount() > index) {
TestElement childElement = parentElement.getChildAt(index);
treeViewer.replace(parent, index, childElement);
@@ -34,28 +34,28 @@ public class TestModelLazyTreeContentProvider extends TestModelContentProvider
}
}
- public Object[] getChildren(Object element) {
+ public TestElement[] getChildren(TestElement element) {
Assert.fail("should not be called on a LazyTreeContentProvider");
return null;
}
- public Object[] getElements(Object element) {
+ public TestElement[] getElements(TestElement element) {
Assert.fail("should not be called on a LazyTreeContentProvider");
return null;
}
- public boolean hasChildren(Object element) {
+ public boolean hasChildren(TestElement element) {
Assert.fail("should not be called on a LazyTreeContentProvider");
return false;
}
- public void inputChanged(Viewer viewer, Object oldInput,
- final Object newInput) {
+ public void inputChanged(Viewer<TestElement> viewer, TestElement oldInput,
+ final TestElement newInput) {
super.inputChanged(viewer, oldInput, newInput);
}
- public void updateChildCount(Object element, int currentChildCount) {
- treeViewer.setChildCount(element, ((TestElement) element).getChildCount());
+ public void updateChildCount(TestElement element, int currentChildCount) {
+ treeViewer.setChildCount(element, element.getChildCount());
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java
index 288617e..b0595e9 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeManagerTest.java
@@ -20,88 +20,88 @@ import org.eclipse.ui.internal.dialogs.TreeManager;
import org.eclipse.ui.internal.dialogs.TreeManager.TreeItem;
public class TreeManagerTest extends TestCase {
-
- private static final List STATE_NAMES;
-
+
+ private static final List<String> STATE_NAMES;
+
private static final int CHECKSTATE_UNCHECKED = 0;
private static final int CHECKSTATE_GRAY = 1;
private static final int CHECKSTATE_CHECKED = 2;
-
+
static {
- STATE_NAMES = new ArrayList();
+ STATE_NAMES = new ArrayList<String>();
STATE_NAMES.add(CHECKSTATE_UNCHECKED, "unchecked");
STATE_NAMES.add(CHECKSTATE_GRAY, "gray");
STATE_NAMES.add(CHECKSTATE_CHECKED, "checked");
}
-
+
private static String getName(int checkstate) {
- return (String)STATE_NAMES.get(checkstate);
+ return STATE_NAMES.get(checkstate);
}
-
+
private static void assertState(TreeItem item, int expectedState) throws Exception {
Field checkStateField = TreeItem.class.getDeclaredField("checkState");
checkStateField.setAccessible(true);
int checkState = checkStateField.getInt(item);
-
- assertEquals("For TreeItem " + item.getLabel() + ", expected " +
+
+ assertEquals("For TreeItem " + item.getLabel() + ", expected " +
getName(expectedState) + " but was " + getName(checkState) + ";",
expectedState, checkState);
}
-
+
public void testSingleEntry() throws Exception {
TreeManager manager = new TreeManager();
TreeItem item = manager.new TreeItem("item");
-
- item.setCheckState(true);
+
+ item.setCheckState(true);
assertState(item, CHECKSTATE_CHECKED);
-
- item.setCheckState(true);
+
+ item.setCheckState(true);
assertState(item, CHECKSTATE_CHECKED);
-
- item.setCheckState(false);
+
+ item.setCheckState(false);
assertState(item, CHECKSTATE_UNCHECKED);
-
- item.setCheckState(true);
+
+ item.setCheckState(true);
assertState(item, CHECKSTATE_CHECKED);
-
- item.setCheckState(false);
+
+ item.setCheckState(false);
assertState(item, CHECKSTATE_UNCHECKED);
- item.setCheckState(false);
+ item.setCheckState(false);
assertState(item, CHECKSTATE_UNCHECKED);
}
-
+
public void testSingleChildAffectsParent() throws Exception {
TreeManager manager = new TreeManager();
TreeItem parent = manager.new TreeItem("parent");
TreeItem child = manager.new TreeItem("child");
parent.addChild(child);
-
+
child.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
child.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
child.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
-
+
child.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
child.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
-
+
child.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
}
-
+
public void testTwoChildrenAffectParent() throws Exception {
TreeManager manager = new TreeManager();
TreeItem parent = manager.new TreeItem("parent");
@@ -109,29 +109,29 @@ public class TreeManagerTest extends TestCase {
TreeItem daughter = manager.new TreeItem("daughter");
parent.addChild(son);
parent.addChild(daughter);
-
+
son.setCheckState(true);
daughter.setCheckState(false);
assertState(parent, CHECKSTATE_GRAY);
assertState(son, CHECKSTATE_CHECKED);
assertState(daughter, CHECKSTATE_UNCHECKED);
-
+
daughter.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(son, CHECKSTATE_CHECKED);
assertState(daughter, CHECKSTATE_CHECKED);
-
+
son.setCheckState(false);
assertState(parent, CHECKSTATE_GRAY);
assertState(son, CHECKSTATE_UNCHECKED);
assertState(daughter, CHECKSTATE_CHECKED);
-
+
daughter.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(son, CHECKSTATE_UNCHECKED);
assertState(daughter, CHECKSTATE_UNCHECKED);
}
-
+
public void testCheckUncheckChildAt3Deep() throws Exception {
TreeManager manager = new TreeManager();
TreeItem grandparent = manager.new TreeItem("grandparent");
@@ -139,38 +139,38 @@ public class TreeManagerTest extends TestCase {
TreeItem child = manager.new TreeItem("child");
grandparent.addChild(parent);
parent.addChild(child);
-
+
child.setCheckState(true);
assertState(grandparent, CHECKSTATE_CHECKED);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
child.setCheckState(true);
assertState(grandparent, CHECKSTATE_CHECKED);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
child.setCheckState(false);
assertState(grandparent, CHECKSTATE_UNCHECKED);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
-
+
child.setCheckState(true);
assertState(grandparent, CHECKSTATE_CHECKED);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
child.setCheckState(false);
assertState(grandparent, CHECKSTATE_UNCHECKED);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
-
+
child.setCheckState(false);
assertState(grandparent, CHECKSTATE_UNCHECKED);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
}
-
+
public void testCauseGrayAt3Deep() throws Exception {
TreeManager manager = new TreeManager();
TreeItem grandparent = manager.new TreeItem("grandparent");
@@ -180,33 +180,33 @@ public class TreeManagerTest extends TestCase {
grandparent.addChild(parent);
parent.addChild(child1);
parent.addChild(child2);
-
+
child1.setCheckState(true);
child2.setCheckState(false);
assertState(grandparent, CHECKSTATE_GRAY);
assertState(parent, CHECKSTATE_GRAY);
assertState(child1, CHECKSTATE_CHECKED);
assertState(child2, CHECKSTATE_UNCHECKED);
-
+
child2.setCheckState(true);
assertState(grandparent, CHECKSTATE_CHECKED);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child1, CHECKSTATE_CHECKED);
assertState(child2, CHECKSTATE_CHECKED);
-
+
child1.setCheckState(false);
assertState(grandparent, CHECKSTATE_GRAY);
assertState(parent, CHECKSTATE_GRAY);
assertState(child1, CHECKSTATE_UNCHECKED);
assertState(child2, CHECKSTATE_CHECKED);
-
+
child2.setCheckState(false);
assertState(grandparent, CHECKSTATE_UNCHECKED);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child1, CHECKSTATE_UNCHECKED);
assertState(child2, CHECKSTATE_UNCHECKED);
}
-
+
public void testCheckUncheckChildAt5Deep() throws Exception {
TreeManager manager = new TreeManager();
TreeItem items[] = new TreeItem[5];
@@ -215,16 +215,16 @@ public class TreeManagerTest extends TestCase {
if(i > 0)
items[i-1].addChild(items[i]);
}
-
+
items[4].setCheckState(true);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_CHECKED);
-
+
items[4].setCheckState(false);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_UNCHECKED);
}
-
+
public void testCauseGrayAt5Deep() throws Exception {
TreeManager manager = new TreeManager();
TreeItem items[] = new TreeItem[4];
@@ -237,33 +237,33 @@ public class TreeManagerTest extends TestCase {
TreeItem child2 = manager.new TreeItem("child2");
items[3].addChild(child1);
items[3].addChild(child2);
-
+
child1.setCheckState(true);
child2.setCheckState(false);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_GRAY);
assertState(child1, CHECKSTATE_CHECKED);
assertState(child2, CHECKSTATE_UNCHECKED);
-
+
child2.setCheckState(true);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_CHECKED);
assertState(child1, CHECKSTATE_CHECKED);
assertState(child2, CHECKSTATE_CHECKED);
-
+
child1.setCheckState(false);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_GRAY);
assertState(child1, CHECKSTATE_UNCHECKED);
assertState(child2, CHECKSTATE_CHECKED);
-
+
child2.setCheckState(false);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_UNCHECKED);
assertState(child1, CHECKSTATE_UNCHECKED);
assertState(child2, CHECKSTATE_UNCHECKED);
}
-
+
public void testChildrenInMultipleBranchesAffectAncestors() throws Exception {
TreeManager manager = new TreeManager();
TreeItem root = manager.new TreeItem("root");
@@ -273,19 +273,19 @@ public class TreeManagerTest extends TestCase {
TreeItem itemB = manager.new TreeItem("itemB");
TreeItem itemB1 = manager.new TreeItem("itemB1");
TreeItem itemB2 = manager.new TreeItem("itemB2");
-
+
root.addChild(itemA);
root.addChild(itemB);
itemA.addChild(itemA1);
itemA.addChild(itemA2);
itemB.addChild(itemB1);
itemB.addChild(itemB2);
-
+
itemA1.setCheckState(true);
itemA2.setCheckState(false);
itemB1.setCheckState(false);
itemB2.setCheckState(false);
-
+
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_GRAY);
assertState(itemA1, CHECKSTATE_CHECKED);
@@ -293,7 +293,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_UNCHECKED);
assertState(itemB1, CHECKSTATE_UNCHECKED);
assertState(itemB2, CHECKSTATE_UNCHECKED);
-
+
itemB2.setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_GRAY);
@@ -302,7 +302,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_GRAY);
assertState(itemB1, CHECKSTATE_UNCHECKED);
assertState(itemB2, CHECKSTATE_CHECKED);
-
+
itemA1.setCheckState(false);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_UNCHECKED);
@@ -311,7 +311,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_GRAY);
assertState(itemB1, CHECKSTATE_UNCHECKED);
assertState(itemB2, CHECKSTATE_CHECKED);
-
+
itemB1.setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_UNCHECKED);
@@ -320,7 +320,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_CHECKED);
assertState(itemB1, CHECKSTATE_CHECKED);
assertState(itemB2, CHECKSTATE_CHECKED);
-
+
itemA1.setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_GRAY);
@@ -329,7 +329,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_CHECKED);
assertState(itemB1, CHECKSTATE_CHECKED);
assertState(itemB2, CHECKSTATE_CHECKED);
-
+
itemA2.setCheckState(true);
assertState(root, CHECKSTATE_CHECKED);
assertState(itemA, CHECKSTATE_CHECKED);
@@ -338,7 +338,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_CHECKED);
assertState(itemB1, CHECKSTATE_CHECKED);
assertState(itemB2, CHECKSTATE_CHECKED);
-
+
itemB2.setCheckState(false);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_CHECKED);
@@ -347,7 +347,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_GRAY);
assertState(itemB1, CHECKSTATE_CHECKED);
assertState(itemB2, CHECKSTATE_UNCHECKED);
-
+
itemA1.setCheckState(false);
itemA2.setCheckState(false);
itemB1.setCheckState(false);
@@ -359,7 +359,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB1, CHECKSTATE_UNCHECKED);
assertState(itemB2, CHECKSTATE_UNCHECKED);
}
-
+
public void testMultipleChildrenInOneBranchAffectParent() throws Exception {
TreeManager manager = new TreeManager();
TreeItem root = manager.new TreeItem("root");
@@ -369,7 +369,7 @@ public class TreeManagerTest extends TestCase {
root.addChild(items[i]);
items[i].setCheckState(false);
}
-
+
items[0].setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
assertState(items[0], CHECKSTATE_CHECKED);
@@ -377,7 +377,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_UNCHECKED);
assertState(items[3], CHECKSTATE_UNCHECKED);
assertState(items[4], CHECKSTATE_UNCHECKED);
-
+
items[1].setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
assertState(items[0], CHECKSTATE_CHECKED);
@@ -385,7 +385,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_UNCHECKED);
assertState(items[3], CHECKSTATE_UNCHECKED);
assertState(items[4], CHECKSTATE_UNCHECKED);
-
+
items[0].setCheckState(false);
assertState(root, CHECKSTATE_GRAY);
assertState(items[0], CHECKSTATE_UNCHECKED);
@@ -393,7 +393,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_UNCHECKED);
assertState(items[3], CHECKSTATE_UNCHECKED);
assertState(items[4], CHECKSTATE_UNCHECKED);
-
+
items[2].setCheckState(true);
items[3].setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
@@ -402,7 +402,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_CHECKED);
assertState(items[3], CHECKSTATE_CHECKED);
assertState(items[4], CHECKSTATE_UNCHECKED);
-
+
items[0].setCheckState(true);
items[4].setCheckState(true);
assertState(root, CHECKSTATE_CHECKED);
@@ -411,7 +411,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_CHECKED);
assertState(items[3], CHECKSTATE_CHECKED);
assertState(items[4], CHECKSTATE_CHECKED);
-
+
items[2].setCheckState(false);
assertState(root, CHECKSTATE_GRAY);
assertState(items[0], CHECKSTATE_CHECKED);
@@ -419,7 +419,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_UNCHECKED);
assertState(items[3], CHECKSTATE_CHECKED);
assertState(items[4], CHECKSTATE_CHECKED);
-
+
items[0].setCheckState(false);
items[1].setCheckState(false);
items[3].setCheckState(false);
@@ -431,38 +431,38 @@ public class TreeManagerTest extends TestCase {
assertState(items[3], CHECKSTATE_UNCHECKED);
assertState(items[4], CHECKSTATE_UNCHECKED);
}
-
+
public void testParentAffectsSingleChild() throws Exception {
TreeManager manager = new TreeManager();
TreeItem parent = manager.new TreeItem("parent");
TreeItem child = manager.new TreeItem("child");
parent.addChild(child);
-
+
parent.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
parent.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
parent.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
-
+
parent.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(child, CHECKSTATE_CHECKED);
-
+
parent.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
-
+
parent.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(child, CHECKSTATE_UNCHECKED);
}
-
+
public void testParentAffectsTwoChildren() throws Exception {
TreeManager manager = new TreeManager();
TreeItem parent = manager.new TreeItem("parent");
@@ -470,38 +470,38 @@ public class TreeManagerTest extends TestCase {
TreeItem daughter = manager.new TreeItem("daughter");
parent.addChild(son);
parent.addChild(daughter);
-
+
parent.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(son, CHECKSTATE_CHECKED);
assertState(daughter, CHECKSTATE_CHECKED);
-
+
parent.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(son, CHECKSTATE_CHECKED);
assertState(daughter, CHECKSTATE_CHECKED);
-
+
parent.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(son, CHECKSTATE_UNCHECKED);
assertState(daughter, CHECKSTATE_UNCHECKED);
-
+
parent.setCheckState(true);
assertState(parent, CHECKSTATE_CHECKED);
assertState(son, CHECKSTATE_CHECKED);
assertState(daughter, CHECKSTATE_CHECKED);
-
+
parent.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(son, CHECKSTATE_UNCHECKED);
assertState(daughter, CHECKSTATE_UNCHECKED);
-
+
parent.setCheckState(false);
assertState(parent, CHECKSTATE_UNCHECKED);
assertState(son, CHECKSTATE_UNCHECKED);
assertState(daughter, CHECKSTATE_UNCHECKED);
}
-
+
public void testParentAffectsMultipleChildrenInOneBranch() throws Exception {
TreeManager manager = new TreeManager();
TreeItem root = manager.new TreeItem("root");
@@ -511,7 +511,7 @@ public class TreeManagerTest extends TestCase {
root.addChild(items[i]);
items[i].setCheckState(false);
}
-
+
root.setCheckState(true);
assertState(root, CHECKSTATE_CHECKED);
assertState(items[0], CHECKSTATE_CHECKED);
@@ -519,7 +519,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[2], CHECKSTATE_CHECKED);
assertState(items[3], CHECKSTATE_CHECKED);
assertState(items[4], CHECKSTATE_CHECKED);
-
+
root.setCheckState(false);
assertState(root, CHECKSTATE_UNCHECKED);
assertState(items[0], CHECKSTATE_UNCHECKED);
@@ -528,7 +528,7 @@ public class TreeManagerTest extends TestCase {
assertState(items[3], CHECKSTATE_UNCHECKED);
assertState(items[4], CHECKSTATE_UNCHECKED);
}
-
+
public void testParentAffectsDescendantsInMultipleBranches() throws Exception {
TreeManager manager = new TreeManager();
TreeItem root = manager.new TreeItem("root");
@@ -538,14 +538,14 @@ public class TreeManagerTest extends TestCase {
TreeItem itemB = manager.new TreeItem("itemB");
TreeItem itemB1 = manager.new TreeItem("itemB1");
TreeItem itemB2 = manager.new TreeItem("itemB2");
-
+
root.addChild(itemA);
root.addChild(itemB);
itemA.addChild(itemA1);
itemA.addChild(itemA2);
itemB.addChild(itemB1);
itemB.addChild(itemB2);
-
+
root.setCheckState(true);
assertState(root, CHECKSTATE_CHECKED);
assertState(itemA, CHECKSTATE_CHECKED);
@@ -554,7 +554,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB, CHECKSTATE_CHECKED);
assertState(itemB1, CHECKSTATE_CHECKED);
assertState(itemB2, CHECKSTATE_CHECKED);
-
+
root.setCheckState(false);
assertState(root, CHECKSTATE_UNCHECKED);
assertState(itemA, CHECKSTATE_UNCHECKED);
@@ -564,7 +564,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemB1, CHECKSTATE_UNCHECKED);
assertState(itemB2, CHECKSTATE_UNCHECKED);
}
-
+
public void testCheckUncheckParentWithDescendants5Deep() throws Exception {
TreeManager manager = new TreeManager();
TreeItem items[] = new TreeItem[5];
@@ -573,16 +573,16 @@ public class TreeManagerTest extends TestCase {
if(i > 0)
items[i-1].addChild(items[i]);
}
-
+
items[0].setCheckState(true);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_CHECKED);
-
+
items[0].setCheckState(false);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_UNCHECKED);
}
-
+
public void testChangeOnGray() throws Exception {
TreeManager manager = new TreeManager();
TreeItem root = manager.new TreeItem("root");
@@ -590,40 +590,40 @@ public class TreeManagerTest extends TestCase {
TreeItem itemA1 = manager.new TreeItem("itemA1");
TreeItem itemA2 = manager.new TreeItem("itemA2");
TreeItem itemB = manager.new TreeItem("itemB");
-
+
root.addChild(itemA);
root.addChild(itemB);
itemA.addChild(itemA1);
itemA.addChild(itemA2);
-
+
root.setCheckState(true);
assertState(root, CHECKSTATE_CHECKED);
assertState(itemA, CHECKSTATE_CHECKED);
assertState(itemA1, CHECKSTATE_CHECKED);
assertState(itemA2, CHECKSTATE_CHECKED);
assertState(itemB, CHECKSTATE_CHECKED);
-
+
itemA.setCheckState(false);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_UNCHECKED);
assertState(itemA1, CHECKSTATE_UNCHECKED);
assertState(itemA2, CHECKSTATE_UNCHECKED);
assertState(itemB, CHECKSTATE_CHECKED);
-
+
itemA1.setCheckState(true);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_GRAY);
assertState(itemA1, CHECKSTATE_CHECKED);
assertState(itemA2, CHECKSTATE_UNCHECKED);
assertState(itemB, CHECKSTATE_CHECKED);
-
+
itemA.setCheckState(false);
assertState(root, CHECKSTATE_GRAY);
assertState(itemA, CHECKSTATE_UNCHECKED);
assertState(itemA1, CHECKSTATE_UNCHECKED);
assertState(itemA2, CHECKSTATE_UNCHECKED);
assertState(itemB, CHECKSTATE_CHECKED);
-
+
itemA.setCheckState(true);
assertState(root, CHECKSTATE_CHECKED);
assertState(itemA, CHECKSTATE_CHECKED);
@@ -631,7 +631,7 @@ public class TreeManagerTest extends TestCase {
assertState(itemA2, CHECKSTATE_CHECKED);
assertState(itemB, CHECKSTATE_CHECKED);
}
-
+
public void testCheckUncheckItemWithAncestorsAndDescendants() throws Exception {
TreeManager manager = new TreeManager();
TreeItem items[] = new TreeItem[5];
@@ -640,15 +640,15 @@ public class TreeManagerTest extends TestCase {
if(i > 0)
items[i-1].addChild(items[i]);
}
-
+
items[3].setCheckState(true);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_CHECKED);
-
+
items[3].setCheckState(false);
for(int i = 0; i < items.length; i++)
assertState(items[i], CHECKSTATE_UNCHECKED);
}
-
-
+
+
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerColumnTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerColumnTest.java
index 22f0bd0..b1608c1 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerColumnTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerColumnTest.java
@@ -27,23 +27,23 @@ import org.eclipse.swt.widgets.TreeItem;
public class TreeViewerColumnTest extends AbstractTreeViewerTest {
public static class TableTreeTestLabelProvider extends TestLabelProvider
- implements ITableLabelProvider {
+ implements ITableLabelProvider<TestElement> {
public boolean fExtended = false;
- public String getText(Object element) {
+ public String getText(TestElement element) {
if (fExtended)
- return providedString((String) element);
+ return providedString(element.toString());
return element.toString();
}
- public String getColumnText(Object element, int index) {
+ public String getColumnText(TestElement element, int index) {
if (fExtended)
- return providedString((TestElement) element);
+ return providedString(element);
return element.toString();
}
- public Image getColumnImage(Object element, int columnIndex) {
+ public Image getColumnImage(TestElement element, int columnIndex) {
return null;
}
}
@@ -52,8 +52,8 @@ public class TreeViewerColumnTest extends AbstractTreeViewerTest {
super(name);
}
- protected StructuredViewer createViewer(Composite parent) {
- TreeViewer viewer = new TreeViewer(parent);
+ protected StructuredViewer<TestElement,TestElement> createViewer(Composite parent) {
+ TreeViewer<TestElement,TestElement> viewer = new TreeViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
viewer.setLabelProvider(new TableTreeTestLabelProvider());
viewer.getTree().setLinesVisible(true);
@@ -74,7 +74,7 @@ public class TreeViewerColumnTest extends AbstractTreeViewerTest {
fTreeViewer = viewer;
return viewer;
}
-
+
protected int getItemCount() {
TestElement first = fRootElement.getFirstChild();
TreeItem ti = (TreeItem) fViewer.testFindItem(first);
@@ -94,26 +94,26 @@ public class TreeViewerColumnTest extends AbstractTreeViewerTest {
junit.textui.TestRunner.run(TreeViewerColumnTest.class);
}
- private ViewerColumn getViewerColumn(ColumnViewer viewer, int index) {
+ private ViewerColumn<TestElement,TestElement> getViewerColumn(ColumnViewer<TestElement,TestElement> viewer, int index) {
Method method;
try {
method = ColumnViewer.class.getDeclaredMethod("getViewerColumn", new Class[]{int.class});
method.setAccessible(true);
- return (ViewerColumn) method.invoke(viewer, new Object[]{new Integer(index)});
+ return (ViewerColumn<TestElement,TestElement>) method.invoke(viewer, new Object[]{new Integer(index)});
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void testViewerColumn() {
- assertNull(getViewerColumn((TreeViewer) fViewer, -1));
- assertNotNull(getViewerColumn((TreeViewer) fViewer, 0));
- assertNotNull(getViewerColumn((TreeViewer) fViewer, 1));
- assertNull(getViewerColumn((TreeViewer) fViewer, 2));
+ assertNull(getViewerColumn((TreeViewer<TestElement,TestElement>) fViewer, -1));
+ assertNotNull(getViewerColumn((TreeViewer<TestElement,TestElement>) fViewer, 0));
+ assertNotNull(getViewerColumn((TreeViewer<TestElement,TestElement>) fViewer, 1));
+ assertNull(getViewerColumn((TreeViewer<TestElement,TestElement>) fViewer, 2));
}
-
+
public void testLabelProvider() {
- TreeViewer viewer = (TreeViewer) fViewer;
+ TreeViewer<TestElement,TestElement> viewer = (TreeViewer<TestElement,TestElement>) fViewer;
TableTreeTestLabelProvider provider = (TableTreeTestLabelProvider) viewer
.getLabelProvider();
provider.fExtended = true;
@@ -128,7 +128,7 @@ public class TreeViewerColumnTest extends AbstractTreeViewerTest {
}
public void testLabelProviderStateChange() {
- TreeViewer viewer = (TreeViewer) fViewer;
+ TreeViewer<TestElement,TestElement> viewer = (TreeViewer<TestElement,TestElement>) fViewer;
TableTreeTestLabelProvider provider = (TableTreeTestLabelProvider) viewer
.getLabelProvider();
provider.fExtended = true;
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerComparatorTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerComparatorTest.java
index 8f3a08b..7f9ffdf 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerComparatorTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerComparatorTest.java
@@ -31,9 +31,9 @@ import org.eclipse.swt.widgets.TreeItem;
*
*/
public class TreeViewerComparatorTest extends ViewerComparatorTest{
-
- protected class TeamModelTreeContentProvider extends TeamModelContentProvider
- implements ITreeContentProvider{
+
+ protected class TeamModelTreeContentProvider extends TeamModelContentProvider
+ implements ITreeContentProvider<Object,Object>{
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
@@ -41,14 +41,14 @@ public class TreeViewerComparatorTest extends ViewerComparatorTest{
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
*/
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof List){
- List children = new ArrayList();
- Iterator iter = ((List)parentElement).iterator();
+ List<Object> children = new ArrayList<Object>();
+ Iterator<Object> iter = ((List<Object>)parentElement).iterator();
while(iter.hasNext()){
Object next = iter.next();
if (next instanceof Team){
@@ -61,7 +61,7 @@ public class TreeViewerComparatorTest extends ViewerComparatorTest{
else if (parentElement instanceof Team){
return ((Team)parentElement).members;
}
- return null;
+ return null;
}
/* (non-Javadoc)
@@ -85,116 +85,117 @@ public class TreeViewerComparatorTest extends ViewerComparatorTest{
}
return false;
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- List oldElement = (List) oldInput;
+ public void inputChanged(Viewer<Object> viewer, Object oldInput, Object newInput) {
+ List<Object> oldElement = (List<Object>) oldInput;
if (oldElement != null) {
- Iterator iter = oldElement.iterator();
+ Iterator<Object> iter = oldElement.iterator();
while (iter.hasNext()){
((Team)iter.next()).removeListener(this);
}
}
- List newElement = (List) newInput;
+ List<Object> newElement = (List<Object>) newInput;
if (newElement != null) {
- Iterator iter = newElement.iterator();
+ Iterator<Object> iter = newElement.iterator();
while (iter.hasNext()){
((Team)iter.next()).addListener(this);
}
- }
+ }
}
}
-
+
/**
* constructor
*/
public TreeViewerComparatorTest(String name) {
super(name);
}
-
+
public void testViewerSorter(){
- fViewer.setSorter(new ViewerSorter());
+ comparatorTestViewer.setSorter(new ViewerSorter());
getTreeViewer().expandAll();
String[][] expected = {TEAM3_SORTED, TEAM2_SORTED, TEAM1_SORTED};
assertSortedResult(expected);
}
-
+
public void testViewerSorterInsertElement(){
- fViewer.setSorter(new ViewerSorter());
+ comparatorTestViewer.setSorter(new ViewerSorter());
getTreeViewer().expandAll();
team1.addMember("Duong");
String[][] expected = {TEAM3_SORTED, TEAM2_SORTED, TEAM1_SORTED_WITH_INSERT};
assertSortedResult(expected);
}
-
+
public void testViewerComparator(){
- fViewer.setComparator(new ViewerComparator());
+ comparatorTestViewer.setComparator(new ViewerComparator<Object,Object>());
getTreeViewer().expandAll();
String[][] expected = {TEAM3_SORTED, TEAM2_SORTED, TEAM1_SORTED};
assertSortedResult(expected);
}
-
+
public void testViewerComparatorInsertElement(){
- fViewer.setComparator(new ViewerComparator());
+ comparatorTestViewer.setComparator(new ViewerComparator<Object,Object>());
getTreeViewer().expandAll();
team1.addMember("Duong");
String[][] expected = {TEAM3_SORTED, TEAM2_SORTED, TEAM1_SORTED_WITH_INSERT};
assertSortedResult(expected);
}
-
+
private void assertSortedResult(String[][] resultArrays){
TreeItem[] rootItems = getTreeViewer().getTree().getItems();
assertEquals("Number of root items in tree not correct (actual=" + rootItems.length + ")", 3, rootItems.length);
TreeItem item = rootItems[0];
- assertEquals("Item not expected. actual=" + item.getText() + " expected=" + CORE, CORE, item.getText());
+ assertEquals("Item not expected. actual=" + item.getText() + " expected=" + CORE, CORE, item.getText());
item = rootItems[1];
- assertEquals("Item not expected. actual=" + item.getText() + " expected=" + RUNTIME, RUNTIME, item.getText());
+ assertEquals("Item not expected. actual=" + item.getText() + " expected=" + RUNTIME, RUNTIME, item.getText());
item = rootItems[2];
- assertEquals("Item not expected. actual=" + item.getText() + " expected=" + UI, UI, item.getText());
-
+ assertEquals("Item not expected. actual=" + item.getText() + " expected=" + UI, UI, item.getText());
+
TreeItem[] childItems = rootItems[0].getItems();
for (int i = 0; i < childItems.length; i++){
TreeItem child = childItems[i];
String result = child.getText();
- assertEquals("", resultArrays[0][i], result);
+ assertEquals("", resultArrays[0][i], result);
}
childItems = rootItems[1].getItems();
for (int i = 0; i < childItems.length; i++){
TreeItem child = childItems[i];
String result = child.getText();
- assertEquals("", resultArrays[1][i], result);
+ assertEquals("", resultArrays[1][i], result);
}
childItems = rootItems[2].getItems();
for (int i = 0; i < childItems.length; i++){
TreeItem child = childItems[i];
String result = child.getText();
- assertEquals("", resultArrays[2][i], result);
+ assertEquals("", resultArrays[2][i], result);
}
}
- protected TreeViewer getTreeViewer(){
- return (TreeViewer)fViewer;
+ protected TreeViewer<Object,Object> getTreeViewer(){
+ return (TreeViewer<Object,Object>)comparatorTestViewer;
}
-
+
protected StructuredViewer createViewer(Composite parent) {
Tree tree = new Tree(fShell, SWT.SINGLE | SWT.H_SCROLL
| SWT.V_SCROLL | SWT.BORDER);
- TreeViewer viewer = new TreeViewer(tree);
+ TreeViewer<Object,Object> viewer = new TreeViewer<Object,Object>(tree);
viewer.setContentProvider(new TeamModelTreeContentProvider());
viewer.setLabelProvider(new TeamModelLabelProvider());
+ comparatorTestViewer = viewer;
return viewer;
}
protected void setInput() {
- List input = new ArrayList(3);
+ List<Object> input = new ArrayList<Object>(3);
input.add(team1);
input.add(team2);
input.add(team3);
- fViewer.setInput(input);
+ comparatorTestViewer.setInput(input);
}
-
+
/**
* @param args
*/
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerTest.java
index f956147..3571e4f 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/TreeViewerTest.java
@@ -23,7 +23,7 @@ public class TreeViewerTest extends AbstractTreeViewerTest {
}
protected StructuredViewer createViewer(Composite parent) {
- fTreeViewer = new TreeViewer(parent);
+ fTreeViewer = new TreeViewer<TestElement,TestElement>(parent);
fTreeViewer.setContentProvider(new TestModelContentProvider());
return fTreeViewer;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerComparatorTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerComparatorTest.java
index 79ea88d..677e84e 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerComparatorTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerComparatorTest.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ListViewer;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -30,17 +31,17 @@ import org.eclipse.jface.viewers.Viewer;
*/
public abstract class ViewerComparatorTest extends ViewerTestCase {
protected String UI = "UI";
- protected String[] TEAM1 = {"Karice", "Tod", "Eric", "Paul",
+ protected String[] TEAM1 = {"Karice", "Tod", "Eric", "Paul",
"Mike", "Michael", "Andrea", "Kim", "Boris", "Susan"};
- protected String[] TEAM1_SORTED = {"Andrea", "Boris", "Eric", "Karice", "Kim",
+ protected String[] TEAM1_SORTED = {"Andrea", "Boris", "Eric", "Karice", "Kim",
"Michael", "Mike", "Paul", "Susan", "Tod"};
- protected String[] TEAM1_SORTED_WITH_INSERT = {"Andrea", "Boris", "Duong", "Eric", "Karice", "Kim",
+ protected String[] TEAM1_SORTED_WITH_INSERT = {"Andrea", "Boris", "Duong", "Eric", "Karice", "Kim",
"Michael", "Mike", "Paul", "Susan", "Tod"};
-
+
protected String RUNTIME = "Runtime";
protected String[] TEAM2 = {"Pascal", "DJ", "Jeff", "Andrew", "Oleg"};
protected String[] TEAM2_SORTED = {"Andrew", "DJ", "Jeff", "Oleg", "Pascal"};
-
+
protected String CORE = "Core";
protected String[] TEAM3 = {"John", "Michael", "Bogdan"};
protected String[] TEAM3_SORTED = {"Bogdan", "John", "Michael"};
@@ -48,23 +49,25 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
protected Team team1 = new Team(UI, TEAM1);
protected Team team2 = new Team(RUNTIME, TEAM2);
protected Team team3 = new Team(CORE, TEAM3);
-
+
+ protected StructuredViewer<Object, Object> comparatorTestViewer;
+
/*
* model object - parent
*/
protected class Team {
- Vector fListeners = new Vector();
-
+ Vector<IComparatorModelListener> fListeners = new Vector<IComparatorModelListener>();
+
TeamMember[] members;
String name;
-
+
public Team(String name, String[] members){
this.name = name;
this.members = new TeamMember[members.length];
for (int i = 0; i < members.length; i++)
this.members[i] = new TeamMember(members[i], this);
}
-
+
public void addMember(String person){
TeamMember newMember = new TeamMember(person, this);
TeamMember[] newMembers = new TeamMember[members.length + 1];
@@ -77,7 +80,7 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
newMembers = null;
fireModelChanged(new ComparatorModelChange(TestModelChange.INSERT, this, newMember));
}
-
+
public void addListener(IComparatorModelListener listener) {
fListeners.addElement(listener);
}
@@ -87,7 +90,7 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
*/
public void fireModelChanged(ComparatorModelChange change) {
for (int i = 0; i < fListeners.size(); ++i) {
- IComparatorModelListener listener = (IComparatorModelListener) fListeners
+ IComparatorModelListener listener = fListeners
.get(i);
listener.modelChanged(change);
}
@@ -97,24 +100,24 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
fListeners.removeElement(listener);
}
}
-
+
/*
* model object - child
*/
protected class TeamMember {
String name;
Team team;
-
+
public TeamMember(String name, Team team){
this.name = name;
this.team = team;
}
}
-
+
/*
* label provider
*/
- protected class TeamModelLabelProvider extends LabelProvider{
+ protected class TeamModelLabelProvider extends LabelProvider<Object>{
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
*/
@@ -125,13 +128,13 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
return ((TeamMember)element).name;
}
return element.toString();
- }
+ }
}
-
+
/*
* content provider
*/
- protected class TeamModelContentProvider implements IComparatorModelListener,IStructuredContentProvider{
+ protected class TeamModelContentProvider implements IComparatorModelListener,IStructuredContentProvider<Object,Object>{
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
@@ -151,11 +154,11 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<Object> viewer, Object oldInput, Object newInput) {
if (oldInput != null){
((Team) oldInput).removeListener(this);;
}
-
+
if (newInput != null){
((Team) newInput).addListener(this);
}
@@ -182,62 +185,62 @@ public abstract class ViewerComparatorTest extends ViewerTestCase {
StructuredSelection selection = new StructuredSelection(change
.getChildren());
if ((change.getModifiers() & TestModelChange.SELECT) != 0) {
- fViewer.setSelection(selection);
+ comparatorTestViewer.setSelection(selection);
}
if ((change.getModifiers() & TestModelChange.REVEAL) != 0) {
Object element = selection.getFirstElement();
if (element != null) {
- fViewer.reveal(element);
+ comparatorTestViewer.reveal(element);
}
}
}
-
+
protected void doInsert(ComparatorModelChange change) {
- if (fViewer instanceof ListViewer) {
+ if (comparatorTestViewer instanceof ListViewer) {
if (change.getParent() != null
- && change.getParent().equals(fViewer.getInput())) {
- ((ListViewer) fViewer).add(change.getChildren());
+ && change.getParent().equals(comparatorTestViewer.getInput())) {
+ ((ListViewer<Object,Object>) comparatorTestViewer).add(change.getChildren());
}
- } else if (fViewer instanceof TableViewer) {
+ } else if (comparatorTestViewer instanceof TableViewer) {
if (change.getParent() != null
- && change.getParent().equals(fViewer.getInput())) {
- ((TableViewer) fViewer).add(change.getChildren());
+ && change.getParent().equals(comparatorTestViewer.getInput())) {
+ ((TableViewer<Object,Object>) comparatorTestViewer).add(change.getChildren());
}
- } else if (fViewer instanceof AbstractTreeViewer) {
- ((AbstractTreeViewer) fViewer).add(change.getParent(), change
+ } else if (comparatorTestViewer instanceof AbstractTreeViewer) {
+ ((AbstractTreeViewer<Object,Object>) comparatorTestViewer).add(change.getParent(), change
.getChildren());
- } else if (fViewer instanceof ComboViewer) {
- ((ComboViewer) fViewer).add(change.getChildren());
+ } else if (comparatorTestViewer instanceof ComboViewer) {
+ ((ComboViewer<Object,Object>) comparatorTestViewer).add(change.getChildren());
} else {
Assert.isTrue(false, "Unknown kind of viewer");
}
}
protected void doNonStructureChange(ComparatorModelChange change) {
- fViewer.update(change.getParent(),
+ comparatorTestViewer.update(change.getParent(),
new String[] { IBasicPropertyConstants.P_TEXT });
}
protected void doRemove(ComparatorModelChange change) {
- if (fViewer instanceof ListViewer) {
- ((ListViewer) fViewer).remove(change.getChildren());
- } else if (fViewer instanceof TableViewer) {
- ((TableViewer) fViewer).remove(change.getChildren());
- } else if (fViewer instanceof AbstractTreeViewer) {
- ((AbstractTreeViewer) fViewer).remove(change.getChildren());
- } else if (fViewer instanceof ComboViewer) {
- ((ComboViewer) fViewer).remove(change.getChildren());
+ if (comparatorTestViewer instanceof ListViewer) {
+ ((ListViewer<Object,Object>) comparatorTestViewer).remove(change.getChildren());
+ } else if (comparatorTestViewer instanceof TableViewer) {
+ ((TableViewer<Object,Object>) comparatorTestViewer).remove(change.getChildren());
+ } else if (comparatorTestViewer instanceof AbstractTreeViewer) {
+ ((AbstractTreeViewer<Object,Object>) comparatorTestViewer).remove(change.getChildren());
+ } else if (comparatorTestViewer instanceof ComboViewer) {
+ ((ComboViewer<Object,Object>) comparatorTestViewer).remove(change.getChildren());
} else {
Assert.isTrue(false, "Unknown kind of viewer");
}
}
protected void doStructureChange(ComparatorModelChange change) {
- fViewer.refresh(change.getParent());
+ comparatorTestViewer.refresh(change.getParent());
}
-
+
}
-
+
public ViewerComparatorTest(String name) {
super(name);
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java
index 711eed3..caab4b7 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/ViewerTestCase.java
@@ -33,10 +33,10 @@ public abstract class ViewerTestCase extends TestCase {
Display fDisplay;
protected Shell fShell;
- protected StructuredViewer fViewer;
+ protected StructuredViewer<TestElement,TestElement> fViewer;
protected TestElement fRootElement;
public TestModel fModel;
-
+
protected boolean disableTestsBug347491 = false;
public ViewerTestCase(String name) {
@@ -52,7 +52,7 @@ public abstract class ViewerTestCase extends TestCase {
assertEquals("selectionEquals - " + message, selection, expectedSelection);
}
- protected abstract StructuredViewer createViewer(Composite parent);
+ protected abstract StructuredViewer<TestElement,TestElement> createViewer(Composite parent);
public void interact() {
Shell shell = fShell;
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTableViewerTest.java
index 202d4fb..089ecc6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualLazyTableViewerTest.java
@@ -25,8 +25,8 @@ import org.eclipse.swt.widgets.Table;
* with lazy population.
*/
public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
-
- private List updatedElements;
+
+ private List<Integer> updatedElements;
// by default, no failure is triggered when updateElement is called
int updatedElementFailureTriggerIndex = -1;
@@ -43,13 +43,13 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
protected TestModelContentProvider getContentProvider() {
return new TestLazyModelContentProvider(this);
}
-
+
public void setUp() {
- updatedElements = new ArrayList();
+ updatedElements = new ArrayList<Integer>();
super.setUp();
processEvents();
}
-
+
protected void setUpModel() {
fRootElement = TestElement.createModel(2, 100);
fModel = fRootElement.getModel();
@@ -59,7 +59,7 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
super.tearDown();
updatedElements = null;
}
-
+
// this method is called from TestLazyModelContentProvider
public void updateElementCalled(int index) {
updatedElements.add(new Integer(index));
@@ -67,7 +67,7 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
fail("unexpected call to updateElement, this is the " + updatedElements.size() + "th call");
}
}
-
+
/**
* Test selecting all elements.
*/
@@ -76,19 +76,19 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
int selectionSize = children.length / 2;
int[] indices = new int[selectionSize];
for (int i = 0; i < indices.length; i++) {
- indices[i] = i * 2;
+ indices[i] = i * 2;
}
-
- Table table = ((TableViewer) fViewer).getTable();
+
+ Table table = ((TableViewer<TestElement,TestElement>) fViewer).getTable();
table.setSelection(indices);
// we are virtual, so not all indices we requested to select will be selected.
indices = table.getSelectionIndices();
selectionSize = indices.length;
assertTrue("Expected at least one selected element", selectionSize > 0);
-
+
table.showSelection();
-
+
IStructuredSelection result = (IStructuredSelection) fViewer
.getSelection();
assertEquals(selectionSize, result.size());
@@ -98,9 +98,9 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
assertTrue(
"Last elements do not match ",
result.toArray()[result.size() - 1] == children[lastIndex]);
-
+
}
-
+
public void testSetInputDoesNotMaterializeEverything() {
fViewer.setInput(null);
updatedElements.clear();
@@ -118,7 +118,7 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
fViewer.setInput(fRootElement);
assertEquals(materializedSize, updatedElements.size());
}
-
+
public void testBug160153() {
int childCount = fRootElement.getChildCount();
TestElement lastChild = fRootElement.getChildAt(childCount-1);
@@ -126,35 +126,35 @@ public class VirtualLazyTableViewerTest extends VirtualTableViewerTest {
fViewer.setSelection(new StructuredSelection(lastChild));
processEvents();
assertNotNull("last Child should be in the map", fViewer.testFindItem(lastChild));
- ((TableViewer)fViewer).setItemCount(childCount - 1);
+ ((TableViewer<TestElement,TestElement>)fViewer).setItemCount(childCount - 1);
assertNull("last Child should no longer be in the map", fViewer.testFindItem(lastChild));
}
-
+
public void testSorter() {
// This test is no use here as it is
// based on the assumption that all items
// are created.
}
-
+
public void testRenameWithSorter() {
// This test is no use here as it is
// based on the assumption that all items
// are created.
}
-
+
public void testSetFilters() {
// This test is no use here as it is
// based on the assumption that all items
// are created.
}
-
+
public void testFilter() {
// This test is no use here as it is
// based on the assumption that all items
// are created.
}
-
+
public void testRenameWithFilter() {
// This test is no use here as it is
// based on the assumption that all items
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java
index d8122e6..fc20cdc 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTableViewerTest.java
@@ -31,21 +31,21 @@ import org.eclipse.swt.widgets.TableItem;
*/
public class VirtualTableViewerTest extends TableViewerTest {
- Set visibleItems = new HashSet();
+ Set<TableItem> visibleItems = new HashSet<TableItem>();
/**
* Checks if the virtual tree / table functionality can be tested in the current settings.
* The virtual trees and tables rely on SWT.SetData event which is only sent if OS requests
* information about the tree / table. If the window is not visible (obscured by another window,
* outside of visible area, or OS determined that it can skip drawing), then OS request won't
- * be send, causing automated tests to fail.
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=118919 .
+ * be send, causing automated tests to fail.
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=118919 .
*/
protected boolean setDataCalled = false;
/**
* Create a new instance of the receiver.
- *
+ *
* @param name
*/
public VirtualTableViewerTest(String name) {
@@ -63,18 +63,18 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.TableViewerTest#createTableViewer(org.eclipse.swt.widgets.Composite)
*/
- protected TableViewer createTableViewer(Composite parent) {
- visibleItems = new HashSet();
- TableViewer viewer = new TableViewer(parent, SWT.VIRTUAL | SWT.MULTI);
+ protected TableViewer<TestElement,TestElement> createTableViewer(Composite parent) {
+ visibleItems = new HashSet<TableItem>();
+ TableViewer<TestElement,TestElement> viewer = new TableViewer<TestElement,TestElement>(parent, SWT.VIRTUAL | SWT.MULTI);
viewer.setUseHashlookup(true);
final Table table = viewer.getTable();
table.addListener(SWT.SetData, new Listener() {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
*/
public void handleEvent(Event event) {
@@ -85,15 +85,15 @@ public class VirtualTableViewerTest extends TableViewerTest {
});
return viewer;
}
-
+
/**
* Checks if update occurred. Updates for virtual items will be skipped
- * if, for instance, another window is in the foreground.
+ * if, for instance, another window is in the foreground.
* @return <code>true</code> if update occurred
*/
protected boolean updateTable() {
setDataCalled = false;
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
if (setDataCalled)
return true;
System.err.println("SWT.SetData is not received. Cancelled test " + getName());
@@ -102,11 +102,11 @@ public class VirtualTableViewerTest extends TableViewerTest {
/**
* Get the collection of currently visible table items.
- *
+ *
* @return TableItem[]
*/
private TableItem[] getVisibleItems() {
- return (TableItem[]) visibleItems.toArray(new TableItem[visibleItems.size()]);
+ return visibleItems.toArray(new TableItem[visibleItems.size()]);
}
public void testElementsCreated() {
@@ -122,7 +122,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.TableViewerTest#getItemCount()
*/
protected int getItemCount() {
@@ -131,18 +131,18 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testFilter()
*/
public void testFilter() {
- ViewerFilter filter = new TestLabelFilter();
- visibleItems = new HashSet();
+ ViewerFilter<TestElement,TestElement> filter = new TestLabelFilter();
+ visibleItems = new HashSet<TableItem>();
fViewer.addFilter(filter);
if (!updateTable())
return;
assertEquals("filtered count", 5, getItemCount());
- visibleItems = new HashSet();
+ visibleItems = new HashSet<TableItem>();
fViewer.removeFilter(filter);
if (!updateTable())
return;
@@ -150,20 +150,20 @@ public class VirtualTableViewerTest extends TableViewerTest {
}
public void testSetFilters() {
- ViewerFilter filter = new TestLabelFilter();
- visibleItems = new HashSet();
+ ViewerFilter<TestElement,TestElement> filter = new TestLabelFilter();
+ visibleItems = new HashSet<TableItem>();
fViewer.setFilters(new ViewerFilter[] { filter, new TestLabelFilter2() });
if (!updateTable())
return;
assertEquals("2 filters count",1, getItemCount());
- visibleItems = new HashSet();
+ visibleItems = new HashSet<TableItem>();
fViewer.setFilters(new ViewerFilter[] { filter });
if (!updateTable())
return;
assertEquals("1 filtered count",5, getItemCount());
- visibleItems = new HashSet();
+ visibleItems = new HashSet<TableItem>();
fViewer.setFilters(new ViewerFilter[0]);
if (!updateTable())
return;
@@ -171,7 +171,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSibling()
*/
public void testInsertSibling() {
@@ -182,7 +182,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSiblingReveal()
*/
public void testInsertSiblingReveal() {
@@ -193,7 +193,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSiblings()
*/
public void testInsertSiblings() {
@@ -204,7 +204,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSiblingWithFilterFiltered()
*/
public void testInsertSiblingWithFilterFiltered() {
@@ -215,7 +215,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSiblingWithFilterNotFiltered()
*/
public void testInsertSiblingWithFilterNotFiltered() {
@@ -226,7 +226,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSiblingWithSorter()
*/
public void testInsertSiblingWithSorter() {
@@ -237,7 +237,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testRenameWithFilter()
*/
public void testRenameWithFilter() {
@@ -250,19 +250,19 @@ public class VirtualTableViewerTest extends TableViewerTest {
return;
TestElement first = fRootElement.getFirstChild();
first.setLabel("name-1111"); // should disappear
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
assertNull("changed sibling is not visible", fViewer
.testFindItem(first));
first.setLabel("name-2222"); // should reappear
fViewer.refresh();
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
assertNotNull("changed sibling is not visible", fViewer
.testFindItem(first));
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testSetInput()
*/
public void testSetInput() {
@@ -273,18 +273,18 @@ public class VirtualTableViewerTest extends TableViewerTest {
public void testRenameWithSorter() {
// Call update to make sure the viewer is in a correct state
// At least on MacOSX I get failures without this call
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
fViewer.setSorter(new TestLabelSorter());
TestElement first = fRootElement.getFirstChild();
first.setLabel("name-9999");
String newElementLabel = first.toString();
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
assertEquals("sorted first", newElementLabel, getItemText(0));
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testSorter()
*/
public void testSorter() {
@@ -294,21 +294,21 @@ public class VirtualTableViewerTest extends TableViewerTest {
String firstLabel = first.toString();
String lastLabel = last.toString();
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
assertEquals("unsorted", firstLabel, getItemText(0));
fViewer.setSorter(new TestLabelSorter());
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
assertEquals("reverse sorted", lastLabel, getItemText(0));
fViewer.setSorter(null);
- ((TableViewer) fViewer).getControl().update();
+ ((TableViewer<TestElement,TestElement>) fViewer).getControl().update();
assertEquals("unsorted", firstLabel, getItemText(0));
}
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testInsertSiblingSelectExpanded()
*/
public void testInsertSiblingSelectExpanded() {
@@ -319,7 +319,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testSomeChildrenChanged()
*/
public void testSomeChildrenChanged() {
@@ -330,7 +330,7 @@ public class VirtualTableViewerTest extends TableViewerTest {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testWorldChanged()
*/
public void testWorldChanged() {
@@ -338,25 +338,25 @@ public class VirtualTableViewerTest extends TableViewerTest {
// based on the assumption that all items
// are created.
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testDeleteSibling()
*/
public void testDeleteSibling() {
//Force creation of the item first
- ((TableViewer) fViewer).getTable().getItem(0).getText();
+ ((TableViewer<TestElement,TestElement>) fViewer).getTable().getItem(0).getText();
super.testDeleteSibling();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.StructuredViewerTest#testSetSelection()
*/
public void testSetSelection() {
//Force creation of the item first
- ((TableViewer) fViewer).getTable().getItem(0).getText();
+ ((TableViewer<TestElement,TestElement>) fViewer).getTable().getItem(0).getText();
super.testSetSelection();
}
-
+
/**
* Test selecting all elements.
*/
@@ -369,8 +369,8 @@ public class VirtualTableViewerTest extends TableViewerTest {
assertTrue("Size was " + String.valueOf(result.size()) + " expected "
+ String.valueOf(children.length),
(result.size() == children.length));
- Set childrenSet = new HashSet(Arrays.asList(children));
- Set selectedSet = new HashSet(result.toList());
+ Set<TestElement> childrenSet = new HashSet<TestElement>(Arrays.asList(children));
+ Set<IStructuredSelection> selectedSet = new HashSet<IStructuredSelection>(result.toList());
assertTrue("Elements do not match ", childrenSet.equals(selectedSet));
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTreeViewerTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTreeViewerTest.java
index 4f4a7ff..8ffb719 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTreeViewerTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/VirtualTreeViewerTest.java
@@ -28,7 +28,7 @@ public class VirtualTreeViewerTest extends TreeViewerTest {
protected StructuredViewer createViewer(Composite parent) {
Tree tree = new Tree(parent, SWT.VIRTUAL);
- fTreeViewer = new TreeViewer(tree);
+ fTreeViewer = new TreeViewer<TestElement,TestElement>(tree);
fTreeViewer.setContentProvider(new TestModelContentProvider());
return fTreeViewer;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddElementAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddElementAction.java
index f90e426..df8706e 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddElementAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddElementAction.java
@@ -21,7 +21,7 @@ public class AddElementAction extends TestBrowserAction {
}
public void run() {
- TestElement element = (TestElement) getBrowser().getViewer().getInput();
+ TestElement element = getBrowser().getViewer().getInput();
element.addChild(TestModelChange.INSERT);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddFilterAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddFilterAction.java
index 0bc3bfe..95a3586 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddFilterAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/AddFilterAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -20,8 +21,8 @@ public class AddFilterAction extends TestBrowserAction {
}
public void run() {
- Viewer viewer = getBrowser().getViewer();
+ Viewer<TestElement> viewer = getBrowser().getViewer();
if (viewer instanceof StructuredViewer)
- ((StructuredViewer) viewer).addFilter(new Filter());
+ ((StructuredViewer<TestElement,TestElement>) viewer).addFilter(new Filter());
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ChangeInputLabelAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ChangeInputLabelAction.java
index 5493282..39b9e5d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ChangeInputLabelAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ChangeInputLabelAction.java
@@ -19,7 +19,7 @@ public class ChangeInputLabelAction extends TestBrowserAction {
}
public void run() {
- TestElement element = (TestElement) getBrowser().getInput();
+ TestElement element = getBrowser().getInput();
element.setLabel(element.getLabel() + " changed");
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java
index de9c246..32e555d 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ConcurrentTableTestView.java
@@ -36,10 +36,10 @@ import org.eclipse.ui.progress.WorkbenchJob;
*/
public class ConcurrentTableTestView extends ViewPart {
- private TableViewer table;
+ private TableViewer<Object,SetModel> table;
private boolean enableSlowComparisons = false;
private TestComparator comparator = new TestComparator() {
-
+
/* (non-Javadoc)
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -52,24 +52,24 @@ public class ConcurrentTableTestView extends ViewPart {
if (enableSlowComparisons) {
int delay = 2; // Time to spin the CPU for (milliseconds)
-
- // Do some work to occupy time
+
+ // Do some work to occupy time
long timestamp = System.currentTimeMillis();
while (System.currentTimeMillis() < timestamp + delay) {
}
}
-
+
int result = super.compare(arg0, arg1);
-
+
scheduleComparisonUpdate();
-
+
return result;
}
};
private DeferredContentProvider contentProvider;
-
+
private WorkbenchJob updateCountRunnable = new WorkbenchJob("") {
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor)
*/
@@ -78,12 +78,12 @@ public class ConcurrentTableTestView extends ViewPart {
return Status.OK_STATUS;
}
};
-
+
private Label updateCount;
private SetModel model = new SetModel();
private Random rand = new Random();
private Button slowComparisons;
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
@@ -91,20 +91,20 @@ public class ConcurrentTableTestView extends ViewPart {
Composite parent = new Composite(temp, SWT.NONE);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
-
+
parent.setLayout(layout);
-
+
// Create the table
{
- table = new TableViewer(parent, SWT.VIRTUAL);
+ table = new TableViewer<Object,SetModel>(parent, SWT.VIRTUAL);
contentProvider = new DeferredContentProvider(comparator);
table.setContentProvider(contentProvider);
-
+
GridData data = new GridData(GridData.FILL_BOTH);
table.getControl().setLayoutData(data);
table.setInput(model);
}
-
+
// Create the buttons
Composite buttonBar = new Composite(parent, SWT.NONE);
buttonBar.setLayoutData(new GridData(GridData.FILL_BOTH));
@@ -129,8 +129,8 @@ public class ConcurrentTableTestView extends ViewPart {
super.widgetSelected(e);
}
});
-
-
+
+
final Button limitSize = new Button(buttonBar, SWT.CHECK);
limitSize.setLayoutData(new GridData(GridData.FILL_BOTH));
limitSize.setText("Limit table size to 400");
@@ -147,7 +147,7 @@ public class ConcurrentTableTestView extends ViewPart {
super.widgetSelected(e);
}
});
-
+
Button resetCountButton = new Button(buttonBar, SWT.PUSH);
resetCountButton.setLayoutData(new GridData(GridData.FILL_BOTH));
resetCountButton.setText("Reset comparison count");
@@ -158,9 +158,9 @@ public class ConcurrentTableTestView extends ViewPart {
public void widgetSelected(SelectionEvent e) {
comparator.comparisons = 0;
scheduleComparisonUpdate();
- }
+ }
});
-
+
Button testButton = new Button(buttonBar, SWT.PUSH);
testButton.setLayoutData(new GridData(GridData.FILL_BOTH));
testButton.setText("add 100000 elements");
@@ -170,9 +170,9 @@ public class ConcurrentTableTestView extends ViewPart {
*/
public void widgetSelected(SelectionEvent e) {
addRandomElements(100000);
- }
+ }
});
-
+
Button removeButton = new Button(buttonBar, SWT.PUSH);
removeButton.setLayoutData(new GridData(GridData.FILL_BOTH));
removeButton.setText("remove all");
@@ -182,15 +182,15 @@ public class ConcurrentTableTestView extends ViewPart {
*/
public void widgetSelected(SelectionEvent e) {
clear();
- }
+ }
});
}
}
-
-
+
+
/**
- *
+ *
* @since 3.1
*/
protected void scheduleComparisonUpdate() {
@@ -200,20 +200,20 @@ public class ConcurrentTableTestView extends ViewPart {
public void addRandomElements(int amount) {
-
- ArrayList tempList = new ArrayList();
+
+ ArrayList<String> tempList = new ArrayList<String>();
for (int counter = 0; counter < amount; counter++) {
tempList.add("" + rand.nextLong() + " " + counter );
}
-
+
model.addAll(tempList);
}
-
+
public void clear() {
model.clear();
}
-
+
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchPart#setFocus()
*/
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ExpandAllAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ExpandAllAction.java
index 610e7f1..7b19ea1 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ExpandAllAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ExpandAllAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -20,8 +21,8 @@ public class ExpandAllAction extends TestBrowserAction {
}
public void run() {
- Viewer viewer = getBrowser().getViewer();
+ Viewer<TestElement> viewer = getBrowser().getViewer();
if (viewer instanceof AbstractTreeViewer)
- ((AbstractTreeViewer) viewer).expandAll();
+ ((AbstractTreeViewer<TestElement,TestElement>) viewer).expandAll();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/Filter.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/Filter.java
index e3be1ef..ffbbe73 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/Filter.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/Filter.java
@@ -12,20 +12,22 @@ package org.eclipse.jface.tests.viewers.interactive;
import java.util.ArrayList;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-public class Filter extends ViewerFilter {
+public class Filter extends ViewerFilter<TestElement,TestElement> {
- public Object[] filter(Viewer viewer, Object parent, Object[] elements) {
- ArrayList result = new ArrayList();
+ public TestElement[] filter(Viewer<TestElement> viewer, Object parent, TestElement[] elements) {
+ ArrayList<TestElement> result = new ArrayList<TestElement>();
for (int i = 0; i < elements.length; ++i) {
// toss every second item
if (i % 2 == 1) {
result.add(elements[i]);
}
}
- return result.toArray();
+ TestElement[] resultArray = new TestElement[result.size()];
+ return result.toArray(resultArray);
}
public boolean isFilterProperty(Object element, Object aspect) {
@@ -35,7 +37,7 @@ public class Filter extends ViewerFilter {
/* (non-Javadoc)
* Method declared on ViewerFilter
*/
- public boolean select(Viewer viewer, Object parentElement, Object element) {
+ public boolean select(Viewer<TestElement> viewer, Object parentElement, TestElement element) {
// not used
return false;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyDeferredVirtualTableView.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyDeferredVirtualTableView.java
index be77f5e..3b823c5 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyDeferredVirtualTableView.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyDeferredVirtualTableView.java
@@ -32,11 +32,11 @@ public class LazyDeferredVirtualTableView extends VirtualTableView {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.tests.viewers.interactive.VirtualTableView#getContentProvider()
*/
- protected IContentProvider getContentProvider() {
- return new ILazyContentProvider() {
+ protected IContentProvider<Object> getContentProvider() {
+ return new ILazyContentProvider<Object>() {
int rangeStart = -1;
@@ -59,7 +59,7 @@ public class LazyDeferredVirtualTableView extends VirtualTableView {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.ILazyContentProvider#updateElements(int,
* int)
*/
@@ -113,7 +113,7 @@ public class LazyDeferredVirtualTableView extends VirtualTableView {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
@@ -122,11 +122,11 @@ public class LazyDeferredVirtualTableView extends VirtualTableView {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput,
+ public void inputChanged(Viewer<Object> viewer, Object oldInput,
Object newInput) {
// Do nothing.
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java
index 0206c11..2d235d6 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/LazyVirtualTableView.java
@@ -23,7 +23,7 @@ import org.eclipse.jface.viewers.Viewer;
*/
public class LazyVirtualTableView extends VirtualTableView {
- private List elements;
+ private List<String> elements;
/**
* Create a new instance of the receiver.
@@ -34,10 +34,10 @@ public class LazyVirtualTableView extends VirtualTableView {
}
/**
- *
+ *
*/
private void initElements() {
- elements = new ArrayList();
+ elements = new ArrayList<String>();
for (int i = 0; i < itemCount; i++) {
elements.add("Element " + String.valueOf(i));
}
@@ -46,9 +46,9 @@ public class LazyVirtualTableView extends VirtualTableView {
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.interactive.VirtualTableView#getContentProvider()
*/
- protected IContentProvider getContentProvider() {
- return new ILazyContentProvider() {
-
+ protected IContentProvider<Object> getContentProvider() {
+ return new ILazyContentProvider<Object>() {
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ILazyContentProvider#updateElements(int, int)
*/
@@ -65,16 +65,16 @@ public class LazyVirtualTableView extends VirtualTableView {
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<Object> viewer, Object oldInput, Object newInput) {
// Do nothing.
}
};
}
-
+
/* (non-Javadoc)
* @see org.eclipse.jface.tests.viewers.interactive.VirtualTableView#doRemove(java.lang.Object[])
*/
- protected void doRemove(Object[] selection, int[] selectionIndices) {
+ protected void doRemove(String[] selection, int[] selectionIndices) {
for (int i = 0; i < selectionIndices.length; i++) {
int index = selectionIndices[i];
elements.remove(index);
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetFilterAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetFilterAction.java
index a44dff4..2521e68 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetFilterAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetFilterAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -20,9 +21,9 @@ public class ResetFilterAction extends TestBrowserAction {
}
public void run() {
- Viewer viewer = getBrowser().getViewer();
+ Viewer<TestElement> viewer = getBrowser().getViewer();
if (viewer instanceof StructuredViewer) {
- StructuredViewer v = (StructuredViewer) viewer;
+ StructuredViewer<TestElement,TestElement> v = (StructuredViewer<TestElement,TestElement>) viewer;
v.resetFilters();
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetSorterAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetSorterAction.java
index fa2d616..75460de 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetSorterAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/ResetSorterAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -20,9 +21,9 @@ public class ResetSorterAction extends TestBrowserAction {
}
public void run() {
- Viewer viewer = getBrowser().getViewer();
+ Viewer<TestElement> viewer = getBrowser().getViewer();
if (viewer instanceof StructuredViewer) {
- StructuredViewer v = (StructuredViewer) viewer;
+ StructuredViewer<TestElement,TestElement> v = (StructuredViewer<TestElement,TestElement>) viewer;
v.setSorter(null);
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetLabelProviderAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetLabelProviderAction.java
index b348b35..1f68d1f 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetLabelProviderAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetLabelProviderAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.tests.viewers.TestLabelProvider;
import org.eclipse.jface.viewers.ContentViewer;
@@ -20,7 +21,7 @@ public class SetLabelProviderAction extends TestBrowserAction {
}
public void run() {
- ((ContentViewer) getBrowser().getViewer())
- .setLabelProvider(new TestLabelProvider());
+ ((ContentViewer<TestElement,TestElement>) getBrowser().getViewer())
+ .setLabelProvider(new TestLabelProvider<TestElement>());
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetSorterAction.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetSorterAction.java
index 7d72a9b..5fc2140 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetSorterAction.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/SetSorterAction.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer;
@@ -20,9 +21,9 @@ public class SetSorterAction extends TestBrowserAction {
}
public void run() {
- Viewer viewer = getBrowser().getViewer();
+ Viewer<TestElement> viewer = getBrowser().getViewer();
if (viewer instanceof StructuredViewer) {
- StructuredViewer v = (StructuredViewer) viewer;
+ StructuredViewer<TestElement,TestElement> v = (StructuredViewer<TestElement,TestElement>) viewer;
v.setSorter(new Sorter());
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java
index b087531..2c222e1 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/StyledCellLabelProviderTests.java
@@ -49,7 +49,7 @@ import org.eclipse.swt.widgets.Shell;
*/
public class StyledCellLabelProviderTests {
-
+
private static int IMAGE_SIZE= 16;
private static Image IMAGE1;
@@ -60,7 +60,7 @@ public class StyledCellLabelProviderTests {
Display display = new Display();
JFaceResources.getColorRegistry().put(JFacePreferences.COUNTER_COLOR, new RGB(0,127,174));
-
+
IMAGE1= new Image(display, display.getSystemImage(SWT.ICON_WARNING).getImageData().scaledTo(IMAGE_SIZE, IMAGE_SIZE));
IMAGE2= new Image(display, display.getSystemImage(SWT.ICON_ERROR).getImageData().scaledTo(IMAGE_SIZE, IMAGE_SIZE));
@@ -71,7 +71,7 @@ public class StyledCellLabelProviderTests {
StyledCellLabelProviderTests example= new StyledCellLabelProviderTests();
Control composite= example.createPartControl(shell);
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
-
+
shell.open();
while (!shell.isDisposed()) {
@@ -83,7 +83,7 @@ public class StyledCellLabelProviderTests {
}
protected boolean useBold;
- protected TableViewerColumn column;
+ protected TableViewerColumn<File,Object> column;
public StyledCellLabelProviderTests() {
}
@@ -96,9 +96,9 @@ public class StyledCellLabelProviderTests {
final Label label= new Label(composite, SWT.NONE);
label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
label.setText("Operations per second: xxxxx"); //$NON-NLS-1$
-
+
final Runnable[] operation = new Runnable[1];
-
+
final Button timeButton = new Button(composite, SWT.CHECK);
timeButton.setText("Time");
timeButton.addSelectionListener(new SelectionAdapter(){
@@ -106,11 +106,11 @@ public class StyledCellLabelProviderTests {
setTimer(timeButton.getDisplay(), timeButton.getSelection(), operation, label);
}
});
-
+
final Button stylingButton = new Button(composite, SWT.CHECK);
stylingButton.setText("enable styling");
stylingButton.setSelection(true);
-
+
final Button boldButton = new Button(composite, SWT.CHECK);
boldButton.setText("use bold");
@@ -122,12 +122,12 @@ public class StyledCellLabelProviderTests {
final Button rightButton = new Button(composite, SWT.RADIO);
rightButton.setText("align right");
- final TableViewer tableViewer= new TableViewer(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ final TableViewer<File,Object> tableViewer= new TableViewer<File,Object>(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
tableViewer.getTable().setHeaderVisible(true);
FontData[] boldFontData= getModifiedFontData(tableViewer.getTable().getFont().getFontData(), SWT.BOLD);
Font boldFont = new Font(Display.getCurrent(), boldFontData);
final ExampleLabelProvider labelProvider= new ExampleLabelProvider(boldFont);
-
+
createColumn(tableViewer, SWT.LEFT, labelProvider);
boldButton.addSelectionListener(new SelectionAdapter() {
@@ -136,7 +136,7 @@ public class StyledCellLabelProviderTests {
tableViewer.refresh();
}
});
-
+
operation[0] = new Runnable(){
public void run() {
tableViewer.refresh();
@@ -151,15 +151,15 @@ public class StyledCellLabelProviderTests {
createColumn(tableViewer, style, labelProvider);
}
}
- };
+ };
leftButton.addSelectionListener(adapter);
centerButton.addSelectionListener(adapter);
rightButton.addSelectionListener(adapter);
TestContentProvider contentProvider= new TestContentProvider();
-
+
tableViewer.setContentProvider(contentProvider);
-
+
stylingButton.addSelectionListener(new SelectionAdapter(){
public void widgetSelected(SelectionEvent e) {
labelProvider.setOwnerDrawEnabled(stylingButton.getSelection());
@@ -174,20 +174,20 @@ public class StyledCellLabelProviderTests {
return composite;
}
-
- private void createColumn(TableViewer viewer, int style, CellLabelProvider labelProvider) {
- column = new TableViewerColumn(viewer, style);
+
+ private void createColumn(TableViewer<File,Object> viewer, int style, CellLabelProvider<File,Object> labelProvider) {
+ column = new TableViewerColumn<File,Object>(viewer, style);
column.getColumn().setWidth(200);
column.getColumn().setText("Column");
column.setLabelProvider(labelProvider);
viewer.refresh();
}
-
+
boolean timerOn = false;
long startTime;
int numOperations;
DecimalFormat decimalFormat = new DecimalFormat("##.#");
-
+
protected void setTimer(final Display display, boolean selection, final Runnable[] operation, final Label resultLabel) {
timerOn = selection;
if (timerOn) {
@@ -229,11 +229,11 @@ public class StyledCellLabelProviderTests {
}
return styleData;
}
-
+
private class ExampleLabelProvider extends StyledCellLabelProvider {
- private final Styler fBoldStyler;
-
+ private final Styler fBoldStyler;
+
public ExampleLabelProvider(final Font boldFont) {
fBoldStyler= new Styler() {
public void applyStyles(TextStyle textStyle) {
@@ -241,21 +241,21 @@ public class StyledCellLabelProviderTests {
}
};
}
-
+
public void update(ViewerCell cell) {
Object element= cell.getElement();
-
+
if (element instanceof File) {
File file= (File) element;
-
+
Styler style= file.isDirectory() && useBold ? fBoldStyler: null;
StyledString styledString= new StyledString(file.getName(), style);
String decoration = MessageFormat.format(" ({0} bytes)", new Object[] { new Long(file.length()) }); //$NON-NLS-1$
styledString.append(decoration, StyledString.COUNTER_STYLER);
-
+
cell.setText(styledString.toString());
cell.setStyleRanges(styledString.getStyleRanges());
-
+
if (file.isDirectory()) {
cell.setImage(IMAGE1);
} else {
@@ -267,7 +267,7 @@ public class StyledCellLabelProviderTests {
super.update(cell);
}
-
+
protected void measure(Event event, Object element) {
super.measure(event, element);
}
@@ -298,10 +298,10 @@ public class StyledCellLabelProviderTests {
}
}
-
- private static class TestContentProvider implements IStructuredContentProvider {
- public Object[] getElements(Object element) {
+ private static class TestContentProvider implements IStructuredContentProvider<File,Object> {
+
+ public File[] getElements(Object element) {
return new File[]{
new File("asdfkjghfasdkjasdfhjgasdfkjhg", 2348, false),
new File("sdafkuyasdfkljh", 2348, false),
@@ -357,7 +357,7 @@ public class StyledCellLabelProviderTests {
public void dispose() {
}
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ public void inputChanged(Viewer<Object> viewer, Object oldInput, Object newInput) {
}
}
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestBrowser.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestBrowser.java
index 6854e11..f202f9b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestBrowser.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestBrowser.java
@@ -28,7 +28,7 @@ import org.eclipse.swt.widgets.Shell;
public abstract class TestBrowser extends ApplicationWindow {
TestElement fInput;
- Viewer fViewer;
+ Viewer<TestElement> fViewer;
Action fChangeLabelAction;
@@ -152,17 +152,17 @@ public abstract class TestBrowser extends ApplicationWindow {
ViewForm form = new ViewForm(parent, SWT.NONE);
CLabel label = new CLabel(form, SWT.NONE);
form.setTopLeft(label);
- Object input = getInput();
+ TestElement input = getInput();
label.setText(input.toString());
if (fPanes == 1) {
- Viewer viewer = createViewer(form);
+ Viewer<TestElement> viewer = createViewer(form);
form.setContent(viewer.getControl());
fViewer = viewer;
- setInput((TestElement) input);
+ setInput(input);
} else if (fPanes == 2) {
SashForm sashForm = new SashForm(form, SWT.VERTICAL);
form.setContent(sashForm);
- Viewer viewer = createViewer(sashForm);
+ Viewer<TestElement> viewer = createViewer(sashForm);
fViewer = viewer;
viewer.setInput(input);
viewer = createViewer(sashForm);
@@ -175,7 +175,7 @@ public abstract class TestBrowser extends ApplicationWindow {
return form;
}
- public abstract Viewer createViewer(Composite parent);
+ public abstract Viewer<TestElement> createViewer(Composite parent);
protected void fillMenuBar(MenuManager mgr) {
@@ -232,7 +232,7 @@ public abstract class TestBrowser extends ApplicationWindow {
return fInput;
}
- public Viewer getViewer() {
+ public Viewer<TestElement> getViewer() {
return fViewer;
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestLazyVirtualTree.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestLazyVirtualTree.java
index c2c897f..4ec2f77 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestLazyVirtualTree.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestLazyVirtualTree.java
@@ -23,7 +23,7 @@ import org.eclipse.swt.widgets.TreeItem;
public class TestLazyVirtualTree extends TestTree {
- public Viewer createViewer(Composite parent) {
+ public Viewer<TestElement> createViewer(Composite parent) {
Tree tree = new Tree(parent, SWT.VIRTUAL);
tree.addListener(SWT.SetData, new Listener() {
private String getPosition(TreeItem item) {
@@ -39,7 +39,7 @@ public class TestLazyVirtualTree extends TestTree {
System.out.println("updating " + position);
}
});
- TreeViewer viewer = new TreeViewer(tree);
+ TreeViewer<TestElement,TestElement> viewer = new TreeViewer<TestElement,TestElement>(tree);
viewer.setContentProvider(new TestModelLazyTreeContentProvider(viewer));
viewer.setUseHashlookup(true);
@@ -47,7 +47,7 @@ public class TestLazyVirtualTree extends TestTree {
fViewer = viewer;
return viewer;
}
-
+
public void setInput(TestElement input) {
if(fViewer!=null) {
Object oldInput = fViewer.getInput();
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestList.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestList.java
index 959788c..c68136b 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestList.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestList.java
@@ -18,8 +18,8 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
public class TestList extends TestBrowser {
- public Viewer createViewer(Composite parent) {
- ListViewer viewer = new ListViewer(parent);
+ public Viewer<TestElement> createViewer(Composite parent) {
+ ListViewer<TestElement,TestElement> viewer = new ListViewer<TestElement,TestElement>(parent);
viewer.setUseHashlookup(true);
viewer.setContentProvider(new TestModelContentProvider());
return viewer;
@@ -32,7 +32,7 @@ public class TestList extends TestBrowser {
}
/**
- *
+ *
*/
protected void viewerFillMenuBar(MenuManager mgr) {
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTable.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTable.java
index 4df5e8a..0583863 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTable.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTable.java
@@ -25,10 +25,10 @@ import org.eclipse.swt.widgets.TableColumn;
public class TestTable extends TestBrowser {
- public Viewer createViewer(Composite parent) {
- TableViewer viewer = new TableViewer(parent);
+ public Viewer<TestElement> createViewer(Composite parent) {
+ TableViewer<TestElement,TestElement> viewer = new TableViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
- viewer.setLabelProvider(new TestLabelProvider());
+ viewer.setLabelProvider(new TestLabelProvider<TestElement>());
viewer.getTable().setLinesVisible(true);
TableLayout layout = new TableLayout();
@@ -61,7 +61,7 @@ public class TestTable extends TestBrowser {
}
/**
- *
+ *
*/
protected void viewerFillMenuBar(MenuManager mgr) {
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTree.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTree.java
index 4c2e0f7..e490105 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTree.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestTree.java
@@ -20,7 +20,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;
public class TestTree extends TestBrowser {
- TreeViewer fViewer;
+ TreeViewer<TestElement,TestElement> fViewer;
Action fExpandAllAction;
@@ -30,10 +30,10 @@ public class TestTree extends TestBrowser {
}
/**
- *
+ *
*/
- public Viewer createViewer(Composite parent) {
- TreeViewer viewer = new TreeViewer(parent);
+ public Viewer<TestElement> createViewer(Composite parent) {
+ TreeViewer<TestElement,TestElement> viewer = new TreeViewer<TestElement,TestElement>(parent);
viewer.setContentProvider(new TestModelContentProvider());
viewer.setUseHashlookup(true);
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestVirtualTree.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestVirtualTree.java
index f227105..0bef3f4 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestVirtualTree.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/TestVirtualTree.java
@@ -23,7 +23,7 @@ import org.eclipse.swt.widgets.TreeItem;
public class TestVirtualTree extends TestTree {
- public Viewer createViewer(Composite parent) {
+ public Viewer<TestElement> createViewer(Composite parent) {
Tree tree = new Tree(parent, SWT.VIRTUAL);
tree.addListener(SWT.SetData, new Listener() {
private String getPosition(TreeItem item) {
@@ -41,7 +41,7 @@ public class TestVirtualTree extends TestTree {
System.out.println("updating " + position);
}
});
- TreeViewer viewer = new TreeViewer(tree);
+ TreeViewer<TestElement,TestElement> viewer = new TreeViewer<TestElement,TestElement>(tree);
viewer.setContentProvider(new TestModelContentProvider());
viewer.setUseHashlookup(true);
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java
index 8dff268..30df723 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/viewers/interactive/VirtualTableView.java
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;
+import java.util.List;
+
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -25,12 +27,12 @@ import org.eclipse.ui.part.ViewPart;
/**
* The is a test VirtualTableView of the support for SWT.VIRTUAL in JFace.
- *
+ *
* @since 3.1
*/
public class VirtualTableView extends ViewPart {
- TableViewer viewer;
+ TableViewer<String,Object> viewer;
int itemCount = 10000;
@@ -43,16 +45,16 @@ public class VirtualTableView extends ViewPart {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
public void createPartControl(Composite parent) {
- viewer = new TableViewer(parent, SWT.VIRTUAL);
+ viewer = new TableViewer<String,Object>(parent, SWT.VIRTUAL);
viewer.setContentProvider(getContentProvider());
viewer.setInput(this);
viewer.setItemCount(itemCount);
-
+
Composite buttonComposite = new Composite(parent,SWT.NONE);
buttonComposite.setLayout(new GridLayout());
@@ -63,37 +65,39 @@ public class VirtualTableView extends ViewPart {
resetInput();
}
});
-
+
Button delete = new Button(buttonComposite, SWT.PUSH);
delete.setText("Delete selection");
delete.addSelectionListener(new SelectionAdapter() {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
public void widgetSelected(SelectionEvent e) {
- Object[] selection = ((IStructuredSelection) viewer.getSelection()).toArray();
+ String[] ar = new String[((IStructuredSelection) viewer.getSelection()).toArray().length];
+ List<String> selectionList = ((IStructuredSelection)viewer.getSelection()).toList();
+ String[] selection = selectionList.toArray(ar);
doRemove(selection, viewer.getTable().getSelectionIndices());
}
});
}
- protected void doRemove(Object[] selection, int[] selectionIndices) {
+ protected void doRemove(String[] selection, int[] selectionIndices) {
viewer.remove(selection);
}
/**
* Get the content provider for the receiver.
- *
+ *
* @return IContentProvider
*/
- protected IContentProvider getContentProvider() {
- return new IStructuredContentProvider() {
+ protected IContentProvider<Object> getContentProvider() {
+ return new IStructuredContentProvider<String,Object>() {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
@@ -103,10 +107,10 @@ public class VirtualTableView extends ViewPart {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
*/
- public Object[] getElements(Object inputElement) {
+ public String[] getElements(Object inputElement) {
String[] elements = new String[itemCount];
for (int i = 0; i < itemCount; i++) {
elements[i] = "Element " + String.valueOf(i);
@@ -116,11 +120,11 @@ public class VirtualTableView extends ViewPart {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
* java.lang.Object, java.lang.Object)
*/
- public void inputChanged(Viewer viewer, Object oldInput,
+ public void inputChanged(Viewer<Object> viewer, Object oldInput,
Object newInput) {
// Nothing to do here.
@@ -130,7 +134,7 @@ public class VirtualTableView extends ViewPart {
/*
* (non-Javadoc)
- *
+ *
* @see org.eclipse.ui.IWorkbenchPart#setFocus()
*/
public void setFocus() {