Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbvosburgh2008-01-25 23:20:21 +0000
committerbvosburgh2008-01-25 23:20:21 +0000
commit2fdd5970b5ff56bae0c9ffd88a304cc1c6d70729 (patch)
tree0d403274ee32be1d2ecb9f2e2e2f18169e12f589
parent805d596449c918793cb0c9037617b6bf9cb89880 (diff)
downloadwebtools.dali-2fdd5970b5ff56bae0c9ffd88a304cc1c6d70729.tar.gz
webtools.dali-2fdd5970b5ff56bae0c9ffd88a304cc1c6d70729.tar.xz
webtools.dali-2fdd5970b5ff56bae0c9ffd88a304cc1c6d70729.zip
parameterized CollectionValueModel
-rw-r--r--jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/ListBoxModelAdapter.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java16
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java38
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java4
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java53
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java123
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java35
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java30
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java28
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java51
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java55
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java8
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java42
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java2
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java10
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java14
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java18
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java50
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java20
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java6
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java71
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java23
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java59
-rw-r--r--jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java12
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java42
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java4
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java78
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java71
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java6
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java8
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java12
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java30
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java12
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java14
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java2
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java10
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java28
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java129
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java133
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java18
-rw-r--r--jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java13
70 files changed, 906 insertions, 848 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/ListBoxModelAdapter.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/ListBoxModelAdapter.java
index 27580418de..4f70695397 100644
--- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/ListBoxModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/swt/ListBoxModelAdapter.java
@@ -58,7 +58,7 @@ public class ListBoxModelAdapter<E> {
/**
* A value model on the underlying model selections.
*/
- protected final CollectionValueModel selectedItemsHolder;
+ protected final CollectionValueModel<E> selectedItemsHolder;
/**
* A listener that allows us to synchronize the list box's selection with
@@ -111,7 +111,7 @@ public class ListBoxModelAdapter<E> {
*/
public static <T> ListBoxModelAdapter<T> adapt(
ListValueModel listHolder,
- CollectionValueModel selectedItemsHolder,
+ CollectionValueModel<T> selectedItemsHolder,
List listBox)
{
return adapt(listHolder, selectedItemsHolder, listBox, StringConverter.Default.<T>instance());
@@ -124,7 +124,7 @@ public class ListBoxModelAdapter<E> {
*/
public static <T> ListBoxModelAdapter<T> adapt(
ListValueModel listHolder,
- CollectionValueModel selectedItemsHolder,
+ CollectionValueModel<T> selectedItemsHolder,
List listBox,
StringConverter<T> stringConverter)
{
@@ -156,7 +156,7 @@ public class ListBoxModelAdapter<E> {
List listBox,
StringConverter<T> stringConverter)
{
- return new ListBoxModelAdapter<T>(listHolder, new PropertyCollectionValueModelAdapter(selectedItemHolder), listBox, stringConverter);
+ return new ListBoxModelAdapter<T>(listHolder, new PropertyCollectionValueModelAdapter<T>(selectedItemHolder), listBox, stringConverter);
}
@@ -168,7 +168,7 @@ public class ListBoxModelAdapter<E> {
*/
protected ListBoxModelAdapter(
ListValueModel listHolder,
- CollectionValueModel selectedItemsHolder,
+ CollectionValueModel<E> selectedItemsHolder,
List listBox,
StringConverter<E> stringConverter)
{
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java
index 7de0f24255..8eb3a95adb 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleStringMatcher.java
@@ -37,12 +37,12 @@ import java.util.regex.Pattern;
* object is compared to the pattern. By default the string returned
* by the object's #toString() method is passed to the pattern matcher.
*/
-public class SimpleStringMatcher
- implements StringMatcher, Filter, Serializable
+public class SimpleStringMatcher<T>
+ implements StringMatcher, Filter<T>, Serializable
{
/** An adapter that converts the objects into strings to be matched with the pattern. */
- private StringConverter stringConverter;
+ private StringConverter<T> stringConverter;
/** The string used to construct the regular expression pattern. */
private String patternString;
@@ -135,7 +135,7 @@ public class SimpleStringMatcher
// ********** Filter implementation **********
- public synchronized boolean accept(Object o) {
+ public synchronized boolean accept(T o) {
return this.matches(this.stringConverter.convertToString(o));
}
@@ -146,7 +146,7 @@ public class SimpleStringMatcher
* Return the string converter used to convert the objects
* passed to the matcher into strings.
*/
- public synchronized StringConverter getStringConverter() {
+ public synchronized StringConverter<T> stringConverter() {
return this.stringConverter;
}
@@ -154,14 +154,14 @@ public class SimpleStringMatcher
* Set the string converter used to convert the objects
* passed to the matcher into strings.
*/
- public synchronized void setStringConverter(StringConverter stringConverter) {
+ public synchronized void setStringConverter(StringConverter<T> stringConverter) {
this.stringConverter = stringConverter;
}
/**
* Return the original pattern string.
*/
- public synchronized String getPatternString() {
+ public synchronized String patternString() {
return this.patternString;
}
@@ -183,7 +183,7 @@ public class SimpleStringMatcher
/**
* Return the regular expression pattern.
*/
- public synchronized Pattern getPattern() {
+ public synchronized Pattern pattern() {
return this.pattern;
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java
index 5dd8f28725..d4b4efe905 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringMatcher.java
@@ -33,19 +33,26 @@ public interface StringMatcher {
boolean matches(String string);
- StringMatcher NULL_INSTANCE =
- new StringMatcher() {
- public void setPatternString(String patternString) {
- // ignore the pattern string
- }
- public boolean matches(String string) {
- // everything is a match
- return true;
- }
- @Override
- public String toString() {
- return "NullStringMatcher";
- }
- };
+ final class Null implements StringMatcher {
+ public static final StringMatcher INSTANCE = new Null();
+ public static StringMatcher instance() {
+ return INSTANCE;
+ }
+ // ensure single instance
+ private Null() {
+ super();
+ }
+ public void setPatternString(String patternString) {
+ // ignore the pattern string
+ }
+ public boolean matches(String string) {
+ // everything is a match
+ return true;
+ }
+ @Override
+ public String toString() {
+ return "StringMatcher.Null";
+ }
+ }
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
index 5e82018683..f2aaa12c16 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionAspectAdapter.java
@@ -40,9 +40,9 @@ import org.eclipse.jpt.utility.internal.model.listener.CollectionChangeListener;
* override this method only if returning a zero when the
* subject is null is unacceptable
*/
-public abstract class CollectionAspectAdapter<S extends Model>
+public abstract class CollectionAspectAdapter<S extends Model, E>
extends AspectAdapter<S>
- implements CollectionValueModel
+ implements CollectionValueModel<E>
{
/**
* The name of the subject's collections that we use for the value.
@@ -134,8 +134,8 @@ public abstract class CollectionAspectAdapter<S extends Model>
/**
* Return the elements of the subject's collection aspect.
*/
- public Iterator iterator() {
- return (this.subject == null) ? EmptyIterator.instance() : this.iterator_();
+ public Iterator<E> iterator() {
+ return (this.subject == null) ? EmptyIterator.<E>instance() : this.iterator_();
}
/**
@@ -143,7 +143,7 @@ public abstract class CollectionAspectAdapter<S extends Model>
* At this point we can be sure that the subject is not null.
* @see #iterator()
*/
- protected Iterator iterator_() {
+ protected Iterator<E> iterator_() {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
index 88b5076af5..83be9919be 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionListValueModelAdapter.java
@@ -36,12 +36,12 @@ import org.eclipse.jpt.utility.internal.model.listener.ListChangeListener;
* we do not have any listeners. This should not be too painful since,
* most likely, client objects will also be listeners.
*/
-public class CollectionListValueModelAdapter
+public class CollectionListValueModelAdapter<E>
extends AbstractModel
implements ListValueModel
{
/** The wrapped collection value model. */
- protected final CollectionValueModel collectionHolder;
+ protected final CollectionValueModel<E> collectionHolder;
/** A listener that forwards any events fired by the collection holder. */
protected final CollectionChangeListener collectionChangeListener;
@@ -51,7 +51,7 @@ public class CollectionListValueModelAdapter
* the wrapped collection, but keeps them in order.
*/
// we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList list;
+ protected final ArrayList<E> list;
// ********** constructors **********
@@ -59,14 +59,14 @@ public class CollectionListValueModelAdapter
/**
* Wrap the specified CollectionValueModel.
*/
- public CollectionListValueModelAdapter(CollectionValueModel collectionHolder) {
+ public CollectionListValueModelAdapter(CollectionValueModel<E> collectionHolder) {
super();
if (collectionHolder == null) {
throw new NullPointerException();
}
this.collectionHolder = collectionHolder;
this.collectionChangeListener = this.buildCollectionChangeListener();
- this.list = new ArrayList();
+ this.list = new ArrayList<E>();
// postpone building the list and listening to the underlying collection
// until we have listeners ourselves...
}
@@ -107,13 +107,13 @@ public class CollectionListValueModelAdapter
// ********** ListValueModel implementation **********
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return this.listIterator();
}
- public ListIterator listIterator() {
+ public ListIterator<E> listIterator() {
// try to prevent backdoor modification of the list
- return new ReadOnlyListIterator(this.list);
+ return new ReadOnlyListIterator<E>(this.list);
}
public Object get(int index) {
@@ -211,7 +211,7 @@ public class CollectionListValueModelAdapter
// ********** behavior **********
protected void buildList() {
- Iterator stream = (Iterator) this.collectionHolder.iterator();
+ Iterator<E> stream = this.collectionHolder.iterator();
// if the new collection is empty, do nothing
if (stream.hasNext()) {
this.list.ensureCapacity(this.collectionHolder.size());
@@ -244,17 +244,22 @@ public class CollectionListValueModelAdapter
}
protected void itemsAdded(CollectionChangeEvent e) {
- this.addItemsToList(this.indexToAddItems(), CollectionTools.list(e.items()), this.list, LIST_VALUES);
+ this.addItemsToList(this.indexToAddItems(), CollectionTools.list(this.items(e)), this.list, LIST_VALUES);
}
- protected int indexToAddItems() {
- return this.list.size();
- }
-
+ protected int indexToAddItems() {
+ return this.list.size();
+ }
+
+ @SuppressWarnings("unchecked")
+ protected Iterator<E> items(CollectionChangeEvent e) {
+ return (Iterator<E>) e.items();
+ }
+
protected void itemsRemoved(CollectionChangeEvent e) {
// we have to remove the items individually,
// since they are probably not in sequence
- for (Iterator stream = e.items(); stream.hasNext(); ) {
+ for (Iterator<E> stream = this.items(e); stream.hasNext(); ) {
this.removeItemFromList(this.lastIdentityIndexOf(stream.next()), this.list, LIST_VALUES);
}
}
@@ -270,7 +275,8 @@ public class CollectionListValueModelAdapter
protected void collectionChanged(CollectionChangeEvent e) {
// put in empty check so we don't fire events unnecessarily
if ( ! this.list.isEmpty()) {
- ArrayList removedItems = (ArrayList) this.list.clone();
+ @SuppressWarnings("unchecked")
+ ArrayList<E> removedItems = (ArrayList<E>) this.list.clone();
this.list.clear();
this.fireItemsRemoved(LIST_VALUES, 0, removedItems);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
index 886c72c120..b03ebfb4a5 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionPropertyValueModelAdapter.java
@@ -34,7 +34,7 @@ public abstract class CollectionPropertyValueModelAdapter<T>
extends AspectPropertyValueModelAdapter<T>
{
/** The wrapped collection value model. */
- protected final CollectionValueModel collectionHolder;
+ protected final CollectionValueModel<?> collectionHolder;
/** A listener that allows us to synch with changes to the wrapped collection holder. */
protected final CollectionChangeListener collectionChangeListener;
@@ -46,7 +46,7 @@ public abstract class CollectionPropertyValueModelAdapter<T>
* Construct a property value model with the specified wrapped
* collection value model.
*/
- protected CollectionPropertyValueModelAdapter(CollectionValueModel collectionHolder) {
+ protected CollectionPropertyValueModelAdapter(CollectionValueModel<?> collectionHolder) {
super();
this.collectionHolder = collectionHolder;
this.collectionChangeListener = this.buildCollectionChangeListener();
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java
index bc17035f97..6fb00cb5b9 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModel.java
@@ -17,14 +17,14 @@ import org.eclipse.jpt.utility.internal.model.Model;
* Interface used to abstract collection accessing and
* change notification and make it more pluggable.
*/
-public interface CollectionValueModel
- extends Model//, Iterable<E>
+public interface CollectionValueModel<E>
+ extends Model, Iterable<E>
{
/**
* Return the collection's values.
*/
- Iterator iterator();
+ Iterator<E> iterator();
String VALUES = "values";
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
index 969ffdc7a9..0deb5a8bed 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CollectionValueModelWrapper.java
@@ -9,6 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.utility.internal.model.value;
+import java.util.Iterator;
+
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.ChangeSupport;
import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
@@ -20,13 +22,12 @@ import org.eclipse.jpt.utility.internal.model.listener.CollectionChangeListener;
* another collection value model, "lazily" listen to it, and propagate
* its change notifications.
*/
-public abstract class CollectionValueModelWrapper
+public abstract class CollectionValueModelWrapper<E>
extends AbstractModel
- implements CollectionValueModel
{
/** The wrapped collection value model. */
- protected final CollectionValueModel collectionHolder;
+ protected final CollectionValueModel<E> collectionHolder;
/** A listener that allows us to synch with changes to the wrapped collection holder. */
protected final CollectionChangeListener collectionChangeListener;
@@ -38,7 +39,7 @@ public abstract class CollectionValueModelWrapper
* Construct a collection value model with the specified wrapped
* collection value model.
*/
- protected CollectionValueModelWrapper(CollectionValueModel collectionHolder) {
+ protected CollectionValueModelWrapper(CollectionValueModel<E> collectionHolder) {
super();
this.collectionHolder = collectionHolder;
this.collectionChangeListener = this.buildCollectionChangeListener();
@@ -49,22 +50,22 @@ public abstract class CollectionValueModelWrapper
@Override
protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, CollectionChangeListener.class, VALUES);
+ return new SingleAspectChangeSupport(this, CollectionChangeListener.class, CollectionValueModel.VALUES);
}
protected CollectionChangeListener buildCollectionChangeListener() {
return new CollectionChangeListener() {
- public void itemsAdded(CollectionChangeEvent e) {
- CollectionValueModelWrapper.this.itemsAdded(e);
+ public void itemsAdded(CollectionChangeEvent event) {
+ CollectionValueModelWrapper.this.itemsAdded(event);
}
- public void itemsRemoved(CollectionChangeEvent e) {
- CollectionValueModelWrapper.this.itemsRemoved(e);
+ public void itemsRemoved(CollectionChangeEvent event) {
+ CollectionValueModelWrapper.this.itemsRemoved(event);
}
- public void collectionCleared(CollectionChangeEvent e) {
- CollectionValueModelWrapper.this.collectionCleared(e);
+ public void collectionCleared(CollectionChangeEvent event) {
+ CollectionValueModelWrapper.this.collectionCleared(event);
}
- public void collectionChanged(CollectionChangeEvent e) {
- CollectionValueModelWrapper.this.collectionChanged(e);
+ public void collectionChanged(CollectionChangeEvent event) {
+ CollectionValueModelWrapper.this.collectionChanged(event);
}
@Override
public String toString() {
@@ -81,7 +82,7 @@ public abstract class CollectionValueModelWrapper
*/
@Override
public synchronized void addCollectionChangeListener(CollectionChangeListener listener) {
- if (this.hasNoCollectionChangeListeners(VALUES)) {
+ if (this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
this.engageModel();
}
super.addCollectionChangeListener(listener);
@@ -92,7 +93,7 @@ public abstract class CollectionValueModelWrapper
*/
@Override
public synchronized void addCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
- if (collectionName == VALUES && this.hasNoCollectionChangeListeners(VALUES)) {
+ if (collectionName == CollectionValueModel.VALUES && this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
this.engageModel();
}
super.addCollectionChangeListener(collectionName, listener);
@@ -104,7 +105,7 @@ public abstract class CollectionValueModelWrapper
@Override
public synchronized void removeCollectionChangeListener(CollectionChangeListener listener) {
super.removeCollectionChangeListener(listener);
- if (this.hasNoCollectionChangeListeners(VALUES)) {
+ if (this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
this.disengageModel();
}
}
@@ -115,7 +116,7 @@ public abstract class CollectionValueModelWrapper
@Override
public synchronized void removeCollectionChangeListener(String collectionName, CollectionChangeListener listener) {
super.removeCollectionChangeListener(collectionName, listener);
- if (collectionName == VALUES && this.hasNoCollectionChangeListeners(VALUES)) {
+ if (collectionName == CollectionValueModel.VALUES && this.hasNoCollectionChangeListeners(CollectionValueModel.VALUES)) {
this.disengageModel();
}
}
@@ -127,14 +128,20 @@ public abstract class CollectionValueModelWrapper
* Start listening to the collection holder.
*/
protected void engageModel() {
- this.collectionHolder.addCollectionChangeListener(VALUES, this.collectionChangeListener);
+ this.collectionHolder.addCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
}
/**
* Stop listening to the collection holder.
*/
protected void disengageModel() {
- this.collectionHolder.removeCollectionChangeListener(VALUES, this.collectionChangeListener);
+ this.collectionHolder.removeCollectionChangeListener(CollectionValueModel.VALUES, this.collectionChangeListener);
+ }
+
+ // minimize suppressed warnings
+ @SuppressWarnings("unchecked")
+ protected Iterator<E> items(CollectionChangeEvent event) {
+ return (Iterator<E>) event.items();
}
@Override
@@ -149,24 +156,24 @@ public abstract class CollectionValueModelWrapper
* Items were added to the wrapped collection holder;
* propagate the change notification appropriately.
*/
- protected abstract void itemsAdded(CollectionChangeEvent e);
+ protected abstract void itemsAdded(CollectionChangeEvent event);
/**
* Items were removed from the wrapped collection holder;
* propagate the change notification appropriately.
*/
- protected abstract void itemsRemoved(CollectionChangeEvent e);
+ protected abstract void itemsRemoved(CollectionChangeEvent event);
/**
* The wrapped collection holder was cleared;
* propagate the change notification appropriately.
*/
- protected abstract void collectionCleared(CollectionChangeEvent e);
+ protected abstract void collectionCleared(CollectionChangeEvent event);
/**
* The value of the wrapped collection holder has changed;
* propagate the change notification appropriately.
*/
- protected abstract void collectionChanged(CollectionChangeEvent e);
+ protected abstract void collectionChanged(CollectionChangeEvent event);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
index 5b594454c9..5caf433b6e 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/CompositeCollectionValueModel.java
@@ -35,28 +35,29 @@ import org.eclipse.jpt.utility.internal.model.listener.CollectionChangeListener;
* - components - the component collection value models that are combined
* by this composite collection value model
*/
-public class CompositeCollectionValueModel
- extends CollectionValueModelWrapper
+public class CompositeCollectionValueModel<T, E>
+ extends CollectionValueModelWrapper<T>
+ implements CollectionValueModel<E>
{
/**
* This is the (optional) user-supplied object that transforms
* the items in the wrapped collection to collection value models.
*/
- private final Transformer transformer;
+ private final Transformer<T, CollectionValueModel<E>> transformer;
/**
* Cache of the component collection value models that
* were generated by the transformer; keyed by the item
* in the wrapped collection that was passed to the transformer.
*/
- private final IdentityHashMap components;
+ private final IdentityHashMap<T, CollectionValueModel<E>> components;
/**
* Cache of the collections corresponding to the component
* collection value models above; keyed by the component
* collection value models.
*/
- private final IdentityHashMap collections;
+ private final IdentityHashMap<CollectionValueModel<E>, ArrayList<E>> collections;
/** Listener that listens to all the component collection value models. */
private final CollectionChangeListener componentListener;
@@ -73,19 +74,19 @@ public class CompositeCollectionValueModel
* <code>transform(Object)</code> method instead of building a
* <code>Transformer</code>.
*/
- public CompositeCollectionValueModel(CollectionValueModel collectionHolder) {
- this(collectionHolder, Transformer.Disabled.instance());
+ public CompositeCollectionValueModel(CollectionValueModel<T> collectionHolder) {
+ this(collectionHolder, Transformer.Disabled.<T, CollectionValueModel<E>>instance());
}
/**
* Construct a collection value model with the specified wrapped
* collection value model and transformer.
*/
- public CompositeCollectionValueModel(CollectionValueModel collectionHolder, Transformer transformer) {
+ public CompositeCollectionValueModel(CollectionValueModel<T> collectionHolder, Transformer<T, CollectionValueModel<E>> transformer) {
super(collectionHolder);
this.transformer = transformer;
- this.components = new IdentityHashMap();
- this.collections = new IdentityHashMap();
+ this.components = new IdentityHashMap<T, CollectionValueModel<E>>();
+ this.collections = new IdentityHashMap<CollectionValueModel<E>, ArrayList<E>>();
this.componentListener = this.buildComponentListener();
this.size = 0;
}
@@ -97,15 +98,15 @@ public class CompositeCollectionValueModel
* <code>Transformer</code>.
*/
public CompositeCollectionValueModel(ListValueModel listHolder) {
- this(new ListCollectionValueModelAdapter(listHolder));
+ this(new ListCollectionValueModelAdapter<T>(listHolder));
}
/**
* Construct a collection value model with the specified wrapped
* list value model and transformer.
*/
- public CompositeCollectionValueModel(ListValueModel listHolder, Transformer transformer) {
- this(new ListCollectionValueModelAdapter(listHolder), transformer);
+ public CompositeCollectionValueModel(ListValueModel listHolder, Transformer<T, CollectionValueModel<E>> transformer) {
+ this(new ListCollectionValueModelAdapter<T>(listHolder), transformer);
}
@@ -135,14 +136,14 @@ public class CompositeCollectionValueModel
// ********** CollectionValueModel implementation **********
- public Iterator iterator() {
- return new CompositeIterator(this.buildCollectionsIterators());
+ public Iterator<E> iterator() {
+ return new CompositeIterator<E>(this.buildCollectionsIterators());
}
- protected Iterator buildCollectionsIterators() {
- return new TransformationIterator<ArrayList, Iterator>(this.collections.values().iterator()) {
+ protected Iterator<Iterator<E>> buildCollectionsIterators() {
+ return new TransformationIterator<ArrayList<E>, Iterator<E>>(this.collections.values().iterator()) {
@Override
- protected Iterator transform(ArrayList next) {
+ protected Iterator<E> transform(ArrayList<E> next) {
return next.iterator();
}
};
@@ -163,15 +164,15 @@ public class CompositeCollectionValueModel
// the following will trigger the firing of a number of unnecessary events
// (since we don't have any listeners yet),
// but it reduces the amount of duplicate code
- this.addComponentSources((Iterator) this.collectionHolder.iterator());
+ this.addComponentSources(this.collectionHolder.iterator());
}
@Override
protected void disengageModel() {
super.disengageModel();
// stop listening to the components...
- for (Iterator stream = this.components.values().iterator(); stream.hasNext(); ) {
- ((CollectionValueModel) stream.next()).removeCollectionChangeListener(CollectionValueModel.VALUES, this.componentListener);
+ for (CollectionValueModel<E> cvm : this.components.values()) {
+ cvm.removeCollectionChangeListener(CollectionValueModel.VALUES, this.componentListener);
}
// ...and clear the cache
this.components.clear();
@@ -185,14 +186,14 @@ public class CompositeCollectionValueModel
*/
@Override
protected void itemsAdded(CollectionChangeEvent e) {
- this.addComponentSources(e.items());
+ this.addComponentSources(this.items(e));
}
/**
* Transform the specified sources to collection value models
* and add their items to our cache.
*/
- protected void addComponentSources(Iterator sources) {
+ protected void addComponentSources(Iterator<T> sources) {
while (sources.hasNext()) {
this.addComponentSource(sources.next());
}
@@ -202,13 +203,13 @@ public class CompositeCollectionValueModel
* Transform the specified source to a collection value model
* and add its items to our cache.
*/
- protected void addComponentSource(Object source) {
- CollectionValueModel component = this.transform(source);
+ protected void addComponentSource(T source) {
+ CollectionValueModel<E> component = this.transform(source);
if (this.components.put(source, component) != null) {
throw new IllegalStateException("duplicate component: " + source);
}
component.addCollectionChangeListener(CollectionValueModel.VALUES, this.componentListener);
- ArrayList componentCollection = new ArrayList(component.size());
+ ArrayList<E> componentCollection = new ArrayList<E>(component.size());
if (this.collections.put(component, componentCollection) != null) {
throw new IllegalStateException("duplicate collection: " + source);
}
@@ -221,14 +222,14 @@ public class CompositeCollectionValueModel
*/
@Override
protected void itemsRemoved(CollectionChangeEvent e) {
- this.removeComponentSources(e.items());
+ this.removeComponentSources(this.items(e));
}
/**
* Remove the items corresponding to the specified sources
* from our cache.
*/
- protected void removeComponentSources(Iterator sources) {
+ protected void removeComponentSources(Iterator<T> sources) {
while (sources.hasNext()) {
this.removeComponentSource(sources.next());
}
@@ -238,13 +239,13 @@ public class CompositeCollectionValueModel
* Remove the items corresponding to the specified source
* from our cache.
*/
- protected void removeComponentSource(Object source) {
- CollectionValueModel component = (CollectionValueModel) this.components.remove(source);
+ protected void removeComponentSource(T source) {
+ CollectionValueModel<E> component = this.components.remove(source);
if (component == null) {
throw new IllegalStateException("missing component: " + source);
}
component.removeCollectionChangeListener(CollectionValueModel.VALUES, this.componentListener);
- ArrayList componentCollection = (ArrayList) this.collections.remove(component);
+ ArrayList<E> componentCollection = this.collections.remove(component);
if (componentCollection == null) {
throw new IllegalStateException("missing collection: " + source);
}
@@ -258,7 +259,7 @@ public class CompositeCollectionValueModel
@Override
protected void collectionCleared(CollectionChangeEvent e) {
// copy the keys so we don't eat our own tail
- this.removeComponentSources(new ArrayList(this.components.keySet()).iterator());
+ this.removeComponentSources(new ArrayList<T>(this.components.keySet()).iterator());
}
/**
@@ -268,8 +269,8 @@ public class CompositeCollectionValueModel
@Override
protected void collectionChanged(CollectionChangeEvent e) {
// copy the keys so we don't eat our own tail
- this.removeComponentSources(new ArrayList(this.components.keySet()).iterator());
- this.addComponentSources((Iterator) this.collectionHolder.iterator());
+ this.removeComponentSources(new ArrayList<T>(this.components.keySet()).iterator());
+ this.addComponentSources(this.collectionHolder.iterator());
}
@@ -280,8 +281,8 @@ public class CompositeCollectionValueModel
* Cast to ArrayList so we can use ArrayList-specific methods
* (e.g. #clone() and #ensureCapacity()).
*/
- protected ArrayList getComponentCollection(CollectionValueModel collectionValueModel) {
- return (ArrayList) this.collections.get(collectionValueModel);
+ protected ArrayList<E> componentCollection(CollectionValueModel<E> collectionValueModel) {
+ return this.collections.get(collectionValueModel);
}
@@ -293,8 +294,8 @@ public class CompositeCollectionValueModel
* This method can be overridden by a subclass as an
* alternative to building a <code>Transformer</code>.
*/
- protected CollectionValueModel transform(Object value) {
- return (CollectionValueModel) this.transformer.transform(value);
+ protected CollectionValueModel<E> transform(T value) {
+ return this.transformer.transform(value);
}
/**
@@ -302,27 +303,27 @@ public class CompositeCollectionValueModel
* synchronize our caches.
*/
protected void componentItemsAdded(CollectionChangeEvent e) {
- this.addComponentItems(e.items(), e.itemsSize(), (CollectionValueModel) e.getSource());
+ this.addComponentItems(this.componentItems(e), e.itemsSize(), this.componentCVM(e));
}
/**
* Update our cache.
*/
- protected void addComponentItems(Iterator items, int itemsSize, CollectionValueModel cvm) {
- this.addComponentItems(items, itemsSize, this.getComponentCollection(cvm));
+ protected void addComponentItems(Iterator<E> items, int itemsSize, CollectionValueModel<E> cvm) {
+ this.addComponentItems(items, itemsSize, this.componentCollection(cvm));
}
/**
* Update our cache.
*/
- protected void addComponentItems(CollectionValueModel itemsHolder, ArrayList componentCollection) {
- this.addComponentItems((Iterator) itemsHolder.iterator(), itemsHolder.size(), componentCollection);
+ protected void addComponentItems(CollectionValueModel<E> itemsHolder, ArrayList<E> componentCollection) {
+ this.addComponentItems(itemsHolder.iterator(), itemsHolder.size(), componentCollection);
}
/**
* Update our size and collection cache.
*/
- protected void addComponentItems(Iterator items, int itemsSize, ArrayList componentCollection) {
+ protected void addComponentItems(Iterator<E> items, int itemsSize, ArrayList<E> componentCollection) {
this.size += itemsSize;
componentCollection.ensureCapacity(componentCollection.size() + itemsSize);
this.addItemsToCollection(items, componentCollection, CollectionValueModel.VALUES);
@@ -333,28 +334,29 @@ public class CompositeCollectionValueModel
* synchronize our caches.
*/
protected void componentItemsRemoved(CollectionChangeEvent e) {
- this.removeComponentItems(e.items(), e.itemsSize(), (CollectionValueModel) e.getSource());
+ this.removeComponentItems(this.componentItems(e), e.itemsSize(), this.componentCVM(e));
}
/**
* Update our size and collection cache.
*/
- protected void removeComponentItems(Iterator items, int itemsSize, CollectionValueModel cvm) {
- this.removeComponentItems(items, itemsSize, this.getComponentCollection(cvm));
+ protected void removeComponentItems(Iterator<E> items, int itemsSize, CollectionValueModel<E> cvm) {
+ this.removeComponentItems(items, itemsSize, this.componentCollection(cvm));
}
/**
* Update our size and collection cache.
*/
- protected void clearComponentItems(ArrayList items) {
+ protected void clearComponentItems(ArrayList<E> items) {
// clone the collection so we don't eat our own tail
- this.removeComponentItems(((ArrayList) items.clone()).iterator(), items.size(), items);
+ @SuppressWarnings("unchecked") ArrayList<E> clone = (ArrayList<E>) items.clone();
+ this.removeComponentItems(clone.iterator(), items.size(), items);
}
/**
* Update our size and collection cache.
*/
- protected void removeComponentItems(Iterator items, int itemsSize, ArrayList componentCollection) {
+ protected void removeComponentItems(Iterator<E> items, int itemsSize, ArrayList<E> componentCollection) {
this.size -= itemsSize;
this.removeItemsFromCollection(items, componentCollection, CollectionValueModel.VALUES);
}
@@ -365,8 +367,7 @@ public class CompositeCollectionValueModel
* collection.
*/
protected void componentCollectionCleared(CollectionChangeEvent e) {
- CollectionValueModel component = (CollectionValueModel) e.getSource();
- ArrayList items = this.getComponentCollection(component);
+ ArrayList<E> items = this.componentCollection(this.componentCVM(e));
this.clearComponentItems(items);
}
@@ -376,10 +377,22 @@ public class CompositeCollectionValueModel
* collection and then rebuilding it.
*/
protected void componentCollectionChanged(CollectionChangeEvent e) {
- CollectionValueModel component = (CollectionValueModel) e.getSource();
- ArrayList items = this.getComponentCollection(component);
+ CollectionValueModel<E> componentCVM = this.componentCVM(e);
+ ArrayList<E> items = this.componentCollection(componentCVM);
this.clearComponentItems(items);
- this.addComponentItems(component, items);
+ this.addComponentItems(componentCVM, items);
+ }
+
+ // minimize suppressed warnings
+ @SuppressWarnings("unchecked")
+ protected Iterator<E> componentItems(CollectionChangeEvent e) {
+ return (Iterator<E>) e.items();
+ }
+
+ // minimize suppressed warnings
+ @SuppressWarnings("unchecked")
+ protected CollectionValueModel<E> componentCVM(CollectionChangeEvent e) {
+ return (CollectionValueModel<E>) e.getSource();
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
index da5a33401f..4f30ea64e2 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ExtendedListValueModelWrapper.java
@@ -27,14 +27,15 @@ import org.eclipse.jpt.utility.internal.model.event.ListChangeEvent;
* NB: Be careful using or wrapping this list value model, since the
* "extended" items may be unexpected by the client code or wrapper.
*/
-public class ExtendedListValueModelWrapper
- extends ListValueModelWrapper
+public class ExtendedListValueModelWrapper<E>
+ extends ListValueModelWrapper<E>
+ implements ListValueModel
{
/** the items "prepended" to the wrapped list */
- protected List prefix;
+ protected List<E> prefix;
/** the items "appended" to the wrapped list */
- protected List suffix;
+ protected List<E> suffix;
// ********** lots o' constructors **********
@@ -42,16 +43,16 @@ public class ExtendedListValueModelWrapper
/**
* Extend the specified list with a prefix and suffix.
*/
- public ExtendedListValueModelWrapper(List prefix, ListValueModel listHolder, List suffix) {
+ public ExtendedListValueModelWrapper(List<? extends E> prefix, ListValueModel listHolder, List<? extends E> suffix) {
super(listHolder);
- this.prefix = new ArrayList(prefix);
- this.suffix = new ArrayList(suffix);
+ this.prefix = new ArrayList<E>(prefix);
+ this.suffix = new ArrayList<E>(suffix);
}
/**
* Extend the specified list with a prefix and suffix.
*/
- public ExtendedListValueModelWrapper(Object prefix, ListValueModel listHolder, Object suffix) {
+ public ExtendedListValueModelWrapper(E prefix, ListValueModel listHolder, E suffix) {
super(listHolder);
this.prefix = Collections.singletonList(prefix);
this.suffix = Collections.singletonList(suffix);
@@ -60,36 +61,36 @@ public class ExtendedListValueModelWrapper
/**
* Extend the specified list with a prefix.
*/
- public ExtendedListValueModelWrapper(List prefix, ListValueModel listHolder) {
+ public ExtendedListValueModelWrapper(List<? extends E> prefix, ListValueModel listHolder) {
super(listHolder);
- this.prefix = new ArrayList(prefix);
- this.suffix = Collections.EMPTY_LIST;
+ this.prefix = new ArrayList<E>(prefix);
+ this.suffix = Collections.emptyList();
}
/**
* Extend the specified list with a prefix.
*/
- public ExtendedListValueModelWrapper(Object prefix, ListValueModel listHolder) {
+ public ExtendedListValueModelWrapper(E prefix, ListValueModel listHolder) {
super(listHolder);
this.prefix = Collections.singletonList(prefix);
- this.suffix = Collections.EMPTY_LIST;
+ this.suffix = Collections.emptyList();
}
/**
* Extend the specified list with a suffix.
*/
- public ExtendedListValueModelWrapper(ListValueModel listHolder, List suffix) {
+ public ExtendedListValueModelWrapper(ListValueModel listHolder, List<? extends E> suffix) {
super(listHolder);
- this.prefix = Collections.EMPTY_LIST;
- this.suffix = new ArrayList(suffix);
+ this.prefix = Collections.emptyList();
+ this.suffix = new ArrayList<E>(suffix);
}
/**
* Extend the specified list with a suffix.
*/
- public ExtendedListValueModelWrapper(ListValueModel listHolder, Object suffix) {
+ public ExtendedListValueModelWrapper(ListValueModel listHolder, E suffix) {
super(listHolder);
- this.prefix = Collections.EMPTY_LIST;
+ this.prefix = Collections.emptyList();
this.suffix = Collections.singletonList(suffix);
}
@@ -99,47 +100,47 @@ public class ExtendedListValueModelWrapper
public ExtendedListValueModelWrapper(ListValueModel listHolder) {
super(listHolder);
this.prefix = Collections.singletonList(null);
- this.suffix = Collections.EMPTY_LIST;
+ this.suffix = Collections.emptyList();
}
// ********** ListValueModel implementation **********
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return this.listIterator();
}
- public ListIterator listIterator() {
+ public ListIterator<E> listIterator() {
// try to prevent backdoor modification of the lists
- return new ReadOnlyListIterator(
- new CompositeListIterator(
- this.prefix.listIterator(),
- this.listHolder.listIterator(),
- this.suffix.listIterator()
- )
+ return new ReadOnlyListIterator<E>(this.listIterator_());
+ }
+
+ @SuppressWarnings("unchecked")
+ protected ListIterator<E> listIterator_() {
+ return new CompositeListIterator<E>(
+ this.prefix.listIterator(),
+ this.listHolder.listIterator(),
+ this.suffix.listIterator()
);
}
- @Override
- public Object get(int index) {
+ public E get(int index) {
int prefixSize = this.prefix.size();
if (index < prefixSize) {
return this.prefix.get(index);
} else if (index >= prefixSize + this.listHolder.size()) {
return this.suffix.get(index - (prefixSize + this.listHolder.size()));
} else {
- return this.listHolder.get(index - prefixSize);
+ return (E) this.listHolder.get(index - prefixSize);
}
}
- @Override
public int size() {
return this.prefix.size() + this.listHolder.size() + this.suffix.size();
}
- @Override
public Object[] toArray() {
- ArrayList list = new ArrayList(this.size());
+ ArrayList<E> list = new ArrayList<E>(this.size());
list.addAll(this.prefix);
CollectionTools.addAll(list, this.listHolder.iterator());
list.addAll(this.suffix);
@@ -191,12 +192,12 @@ public class ExtendedListValueModelWrapper
// ********** miscellaneous **********
- public void setPrefix(List prefix) {
+ public void setPrefix(List<E> prefix) {
this.prefix = prefix;
this.fireListChanged(LIST_VALUES);
}
- public void setSuffix(List suffix) {
+ public void setSuffix(List<E> suffix) {
this.suffix = suffix;
this.fireListChanged(LIST_VALUES);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
index fadfcaf6ae..ac03ea8a57 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/FilteringCollectionValueModel.java
@@ -40,14 +40,15 @@ import org.eclipse.jpt.utility.internal.model.event.CollectionChangeEvent;
* changes. The event will cause this wrapper to re-filter the changed
* item and add or remove it from the "filtered" collection as appropriate.
*/
-public class FilteringCollectionValueModel
- extends CollectionValueModelWrapper
+public class FilteringCollectionValueModel<E>
+ extends CollectionValueModelWrapper<E>
+ implements CollectionValueModel<E>
{
/** This filters the items in the nested collection. */
- private Filter filter;
+ private Filter<E> filter;
/** Cache the items that were accepted by the filter */
- private final Collection filteredItems;
+ private final Collection<E> filteredItems;
// ********** constructors **********
@@ -56,18 +57,18 @@ public class FilteringCollectionValueModel
* Construct a collection value model with the specified wrapped
* collection value model and a filter that simply accepts every object.
*/
- public FilteringCollectionValueModel(CollectionValueModel collectionHolder) {
- this(collectionHolder, Filter.Null.instance());
+ public FilteringCollectionValueModel(CollectionValueModel<E> collectionHolder) {
+ this(collectionHolder, Filter.Null.<E>instance());
}
/**
* Construct a collection value model with the specified wrapped
* collection value model and filter.
*/
- public FilteringCollectionValueModel(CollectionValueModel collectionHolder, Filter filter) {
+ public FilteringCollectionValueModel(CollectionValueModel<E> collectionHolder, Filter<E> filter) {
super(collectionHolder);
this.filter = filter;
- this.filteredItems = new ArrayList();
+ this.filteredItems = new ArrayList<E>();
}
/**
@@ -75,22 +76,22 @@ public class FilteringCollectionValueModel
* list value model and a filter that simply accepts every object.
*/
public FilteringCollectionValueModel(ListValueModel listHolder) {
- this(new ListCollectionValueModelAdapter(listHolder));
+ this(new ListCollectionValueModelAdapter<E>(listHolder));
}
/**
* Construct a collection value model with the specified wrapped
* list value model and filter.
*/
- public FilteringCollectionValueModel(ListValueModel listHolder, Filter filter) {
- this(new ListCollectionValueModelAdapter(listHolder), filter);
+ public FilteringCollectionValueModel(ListValueModel listHolder, Filter<E> filter) {
+ this(new ListCollectionValueModelAdapter<E>(listHolder), filter);
}
// ********** CollectionValueModel implementation **********
- public Iterator iterator() {
- return new ReadOnlyIterator(this.filteredItems);
+ public Iterator<E> iterator() {
+ return new ReadOnlyIterator<E>(this.filteredItems);
}
public int size() {
@@ -118,7 +119,7 @@ public class FilteringCollectionValueModel
@Override
protected void itemsAdded(CollectionChangeEvent e) {
// filter the values before propagating the change event
- this.addItemsToCollection(this.filter(e.items()), this.filteredItems, VALUES);
+ this.addItemsToCollection(this.filter(this.items(e)), this.filteredItems, VALUES);
}
@Override
@@ -145,7 +146,7 @@ public class FilteringCollectionValueModel
/**
* Change the filter and rebuild the collection.
*/
- public void setFilter(Filter filter) {
+ public void setFilter(Filter<E> filter) {
this.filter = filter;
this.rebuildFilteredItems();
}
@@ -153,8 +154,8 @@ public class FilteringCollectionValueModel
/**
* Return an iterator that filters the specified iterator.
*/
- protected Iterator filter(Iterator items) {
- return new FilteringIterator(items, this.filter);
+ protected Iterator<E> filter(Iterator<E> items) {
+ return new FilteringIterator<E>(items, this.filter);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java
index bd40dc4c97..740857284b 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemAspectListValueModelAdapter.java
@@ -39,15 +39,16 @@ import org.eclipse.jpt.utility.internal.model.event.ListChangeEvent;
* #stopListeningToItem(Model)
* stop listening to the appropriate aspect of the specified item
*/
-public abstract class ItemAspectListValueModelAdapter
- extends ListValueModelWrapper
+public abstract class ItemAspectListValueModelAdapter<E>
+ extends ListValueModelWrapper<E>
+ implements ListValueModel
{
/**
* Maintain a counter for each of the items in the
* wrapped list holder we are listening to.
*/
- protected final IdentityHashMap counters;
+ protected final IdentityHashMap<E, Counter> counters;
// ********** constructors **********
@@ -57,34 +58,35 @@ public abstract class ItemAspectListValueModelAdapter
*/
protected ItemAspectListValueModelAdapter(ListValueModel listHolder) {
super(listHolder);
- this.counters = new IdentityHashMap();
+ this.counters = new IdentityHashMap<E, Counter>();
}
/**
* Constructor - the collection holder is required.
*/
- protected ItemAspectListValueModelAdapter(CollectionValueModel collectionHolder) {
- this(new CollectionListValueModelAdapter(collectionHolder));
+ protected ItemAspectListValueModelAdapter(CollectionValueModel<E> collectionHolder) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder));
}
// ********** ListValueModel implementation **********
- public ListIterator listIterator() {
+ public Iterator<E> iterator() {
+ return this.listIterator();
+ }
+
+ public ListIterator<E> listIterator() {
return this.listHolder.listIterator();
}
- @Override
- public Object get(int index) {
- return this.listHolder.get(index);
+ public E get(int index) {
+ return (E) this.listHolder.get(index);
}
- @Override
public int size() {
return this.listHolder.size();
}
- @Override
public Object[] toArray() {
return this.listHolder.toArray();
}
@@ -105,15 +107,15 @@ public abstract class ItemAspectListValueModelAdapter
this.engageItems(this.listHolder.iterator());
}
- protected void engageItems(Iterator stream) {
+ protected void engageItems(Iterator<E> stream) {
while (stream.hasNext()) {
this.engageItem(stream.next());
}
}
- protected void engageItem(Object item) {
+ protected void engageItem(E item) {
// listen to an item only once
- Counter counter = (Counter) this.counters.get(item);
+ Counter counter = this.counters.get(item);
if (counter == null) {
counter = new Counter();
this.counters.put(item, counter);
@@ -140,15 +142,15 @@ public abstract class ItemAspectListValueModelAdapter
this.disengageItems(this.listHolder.iterator());
}
- protected void disengageItems(Iterator stream) {
+ protected void disengageItems(Iterator<E> stream) {
while (stream.hasNext()) {
this.disengageItem(stream.next());
}
}
- protected void disengageItem(Object item) {
+ protected void disengageItem(E item) {
// stop listening to an item only once
- Counter counter = (Counter) this.counters.get(item);
+ Counter counter = this.counters.get(item);
if (counter == null) {
// something is wrong if this happens... ~bjv
throw new IllegalStateException("missing counter: " + item);
@@ -175,7 +177,7 @@ public abstract class ItemAspectListValueModelAdapter
protected void itemsAdded(ListChangeEvent e) {
// re-fire event with the wrapper as the source
this.fireItemsAdded(e.cloneWithSource(this, LIST_VALUES));
- this.engageItems(e.items());
+ this.engageItems(this.items(e));
}
/**
@@ -184,7 +186,7 @@ public abstract class ItemAspectListValueModelAdapter
*/
@Override
protected void itemsRemoved(ListChangeEvent e) {
- this.disengageItems(e.items());
+ this.disengageItems(this.items(e));
// re-fire event with the wrapper as the source
this.fireItemsRemoved(e.cloneWithSource(this, LIST_VALUES));
}
@@ -196,10 +198,10 @@ public abstract class ItemAspectListValueModelAdapter
*/
@Override
protected void itemsReplaced(ListChangeEvent e) {
- this.disengageItems(e.replacedItems());
+ this.disengageItems(this.replacedItems(e));
// re-fire event with the wrapper as the source
this.fireItemsReplaced(e.cloneWithSource(this, LIST_VALUES));
- this.engageItems(e.items());
+ this.engageItems(this.items(e));
}
/**
@@ -220,7 +222,7 @@ public abstract class ItemAspectListValueModelAdapter
protected void listCleared(ListChangeEvent e) {
// we should only need to disengage each item once...
// make a copy to prevent a ConcurrentModificationException
- Collection keys = new ArrayList(this.counters.keySet());
+ Collection<E> keys = new ArrayList<E>(this.counters.keySet());
this.disengageItems(keys.iterator());
this.counters.clear();
// re-fire event with the wrapper as the source
@@ -235,7 +237,7 @@ public abstract class ItemAspectListValueModelAdapter
protected void listChanged(ListChangeEvent e) {
// we should only need to disengage each item once...
// make a copy to prevent a ConcurrentModificationException
- Collection keys = new ArrayList(this.counters.keySet());
+ Collection<E> keys = new ArrayList<E>(this.counters.keySet());
this.disengageItems(keys.iterator());
this.counters.clear();
// re-fire event with the wrapper as the source
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
index 5326794918..ab7ee9c7fe 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemCollectionListValueModelAdapter.java
@@ -19,8 +19,8 @@ import org.eclipse.jpt.utility.internal.model.listener.CollectionChangeListener;
* Extend ItemAspectListValueModelAdapter to listen to one or more collection
* aspects of each item in the wrapped list model.
*/
-public class ItemCollectionListValueModelAdapter
- extends ItemAspectListValueModelAdapter
+public class ItemCollectionListValueModelAdapter<E>
+ extends ItemAspectListValueModelAdapter<E>
{
/** The names of the items' collections that we listen to. */
@@ -44,8 +44,8 @@ public class ItemCollectionListValueModelAdapter
/**
* Construct an adapter for the specified item Collections.
*/
- public ItemCollectionListValueModelAdapter(CollectionValueModel collectionHolder, String... collectionNames) {
- this(new CollectionListValueModelAdapter(collectionHolder), collectionNames);
+ public ItemCollectionListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... collectionNames) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder), collectionNames);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java
index 23458674bc..92e4451da0 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemListListValueModelAdapter.java
@@ -19,8 +19,8 @@ import org.eclipse.jpt.utility.internal.model.listener.ListChangeListener;
* Extend ItemAspectListValueModelAdapter to listen to one or more list
* aspects of each item in the wrapped list model.
*/
-public class ItemListListValueModelAdapter
- extends ItemAspectListValueModelAdapter
+public class ItemListListValueModelAdapter<E>
+ extends ItemAspectListValueModelAdapter<E>
{
/** The names of the subject's lists that we listen to. */
@@ -44,8 +44,8 @@ public class ItemListListValueModelAdapter
/**
* Construct an adapter for the specified item List aspects.
*/
- public ItemListListValueModelAdapter(CollectionValueModel collectionHolder, String... listNames) {
- this(new CollectionListValueModelAdapter(collectionHolder), listNames);
+ public ItemListListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... listNames) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder), listNames);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
index 47ea374160..99b657d924 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemPropertyListValueModelAdapter.java
@@ -19,8 +19,8 @@ import org.eclipse.jpt.utility.internal.model.listener.PropertyChangeListener;
* Extend ItemAspectListValueModelAdapter to listen to one or more
* properties of each item in the wrapped list model.
*/
-public class ItemPropertyListValueModelAdapter
- extends ItemAspectListValueModelAdapter
+public class ItemPropertyListValueModelAdapter<E>
+ extends ItemAspectListValueModelAdapter<E>
{
/** The names of the items' properties that we listen to. */
@@ -44,8 +44,8 @@ public class ItemPropertyListValueModelAdapter
/**
* Construct an adapter for the specified item properties.
*/
- public ItemPropertyListValueModelAdapter(CollectionValueModel collectionHolder, String... propertyNames) {
- this(new CollectionListValueModelAdapter(collectionHolder), propertyNames);
+ public ItemPropertyListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... propertyNames) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder), propertyNames);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java
index 9548fbb37e..264a66be8e 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemStateListValueModelAdapter.java
@@ -17,8 +17,8 @@ import org.eclipse.jpt.utility.internal.model.listener.StateChangeListener;
* Extend ItemAspectListValueModelAdapter to listen to the
* "state" of each item in the wrapped list model.
*/
-public class ItemStateListValueModelAdapter
- extends ItemAspectListValueModelAdapter
+public class ItemStateListValueModelAdapter<E>
+ extends ItemAspectListValueModelAdapter<E>
{
/** Listener that listens to all the items in the list. */
protected final StateChangeListener itemStateListener;
@@ -37,8 +37,8 @@ public class ItemStateListValueModelAdapter
/**
* Construct an adapter for the item state.
*/
- public ItemStateListValueModelAdapter(CollectionValueModel collectionHolder) {
- this(new CollectionListValueModelAdapter(collectionHolder));
+ public ItemStateListValueModelAdapter(CollectionValueModel<E> collectionHolder) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder));
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java
index 7d9fd8c738..eb3100aa39 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ItemTreeListValueModelAdapter.java
@@ -19,8 +19,8 @@ import org.eclipse.jpt.utility.internal.model.listener.TreeChangeListener;
* Extend ItemAspectListValueModelAdapter to listen to one or more tree
* aspects of each item in the wrapped list model.
*/
-public class ItemTreeListValueModelAdapter
- extends ItemAspectListValueModelAdapter
+public class ItemTreeListValueModelAdapter<E>
+ extends ItemAspectListValueModelAdapter<E>
{
/** The names of the items' tree that we listen to. */
@@ -44,8 +44,8 @@ public class ItemTreeListValueModelAdapter
/**
* Construct an adapter for the specified item trees.
*/
- public ItemTreeListValueModelAdapter(CollectionValueModel collectionHolder, String... treeNames) {
- this(new CollectionListValueModelAdapter(collectionHolder), treeNames);
+ public ItemTreeListValueModelAdapter(CollectionValueModel<E> collectionHolder, String... treeNames) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder), treeNames);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java
index d3f33a1dc8..5bc4be97dc 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListAspectAdapter.java
@@ -43,7 +43,7 @@ import org.eclipse.jpt.utility.internal.model.listener.ListChangeListener;
* override this method only if returning a zero when the
* subject is null is unacceptable
*/
-public abstract class ListAspectAdapter<S extends Model>
+public abstract class ListAspectAdapter<S extends Model, E>
extends AspectAdapter<S>
implements ListValueModel
{
@@ -145,15 +145,15 @@ public abstract class ListAspectAdapter<S extends Model>
/**
* Return the elements of the subject's list aspect.
*/
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return this.listIterator();
}
/**
* Return the elements of the subject's list aspect.
*/
- public ListIterator listIterator() {
- return (this.subject == null) ? EmptyListIterator.instance() : this.listIterator_();
+ public ListIterator<E> listIterator() {
+ return (this.subject == null) ? EmptyListIterator.<E>instance() : this.listIterator_();
}
/**
@@ -161,7 +161,7 @@ public abstract class ListAspectAdapter<S extends Model>
* At this point we can be sure that the subject is not null.
* @see #listIterator()
*/
- protected ListIterator listIterator_() {
+ protected ListIterator<E> listIterator_() {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
index b3d0bf1d15..360dc27970 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCollectionValueModelAdapter.java
@@ -33,9 +33,9 @@ import org.eclipse.jpt.utility.internal.model.listener.ListChangeListener;
* we do not have any listeners. This should not be too painful since,
* most likely, client objects will also be listeners.
*/
-public class ListCollectionValueModelAdapter
+public class ListCollectionValueModelAdapter<E>
extends AbstractModel
- implements CollectionValueModel
+ implements CollectionValueModel<E>
{
/** The wrapped list value model. */
protected final ListValueModel listHolder;
@@ -48,7 +48,7 @@ public class ListCollectionValueModelAdapter
* the wrapped list.
*/
// we declare this an ArrayList so we can use #clone() and #ensureCapacity(int)
- protected final ArrayList collection;
+ protected final ArrayList<E> collection;
// ********** constructors/initialization **********
@@ -63,7 +63,7 @@ public class ListCollectionValueModelAdapter
}
this.listHolder = listHolder;
this.listChangeListener = this.buildListChangeListener();
- this.collection = new ArrayList();
+ this.collection = new ArrayList<E>();
// postpone building the collection and listening to the underlying list
// until we have listeners ourselves...
}
@@ -107,9 +107,9 @@ public class ListCollectionValueModelAdapter
// ********** CollectionValueModel implementation **********
- public Iterator iterator() {
+ public Iterator<E> iterator() {
// try to prevent backdoor modification of the list
- return new ReadOnlyIterator(this.collection);
+ return new ReadOnlyIterator<E>(this.collection);
}
public int size() {
@@ -199,7 +199,7 @@ public class ListCollectionValueModelAdapter
// ********** behavior **********
protected void buildCollection() {
- Iterator stream = this.listHolder.iterator();
+ Iterator<E> stream = this.listHolder.iterator();
// if the new list is empty, do nothing
if (stream.hasNext()) {
this.collection.ensureCapacity(this.listHolder.size());
@@ -222,11 +222,12 @@ public class ListCollectionValueModelAdapter
this.collection.clear();
}
+ @SuppressWarnings("unchecked")
protected void itemsAdded(ListChangeEvent e) {
- this.addItemsToCollection(e.items(), this.collection, VALUES);
+ this.addItemsToCollection((Iterator<E>) e.items(), this.collection, VALUES);
}
- protected void removeInternalItems(Iterator items) {
+ protected void removeInternalItems(Iterator<E> items) {
// we have to remove the items individually,
// since they are probably not in sequence
while (items.hasNext()) {
@@ -237,13 +238,15 @@ public class ListCollectionValueModelAdapter
}
}
+ @SuppressWarnings("unchecked")
protected void itemsRemoved(ListChangeEvent e) {
- this.removeInternalItems(e.items());
+ this.removeInternalItems((Iterator<E>) e.items());
}
+ @SuppressWarnings("unchecked")
protected void itemsReplaced(ListChangeEvent e) {
- this.removeInternalItems(e.replacedItems());
- this.addItemsToCollection(e.items(), this.collection, VALUES);
+ this.removeInternalItems((Iterator<E>) e.replacedItems());
+ this.addItemsToCollection((Iterator<E>) e.items(), this.collection, VALUES);
}
protected void itemsMoved(ListChangeEvent e) {
@@ -265,7 +268,8 @@ public class ListCollectionValueModelAdapter
protected void listChanged(ListChangeEvent e) {
// put in empty check so we don't fire events unnecessarily
if ( ! this.collection.isEmpty()) {
- ArrayList removedItems = (ArrayList) this.collection.clone();
+ @SuppressWarnings("unchecked")
+ ArrayList<E> removedItems = (ArrayList<E>) this.collection.clone();
this.collection.clear();
this.fireItemsRemoved(VALUES, removedItems);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java
index 33f2f3982e..dbf28ec1fc 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListCurator.java
@@ -27,12 +27,12 @@ import org.eclipse.jpt.utility.internal.model.listener.StateChangeListener;
* by adapting a subject's state change events to a minimum set
* of list change events.
*/
-public abstract class ListCurator<S extends Model>
+public abstract class ListCurator<S extends Model, E>
extends AspectAdapter<S>
implements ListValueModel
{
/** How the list looked before the last state change */
- private final ArrayList record;
+ private final ArrayList<E> record;
/** A listener that listens for the subject's state to change */
private final StateChangeListener stateChangeListener;
@@ -53,7 +53,7 @@ public abstract class ListCurator<S extends Model>
*/
protected ListCurator(PropertyValueModel<S> subjectHolder) {
super(subjectHolder);
- this.record = new ArrayList();
+ this.record = new ArrayList<E>();
this.stateChangeListener = this.buildStateChangeListener();
}
@@ -78,12 +78,12 @@ public abstract class ListCurator<S extends Model>
// ********** ListValueModel implementation **********
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return this.listIterator();
}
- public ListIterator listIterator() {
- return new ReadOnlyListIterator(this.record);
+ public ListIterator<E> listIterator() {
+ return new ReadOnlyListIterator<E>(this.record);
}
/**
@@ -167,24 +167,24 @@ public abstract class ListCurator<S extends Model>
* It is intended to be used only when the subject changes or the
* subject's "state" changes (as signified by a state change event).
*/
- protected abstract Iterator iteratorForRecord();
+ protected abstract Iterator<E> iteratorForRecord();
// ********** behavior **********
void submitInventoryReport() {
- List newRecord = CollectionTools.list(this.iteratorForRecord());
+ List<E> newRecord = CollectionTools.list(this.iteratorForRecord());
int recordIndex = 0;
// add items from the new record
- for (Object newItem : newRecord) {
+ for (E newItem : newRecord) {
this.inventoryNewItem(recordIndex, newItem);
recordIndex++;
}
// clean out items that are no longer in the new record
for (recordIndex = 0; recordIndex < this.record.size(); ) {
- Object item = this.record.get(recordIndex);
+ E item = this.record.get(recordIndex);
if (newRecord.contains(item)) {
recordIndex++;
@@ -194,8 +194,8 @@ public abstract class ListCurator<S extends Model>
}
}
- private void inventoryNewItem(int recordIndex, Object newItem) {
- List rec = new ArrayList(this.record);
+ private void inventoryNewItem(int recordIndex, E newItem) {
+ List<E> rec = new ArrayList<E>(this.record);
if ((recordIndex < rec.size()) && rec.get(recordIndex).equals(newItem)) {
return;
@@ -208,11 +208,11 @@ public abstract class ListCurator<S extends Model>
}
}
- private void addItemToInventory(int index, Object item) {
+ private void addItemToInventory(int index, E item) {
this.addItemToList(index, item, this.record, LIST_VALUES);
}
- private void removeItemFromInventory(int index, Object item) {
+ private void removeItemFromInventory(int index, E item) {
this.removeItemFromList(index, this.record, LIST_VALUES);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java
index f97920c3db..ad7750b7bf 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/ListValueModelWrapper.java
@@ -9,9 +9,8 @@
******************************************************************************/
package org.eclipse.jpt.utility.internal.model.value;
-import java.util.Iterator;
+import java.util.ListIterator;
-import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.ChangeSupport;
import org.eclipse.jpt.utility.internal.model.SingleAspectChangeSupport;
@@ -23,9 +22,8 @@ import org.eclipse.jpt.utility.internal.model.listener.ListChangeListener;
* another list value model, "lazily" listen to it, and propagate
* its change notifications.
*/
-public abstract class ListValueModelWrapper
+public abstract class ListValueModelWrapper<E>
extends AbstractModel
- implements ListValueModel
{
/** The wrapped list value model. */
@@ -55,7 +53,7 @@ public abstract class ListValueModelWrapper
@Override
protected ChangeSupport buildChangeSupport() {
- return new SingleAspectChangeSupport(this, ListChangeListener.class, LIST_VALUES);
+ return new SingleAspectChangeSupport(this, ListChangeListener.class, ListValueModel.LIST_VALUES);
}
protected ListChangeListener buildListChangeListener() {
@@ -86,25 +84,6 @@ public abstract class ListValueModelWrapper
}
- // ********** ListValueModel implementation **********
-
- public Iterator iterator() {
- return this.listIterator();
- }
-
- public Object get(int index) {
- return CollectionTools.get(this.listIterator(), index);
- }
-
- public int size() {
- return CollectionTools.size(this.listIterator());
- }
-
- public Object[] toArray() {
- return CollectionTools.array(this.listIterator());
- }
-
-
// ********** extend change support **********
/**
@@ -112,7 +91,7 @@ public abstract class ListValueModelWrapper
*/
@Override
public synchronized void addListChangeListener(ListChangeListener listener) {
- if (this.hasNoListChangeListeners(LIST_VALUES)) {
+ if (this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
this.engageModel();
}
super.addListChangeListener(listener);
@@ -123,7 +102,7 @@ public abstract class ListValueModelWrapper
*/
@Override
public synchronized void addListChangeListener(String listName, ListChangeListener listener) {
- if (listName == LIST_VALUES && this.hasNoListChangeListeners(LIST_VALUES)) {
+ if (listName == ListValueModel.LIST_VALUES && this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
this.engageModel();
}
super.addListChangeListener(listName, listener);
@@ -135,7 +114,7 @@ public abstract class ListValueModelWrapper
@Override
public synchronized void removeListChangeListener(ListChangeListener listener) {
super.removeListChangeListener(listener);
- if (this.hasNoListChangeListeners(LIST_VALUES)) {
+ if (this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
this.disengageModel();
}
}
@@ -146,7 +125,7 @@ public abstract class ListValueModelWrapper
@Override
public synchronized void removeListChangeListener(String listName, ListChangeListener listener) {
super.removeListChangeListener(listName, listener);
- if (listName == LIST_VALUES && this.hasNoListChangeListeners(LIST_VALUES)) {
+ if (listName == ListValueModel.LIST_VALUES && this.hasNoListChangeListeners(ListValueModel.LIST_VALUES)) {
this.disengageModel();
}
}
@@ -158,14 +137,14 @@ public abstract class ListValueModelWrapper
* Start listening to the list holder.
*/
protected void engageModel() {
- this.listHolder.addListChangeListener(LIST_VALUES, this.listChangeListener);
+ this.listHolder.addListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
}
/**
* Stop listening to the list holder.
*/
protected void disengageModel() {
- this.listHolder.removeListChangeListener(LIST_VALUES, this.listChangeListener);
+ this.listHolder.removeListChangeListener(ListValueModel.LIST_VALUES, this.listChangeListener);
}
@Override
@@ -173,6 +152,18 @@ public abstract class ListValueModelWrapper
sb.append(this.listHolder);
}
+ // minimize suppressed warnings
+ @SuppressWarnings("unchecked")
+ protected ListIterator<E> items(ListChangeEvent e) {
+ return (ListIterator<E>) e.items();
+ }
+
+ // minimize suppressed warnings
+ @SuppressWarnings("unchecked")
+ protected ListIterator<E> replacedItems(ListChangeEvent e) {
+ return (ListIterator<E>) e.replacedItems();
+ }
+
// ********** list change support **********
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
index 30c320b720..a3e8e4cf82 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/NullCollectionValueModel.java
@@ -23,9 +23,9 @@ import org.eclipse.jpt.utility.internal.model.AbstractModel;
*
* We don't use a singleton because we hold on to listeners.
*/
-public final class NullCollectionValueModel
+public final class NullCollectionValueModel<E>
extends AbstractModel
- implements CollectionValueModel
+ implements CollectionValueModel<E>
{
private static final long serialVersionUID = 1L;
@@ -43,7 +43,7 @@ public final class NullCollectionValueModel
return 0;
}
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return EmptyIterator.instance();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
index db20acfabb..9e8ade2717 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/PropertyCollectionValueModelAdapter.java
@@ -27,18 +27,18 @@ import org.eclipse.jpt.utility.internal.model.listener.PropertyChangeListener;
* If the property's value is null, an empty iterator is returned
* (i.e. you can't have a collection with a null element).
*/
-public class PropertyCollectionValueModelAdapter
+public class PropertyCollectionValueModelAdapter<E>
extends AbstractModel
- implements CollectionValueModel
+ implements CollectionValueModel<E>
{
/** The wrapped property value model. */
- protected final PropertyValueModel valueHolder;
+ protected final PropertyValueModel<E> valueHolder;
/** A listener that forwards any events fired by the value holder. */
protected final PropertyChangeListener propertyChangeListener;
/** Cache the value. */
- protected Object value;
+ protected E value;
// ********** constructors/initialization **********
@@ -46,7 +46,7 @@ public class PropertyCollectionValueModelAdapter
/**
* Wrap the specified ListValueModel.
*/
- public PropertyCollectionValueModelAdapter(PropertyValueModel valueHolder) {
+ public PropertyCollectionValueModelAdapter(PropertyValueModel<E> valueHolder) {
super();
if (valueHolder == null) {
throw new NullPointerException();
@@ -68,8 +68,9 @@ public class PropertyCollectionValueModelAdapter
*/
protected PropertyChangeListener buildPropertyChangeListener() {
return new PropertyChangeListener() {
+ @SuppressWarnings("unchecked")
public void propertyChanged(PropertyChangeEvent e) {
- PropertyCollectionValueModelAdapter.this.valueChanged(e.newValue());
+ PropertyCollectionValueModelAdapter.this.valueChanged((E) e.newValue());
}
@Override
public String toString() {
@@ -81,11 +82,11 @@ public class PropertyCollectionValueModelAdapter
// ********** CollectionValueModel implementation **********
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return (this.value == null) ?
- EmptyIterator.instance()
+ EmptyIterator.<E>instance()
:
- new SingleElementIterator(this.value);
+ new SingleElementIterator<E>(this.value);
}
public int size() {
@@ -170,10 +171,10 @@ public class PropertyCollectionValueModelAdapter
* synchronize our internal value with the wrapped value
* and fire the appropriate events
*/
- protected void valueChanged(Object newValue) {
+ protected void valueChanged(E newValue) {
// put in "empty" check so we don't fire events unnecessarily
if (this.value != null) {
- Object oldValue = this.value;
+ E oldValue = this.value;
this.value = null;
this.fireItemRemoved(VALUES, oldValue);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
index 3dc3dfd460..9c282db3c5 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SimpleCollectionValueModel.java
@@ -26,7 +26,7 @@ import org.eclipse.jpt.utility.internal.model.listener.CollectionChangeListener;
*/
public class SimpleCollectionValueModel<E>
extends AbstractModel
- implements CollectionValueModel, Collection<E>
+ implements CollectionValueModel<E>, Collection<E>
{
/** The collection. */
protected Collection<E> collection;
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
index 449cc1e62f..3fb76d718a 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/SortedListValueModelAdapter.java
@@ -35,14 +35,14 @@ import org.eclipse.jpt.utility.internal.model.event.CollectionChangeEvent;
* we do not have any listeners. This should not be too painful since,
* most likely, client objects will also be listeners.
*/
-public class SortedListValueModelAdapter
- extends CollectionListValueModelAdapter
+public class SortedListValueModelAdapter<E>
+ extends CollectionListValueModelAdapter<E>
{
/**
* A comparator used for sorting the elements;
* if it is null, we use "natural ordering".
*/
- protected Comparator comparator;
+ protected Comparator<E> comparator;
// ********** constructors **********
@@ -51,7 +51,7 @@ public class SortedListValueModelAdapter
* Wrap the specified collection value model and sort its contents
* using the specified comparator.
*/
- public SortedListValueModelAdapter(CollectionValueModel collectionHolder, Comparator comparator) {
+ public SortedListValueModelAdapter(CollectionValueModel<E> collectionHolder, Comparator<E> comparator) {
super(collectionHolder);
this.comparator = comparator;
}
@@ -60,7 +60,7 @@ public class SortedListValueModelAdapter
* Wrap the specified collection value model and sort its contents
* based on the elements' "natural ordering".
*/
- public SortedListValueModelAdapter(CollectionValueModel collectionHolder) {
+ public SortedListValueModelAdapter(CollectionValueModel<E> collectionHolder) {
this(collectionHolder, null);
}
@@ -68,8 +68,8 @@ public class SortedListValueModelAdapter
* Wrap the specified list value model and sort its contents
* using the specified comparator.
*/
- public SortedListValueModelAdapter(ListValueModel listHolder, Comparator comparator) {
- this(new ListCollectionValueModelAdapter(listHolder), comparator);
+ public SortedListValueModelAdapter(ListValueModel listHolder, Comparator<E> comparator) {
+ this(new ListCollectionValueModelAdapter<E>(listHolder), comparator);
}
/**
@@ -83,7 +83,7 @@ public class SortedListValueModelAdapter
// ********** accessors **********
- public void setComparator(Comparator comparator) {
+ public void setComparator(Comparator<E> comparator) {
this.comparator = comparator;
this.sortList();
}
@@ -117,12 +117,13 @@ public class SortedListValueModelAdapter
*/
protected void sortList() {
// save the unsorted state of the sorted list so we can minimize the number of "replaced" items
- ArrayList unsortedList = (ArrayList) this.list.clone();
+ @SuppressWarnings("unchecked")
+ ArrayList<E> unsortedList = (ArrayList<E>) this.list.clone();
Collections.sort(this.list, this.comparator);
Range diffRange = CollectionTools.identityDiffRange(unsortedList, this.list);
if (diffRange.size > 0) {
- List unsortedItems = unsortedList.subList(diffRange.start, diffRange.end + 1);
- List sortedItems = this.list.subList(diffRange.start, diffRange.end + 1);
+ List<E> unsortedItems = unsortedList.subList(diffRange.start, diffRange.end + 1);
+ List<E> sortedItems = this.list.subList(diffRange.start, diffRange.end + 1);
this.fireItemsReplaced(LIST_VALUES, diffRange.start, sortedItems, unsortedItems);
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java
index 3ec8d6d3f5..acb9d25171 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticCollectionValueModel.java
@@ -20,12 +20,12 @@ import org.eclipse.jpt.utility.internal.model.AbstractModel;
* returning an iterator on a static collection, but still allows listeners to be added.
* Listeners will NEVER be notified of any changes, because there should be none.
*/
-public class StaticCollectionValueModel
+public class StaticCollectionValueModel<E>
extends AbstractModel
- implements CollectionValueModel
+ implements CollectionValueModel<E>
{
/** The collection. */
- protected final Collection collection;
+ protected final Collection<E> collection;
private static final long serialVersionUID = 1L;
@@ -33,7 +33,7 @@ public class StaticCollectionValueModel
/**
* Construct a static CollectionValueModel for the specified collection.
*/
- public StaticCollectionValueModel(Collection collection) {
+ public StaticCollectionValueModel(Collection<E> collection) {
super();
if (collection == null) {
throw new NullPointerException();
@@ -47,7 +47,7 @@ public class StaticCollectionValueModel
return this.collection.size();
}
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return this.collection.iterator();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java
index 38a8effaec..073995a7c3 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticListValueModel.java
@@ -21,12 +21,12 @@ import org.eclipse.jpt.utility.internal.model.AbstractModel;
* returning a list iterator on a static list, but still allows listeners to be added.
* Listeners will NEVER be notified of any changes, because there should be none.
*/
-public class StaticListValueModel
+public class StaticListValueModel<E>
extends AbstractModel
implements ListValueModel
{
/** The value. */
- protected final List list;
+ protected final List<E> list;
private static final long serialVersionUID = 1L;
@@ -34,7 +34,7 @@ public class StaticListValueModel
/**
* Construct a static ListValueModel for the specified list.
*/
- public StaticListValueModel(List list) {
+ public StaticListValueModel(List<E> list) {
super();
if (list == null) {
throw new NullPointerException();
@@ -45,11 +45,11 @@ public class StaticListValueModel
// ********** ListValueModel implementation **********
- public Iterator iterator() {
+ public Iterator<E> iterator() {
return this.list.iterator();
}
- public ListIterator listIterator() {
+ public ListIterator<E> listIterator() {
return this.list.listIterator();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java
index ec57bd9a44..a2a2a014d6 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/StaticTreeValueModel.java
@@ -20,12 +20,12 @@ import org.eclipse.jpt.utility.internal.model.AbstractModel;
* returning an iterator on a static tree, but still allows listeners to be added.
* Listeners will NEVER be notified of any changes, because there should be none.
*/
-public class StaticTreeValueModel
+public class StaticTreeValueModel<E>
extends AbstractModel
implements TreeValueModel
{
/** The tree's nodes. */
- protected final Iterable nodes;
+ protected final Iterable<E> nodes;
private static final long serialVersionUID = 1L;
@@ -33,7 +33,7 @@ public class StaticTreeValueModel
/**
* Construct a read-only TreeValueModel for the specified nodes.
*/
- public StaticTreeValueModel(Iterable nodes) {
+ public StaticTreeValueModel(Iterable<E> nodes) {
super();
if (nodes == null) {
throw new NullPointerException();
@@ -43,7 +43,7 @@ public class StaticTreeValueModel
// ********** TreeValueModel implementation **********
- public Iterator nodes() {
+ public Iterator<E> nodes() {
return this.nodes.iterator();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
index 60f464fd4f..37d7fb45e1 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TransformationListValueModelAdapter.java
@@ -10,6 +10,7 @@
package org.eclipse.jpt.utility.internal.model.value;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
@@ -35,15 +36,16 @@ import org.eclipse.jpt.utility.internal.model.event.ListChangeEvent;
* we do not have any listeners. This should not be too painful since,
* most likely, client objects will also be listeners.
*/
-public class TransformationListValueModelAdapter
- extends ListValueModelWrapper
+public class TransformationListValueModelAdapter<E1, E2>
+ extends ListValueModelWrapper<E1>
+ implements ListValueModel
{
/** This transforms the items, unless the subclass overrides #transformItem(Object). */
- protected Transformer transformer;
+ protected Transformer<E1, E2> transformer;
/** The list of transformed items. */
- protected final List transformedList;
+ protected final List<E2> transformedList;
// ********** constructors **********
@@ -51,52 +53,53 @@ public class TransformationListValueModelAdapter
/**
* Constructor - the list holder is required.
*/
- public TransformationListValueModelAdapter(ListValueModel listHolder, Transformer transformer) {
+ public TransformationListValueModelAdapter(ListValueModel listHolder, Transformer<E1, E2> transformer) {
super(listHolder);
this.transformer = transformer;
- this.transformedList = new ArrayList();
+ this.transformedList = new ArrayList<E2>();
}
/**
* Constructor - the list holder is required.
*/
public TransformationListValueModelAdapter(ListValueModel listHolder) {
- this(listHolder, Transformer.Null.instance());
+ this(listHolder, Transformer.Null.<E1, E2>instance());
}
/**
* Constructor - the collection holder is required.
*/
- public TransformationListValueModelAdapter(CollectionValueModel collectionHolder, Transformer transformer) {
- this(new CollectionListValueModelAdapter(collectionHolder), transformer);
+ public TransformationListValueModelAdapter(CollectionValueModel<E1> collectionHolder, Transformer<E1, E2> transformer) {
+ this(new CollectionListValueModelAdapter<E1>(collectionHolder), transformer);
}
/**
* Constructor - the collection holder is required.
*/
- public TransformationListValueModelAdapter(CollectionValueModel collectionHolder) {
- this(new CollectionListValueModelAdapter(collectionHolder));
+ public TransformationListValueModelAdapter(CollectionValueModel<E1> collectionHolder) {
+ this(new CollectionListValueModelAdapter<E1>(collectionHolder));
}
// ********** ListValueModel implementation **********
- public ListIterator listIterator() {
+ public Iterator<E2> iterator() {
+ return this.listIterator();
+ }
+
+ public ListIterator<E2> listIterator() {
// try to prevent backdoor modification of the list
- return new ReadOnlyListIterator(this.transformedList);
+ return new ReadOnlyListIterator<E2>(this.transformedList);
}
- @Override
- public Object get(int index) {
+ public E2 get(int index) {
return this.transformedList.get(index);
}
- @Override
public int size() {
return this.transformedList.size();
}
- @Override
public Object[] toArray() {
return this.transformedList.toArray();
}
@@ -121,29 +124,29 @@ public class TransformationListValueModelAdapter
/**
* Transform the items associated with the specified event.
*/
- protected List transformItems(ListChangeEvent e) {
- return this.transformItems(e.items(), e.itemsSize());
+ protected List<E2> transformItems(ListChangeEvent e) {
+ return this.transformItems(this.items(e), e.itemsSize());
}
/**
* Transform the items in the specified list value model.
*/
- protected List transformItems(ListValueModel lvm) {
+ protected List<E2> transformItems(ListValueModel lvm) {
return this.transformItems(lvm.listIterator(), lvm.size());
}
/**
* Transform the replaced items associated with the specified event.
*/
- protected List transformReplacedItems(ListChangeEvent e) {
- return this.transformItems(e.replacedItems(), e.itemsSize());
+ protected List<E2> transformReplacedItems(ListChangeEvent e) {
+ return this.transformItems(this.replacedItems(e), e.itemsSize());
}
/**
* Transform the specified items.
*/
- protected List transformItems(ListIterator items, int size) {
- List result = new ArrayList(size);
+ protected List<E2> transformItems(ListIterator<E1> items, int size) {
+ List<E2> result = new ArrayList<E2>(size);
while (items.hasNext()) {
result.add(this.transformItem(items.next()));
}
@@ -153,14 +156,14 @@ public class TransformationListValueModelAdapter
/**
* Transform the specified item.
*/
- protected Object transformItem(Object item) {
+ protected E2 transformItem(E1 item) {
return this.transformer.transform(item);
}
/**
* Change the transformer and rebuild the collection.
*/
- public void setTransformer(Transformer transformer) {
+ public void setTransformer(Transformer<E1, E2> transformer) {
this.transformer = transformer;
this.rebuildTransformedList();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java
index 00e701fe3a..259274023a 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/TreeAspectAdapter.java
@@ -33,7 +33,7 @@ import org.eclipse.jpt.utility.internal.model.listener.TreeChangeListener;
* override this method only if returning an empty iterator when the
* subject is null is unacceptable
*/
-public abstract class TreeAspectAdapter<S extends Model>
+public abstract class TreeAspectAdapter<S extends Model, E>
extends AspectAdapter<S>
implements TreeValueModel
{
@@ -127,8 +127,8 @@ public abstract class TreeAspectAdapter<S extends Model>
/**
* Return the nodes of the subject's tree aspect.
*/
- public Iterator nodes() {
- return (this.subject == null) ? EmptyIterator.instance() : this.nodes_();
+ public Iterator<E> nodes() {
+ return (this.subject == null) ? EmptyIterator.<E>instance() : this.nodes_();
}
/**
@@ -136,7 +136,7 @@ public abstract class TreeAspectAdapter<S extends Model>
* At this point we can be sure that the subject is not null.
* @see #nodes()
*/
- protected Iterator nodes_() {
+ protected Iterator<E> nodes_() {
throw new UnsupportedOperationException();
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
index b2105a3d95..78d08ca2f1 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencePropertyValueModel.java
@@ -264,7 +264,7 @@ public class PreferencePropertyValueModel<P>
/**
* Return the preference's key.
*/
- public String getKey() {
+ public String key() {
return this.key;
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
index 5518beaff7..dd8b3ea4d7 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/prefs/PreferencesCollectionValueModel.java
@@ -30,13 +30,13 @@ import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
* CollectionValueModel of PreferencePropertyValueModels. It listens for
* "preference" changes and converts them into VALUE collection changes.
*/
-public class PreferencesCollectionValueModel
- extends AspectAdapter
- implements CollectionValueModel
+public class PreferencesCollectionValueModel<P>
+ extends AspectAdapter<Preferences>
+ implements CollectionValueModel<PreferencePropertyValueModel<P>>
{
/** Cache the current preferences, stored in models and keyed by name. */
- protected final HashMap<String, PreferencePropertyValueModel> preferences;
+ protected final HashMap<String, PreferencePropertyValueModel<P>> preferences;
/** A listener that listens to the preferences node for added or removed preferences. */
protected final PreferenceChangeListener preferenceChangeListener;
@@ -48,15 +48,15 @@ public class PreferencesCollectionValueModel
* Construct an adapter for the specified preferences node.
*/
public PreferencesCollectionValueModel(Preferences preferences) {
- this(new StaticPropertyValueModel(preferences));
+ this(new StaticPropertyValueModel<Preferences>(preferences));
}
/**
* Construct an adapter for the specified preferences node.
*/
- public PreferencesCollectionValueModel(PropertyValueModel preferencesHolder) {
+ public PreferencesCollectionValueModel(PropertyValueModel<Preferences> preferencesHolder) {
super(preferencesHolder);
- this.preferences = new HashMap<String, PreferencePropertyValueModel>();
+ this.preferences = new HashMap<String, PreferencePropertyValueModel<P>>();
this.preferenceChangeListener = this.buildPreferenceChangeListener();
}
@@ -85,7 +85,7 @@ public class PreferencesCollectionValueModel
/**
* Return an iterator on the preference models.
*/
- public synchronized Iterator<PreferencePropertyValueModel> iterator() {
+ public synchronized Iterator<PreferencePropertyValueModel<P>> iterator() {
return this.preferences.values().iterator();
}
@@ -123,17 +123,17 @@ public class PreferencesCollectionValueModel
@Override
protected void engageSubject_() {
- ((Preferences) this.subject).addPreferenceChangeListener(this.preferenceChangeListener);
- for (Iterator<PreferencePropertyValueModel> stream = this.preferenceModels(); stream.hasNext(); ) {
- PreferencePropertyValueModel preferenceModel = stream.next();
- this.preferences.put(preferenceModel.getKey(), preferenceModel);
+ this.subject.addPreferenceChangeListener(this.preferenceChangeListener);
+ for (Iterator<PreferencePropertyValueModel<P>> stream = this.preferenceModels(); stream.hasNext(); ) {
+ PreferencePropertyValueModel<P> preferenceModel = stream.next();
+ this.preferences.put(preferenceModel.key(), preferenceModel);
}
}
@Override
protected void disengageSubject_() {
try {
- ((Preferences) this.subject).removePreferenceChangeListener(this.preferenceChangeListener);
+ this.subject.removePreferenceChangeListener(this.preferenceChangeListener);
} catch (IllegalStateException ex) {
// for some odd reason, we are not allowed to remove a listener from a "dead"
// preferences node; so handle the exception that gets thrown here
@@ -160,16 +160,16 @@ public class PreferencesCollectionValueModel
* Return an iterator on the preference models.
* At this point we can be sure that the subject is not null.
*/
- protected Iterator<PreferencePropertyValueModel> preferenceModels() {
+ protected Iterator<PreferencePropertyValueModel<P>> preferenceModels() {
String[] keys;
try {
- keys = ((Preferences) this.subject).keys();
+ keys = this.subject.keys();
} catch (BackingStoreException ex) {
throw new RuntimeException(ex);
}
- return new TransformationIterator<String, PreferencePropertyValueModel>(new ArrayIterator<String>(keys)) {
+ return new TransformationIterator<String, PreferencePropertyValueModel<P>>(new ArrayIterator<String>(keys)) {
@Override
- protected PreferencePropertyValueModel transform(String key) {
+ protected PreferencePropertyValueModel<P> transform(String key) {
return PreferencesCollectionValueModel.this.buildPreferenceModel(key);
}
};
@@ -179,18 +179,18 @@ public class PreferencesCollectionValueModel
* Override this method to tweak the model used to wrap the
* specified preference (e.g. to customize the model's converter).
*/
- protected PreferencePropertyValueModel buildPreferenceModel(String key) {
- return new PreferencePropertyValueModel(this.subjectHolder, key);
+ protected PreferencePropertyValueModel<P> buildPreferenceModel(String key) {
+ return new PreferencePropertyValueModel<P>(this.subjectHolder, key);
}
protected synchronized void preferenceChanged(String key, String newValue) {
if (newValue == null) {
// a preference was removed
- PreferencePropertyValueModel preferenceModel = this.preferences.remove(key);
+ PreferencePropertyValueModel<P> preferenceModel = this.preferences.remove(key);
this.fireItemRemoved(VALUES, preferenceModel);
} else if ( ! this.preferences.containsKey(key)) {
// a preference was added
- PreferencePropertyValueModel preferenceModel = this.buildPreferenceModel(key);
+ PreferencePropertyValueModel<P> preferenceModel = this.buildPreferenceModel(key);
this.preferences.put(key, preferenceModel);
this.fireItemAdded(VALUES, preferenceModel);
} else {
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java
index 725ed6acc9..a1becbe95a 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/AbstractTreeModel.java
@@ -55,7 +55,7 @@ public abstract class AbstractTreeModel
* (There seems to be a pattern of making this type of method public;
* although it should probably be protected....)
*/
- public TreeModelListener[] getTreeModelListeners() {
+ public TreeModelListener[] treeModelListeners() {
return this.listenerList.getListeners(TreeModelListener.class);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java
index 43a3b06972..1b36a51b9a 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ColumnAdapter.java
@@ -22,28 +22,28 @@ public interface ColumnAdapter {
* Return the number of columns in the table.
* Typically this is static.
*/
- int getColumnCount();
+ int columnCount();
/**
* Return the name of the specified column.
*/
- String getColumnName(int index);
+ String columnName(int index);
/**
* Return the class of the specified column.
*/
- Class<?> getColumnClass(int index);
+ Class<?> columnClass(int index);
/**
* Return whether the specified column is editable.
* Typically this is the same for every row.
*/
- boolean isColumnEditable(int index);
+ boolean columnIsEditable(int index);
/**
* Return the cell models for the specified subject
* that corresponds to a single row in the table.
*/
- WritablePropertyValueModel[] cellModels(Object subject);
+ WritablePropertyValueModel<Object>[] cellModels(Object subject);
} \ No newline at end of file
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java
index 617f2b407e..2280de3219 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ComboBoxModelAdapter.java
@@ -64,7 +64,7 @@ public class ComboBoxModelAdapter
/**
* Constructor - the collection holder and selection holder are required;
*/
- public ComboBoxModelAdapter(CollectionValueModel collectionHolder, WritablePropertyValueModel<Object> selectionHolder) {
+ public ComboBoxModelAdapter(CollectionValueModel<?> collectionHolder, WritablePropertyValueModel<Object> selectionHolder) {
super(collectionHolder);
if (selectionHolder == null) {
throw new NullPointerException();
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
index eb71203d55..b8e21dbe73 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DateSpinnerModelAdapter.java
@@ -46,7 +46,7 @@ public class DateSpinnerModelAdapter
private final Date defaultValue;
/** A value model on the underlying date. */
- private final WritablePropertyValueModel dateHolder;
+ private final WritablePropertyValueModel<Object> dateHolder;
/** A listener that allows us to synchronize with changes made to the underlying date. */
private final PropertyChangeListener dateChangeListener;
@@ -58,14 +58,14 @@ public class DateSpinnerModelAdapter
* Constructor - the date holder is required.
* The default spinner value is the current date.
*/
- public DateSpinnerModelAdapter(WritablePropertyValueModel dateHolder) {
+ public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder) {
this(dateHolder, new Date());
}
/**
* Constructor - the date holder and default value are required.
*/
- public DateSpinnerModelAdapter(WritablePropertyValueModel dateHolder, Date defaultValue) {
+ public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder, Date defaultValue) {
this(dateHolder, null, null, Calendar.DAY_OF_MONTH, defaultValue);
}
@@ -73,14 +73,14 @@ public class DateSpinnerModelAdapter
* Constructor - the date holder is required.
* The default spinner value is the current date.
*/
- public DateSpinnerModelAdapter(WritablePropertyValueModel dateHolder, Comparable start, Comparable end, int calendarField) {
+ public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder, Comparable<?> start, Comparable<?> end, int calendarField) {
this(dateHolder, start, end, calendarField, new Date());
}
/**
* Constructor - the date holder is required.
*/
- public DateSpinnerModelAdapter(WritablePropertyValueModel dateHolder, Comparable start, Comparable end, int calendarField, Date defaultValue) {
+ public DateSpinnerModelAdapter(WritablePropertyValueModel<Object> dateHolder, Comparable<?> start, Comparable<?> end, int calendarField, Date defaultValue) {
super(dateHolder.value() == null ? defaultValue : (Date) dateHolder.value(), start, end, calendarField);
this.dateHolder = dateHolder;
this.dateChangeListener = this.buildDateChangeListener();
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java
index 5307abd1ad..13c1731cb6 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/DocumentAdapter.java
@@ -51,7 +51,7 @@ public class DocumentAdapter
protected final CombinedListener delegateListener;
/** A value model on the underlying model string. */
- protected final WritablePropertyValueModel stringHolder;
+ protected final WritablePropertyValueModel<String> stringHolder;
/** A listener that allows us to synchronize with changes made to the underlying model string. */
protected final PropertyChangeListener stringListener;
@@ -66,7 +66,7 @@ public class DocumentAdapter
* Constructor - the string holder is required.
* Wrap the specified document.
*/
- public DocumentAdapter(WritablePropertyValueModel stringHolder, Document delegate) {
+ public DocumentAdapter(WritablePropertyValueModel<String> stringHolder, Document delegate) {
super();
if (stringHolder == null || delegate == null) {
throw new NullPointerException();
@@ -83,7 +83,7 @@ public class DocumentAdapter
* Constructor - the string holder is required.
* Wrap a plain document.
*/
- public DocumentAdapter(WritablePropertyValueModel stringHolder) {
+ public DocumentAdapter(WritablePropertyValueModel<String> stringHolder) {
this(stringHolder, new PlainDocument());
}
@@ -220,11 +220,11 @@ public class DocumentAdapter
// ********** queries **********
- public DocumentListener[] getDocumentListeners() {
+ public DocumentListener[] documentListeners() {
return this.listenerList.getListeners(DocumentListener.class);
}
- public UndoableEditListener[] getUndoableEditListeners() {
+ public UndoableEditListener[] undoableEditListeners() {
return this.listenerList.getListeners(UndoableEditListener.class);
}
@@ -258,7 +258,7 @@ public class DocumentAdapter
protected void engageStringHolder() {
this.stringHolder.addPropertyChangeListener(PropertyValueModel.VALUE, this.stringListener);
- this.synchronizeDelegate((String) this.stringHolder.value());
+ this.synchronizeDelegate(this.stringHolder.value());
}
protected void disengageStringHolder() {
@@ -269,7 +269,7 @@ public class DocumentAdapter
// no need to lazy-initialize the event;
// we wouldn't get here if we did not have listeners...
DocumentEvent ee = new InternalDocumentEvent(this, e);
- DocumentListener[] listeners = this.getDocumentListeners();
+ DocumentListener[] listeners = this.documentListeners();
for (int i = listeners.length; i-- > 0; ) {
listeners[i].changedUpdate(ee);
}
@@ -279,7 +279,7 @@ public class DocumentAdapter
// no need to lazy-initialize the event;
// we wouldn't get here if we did not have listeners...
DocumentEvent ee = new InternalDocumentEvent(this, e);
- DocumentListener[] listeners = this.getDocumentListeners();
+ DocumentListener[] listeners = this.documentListeners();
for (int i = listeners.length; i-- > 0; ) {
listeners[i].insertUpdate(ee);
}
@@ -289,7 +289,7 @@ public class DocumentAdapter
// no need to lazy-initialize the event;
// we wouldn't get here if we did not have listeners...
DocumentEvent ee = new InternalDocumentEvent(this, e);
- DocumentListener[] listeners = this.getDocumentListeners();
+ DocumentListener[] listeners = this.documentListeners();
for (int i = listeners.length; i-- > 0; ) {
listeners[i].removeUpdate(ee);
}
@@ -299,7 +299,7 @@ public class DocumentAdapter
// no need to lazy-initialize the event;
// we wouldn't get here if we did not have listeners...
UndoableEditEvent ee = new UndoableEditEvent(this, e.getEdit());
- UndoableEditListener[] listeners = this.getUndoableEditListeners();
+ UndoableEditListener[] listeners = this.undoableEditListeners();
for (int i = listeners.length; i-- > 0; ) {
listeners[i].undoableEditHappened(ee);
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java
index b83d5ca3dd..f2a4a51360 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListModelAdapter.java
@@ -67,7 +67,7 @@ public class ListModelAdapter
/**
* Constructor - the collection holder is required.
*/
- public ListModelAdapter(CollectionValueModel collectionHolder) {
+ public ListModelAdapter(CollectionValueModel<?> collectionHolder) {
this();
this.setModel(collectionHolder);
}
@@ -147,7 +147,7 @@ public class ListModelAdapter
/**
* Return the underlying list model.
*/
- public ListValueModel getModel() {
+ public ListValueModel model() {
return this.listHolder;
}
@@ -172,7 +172,7 @@ public class ListModelAdapter
/**
* Set the underlying collection model.
*/
- public void setModel(CollectionValueModel collectionHolder) {
+ public void setModel(CollectionValueModel<?> collectionHolder) {
this.setModel(new CollectionListValueModelAdapter(collectionHolder));
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
index 10a8d73b69..9c7ae8bf6e 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ListSpinnerModelAdapter.java
@@ -51,7 +51,7 @@ public class ListSpinnerModelAdapter
private final Object defaultValue;
/** A value model on the underlying value. */
- private final WritablePropertyValueModel valueHolder;
+ private final WritablePropertyValueModel<Object> valueHolder;
/** A listener that allows us to synchronize with changes made to the underlying value. */
private final PropertyChangeListener valueChangeListener;
@@ -63,14 +63,14 @@ public class ListSpinnerModelAdapter
* Constructor - the value holder is required.
* Use the model value itself as the default spinner value.
*/
- public ListSpinnerModelAdapter(WritablePropertyValueModel valueHolder) {
+ public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder) {
this(valueHolder, valueHolder.value());
}
/**
* Constructor - the value holder is required.
*/
- public ListSpinnerModelAdapter(WritablePropertyValueModel valueHolder, Object defaultValue) {
+ public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object defaultValue) {
this(valueHolder, new Object[] {defaultValue}, defaultValue);
}
@@ -78,14 +78,14 @@ public class ListSpinnerModelAdapter
* Constructor - the value holder is required.
* Use the first item in the list of values as the default spinner value.
*/
- public ListSpinnerModelAdapter(WritablePropertyValueModel valueHolder, Object[] values) {
+ public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object[] values) {
this(valueHolder, values, values[0]);
}
/**
* Constructor - the value holder is required.
*/
- public ListSpinnerModelAdapter(WritablePropertyValueModel valueHolder, Object[] values, Object defaultValue) {
+ public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object[] values, Object defaultValue) {
this(valueHolder, Arrays.asList(values), defaultValue);
}
@@ -93,14 +93,14 @@ public class ListSpinnerModelAdapter
* Constructor - the value holder is required.
* Use the first item in the list of values as the default spinner value.
*/
- public ListSpinnerModelAdapter(WritablePropertyValueModel valueHolder, List values) {
+ public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, List<Object> values) {
this(valueHolder, values, values.get(0));
}
/**
* Constructor - the value holder is required.
*/
- public ListSpinnerModelAdapter(WritablePropertyValueModel valueHolder, List values, Object defaultValue) {
+ public ListSpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, List<Object> values, Object defaultValue) {
super(values);
this.valueHolder = valueHolder;
this.valueChangeListener = this.buildValueChangeListener();
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
index 388358eb61..2760899689 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/NumberSpinnerModelAdapter.java
@@ -43,7 +43,7 @@ public class NumberSpinnerModelAdapter
private final Number defaultValue;
/** A value model on the underlying number. */
- private final WritablePropertyValueModel numberHolder;
+ private final WritablePropertyValueModel<Number> numberHolder;
/**
* A listener that allows us to synchronize with
@@ -59,7 +59,7 @@ public class NumberSpinnerModelAdapter
* The default spinner value is zero.
* The step size is one.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder) {
this(numberHolder, 0);
}
@@ -67,7 +67,7 @@ public class NumberSpinnerModelAdapter
* Constructor - the number holder is required.
* The step size is one.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder, int defaultValue) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, int defaultValue) {
this(numberHolder, null, null, new Integer(1), new Integer(defaultValue));
}
@@ -75,14 +75,14 @@ public class NumberSpinnerModelAdapter
* Constructor - the number holder is required.
* Use the minimum value as the default spinner value.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder, int minimum, int maximum, int stepSize) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, int minimum, int maximum, int stepSize) {
this(numberHolder, minimum, maximum, stepSize, minimum);
}
/**
* Constructor - the number holder is required.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder, int minimum, int maximum, int stepSize, int defaultValue) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, int minimum, int maximum, int stepSize, int defaultValue) {
this(numberHolder, new Integer(minimum), new Integer(maximum), new Integer(stepSize), new Integer(defaultValue));
}
@@ -90,21 +90,21 @@ public class NumberSpinnerModelAdapter
* Constructor - the number holder is required.
* Use the minimum value as the default spinner value.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder, double value, double minimum, double maximum, double stepSize) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, double value, double minimum, double maximum, double stepSize) {
this(numberHolder, value, minimum, maximum, stepSize, minimum);
}
/**
* Constructor - the number holder is required.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder, double value, double minimum, double maximum, double stepSize, double defaultValue) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, double value, double minimum, double maximum, double stepSize, double defaultValue) {
this(numberHolder, new Double(minimum), new Double(maximum), new Double(stepSize), new Double(defaultValue));
}
/**
* Constructor - the number holder is required.
*/
- public NumberSpinnerModelAdapter(WritablePropertyValueModel numberHolder, Comparable minimum, Comparable maximum, Number stepSize, Number defaultValue) {
+ public NumberSpinnerModelAdapter(WritablePropertyValueModel<Number> numberHolder, Comparable<?> minimum, Comparable<?> maximum, Number stepSize, Number defaultValue) {
super(numberHolder.value() == null ? defaultValue : (Number) numberHolder.value(), minimum, maximum, stepSize);
this.numberHolder = numberHolder;
this.numberChangeListener = this.buildNumberChangeListener();
@@ -158,7 +158,7 @@ public class NumberSpinnerModelAdapter
@Override
public void setValue(Object value) {
super.setValue(value);
- this.numberHolder.setValue(value);
+ this.numberHolder.setValue((Number) value);
}
/**
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java
index c3d912017a..6b8e063f52 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/ObjectListSelectionModel.java
@@ -111,11 +111,11 @@ public class ObjectListSelectionModel
/**
* Return the list model referenced by the list selection model.
*/
- public ListModel getListModel() {
+ public ListModel listModel() {
return this.listModel;
}
- public int getSelectedValuesSize() {
+ public int selectedValuesSize() {
int min = this.getMinSelectionIndex();
int max = this.getMaxSelectionIndex();
@@ -124,7 +124,7 @@ public class ObjectListSelectionModel
}
int n = 0;
- int count = this.getListModel().getSize();
+ int count = this.listModel().getSize();
for (int i = min; i <= max; i++) {
if (this.isSelectedIndex(i) && (i < count)) {
n++;
@@ -137,21 +137,21 @@ public class ObjectListSelectionModel
* Return the first selected value.
* Return null if the selection is empty.
*/
- public Object getSelectedValue() {
+ public Object selectedValue() {
int index = this.getMinSelectionIndex();
if (index == -1) {
return null;
}
- if (this.getListModel().getSize() <= index) {
+ if (this.listModel().getSize() <= index) {
return null;
}
- return this.getListModel().getElementAt(index);
+ return this.listModel().getElementAt(index);
}
/**
* Return an array of the selected values.
*/
- public Object[] getSelectedValues() {
+ public Object[] selectedValues() {
int min = this.getMinSelectionIndex();
int max = this.getMaxSelectionIndex();
@@ -162,10 +162,10 @@ public class ObjectListSelectionModel
int maxSize = (max - min) + 1;
Object[] temp = new Object[maxSize];
int n = 0;
- int count = this.getListModel().getSize();
+ int count = this.listModel().getSize();
for (int i = min; i <= max; i++) {
if (this.isSelectedIndex(i) && (i < count)) {
- temp[n++] = this.getListModel().getElementAt(i);
+ temp[n++] = this.listModel().getElementAt(i);
}
}
if (n == maxSize) {
@@ -181,7 +181,7 @@ public class ObjectListSelectionModel
/**
* Return an array of the selected indices in ordered.
*/
- public int[] getSelectedIndices() {
+ public int[] selectedIndices() {
int min = this.getMinSelectionIndex();
int max = this.getMaxSelectionIndex();
@@ -192,7 +192,7 @@ public class ObjectListSelectionModel
int maxSize = (max - min) + 1;
int[] temp = new int[maxSize];
int n = 0;
- int count = this.getListModel().getSize();
+ int count = this.listModel().getSize();
for (int i = min; i <= max; i++) {
if (this.isSelectedIndex(i) && (i < count)) {
temp[n++] = i;
@@ -221,7 +221,7 @@ public class ObjectListSelectionModel
* Set the current set of selected objects to the specified objects.
* @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
*/
- public void setSelectedValues(Iterator objects) {
+ public void setSelectedValues(Iterator<?> objects) {
this.setValueIsAdjusting(true);
this.clearSelection();
this.addSelectedValuesInternal(objects);
@@ -232,7 +232,7 @@ public class ObjectListSelectionModel
* Set the current set of selected objects to the specified objects.
* @see javax.swing.ListSelectionModel#setSelectionInterval(int, int)
*/
- public void setSelectedValues(Collection objects) {
+ public void setSelectedValues(Collection<?> objects) {
this.setSelectedValues(objects.iterator());
}
@@ -256,7 +256,7 @@ public class ObjectListSelectionModel
* Add the specified objects to the current set of selected objects.
* @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
*/
- public void addSelectedValues(Iterator objects) {
+ public void addSelectedValues(Iterator<?> objects) {
this.setValueIsAdjusting(true);
this.addSelectedValuesInternal(objects);
this.setValueIsAdjusting(false);
@@ -266,7 +266,7 @@ public class ObjectListSelectionModel
* Add the specified objects to the current set of selected objects.
* @see javax.swing.ListSelectionModel#addSelectionInterval(int, int)
*/
- public void addSelectedValues(Collection objects) {
+ public void addSelectedValues(Collection<?> objects) {
this.addSelectedValues(objects.iterator());
}
@@ -290,9 +290,9 @@ public class ObjectListSelectionModel
* Remove the specified objects from the current set of selected objects.
* @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
*/
- public void removeSelectedValues(Iterator objects) {
+ public void removeSelectedValues(Iterator<?> objects) {
this.setValueIsAdjusting(true);
- ListModel lm = this.getListModel();
+ ListModel lm = this.listModel();
int lmSize = lm.getSize();
while (objects.hasNext()) {
int index = this.indexOf(objects.next(), lm, lmSize);
@@ -305,7 +305,7 @@ public class ObjectListSelectionModel
* Remove the specified objects from the current set of selected objects.
* @see javax.swing.ListSelectionModel#removeSelectionInterval(int, int)
*/
- public void removeSelectedValues(Collection objects) {
+ public void removeSelectedValues(Collection<?> objects) {
this.removeSelectedValues(objects.iterator());
}
@@ -326,7 +326,7 @@ public class ObjectListSelectionModel
if (index == -1) {
return null;
}
- return this.getListModel().getElementAt(index);
+ return this.listModel().getElementAt(index);
}
/**
@@ -345,7 +345,7 @@ public class ObjectListSelectionModel
if (index == -1) {
return null;
}
- return this.getListModel().getElementAt(index);
+ return this.listModel().getElementAt(index);
}
/**
@@ -364,7 +364,7 @@ public class ObjectListSelectionModel
if (index == -1) {
return null;
}
- return this.getListModel().getElementAt(index);
+ return this.listModel().getElementAt(index);
}
/**
@@ -376,7 +376,7 @@ public class ObjectListSelectionModel
if (index == -1) {
return null;
}
- return this.getListModel().getElementAt(index);
+ return this.listModel().getElementAt(index);
}
/**
@@ -390,8 +390,8 @@ public class ObjectListSelectionModel
* Add the specified objects to the current set of selected objects,
* without wrapping the actions in "adjusting" events.
*/
- private void addSelectedValuesInternal(Iterator objects) {
- ListModel lm = this.getListModel();
+ private void addSelectedValuesInternal(Iterator<?> objects) {
+ ListModel lm = this.listModel();
int listModelSize = lm.getSize();
while (objects.hasNext()) {
int index = this.indexOf(objects.next(), lm, listModelSize);
@@ -404,7 +404,7 @@ public class ObjectListSelectionModel
* Return -1 if the object is not in the list model.
*/
private int indexOf(Object object) {
- ListModel lm = this.getListModel();
+ ListModel lm = this.listModel();
return this.indexOf(object, lm, lm.getSize());
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java
index 9fe36090ab..14e783cb05 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/RadioButtonModelAdapter.java
@@ -35,7 +35,7 @@ public class RadioButtonModelAdapter
/**
* Constructor - the value holder is required.
*/
- public RadioButtonModelAdapter(WritablePropertyValueModel valueHolder, Object buttonValue, boolean defaultValue) {
+ public RadioButtonModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object buttonValue, boolean defaultValue) {
super(buildBooleanHolder(valueHolder, buttonValue), defaultValue);
}
@@ -43,7 +43,7 @@ public class RadioButtonModelAdapter
* Constructor - the value holder is required.
* The default value will be false.
*/
- public RadioButtonModelAdapter(WritablePropertyValueModel valueHolder, Object buttonValue) {
+ public RadioButtonModelAdapter(WritablePropertyValueModel<Object> valueHolder, Object buttonValue) {
super(buildBooleanHolder(valueHolder, buttonValue));
}
@@ -59,9 +59,9 @@ public class RadioButtonModelAdapter
* value is set to true, the wrapper will set the value holder's
* value to the button value.
*/
- public static WritablePropertyValueModel buildBooleanHolder(WritablePropertyValueModel valueHolder, Object buttonValue) {
- WritablePropertyValueModel filteringPVM = new FilteringWritablePropertyValueModel(valueHolder, new RadioButtonFilter(buttonValue));
- return new TransformationWritablePropertyValueModel(filteringPVM, new RadioButtonTransformer(buttonValue));
+ public static WritablePropertyValueModel<Boolean> buildBooleanHolder(WritablePropertyValueModel<Object> valueHolder, Object buttonValue) {
+ WritablePropertyValueModel<Object> filteringPVM = new FilteringWritablePropertyValueModel<Object>(valueHolder, new RadioButtonFilter(buttonValue));
+ return new TransformationWritablePropertyValueModel<Object, Boolean>(filteringPVM, new RadioButtonTransformer(buttonValue));
}
@@ -91,7 +91,7 @@ public class RadioButtonModelAdapter
* This filter will only pass through a new value to the wrapped
* value holder when it matches the configured button value.
*/
- public static class RadioButtonFilter implements BidiFilter {
+ public static class RadioButtonFilter implements BidiFilter<Object> {
private Object buttonValue;
public RadioButtonFilter(Object buttonValue) {
@@ -120,7 +120,7 @@ public class RadioButtonModelAdapter
* This transformer will convert the wrapped value to Boolean.TRUE
* when it matches the configured button value.
*/
- public static class RadioButtonTransformer implements BidiTransformer {
+ public static class RadioButtonTransformer implements BidiTransformer<Object, Boolean> {
private Object buttonValue;
public RadioButtonTransformer(Object buttonValue) {
@@ -134,7 +134,7 @@ public class RadioButtonModelAdapter
* but if it is null simply pass it through because it will cause the
* button model's default value to be used
*/
- public Object transform(Object value) {
+ public Boolean transform(Object value) {
return (value == null) ? null : Boolean.valueOf(value == this.buttonValue);
}
@@ -142,8 +142,8 @@ public class RadioButtonModelAdapter
* if the new value is true, pass through the our button value;
* otherwise pass through null
*/
- public Object reverseTransform(Object value) {
- return (((Boolean) value).booleanValue()) ? this.buttonValue : null;
+ public Object reverseTransform(Boolean value) {
+ return (value.booleanValue()) ? this.buttonValue : null;
}
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java
index 86235fb70b..bc296d51b5 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/SpinnerModelAdapter.java
@@ -46,7 +46,7 @@ public class SpinnerModelAdapter
protected final ChangeListener delegateListener;
/** A value model on the underlying value. */
- protected final WritablePropertyValueModel valueHolder;
+ protected final WritablePropertyValueModel<Object> valueHolder;
/** A listener that allows us to synchronize with changes made to the underlying value. */
protected final PropertyChangeListener valueListener;
@@ -57,7 +57,7 @@ public class SpinnerModelAdapter
/**
* Constructor - the value holder and delegate are required.
*/
- public SpinnerModelAdapter(WritablePropertyValueModel valueHolder, SpinnerModel delegate) {
+ public SpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder, SpinnerModel delegate) {
super();
if (valueHolder == null || delegate == null) {
throw new NullPointerException();
@@ -74,7 +74,7 @@ public class SpinnerModelAdapter
* Constructor - the value holder is required.
* This will wrap a simple number spinner model.
*/
- public SpinnerModelAdapter(WritablePropertyValueModel valueHolder) {
+ public SpinnerModelAdapter(WritablePropertyValueModel<Object> valueHolder) {
this(valueHolder, new SpinnerNumberModel());
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java
index ae9738184b..c7daa2b432 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/model/value/swing/TableModelAdapter.java
@@ -59,7 +59,7 @@ import org.eclipse.jpt.utility.internal.model.value.PropertyValueModel;
* - 1 cell listener per row
* - 1 cell listener per cell
*/
-public class TableModelAdapter
+public class TableModelAdapter<E>
extends AbstractTableModel
{
/**
@@ -73,7 +73,7 @@ public class TableModelAdapter
* each row is an array of cell models
*/
// declare as ArrayList so we can use #ensureCapacity(int)
- private final ArrayList<WritablePropertyValueModel[]> rows;
+ private final ArrayList<WritablePropertyValueModel<Object>[]> rows;
/**
* client-supplied adapter that provides with the various column
@@ -102,7 +102,7 @@ public class TableModelAdapter
this.listHolder = listHolder;
this.columnAdapter = columnAdapter;
this.listChangeListener = this.buildListChangeListener();
- this.rows = new ArrayList<WritablePropertyValueModel[]>();
+ this.rows = new ArrayList<WritablePropertyValueModel<Object>[]>();
this.cellListener = this.buildCellListener();
}
@@ -110,8 +110,8 @@ public class TableModelAdapter
* Construct a table model adapter for the specified objects
* and adapter.
*/
- public TableModelAdapter(CollectionValueModel collectionHolder, ColumnAdapter columnAdapter) {
- this(new CollectionListValueModelAdapter(collectionHolder), columnAdapter);
+ public TableModelAdapter(CollectionValueModel<E> collectionHolder, ColumnAdapter columnAdapter) {
+ this(new CollectionListValueModelAdapter<E>(collectionHolder), columnAdapter);
}
@@ -124,13 +124,13 @@ public class TableModelAdapter
protected ListChangeListener buildListChangeListener_() {
return new ListChangeListener() {
public void itemsAdded(ListChangeEvent e) {
- TableModelAdapter.this.addRows(e.index(), e.itemsSize(), e.items());
+ TableModelAdapter.this.addRows(e.index(), e.itemsSize(), this.items(e));
}
public void itemsRemoved(ListChangeEvent e) {
TableModelAdapter.this.removeRows(e.index(), e.itemsSize());
}
public void itemsReplaced(ListChangeEvent e) {
- TableModelAdapter.this.replaceRows(e.index(), e.items());
+ TableModelAdapter.this.replaceRows(e.index(), this.items(e));
}
public void itemsMoved(ListChangeEvent e) {
TableModelAdapter.this.moveRows(e.targetIndex(), e.sourceIndex(), e.moveLength());
@@ -141,6 +141,13 @@ public class TableModelAdapter
public void listChanged(ListChangeEvent e) {
TableModelAdapter.this.rebuildTable();
}
+ /**
+ * minimize scope of suppressed warnings
+ */
+ @SuppressWarnings("unchecked")
+ protected Iterator<Object> items(ListChangeEvent event) {
+ return (Iterator<Object>) event.items();
+ }
@Override
public String toString() {
return "list listener";
@@ -148,14 +155,16 @@ public class TableModelAdapter
};
}
+
protected PropertyChangeListener buildCellListener() {
return new AWTPropertyChangeListenerWrapper(this.buildCellListener_());
}
protected PropertyChangeListener buildCellListener_() {
return new PropertyChangeListener() {
+ @SuppressWarnings("unchecked")
public void propertyChanged(PropertyChangeEvent evt) {
- TableModelAdapter.this.cellChanged((WritablePropertyValueModel) evt.getSource());
+ TableModelAdapter.this.cellChanged((WritablePropertyValueModel<Object>) evt.getSource());
}
@Override
public String toString() {
@@ -168,7 +177,7 @@ public class TableModelAdapter
// ********** TableModel implementation **********
public int getColumnCount() {
- return this.columnAdapter.getColumnCount();
+ return this.columnAdapter.columnCount();
}
public int getRowCount() {
@@ -177,27 +186,27 @@ public class TableModelAdapter
@Override
public String getColumnName(int column) {
- return this.columnAdapter.getColumnName(column);
+ return this.columnAdapter.columnName(column);
}
@Override
- public Class getColumnClass(int columnIndex) {
- return this.columnAdapter.getColumnClass(columnIndex);
+ public Class<?> getColumnClass(int columnIndex) {
+ return this.columnAdapter.columnClass(columnIndex);
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
- return this.columnAdapter.isColumnEditable(columnIndex);
+ return this.columnAdapter.columnIsEditable(columnIndex);
}
public Object getValueAt(int rowIndex, int columnIndex) {
- WritablePropertyValueModel[] row = this.rows.get(rowIndex);
+ WritablePropertyValueModel<Object>[] row = this.rows.get(rowIndex);
return row[columnIndex].value();
}
@Override
public void setValueAt(Object value, int rowIndex, int columnIndex) {
- WritablePropertyValueModel[] row = this.rows.get(rowIndex);
+ WritablePropertyValueModel<Object>[] row = this.rows.get(rowIndex);
row[columnIndex].setValue(value);
}
@@ -229,7 +238,7 @@ public class TableModelAdapter
/**
* Return the underlying list model.
*/
- public ListValueModel getModel() {
+ public ListValueModel model() {
return this.listHolder;
}
@@ -254,8 +263,8 @@ public class TableModelAdapter
/**
* Set the underlying collection model.
*/
- public void setModel(CollectionValueModel collectionHolder) {
- this.setModel(new CollectionListValueModelAdapter(collectionHolder));
+ public void setModel(CollectionValueModel<E> collectionHolder) {
+ this.setModel(new CollectionListValueModelAdapter<E>(collectionHolder));
}
@@ -292,8 +301,8 @@ public class TableModelAdapter
*/
private void engageAllCells() {
this.rows.ensureCapacity(this.listHolder.size());
- for (Iterator stream = this.listHolder.iterator(); stream.hasNext(); ) {
- WritablePropertyValueModel[] row = this.columnAdapter.cellModels(stream.next());
+ for (Iterator<E> stream = this.listHolder.iterator(); stream.hasNext(); ) {
+ WritablePropertyValueModel<Object>[] row = this.columnAdapter.cellModels(stream.next());
this.engageRow(row);
this.rows.add(row);
}
@@ -302,7 +311,7 @@ public class TableModelAdapter
/**
* Listen to the cells in the specified row.
*/
- private void engageRow(WritablePropertyValueModel[] row) {
+ private void engageRow(WritablePropertyValueModel<Object>[] row) {
for (int i = row.length; i-- > 0; ) {
row[i].addPropertyChangeListener(PropertyValueModel.VALUE, this.cellListener);
}
@@ -317,13 +326,13 @@ public class TableModelAdapter
}
private void disengageAllCells() {
- for (WritablePropertyValueModel[] row : this.rows) {
+ for (WritablePropertyValueModel<Object>[] row : this.rows) {
this.disengageRow(row);
}
this.rows.clear();
}
- private void disengageRow(WritablePropertyValueModel[] row) {
+ private void disengageRow(WritablePropertyValueModel<Object>[] row) {
for (int i = row.length; i-- > 0; ) {
row[i].removePropertyChangeListener(PropertyValueModel.VALUE, this.cellListener);
}
@@ -332,9 +341,9 @@ public class TableModelAdapter
/**
* brute-force search for the cell(s) that changed...
*/
- void cellChanged(WritablePropertyValueModel cellHolder) {
+ void cellChanged(WritablePropertyValueModel<Object> cellHolder) {
for (int i = this.rows.size(); i-- > 0; ) {
- WritablePropertyValueModel[] row = this.rows.get(i);
+ WritablePropertyValueModel<Object>[] row = this.rows.get(i);
for (int j = row.length; j-- > 0; ) {
if (row[j] == cellHolder) {
this.fireTableCellUpdated(i, j);
@@ -346,10 +355,10 @@ public class TableModelAdapter
/**
* convert the items to rows
*/
- void addRows(int index, int size, Iterator items) {
- List<WritablePropertyValueModel[]> newRows = new ArrayList<WritablePropertyValueModel[]>(size);
+ void addRows(int index, int size, Iterator<Object> items) {
+ List<WritablePropertyValueModel<Object>[]> newRows = new ArrayList<WritablePropertyValueModel<Object>[]>(size);
while (items.hasNext()) {
- WritablePropertyValueModel[] row = this.columnAdapter.cellModels(items.next());
+ WritablePropertyValueModel<Object>[] row = this.columnAdapter.cellModels(items.next());
this.engageRow(row);
newRows.add(row);
}
@@ -364,10 +373,10 @@ public class TableModelAdapter
this.fireTableRowsDeleted(index, index + size - 1);
}
- void replaceRows(int index, Iterator items) {
+ void replaceRows(int index, Iterator<Object> items) {
int i = index;
while (items.hasNext()) {
- WritablePropertyValueModel[] row = this.rows.get(i);
+ WritablePropertyValueModel<Object>[] row = this.rows.get(i);
this.disengageRow(row);
row = this.columnAdapter.cellModels(items.next());
this.engageRow(row);
@@ -378,7 +387,7 @@ public class TableModelAdapter
}
void moveRows(int targetIndex, int sourceIndex, int length) {
- ArrayList<WritablePropertyValueModel[]> temp = new ArrayList<WritablePropertyValueModel[]>(length);
+ ArrayList<WritablePropertyValueModel<Object>[]> temp = new ArrayList<WritablePropertyValueModel<Object>[]>(length);
for (int i = 0; i < length; i++) {
temp.add(this.rows.remove(sourceIndex));
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java
index e5a1d39523..eca0a3f3cd 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListBrowser.java
@@ -20,10 +20,10 @@ import javax.swing.ListModel;
* is passed a FilteringListPanel to assist the user in making
* a selection.
*/
-public class FilteringListBrowser
+public class FilteringListBrowser<T>
implements ListChooser.ListBrowser
{
- private FilteringListPanel panel;
+ private FilteringListPanel<T> panel;
/**
* Default constructor.
@@ -33,8 +33,8 @@ public class FilteringListBrowser
this.panel = this.buildPanel();
}
- protected FilteringListPanel buildPanel() {
- return new LocalFilteringListPanel();
+ protected FilteringListPanel<T> buildPanel() {
+ return new LocalFilteringListPanel<T>();
}
/**
@@ -57,16 +57,16 @@ public class FilteringListBrowser
);
if (option == JOptionPane.OK_OPTION) {
- chooser.getModel().setSelectedItem(this.panel.getSelection());
+ chooser.getModel().setSelectedItem(this.panel.selection());
}
// clear the text field so the list box is re-filtered
- this.panel.getTextField().setText("");
+ this.panel.textField().setText("");
}
protected void initializeCellRenderer(JComboBox comboBox) {
// default behavior should be to use the cell renderer from the combobox.
- this.panel.getListBox().setCellRenderer(comboBox.getRenderer());
+ this.panel.listBox().setCellRenderer(comboBox.getRenderer());
}
/**
@@ -118,10 +118,11 @@ public class FilteringListBrowser
// ********** custom panel **********
- protected class LocalFilteringListPanel extends FilteringListPanel {
-
+ protected static class LocalFilteringListPanel<S> extends FilteringListPanel<S> {
+ protected static final Object[] EMPTY_ARRAY = new Object[0];
+
protected LocalFilteringListPanel() {
- super(new Object[0], null);
+ super(EMPTY_ARRAY, null);
}
/**
@@ -129,9 +130,11 @@ public class FilteringListBrowser
* will try open wide enough to disable the horizontal scroll bar;
* and it looks a bit clumsy.
*/
+ @Override
protected String prototypeCellValue() {
return null;
}
}
+
}
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java
index bb36dfbef5..ed5572ca8d 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/FilteringListPanel.java
@@ -65,7 +65,7 @@ import org.eclipse.jpt.utility.internal.StringMatcher;
* dialog that directs the user's behavior (as opposed to a "normal"
* window).
*/
-public class FilteringListPanel extends JPanel {
+public class FilteringListPanel<T> extends JPanel {
/**
* The complete list of available choices
@@ -78,7 +78,7 @@ public class FilteringListPanel extends JPanel {
* to strings so they can be run through the matcher
* and displayed in the text field.
*/
- StringConverter stringConverter;
+ StringConverter<T> stringConverter;
/** The text field. */
private JTextField textField;
@@ -120,7 +120,7 @@ public class FilteringListPanel extends JPanel {
* the objects).
*/
public FilteringListPanel(Object[] completeList, Object initialSelection) {
- this(completeList, initialSelection, StringConverter.Default.instance());
+ this(completeList, initialSelection, StringConverter.Default.<T>instance());
}
/**
@@ -128,7 +128,7 @@ public class FilteringListPanel extends JPanel {
* and initial selection. Use the specified string converter to convert the
* choices and selection to strings.
*/
- public FilteringListPanel(Object[] completeList, Object initialSelection, StringConverter stringConverter) {
+ public FilteringListPanel(Object[] completeList, Object initialSelection, StringConverter<T> stringConverter) {
super(new BorderLayout());
this.completeList = completeList;
this.stringConverter = stringConverter;
@@ -140,7 +140,7 @@ public class FilteringListPanel extends JPanel {
private void initialize(Object initialSelection) {
this.maxListSize = this.defaultMaxListSize();
- this.buffer = new Object[this.max()];
+ this.buffer = this.buildBuffer();
this.textFieldListener = this.buildTextFieldListener();
@@ -149,6 +149,10 @@ public class FilteringListPanel extends JPanel {
this.initializeLayout(initialSelection);
}
+ private Object[] buildBuffer() {
+ return new Object[this.max()];
+ }
+
/**
* Return the current max number of entries allowed in the list box.
*/
@@ -186,7 +190,7 @@ public class FilteringListPanel extends JPanel {
}
private StringMatcher buildStringMatcher() {
- return new SimpleStringMatcher();
+ return new SimpleStringMatcher<T>();
}
private void initializeLayout(Object initialSelection) {
@@ -234,7 +238,7 @@ public class FilteringListPanel extends JPanel {
// ********** public API **********
- public Object getSelection() {
+ public Object selection() {
return this.listBox.getSelectedValue();
}
@@ -242,7 +246,7 @@ public class FilteringListPanel extends JPanel {
this.listBox.setSelectedValue(selection, true);
}
- public Object[] getCompleteList() {
+ public Object[] completeList() {
return this.completeList;
}
@@ -253,33 +257,33 @@ public class FilteringListPanel extends JPanel {
public void setCompleteList(Object[] completeList) {
this.completeList = completeList;
if (this.buffer.length < this.max()) {
- // the buffer will never shrink - might want to re-consider... -bjv
- this.buffer = new Object[this.max()];
+ // the buffer will never shrink - might want to re-consider... ~bjv
+ this.buffer = this.buildBuffer();
}
this.filterList();
}
- public int getMaxListSize() {
+ public int maxListSize() {
return this.maxListSize;
}
public void setMaxListSize(int maxListSize) {
this.maxListSize = maxListSize;
if (this.buffer.length < this.max()) {
- // the buffer will never shrink - might want to re-consider... -bjv
- this.buffer = new Object[this.max()];
+ // the buffer will never shrink - might want to re-consider... ~bjv
+ this.buffer = this.buildBuffer();
}
this.filterList();
}
- public StringConverter getStringConverter() {
+ public StringConverter<T> stringConverter() {
return this.stringConverter;
}
/**
* apply the new filter to the list
*/
- public void setStringConverter(StringConverter stringConverter) {
+ public void setStringConverter(StringConverter<T> stringConverter) {
this.stringConverter = stringConverter;
this.filterList();
}
@@ -288,14 +292,14 @@ public class FilteringListPanel extends JPanel {
* allow client code to access the text field
* (so we can set the focus)
*/
- public JTextField getTextField() {
+ public JTextField textField() {
return this.textField;
}
/**
* allow client code to access the text field label
*/
- public JLabel getTextFieldLabel() {
+ public JLabel textFieldLabel() {
return this.textFieldLabel;
}
@@ -310,7 +314,7 @@ public class FilteringListPanel extends JPanel {
* allow client code to access the list box
* (so we can add mouse listeners for double-clicking)
*/
- public JList getListBox() {
+ public JList listBox() {
return this.listBox;
}
@@ -324,7 +328,7 @@ public class FilteringListPanel extends JPanel {
/**
* allow client code to access the list box label
*/
- public JLabel getListBoxLabel() {
+ public JLabel listBoxLabel() {
return this.listBoxLabel;
}
@@ -345,7 +349,7 @@ public class FilteringListPanel extends JPanel {
this.listBox.setFont(font);
}
- public StringMatcher getStringMatcher() {
+ public StringMatcher stringMatcher() {
return this.stringMatcher;
}
@@ -375,8 +379,9 @@ public class FilteringListPanel extends JPanel {
protected ListCellRenderer buildDefaultCellRenderer() {
return new SimpleListCellRenderer() {
@Override
+ @SuppressWarnings("unchecked")
protected String buildText(Object value) {
- return FilteringListPanel.this.stringConverter.convertToString(value);
+ return FilteringListPanel.this.stringConverter.convertToString((T) value);
}
};
}
@@ -385,7 +390,7 @@ public class FilteringListPanel extends JPanel {
* Something has changed that requires us to filter the list.
*
* This method is synchronized because a fast typist can
- * generate events quicker than we can filter the list. (? -bjv)
+ * generate events quicker than we can filter the list. (? ~bjv)
*/
synchronized void filterList() {
// temporarily stop listening to the list box selection, since we will
@@ -407,7 +412,7 @@ public class FilteringListPanel extends JPanel {
int len = this.completeList.length;
int max = this.max();
for (int i = 0; i < len; i++) {
- if (this.stringMatcher.matches(this.stringConverter.convertToString(this.completeList[i]))) {
+ if (this.stringMatcher.matches(this.stringConverter.convertToString(this.entry(i)))) {
this.buffer[j++] = this.completeList[i];
}
if (j == max) {
@@ -428,6 +433,14 @@ public class FilteringListPanel extends JPanel {
}
/**
+ * minimize scope of suppressed warnings
+ */
+ @SuppressWarnings("unchecked")
+ private T entry(int index) {
+ return (T) this.completeList[index];
+ }
+
+ /**
* Build a list model that wraps only a portion of the specified array.
* The model will include the array entries from 0 to (size - 1).
*/
diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java
index 52f8c8f9a4..81a9d75273 100644
--- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java
+++ b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/swing/ListChooser.java
@@ -113,12 +113,12 @@ public class ListChooser
//These are used to workaround problems with Swing trying to
//determine the size of a comboBox with a large model
setPrototypeDisplayValue(prototypeLabel);
- getListBox().setPrototypeCellValue(prototypeLabel);
+ listBox().setPrototypeCellValue(prototypeLabel);
}
- private JList getListBox() {
- return (JList) ClassTools.getFieldValue(this.ui, "listBox");
+ private JList listBox() {
+ return (JList) ClassTools.fieldValue(this.ui, "listBox");
}
/**
@@ -215,7 +215,7 @@ public class ListChooser
private void updateArrowButton() {
try {
BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) ListChooser.this.getUI();
- JButton arrowButton = (JButton) ClassTools.getFieldValue(comboBoxUi, "arrowButton");
+ JButton arrowButton = (JButton) ClassTools.fieldValue(comboBoxUi, "arrowButton");
arrowButton.setEnabled(this.isEnabled() && this.choosable);
}
catch (Exception e) {
@@ -241,7 +241,7 @@ public class ListChooser
// **************** Public ************************************************
- public int getLongListSize() {
+ public int longListSize() {
return this.longListSize;
}
@@ -389,7 +389,7 @@ public class ListChooser
private void checkComboBoxButton() {
try {
BasicComboBoxUI comboBoxUi = (BasicComboBoxUI) ListChooser.this.getUI();
- JButton arrowButton = (JButton) ClassTools.getFieldValue(comboBoxUi, "arrowButton");
+ JButton arrowButton = (JButton) ClassTools.fieldValue(comboBoxUi, "arrowButton");
arrowButton.getModel().setPressed(false);
}
catch (Exception e) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
index 5b8cd461fd..4e3ad67378 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencePropertyValueModelTests.java
@@ -358,7 +358,7 @@ public class PreferencePropertyValueModelTests extends PreferencesTestCase {
}
private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.getFieldValue(node, "prefListeners");
+ PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.fieldValue(node, "prefListeners");
return prefListeners.length > 0;
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
index 82cbaebb68..95b6106e29 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesCollectionValueModelTests.java
@@ -31,9 +31,9 @@ import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencePropertyValu
import org.eclipse.jpt.utility.internal.model.value.prefs.PreferencesCollectionValueModel;
public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
- private Map expectedValues;
- private WritablePropertyValueModel nodeHolder;
- PreferencesCollectionValueModel preferencesAdapter;
+ private Map<String, String> expectedValues;
+ private WritablePropertyValueModel<Preferences> nodeHolder;
+ PreferencesCollectionValueModel<String> preferencesAdapter;
CollectionChangeEvent event;
CollectionChangeListener listener;
private PropertyChangeListener itemListener;
@@ -52,13 +52,13 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.expectedValues = new HashMap();
+ this.expectedValues = new HashMap<String, String>();
this.testNode.put(KEY_NAME_1, STRING_VALUE_1); this.expectedValues.put(KEY_NAME_1, STRING_VALUE_1);
this.testNode.put(KEY_NAME_2, STRING_VALUE_2); this.expectedValues.put(KEY_NAME_2, STRING_VALUE_2);
this.testNode.put(KEY_NAME_3, STRING_VALUE_3); this.expectedValues.put(KEY_NAME_3, STRING_VALUE_3);
- this.nodeHolder = new SimplePropertyValueModel(this.testNode);
- this.preferencesAdapter = new PreferencesCollectionValueModel(this.nodeHolder);
+ this.nodeHolder = new SimplePropertyValueModel<Preferences>(this.testNode);
+ this.preferencesAdapter = new PreferencesCollectionValueModel<String>(this.nodeHolder);
this.listener = this.buildCollectionChangeListener();
this.itemListener = this.buildItemListener();
this.preferencesAdapter.addCollectionChangeListener(CollectionValueModel.VALUES, this.listener);
@@ -114,18 +114,18 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
this.nodeHolder.setValue(anotherNode);
// collectionChanged does not pass any items in the this.event
- this.verifyEvent(Collections.EMPTY_MAP);
+ this.verifyEvent(Collections.<String, String>emptyMap());
this.verifyAdapter(this.preferencesAdapter);
this.event = null;
this.expectedValues.clear();
this.nodeHolder.setValue(null);
this.verifyEvent(this.expectedValues);
- assertFalse(((Iterator) this.preferencesAdapter.iterator()).hasNext());
+ assertFalse(this.preferencesAdapter.iterator().hasNext());
this.event = null;
this.nodeHolder.setValue(this.testNode);
- this.verifyEvent(Collections.EMPTY_MAP);
+ this.verifyEvent(Collections.<String, String>emptyMap());
this.expectedValues.clear();
this.expectedValues.put(KEY_NAME_1, STRING_VALUE_1);
this.expectedValues.put(KEY_NAME_2, STRING_VALUE_2);
@@ -141,7 +141,7 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
String ANOTHER_STRING_VALUE = "another string value";
this.testNode.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
this.waitForEventQueueToClear();
- Map expectedItems = new HashMap();
+ Map<String, String> expectedItems = new HashMap<String, String>();
expectedItems.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
this.verifyEvent(expectedItems);
this.expectedValues.put(ANOTHER_KEY_NAME, ANOTHER_STRING_VALUE);
@@ -159,7 +159,9 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
assertEquals(this.preferencesAdapter, this.event.getSource());
assertEquals(CollectionValueModel.VALUES, this.event.collectionName());
assertEquals(1, this.event.itemsSize());
- assertEquals(KEY_NAME_2, ((PreferencePropertyValueModel) this.event.items().next()).getKey());
+ @SuppressWarnings("unchecked")
+ String key = ((PreferencePropertyValueModel<String>) this.event.items().next()).key();
+ assertEquals(KEY_NAME_2, key);
this.expectedValues.remove(KEY_NAME_2);
this.verifyAdapter(this.preferencesAdapter);
@@ -235,12 +237,14 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
assertFalse(this.preferencesAdapter.hasAnyCollectionChangeListeners(CollectionValueModel.VALUES));
}
- private void verifyEvent(Map items) {
+ private void verifyEvent(Map<String, String> items) {
assertNotNull(this.event);
assertEquals(this.preferencesAdapter, this.event.getSource());
assertEquals(CollectionValueModel.VALUES, this.event.collectionName());
assertEquals(items.size(), this.event.itemsSize());
- this.verifyItems(items, this.event.items());
+ @SuppressWarnings("unchecked")
+ Iterator<PreferencePropertyValueModel<String>> eventItems = (Iterator<PreferencePropertyValueModel<String>>) this.event.items();
+ this.verifyItems(items, eventItems);
}
private void verifyNode(Preferences node) throws Exception {
@@ -251,22 +255,22 @@ public class PreferencesCollectionValueModelTests extends PreferencesTestCase {
}
}
- private void verifyAdapter(PreferencesCollectionValueModel cvm) {
+ private void verifyAdapter(PreferencesCollectionValueModel<String> cvm) {
assertEquals(this.expectedValues.size(), cvm.size());
- this.verifyItems(this.expectedValues, (Iterator) cvm.iterator());
+ this.verifyItems(this.expectedValues, cvm.iterator());
}
- private void verifyItems(Map expected, Iterator stream) {
+ private void verifyItems(Map<String, String> expected, Iterator<PreferencePropertyValueModel<String>> stream) {
while (stream.hasNext()) {
- PreferencePropertyValueModel model = (PreferencePropertyValueModel) stream.next();
+ PreferencePropertyValueModel<String> model = stream.next();
model.addPropertyChangeListener(PropertyValueModel.VALUE, this.itemListener);
- assertEquals(expected.get(model.getKey()), model.value());
+ assertEquals(expected.get(model.key()), model.value());
model.removePropertyChangeListener(PropertyValueModel.VALUE, this.itemListener);
}
}
private boolean nodeHasAnyPrefListeners(Preferences node) throws Exception {
- PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.getFieldValue(node, "prefListeners");
+ PreferenceChangeListener[] prefListeners = (PreferenceChangeListener[]) ClassTools.fieldValue(node, "prefListeners");
return prefListeners.length > 0;
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
index 49314df9ef..8c78736e77 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/prefs/PreferencesTestCase.java
@@ -81,7 +81,7 @@ public abstract class PreferencesTestCase extends TestCase {
@SuppressWarnings("unchecked")
private List<EventObject> preferencesEventQueue() {
- return (List<EventObject>) ClassTools.getStaticFieldValue(AbstractPreferences.class, "eventQueue");
+ return (List<EventObject>) ClassTools.staticFieldValue(AbstractPreferences.class, "eventQueue");
}
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
index 2581f10d08..8e3e5a74fe 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/CheckBoxModelAdapterTests.java
@@ -113,12 +113,12 @@ public class CheckBoxModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.getFieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
assertEquals(0, listenerList.getListenerList().length);
}
private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.getFieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
assertFalse(listenerList.getListenerList().length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
index dfa5e695ae..0b88c21077 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest.java
@@ -386,7 +386,7 @@ public class ComboBoxModelAdapterUITest {
}
@Override
protected ListBrowser buildBrowser() {
- return new FilteringListBrowser();
+ return new FilteringListBrowser<String>();
}
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
index 35eaee3648..885eef663f 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ComboBoxModelAdapterUITest2.java
@@ -42,7 +42,7 @@ public class ComboBoxModelAdapterUITest2 extends ComboBoxModelAdapterUITest {
@Override
protected ListValueModel uiColorListHolder() {
// the default is to prepend the wrapped list with a null item
- return new ExtendedListValueModelWrapper(super.uiColorListHolder());
+ return new ExtendedListValueModelWrapper<String>(super.uiColorListHolder());
}
/**
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
index e9b42de544..10f186b356 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DateSpinnerModelAdapterTests.java
@@ -25,7 +25,7 @@ import org.eclipse.jpt.utility.tests.internal.TestTools;
import junit.framework.TestCase;
public class DateSpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Date> valueHolder;
+ private WritablePropertyValueModel<Object> valueHolder;
private SpinnerModel spinnerModelAdapter;
boolean eventFired;
@@ -36,7 +36,7 @@ public class DateSpinnerModelAdapterTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Date>(new Date());
+ this.valueHolder = new SimplePropertyValueModel<Object>(new Date());
this.spinnerModelAdapter = new DateSpinnerModelAdapter(this.valueHolder) {
@Override
protected PropertyChangeListener buildDateChangeListener() {
@@ -63,7 +63,7 @@ public class DateSpinnerModelAdapterTests extends TestCase {
newDate.setTime(777777);
this.spinnerModelAdapter.setValue(newDate);
assertTrue(this.eventFired);
- assertEquals(777777, this.valueHolder.value().getTime());
+ assertEquals(777777, ((Date) this.valueHolder.value()).getTime());
}
public void testSetValueValueHolder() throws Exception {
@@ -99,7 +99,7 @@ public class DateSpinnerModelAdapterTests extends TestCase {
}
public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Date> localValueHolder = (SimplePropertyValueModel<Date>) this.valueHolder;
+ SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
this.verifyHasNoListeners(this.spinnerModelAdapter);
@@ -123,7 +123,7 @@ public class DateSpinnerModelAdapterTests extends TestCase {
public void testNullInitialValue() {
Date today = new Date();
- this.valueHolder = new SimplePropertyValueModel<Date>();
+ this.valueHolder = new SimplePropertyValueModel<Object>();
this.spinnerModelAdapter = new DateSpinnerModelAdapter(this.valueHolder, today) {
@Override
protected PropertyChangeListener buildDateChangeListener() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
index bcaf102073..473e1d1246 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/DocumentAdapterTests.java
@@ -130,13 +130,13 @@ public class DocumentAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object document) throws Exception {
- Object delegate = ClassTools.getFieldValue(document, "delegate");
+ Object delegate = ClassTools.fieldValue(document, "delegate");
Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getDocumentListeners");
assertEquals(0, listeners.length);
}
private void verifyHasListeners(Object document) throws Exception {
- Object delegate = ClassTools.getFieldValue(document, "delegate");
+ Object delegate = ClassTools.fieldValue(document, "delegate");
Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getDocumentListeners");
assertFalse(listeners.length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
index fd2110e146..d0530c0c15 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterTests.java
@@ -60,7 +60,7 @@ public class ListModelAdapterTests extends TestCase {
};
}
- private ListModel buildListModel(CollectionValueModel collectionHolder) {
+ private ListModel buildListModel(CollectionValueModel<String> collectionHolder) {
return new ListModelAdapter(collectionHolder) {
@Override
protected ListChangeListener buildListChangeListener() {
@@ -70,9 +70,9 @@ public class ListModelAdapterTests extends TestCase {
}
public void testCollectionSynchronization() {
- SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
+ SimpleCollectionValueModel<String> collectionHolder = this.buildCollectionHolder();
ListModel listModel = this.buildListModel(collectionHolder);
- CoordinatedList synchList = new CoordinatedList(listModel);
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
assertEquals(6, synchList.size());
this.compare(listModel, synchList);
@@ -92,9 +92,9 @@ public class ListModelAdapterTests extends TestCase {
}
public void testListSynchronization() {
- SimpleListValueModel listHolder = this.buildListHolder();
+ SimpleListValueModel<String> listHolder = this.buildListHolder();
ListModel listModel = this.buildListModel(listHolder);
- CoordinatedList synchList = new CoordinatedList(listModel);
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
assertEquals(6, synchList.size());
this.compare(listModel, synchList);
@@ -114,28 +114,28 @@ public class ListModelAdapterTests extends TestCase {
}
public void testSetModel() {
- SimpleListValueModel listHolder1 = this.buildListHolder();
+ SimpleListValueModel<String> listHolder1 = this.buildListHolder();
ListModelAdapter listModel = this.buildListModel(listHolder1);
- CoordinatedList synchList = new CoordinatedList(listModel);
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
assertTrue(listHolder1.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
assertEquals(6, synchList.size());
this.compare(listModel, synchList);
- SimpleListValueModel listHolder2 = this.buildListHolder2();
+ SimpleListValueModel<String> listHolder2 = this.buildListHolder2();
listModel.setModel(listHolder2);
assertEquals(3, synchList.size());
this.compare(listModel, synchList);
assertTrue(listHolder1.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
assertTrue(listHolder2.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
- listModel.setModel(new SimpleListValueModel());
+ listModel.setModel(new SimpleListValueModel<String>());
assertEquals(0, synchList.size());
this.compare(listModel, synchList);
assertTrue(listHolder1.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
assertTrue(listHolder2.hasNoListChangeListeners(ListValueModel.LIST_VALUES));
}
- private void compare(ListModel listModel, List list) {
+ private void compare(ListModel listModel, List<String> list) {
assertEquals(listModel.getSize(), list.size());
for (int i = 0; i < listModel.getSize(); i++) {
assertEquals(listModel.getElementAt(i), list.get(i));
@@ -158,19 +158,19 @@ public class ListModelAdapterTests extends TestCase {
this.verifyListSort(this.buildCustomComparator());
}
- private Comparator buildCustomComparator() {
+ private Comparator<String> buildCustomComparator() {
// sort with reverse order
- return new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((Comparable) o2).compareTo(o1);
+ return new Comparator<String>() {
+ public int compare(String s1, String s2) {
+ return s2.compareTo(s1);
}
};
}
- private void verifyCollectionSort(Comparator comparator) {
- SimpleCollectionValueModel collectionHolder = this.buildCollectionHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter(collectionHolder, comparator));
- CoordinatedList synchList = new CoordinatedList(listModel);
+ private void verifyCollectionSort(Comparator<String> comparator) {
+ SimpleCollectionValueModel<String> collectionHolder = this.buildCollectionHolder();
+ ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(collectionHolder, comparator));
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
assertEquals(6, synchList.size());
this.compareSort(listModel, synchList, comparator);
@@ -187,10 +187,10 @@ public class ListModelAdapterTests extends TestCase {
this.compareSort(listModel, synchList, comparator);
}
- private void verifyListSort(Comparator comparator) {
- SimpleListValueModel listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter(listHolder, comparator));
- CoordinatedList synchList = new CoordinatedList(listModel);
+ private void verifyListSort(Comparator<String> comparator) {
+ SimpleListValueModel<String> listHolder = this.buildListHolder();
+ ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(listHolder, comparator));
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
assertEquals(6, synchList.size());
this.compareSort(listModel, synchList, comparator);
@@ -208,26 +208,26 @@ public class ListModelAdapterTests extends TestCase {
this.compareSort(listModel, synchList, comparator);
}
- private void compareSort(ListModel listModel, List list, Comparator comparator) {
- SortedSet ss = new TreeSet(comparator);
+ private void compareSort(ListModel listModel, List<String> list, Comparator<String> comparator) {
+ SortedSet<String> ss = new TreeSet<String>(comparator);
for (int i = 0; i < listModel.getSize(); i++) {
- ss.add(listModel.getElementAt(i));
+ ss.add((String) listModel.getElementAt(i));
}
assertEquals(ss.size(), list.size());
- for (Iterator stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
+ for (Iterator<String> stream1 = ss.iterator(), stream2 = list.iterator(); stream1.hasNext(); ) {
assertEquals(stream1.next(), stream2.next());
}
}
public void testHasListeners() throws Exception {
- SimpleListValueModel listHolder = this.buildListHolder();
+ SimpleListValueModel<String> listHolder = this.buildListHolder();
assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
ListModel listModel = this.buildListModel(listHolder);
assertFalse(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
this.verifyHasNoListeners(listModel);
- CoordinatedList synchList = new CoordinatedList(listModel);
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
assertTrue(listHolder.hasAnyListChangeListeners(ListValueModel.LIST_VALUES));
this.verifyHasListeners(listModel);
@@ -237,12 +237,12 @@ public class ListModelAdapterTests extends TestCase {
}
public void testGetSize() throws Exception {
- SimpleListValueModel listHolder = this.buildListHolder();
+ SimpleListValueModel<String> listHolder = this.buildListHolder();
ListModel listModel = this.buildListModel(listHolder);
this.verifyHasNoListeners(listModel);
assertEquals(6, listModel.getSize());
- CoordinatedList synchList = new CoordinatedList(listModel);
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
this.verifyHasListeners(listModel);
assertEquals(6, listModel.getSize());
@@ -252,9 +252,9 @@ public class ListModelAdapterTests extends TestCase {
}
public void testGetElementAt() throws Exception {
- SimpleListValueModel listHolder = this.buildListHolder();
- ListModel listModel = this.buildListModel(new SortedListValueModelAdapter(listHolder));
- CoordinatedList synchList = new CoordinatedList(listModel);
+ SimpleListValueModel<String> listHolder = this.buildListHolder();
+ ListModel listModel = this.buildListModel(new SortedListValueModelAdapter<String>(listHolder));
+ CoordinatedList<String> synchList = new CoordinatedList<String>(listModel);
this.verifyHasListeners(listModel);
assertEquals("bar", listModel.getElementAt(0));
assertEquals("bar", synchList.get(0));
@@ -270,8 +270,8 @@ public class ListModelAdapterTests extends TestCase {
assertTrue(hasListeners);
}
- private SimpleCollectionValueModel buildCollectionHolder() {
- return new SimpleCollectionValueModel(this.buildCollection());
+ private SimpleCollectionValueModel<String> buildCollectionHolder() {
+ return new SimpleCollectionValueModel<String>(this.buildCollection());
}
private Collection<String> buildCollection() {
@@ -280,8 +280,8 @@ public class ListModelAdapterTests extends TestCase {
return bag;
}
- private SimpleListValueModel buildListHolder() {
- return new SimpleListValueModel(this.buildList());
+ private SimpleListValueModel<String> buildListHolder() {
+ return new SimpleListValueModel<String>(this.buildList());
}
private List<String> buildList() {
@@ -299,8 +299,8 @@ public class ListModelAdapterTests extends TestCase {
c.add("jaz");
}
- private SimpleListValueModel buildListHolder2() {
- return new SimpleListValueModel(this.buildList2());
+ private SimpleListValueModel<String> buildListHolder2() {
+ return new SimpleListValueModel<String>(this.buildList2());
}
private List<String> buildList2() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
index ef2830568c..59da8223a9 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListModelAdapterUITest.java
@@ -35,6 +35,7 @@ import javax.swing.JScrollPane;
import javax.swing.ListModel;
import javax.swing.WindowConstants;
+import org.eclipse.jpt.utility.internal.StringTools;
import org.eclipse.jpt.utility.internal.model.AbstractModel;
import org.eclipse.jpt.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.utility.internal.model.value.ListValueModel;
@@ -143,11 +144,11 @@ public class ListModelAdapterUITest {
}
private ListModel buildStandardSortedPrimitiveListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter(this.buildPrimitiveTaskListAdapter()));
+ return new ListModelAdapter(new SortedListValueModelAdapter<String>(this.buildPrimitiveTaskListAdapter()));
}
private ListModel buildCustomSortedPrimitiveListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator()));
+ return new ListModelAdapter(new SortedListValueModelAdapter<String>(this.buildPrimitiveTaskListAdapter(), this.buildCustomStringComparator()));
}
private ListModel buildUnsortedDisplayableListModel() {
@@ -155,11 +156,11 @@ public class ListModelAdapterUITest {
}
private ListModel buildStandardSortedDisplayableListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter(this.buildDisplayableTaskListAdapter()));
+ return new ListModelAdapter(new SortedListValueModelAdapter<Task>(this.buildDisplayableTaskListAdapter()));
}
private ListModel buildCustomSortedDisplayableListModel() {
- return new ListModelAdapter(new SortedListValueModelAdapter(this.buildDisplayableTaskListAdapter(), this.buildCustomTaskObjectComparator()));
+ return new ListModelAdapter(new SortedListValueModelAdapter<Task>(this.buildDisplayableTaskListAdapter(), this.buildCustomTaskObjectComparator()));
}
private Component buildListPanel(String label, ListModel listModel) {
@@ -183,28 +184,28 @@ public class ListModelAdapterUITest {
};
}
- private Comparator<TaskObject> buildCustomTaskObjectComparator() {
- return new Comparator<TaskObject>() {
- public int compare(TaskObject to1, TaskObject to2) {
+ private Comparator<Task> buildCustomTaskObjectComparator() {
+ return new Comparator<Task>() {
+ public int compare(Task to1, Task to2) {
return to2.compareTo(to1);
}
};
}
private ListValueModel buildPrimitiveTaskListAdapter() {
- return new ListAspectAdapter(TaskList.TASKS_LIST, this.taskList()) {
+ return new ListAspectAdapter<TaskList, String>(TaskList.TASK_NAMES_LIST, this.taskList()) {
@Override
protected ListIterator<String> listIterator_() {
- return ((TaskList) this.subject).tasks();
+ return this.subject.taskNames();
}
};
}
private ListValueModel buildDisplayableTaskListAdapter() {
- return new ListAspectAdapter(TaskList.TASK_OBJECTS_LIST, this.taskList()) {
+ return new ListAspectAdapter<TaskList, Task>(TaskList.TASKS_LIST, this.taskList()) {
@Override
- protected ListIterator<TaskObject> listIterator_() {
- return ((TaskList) this.subject).taskObjects();
+ protected ListIterator<Task> listIterator_() {
+ return this.subject.tasks();
}
};
}
@@ -298,50 +299,50 @@ public class ListModelAdapterUITest {
}
private class TaskList extends AbstractModel {
- private List<String> tasks = new ArrayList<String>();
- private List<TaskObject> taskObjects = new ArrayList<TaskObject>();
+ private List<String> taskNames = new ArrayList<String>();
+ private List<Task> taskObjects = new ArrayList<Task>();
+ public static final String TASK_NAMES_LIST = "taskNames";
public static final String TASKS_LIST = "tasks";
- public static final String TASK_OBJECTS_LIST = "taskObjects";
TaskList() {
super();
}
- public ListIterator<String> tasks() {
- return this.tasks.listIterator();
+ public ListIterator<String> taskNames() {
+ return this.taskNames.listIterator();
}
- public ListIterator<TaskObject> taskObjects() {
+ public ListIterator<Task> tasks() {
return this.taskObjects.listIterator();
}
- public void addTask(String task) {
- int index = this.tasks.size();
- this.tasks.add(index, task);
- this.fireItemAdded(TASKS_LIST, index, task);
+ public void addTask(String taskName) {
+ int index = this.taskNames.size();
+ this.taskNames.add(index, taskName);
+ this.fireItemAdded(TASK_NAMES_LIST, index, taskName);
- TaskObject taskObject = new TaskObject(task);
+ Task taskObject = new Task(taskName);
this.taskObjects.add(index, taskObject);
- this.fireItemAdded(TASK_OBJECTS_LIST, index, taskObject);
+ this.fireItemAdded(TASKS_LIST, index, taskObject);
}
- public void removeTask(String task) {
- int index = this.tasks.indexOf(task);
+ public void removeTask(String taskName) {
+ int index = this.taskNames.indexOf(taskName);
if (index != -1) {
- Object removedTask = this.tasks.remove(index);
- this.fireItemRemoved(TASKS_LIST, index, removedTask);
+ Object removedTask = this.taskNames.remove(index);
+ this.fireItemRemoved(TASK_NAMES_LIST, index, removedTask);
// assume the indexes match...
Object removedTaskObject = this.taskObjects.remove(index);
- this.fireItemRemoved(TASK_OBJECTS_LIST, index, removedTaskObject);
+ this.fireItemRemoved(TASKS_LIST, index, removedTaskObject);
}
}
public void clearTasks() {
- this.tasks.clear();
- this.fireListChanged(TASKS_LIST);
+ this.taskNames.clear();
+ this.fireListChanged(TASK_NAMES_LIST);
this.taskObjects.clear();
- this.fireListChanged(TASK_OBJECTS_LIST);
+ this.fireListChanged(TASKS_LIST);
}
}
- private class TaskObject extends AbstractModel implements Displayable {
+ private class Task extends AbstractModel implements Displayable {
private String name;
private Date creationTimeStamp;
- public TaskObject(String name) {
+ public Task(String name) {
this.name = name;
this.creationTimeStamp = new Date();
}
@@ -364,7 +365,7 @@ public class ListModelAdapterUITest {
}
@Override
public String toString() {
- return "TaskObject(" + this.displayString() + ")";
+ return StringTools.buildToStringFor(this, this.displayString());
}
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
index 2982275c93..27d60fa4a0 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ListSpinnerModelAdapterTests.java
@@ -23,7 +23,7 @@ import org.eclipse.jpt.utility.tests.internal.TestTools;
import junit.framework.TestCase;
public class ListSpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<String> valueHolder;
+ private WritablePropertyValueModel<Object> valueHolder;
private SpinnerModel spinnerModelAdapter;
boolean eventFired;
private static final String[] VALUE_LIST = {"red", "green", "blue"};
@@ -36,7 +36,7 @@ public class ListSpinnerModelAdapterTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.valueHolder = new SimplePropertyValueModel<String>(DEFAULT_VALUE);
+ this.valueHolder = new SimplePropertyValueModel<Object>(DEFAULT_VALUE);
this.spinnerModelAdapter = new ListSpinnerModelAdapter(this.valueHolder, VALUE_LIST) {
@Override
protected PropertyChangeListener buildValueChangeListener() {
@@ -100,7 +100,7 @@ public class ListSpinnerModelAdapterTests extends TestCase {
}
public void testHasListeners() throws Exception {
- SimplePropertyValueModel<String> localValueHolder = (SimplePropertyValueModel<String>) this.valueHolder;
+ SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
this.verifyHasNoListeners(this.spinnerModelAdapter);
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
index 90210ce036..6f47c785ea 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/NumberSpinnerModelAdapterTests.java
@@ -23,7 +23,7 @@ import org.eclipse.jpt.utility.tests.internal.TestTools;
import junit.framework.TestCase;
public class NumberSpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Integer> valueHolder;
+ private WritablePropertyValueModel<Number> valueHolder;
private SpinnerModel spinnerModelAdapter;
boolean eventFired;
@@ -34,7 +34,7 @@ public class NumberSpinnerModelAdapterTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Integer>(new Integer(0));
+ this.valueHolder = new SimplePropertyValueModel<Number>(new Integer(0));
this.spinnerModelAdapter = new NumberSpinnerModelAdapter(this.valueHolder, -33, 33, 1) {
@Override
protected PropertyChangeListener buildNumberChangeListener() {
@@ -91,7 +91,7 @@ public class NumberSpinnerModelAdapterTests extends TestCase {
}
public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Integer> localValueHolder = (SimplePropertyValueModel<Integer>) this.valueHolder;
+ SimplePropertyValueModel<Number> localValueHolder = (SimplePropertyValueModel<Number>) this.valueHolder;
assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
this.verifyHasNoListeners(this.spinnerModelAdapter);
@@ -114,7 +114,7 @@ public class NumberSpinnerModelAdapterTests extends TestCase {
}
public void testNullInitialValue() {
- this.valueHolder = new SimplePropertyValueModel<Integer>();
+ this.valueHolder = new SimplePropertyValueModel<Number>();
this.spinnerModelAdapter = new NumberSpinnerModelAdapter(this.valueHolder, new Integer(-33), new Integer(33), new Integer(1), new Integer(0)) {
@Override
protected PropertyChangeListener buildNumberChangeListener() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
index 13aea760de..0c418cabdb 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ObjectListSelectionModelTests.java
@@ -56,22 +56,22 @@ public class ObjectListSelectionModelTests extends TestCase {
public void testListDataListener() {
this.selectionModel.addListSelectionListener(this.buildListSelectionListener());
this.selectionModel.setSelectionInterval(0, 0);
- assertEquals("foo", this.selectionModel.getSelectedValue());
+ assertEquals("foo", this.selectionModel.selectedValue());
this.listModel.set(0, "jar");
- assertEquals("jar", this.selectionModel.getSelectedValue());
+ assertEquals("jar", this.selectionModel.selectedValue());
}
public void testGetSelectedValue() {
this.selectionModel.setSelectionInterval(0, 0);
- assertEquals("foo", this.selectionModel.getSelectedValue());
+ assertEquals("foo", this.selectionModel.selectedValue());
}
public void testGetSelectedValues() {
this.selectionModel.setSelectionInterval(0, 0);
this.selectionModel.addSelectionInterval(2, 2);
- assertEquals(2, this.selectionModel.getSelectedValues().length);
- assertTrue(CollectionTools.contains(this.selectionModel.getSelectedValues(), "foo"));
- assertTrue(CollectionTools.contains(this.selectionModel.getSelectedValues(), "baz"));
+ assertEquals(2, this.selectionModel.selectedValues().length);
+ assertTrue(CollectionTools.contains(this.selectionModel.selectedValues(), "foo"));
+ assertTrue(CollectionTools.contains(this.selectionModel.selectedValues(), "baz"));
}
public void testSetSelectedValue() {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
index 98a293aa4e..7d427e15d1 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/PrimitiveListTreeModelTests.java
@@ -64,30 +64,18 @@ public class PrimitiveListTreeModelTests extends TestCase {
}
private ListValueModel buildListValueModel() {
- return new ListAspectAdapter(TestModel.NAMES_LIST, this.testModel) {
+ return new ListAspectAdapter<TestModel, String>(TestModel.NAMES_LIST, this.testModel) {
@Override
- protected ListIterator listIterator_() {
- return ((TestModel) this.subject).names();
+ protected ListIterator<String> listIterator_() {
+ return this.subject.names();
}
@Override
public Object get(int index) {
- return ((TestModel) this.subject).getName(index);
+ return this.subject.getName(index);
}
@Override
public int size() {
- return ((TestModel) this.subject).namesSize();
- }
- public void add(int index, Object item) {
- ((TestModel) this.subject).addName(index, (String) item);
- }
- public void addAll(int index, List items) {
- ((TestModel) this.subject).addNames(index, items);
- }
- public Object remove(int index) {
- return ((TestModel) this.subject).removeName(index);
- }
- public List remove(int index, int length) {
- return ((TestModel) this.subject).removeNames(index, length);
+ return this.subject.namesSize();
}
};
}
@@ -176,16 +164,16 @@ public class PrimitiveListTreeModelTests extends TestCase {
public void addName(String name) {
this.addName(this.namesSize(), name);
}
- public void addNames(int index, List list) {
+ public void addNames(int index, List<String> list) {
this.addItemsToList(index, this.names, list, NAMES_LIST);
}
- public void addNames(List list) {
+ public void addNames(List<String> list) {
this.addNames(this.namesSize(), list);
}
public String removeName(int index) {
- return (String) this.removeItemFromList(index, this.names, NAMES_LIST);
+ return this.removeItemFromList(index, this.names, NAMES_LIST);
}
- public List removeNames(int index, int length) {
+ public List<String> removeNames(int index, int length) {
return this.removeItemsFromList(index, length, this.names, NAMES_LIST);
}
public String replaceName(int index, String newName) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
index 05540b1e60..ebeb507466 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterTests.java
@@ -25,7 +25,7 @@ import org.eclipse.jpt.utility.tests.internal.TestTools;
import junit.framework.TestCase;
public class RadioButtonModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<String> valueHolder;
+ private WritablePropertyValueModel<Object> valueHolder;
private ButtonModel redButtonModelAdapter;
private ChangeListener redListener;
@@ -52,7 +52,7 @@ public class RadioButtonModelAdapterTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.valueHolder = new SimplePropertyValueModel<String>(null);
+ this.valueHolder = new SimplePropertyValueModel<Object>(null);
// buttonGroup = new ButtonGroup();
this.redButtonModelAdapter = this.buildButtonModel(this.valueHolder, RED);
@@ -85,7 +85,7 @@ public class RadioButtonModelAdapterTests extends TestCase {
this.clearFlags();
}
- private ButtonModel buildButtonModel(WritablePropertyValueModel<String> pvm, Object buttonValue) {
+ private ButtonModel buildButtonModel(WritablePropertyValueModel<Object> pvm, Object buttonValue) {
return new RadioButtonModelAdapter(pvm, buttonValue) {
@Override
protected PropertyChangeListener buildBooleanChangeListener() {
@@ -188,7 +188,7 @@ public class RadioButtonModelAdapterTests extends TestCase {
}
public void testHasListeners() throws Exception {
- SimplePropertyValueModel<String> localValueHolder = (SimplePropertyValueModel<String>) this.valueHolder;
+ SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
this.verifyHasNoListeners(this.redButtonModelAdapter);
this.verifyHasNoListeners(this.greenButtonModelAdapter);
@@ -209,12 +209,12 @@ public class RadioButtonModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.getFieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
assertEquals(0, listenerList.getListenerList().length);
}
private void verifyHasListeners(Object model) throws Exception {
- EventListenerList listenerList = (EventListenerList) ClassTools.getFieldValue(model, "listenerList");
+ EventListenerList listenerList = (EventListenerList) ClassTools.fieldValue(model, "listenerList");
assertFalse(listenerList.getListenerList().length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
index 3c5490c641..3ebc0939b9 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/RadioButtonModelAdapterUITest.java
@@ -42,7 +42,7 @@ public class RadioButtonModelAdapterUITest {
private TestModel testModel;
private WritablePropertyValueModel<TestModel> testModelHolder;
- private WritablePropertyValueModel<String> colorHolder;
+ private WritablePropertyValueModel<Object> colorHolder;
private ButtonModel redButtonModel;
private ButtonModel greenButtonModel;
private ButtonModel blueButtonModel;
@@ -65,20 +65,20 @@ public class RadioButtonModelAdapterUITest {
this.openWindow();
}
- private WritablePropertyValueModel<String> buildColorHolder(PropertyValueModel<TestModel> subjectHolder) {
- return new PropertyAspectAdapter<TestModel, String>(subjectHolder, TestModel.COLOR_PROPERTY) {
+ private WritablePropertyValueModel<Object> buildColorHolder(PropertyValueModel<TestModel> subjectHolder) {
+ return new PropertyAspectAdapter<TestModel, Object>(subjectHolder, TestModel.COLOR_PROPERTY) {
@Override
- protected String buildValue_() {
+ protected Object buildValue_() {
return this.subject.getColor();
}
@Override
- protected void setValue_(String value) {
- this.subject.setColor(value);
+ protected void setValue_(Object value) {
+ this.subject.setColor((String) value);
}
};
}
- private ButtonModel buildRadioButtonModelAdapter(WritablePropertyValueModel<String> colorPVM, String color) {
+ private ButtonModel buildRadioButtonModelAdapter(WritablePropertyValueModel<Object> colorPVM, String color) {
return new RadioButtonModelAdapter(colorPVM, color);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
index 827b625b49..fc48045597 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/ReadOnlyTableModelAdapterUITest.java
@@ -30,7 +30,7 @@ public class ReadOnlyTableModelAdapterUITest extends TableModelAdapterUITest {
protected ColumnAdapter buildColumnAdapter() {
return new PersonColumnAdapter() {
@Override
- public boolean isColumnEditable(int index) {
+ public boolean columnIsEditable(int index) {
return false;
}
};
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
index dee244aa60..d7a805da67 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterTests.java
@@ -24,7 +24,7 @@ import org.eclipse.jpt.utility.tests.internal.TestTools;
import junit.framework.TestCase;
public class SpinnerModelAdapterTests extends TestCase {
- private WritablePropertyValueModel<Integer> valueHolder;
+ private WritablePropertyValueModel<Object> valueHolder;
SpinnerModel spinnerModelAdapter;
boolean eventFired;
@@ -35,7 +35,7 @@ public class SpinnerModelAdapterTests extends TestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- this.valueHolder = new SimplePropertyValueModel<Integer>(new Integer(0));
+ this.valueHolder = new SimplePropertyValueModel<Object>(new Integer(0));
this.spinnerModelAdapter = new SpinnerModelAdapter(this.valueHolder) {
@Override
protected PropertyChangeListener buildValueListener() {
@@ -80,7 +80,7 @@ public class SpinnerModelAdapterTests extends TestCase {
}
public void testHasListeners() throws Exception {
- SimplePropertyValueModel<Integer> localValueHolder = (SimplePropertyValueModel<Integer>) this.valueHolder;
+ SimplePropertyValueModel<Object> localValueHolder = (SimplePropertyValueModel<Object>) this.valueHolder;
assertFalse(localValueHolder.hasAnyPropertyChangeListeners(PropertyValueModel.VALUE));
this.verifyHasNoListeners(this.spinnerModelAdapter);
@@ -95,13 +95,13 @@ public class SpinnerModelAdapterTests extends TestCase {
}
private void verifyHasNoListeners(Object adapter) throws Exception {
- Object delegate = ClassTools.getFieldValue(adapter, "delegate");
+ Object delegate = ClassTools.fieldValue(adapter, "delegate");
Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getChangeListeners");
assertEquals(0, listeners.length);
}
private void verifyHasListeners(Object adapter) throws Exception {
- Object delegate = ClassTools.getFieldValue(adapter, "delegate");
+ Object delegate = ClassTools.fieldValue(adapter, "delegate");
Object[] listeners = (Object[]) ClassTools.executeMethod(delegate, "getChangeListeners");
assertFalse(listeners.length == 0);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
index 52c38c23cf..a8e6a94148 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/SpinnerModelAdapterUITest.java
@@ -46,13 +46,13 @@ public class SpinnerModelAdapterUITest {
private TestModel testModel;
private WritablePropertyValueModel<TestModel> testModelHolder;
- private WritablePropertyValueModel<Date> birthDateHolder;
+ private WritablePropertyValueModel<Object> birthDateHolder;
private SpinnerModel birthDateSpinnerModel;
private WritablePropertyValueModel<Number> ageHolder;
private SpinnerModel ageSpinnerModel;
- private WritablePropertyValueModel<String> eyeColorHolder;
+ private WritablePropertyValueModel<Object> eyeColorHolder;
private SpinnerModel eyeColorSpinnerModel;
@@ -80,20 +80,20 @@ public class SpinnerModelAdapterUITest {
this.openWindow();
}
- private WritablePropertyValueModel<Date> buildBirthDateHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, Date>(vm, TestModel.BIRTH_DATE_PROPERTY) {
+ private WritablePropertyValueModel<Object> buildBirthDateHolder(PropertyValueModel<TestModel> vm) {
+ return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.BIRTH_DATE_PROPERTY) {
@Override
- protected Date buildValue_() {
+ protected Object buildValue_() {
return this.subject.getBirthDate();
}
@Override
- protected void setValue_(Date value) {
- this.subject.setBirthDate(value);
+ protected void setValue_(Object value) {
+ this.subject.setBirthDate((Date) value);
}
};
}
- private SpinnerModel buildBirthDateSpinnerModel(WritablePropertyValueModel<Date> valueHolder) {
+ private SpinnerModel buildBirthDateSpinnerModel(WritablePropertyValueModel<Object> valueHolder) {
return new DateSpinnerModelAdapter(valueHolder);
}
@@ -114,20 +114,20 @@ public class SpinnerModelAdapterUITest {
return new NumberSpinnerModelAdapter(valueHolder, valueHolder.value().intValue(), TestModel.MIN_AGE, TestModel.MAX_AGE, 1);
}
- private WritablePropertyValueModel<String> buildEyeColorHolder(PropertyValueModel<TestModel> vm) {
- return new PropertyAspectAdapter<TestModel, String>(vm, TestModel.EYE_COLOR_PROPERTY) {
+ private WritablePropertyValueModel<Object> buildEyeColorHolder(PropertyValueModel<TestModel> vm) {
+ return new PropertyAspectAdapter<TestModel, Object>(vm, TestModel.EYE_COLOR_PROPERTY) {
@Override
- protected String buildValue_() {
+ protected Object buildValue_() {
return this.subject.getEyeColor();
}
@Override
- protected void setValue_(String value) {
- this.subject.setEyeColor(value);
+ protected void setValue_(Object value) {
+ this.subject.setEyeColor((String) value);
}
};
}
- private SpinnerModel buildEyeColorSpinnerModel(WritablePropertyValueModel<String> valueHolder) {
+ private SpinnerModel buildEyeColorSpinnerModel(WritablePropertyValueModel<Object> valueHolder) {
return new ListSpinnerModelAdapter(valueHolder, TestModel.VALID_EYE_COLORS);
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
index 269fa4ffa4..b71955e725 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterTests.java
@@ -63,7 +63,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testGetRowCount() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
assertEquals(0, tableModelAdapter.getRowCount());
// we need to add a listener to wake up the adapter
tableModelAdapter.addTableModelListener(this.buildTableModelListener());
@@ -71,12 +71,12 @@ public class TableModelAdapterTests extends TestCase {
}
public void testGetColumnCount() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
assertEquals(PersonColumnAdapter.COLUMN_COUNT, tableModelAdapter.getColumnCount());
}
public void testGetValueAt() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
tableModelAdapter.addTableModelListener(this.buildTableModelListener());
List<String> sortedNames = this.sortedNames();
@@ -86,7 +86,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testSetValueAt() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
this.event = null;
tableModelAdapter.addTableModelListener(new TestTableModelListener() {
@Override
@@ -115,7 +115,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testAddRow() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
this.event = null;
tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
// add a person to the end of the list so we only trigger one event
@@ -126,7 +126,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testRemoveRow() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
this.event = null;
tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
// removing a person should only trigger one event, since a re-sort is not needed
@@ -137,7 +137,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testChangeCell() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
this.event = null;
tableModelAdapter.addTableModelListener(this.buildSingleEventListener());
// add a person to the end of the list so we only trigger one event
@@ -149,7 +149,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testLazyListListener() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
TableModelListener listener = this.buildTableModelListener();
assertTrue(this.crowd.hasNoCollectionChangeListeners(Crowd.PEOPLE_COLLECTION));
tableModelAdapter.addTableModelListener(listener);
@@ -159,7 +159,7 @@ public class TableModelAdapterTests extends TestCase {
}
public void testLazyCellListener() throws Exception {
- TableModelAdapter tableModelAdapter = this.buildTableModelAdapter();
+ TableModelAdapter<Person> tableModelAdapter = this.buildTableModelAdapter();
TableModelListener listener = this.buildTableModelListener();
Person person = this.crowd.personNamed("Gollum");
assertTrue(person.hasNoPropertyChangeListeners(Person.NAME_PROPERTY));
@@ -183,8 +183,8 @@ public class TableModelAdapterTests extends TestCase {
assertTrue(person.hasNoPropertyChangeListeners(Person.RANK_PROPERTY));
}
- private TableModelAdapter buildTableModelAdapter() {
- return new TableModelAdapter(this.buildSortedPeopleAdapter(), this.buildColumnAdapter()) {
+ private TableModelAdapter<Person> buildTableModelAdapter() {
+ return new TableModelAdapter<Person>(this.buildSortedPeopleAdapter(), this.buildColumnAdapter()) {
@Override
protected PropertyChangeListener buildCellListener() {
return this.buildCellListener_();
@@ -197,18 +197,18 @@ public class TableModelAdapterTests extends TestCase {
}
private ListValueModel buildSortedPeopleAdapter() {
- return new SortedListValueModelAdapter(this.buildPeopleAdapter());
+ return new SortedListValueModelAdapter<Person>(this.buildPeopleAdapter());
}
- private CollectionValueModel buildPeopleAdapter() {
- return new CollectionAspectAdapter(Crowd.PEOPLE_COLLECTION, this.crowd) {
+ private CollectionValueModel<Person> buildPeopleAdapter() {
+ return new CollectionAspectAdapter<Crowd, Person>(Crowd.PEOPLE_COLLECTION, this.crowd) {
@Override
protected Iterator<Person> iterator_() {
- return ((Crowd) this.subject).people();
+ return this.subject.people();
}
@Override
protected int size_() {
- return ((Crowd) this.subject).peopleSize();
+ return this.subject.peopleSize();
}
};
}
@@ -273,15 +273,15 @@ public class TableModelAdapterTests extends TestCase {
};
- public int getColumnCount() {
+ public int columnCount() {
return COLUMN_COUNT;
}
- public String getColumnName(int index) {
+ public String columnName(int index) {
return COLUMN_NAMES[index];
}
- public Class<?> getColumnClass(int index) {
+ public Class<?> columnClass(int index) {
switch (index) {
case NAME_COLUMN: return Object.class;
case BIRTH_DATE_COLUMN: return Date.class;
@@ -294,112 +294,113 @@ public class TableModelAdapterTests extends TestCase {
}
}
- public boolean isColumnEditable(int index) {
+ public boolean columnIsEditable(int index) {
return index != NAME_COLUMN;
}
- public WritablePropertyValueModel[] cellModels(Object subject) {
+ public WritablePropertyValueModel<Object>[] cellModels(Object subject) {
Person person = (Person) subject;
- WritablePropertyValueModel[] result = new WritablePropertyValueModel[COLUMN_COUNT];
+ @SuppressWarnings("unchecked")
+ WritablePropertyValueModel<Object>[] result = new WritablePropertyValueModel[COLUMN_COUNT];
- result[NAME_COLUMN] = this.buildNameAdapter(person);
- result[BIRTH_DATE_COLUMN] = this.buildBirthDateAdapter(person);
- result[GONE_WEST_DATE_COLUMN] = this.buildGoneWestDateAdapter(person);
- result[EYE_COLOR_COLUMN] = this.buildEyeColorAdapter(person);
- result[EVIL_COLUMN] = this.buildEvilAdapter(person);
- result[RANK_COLUMN] = this.buildRankAdapter(person);
- result[ADVENTURE_COUNT_COLUMN] = this.buildAdventureCountAdapter(person);
+ result[NAME_COLUMN] = this.buildNameAdapter(person);
+ result[BIRTH_DATE_COLUMN] = this.buildBirthDateAdapter(person);
+ result[GONE_WEST_DATE_COLUMN] = this.buildGoneWestDateAdapter(person);
+ result[EYE_COLOR_COLUMN] = this.buildEyeColorAdapter(person);
+ result[EVIL_COLUMN] = this.buildEvilAdapter(person);
+ result[RANK_COLUMN] = this.buildRankAdapter(person);
+ result[ADVENTURE_COUNT_COLUMN] = this.buildAdventureCountAdapter(person);
return result;
}
- private WritablePropertyValueModel buildNameAdapter(Person person) {
- return new PropertyAspectAdapter(Person.NAME_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildNameAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.NAME_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getName();
+ protected String buildValue_() {
+ return this.subject.getName();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setName((String) value);
+ this.subject.setName((String) value);
}
};
}
- private WritablePropertyValueModel buildBirthDateAdapter(Person person) {
- return new PropertyAspectAdapter(Person.BIRTH_DATE_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildBirthDateAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.BIRTH_DATE_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getBirthDate();
+ protected Date buildValue_() {
+ return this.subject.getBirthDate();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setBirthDate((Date) value);
+ this.subject.setBirthDate((Date) value);
}
};
}
- private WritablePropertyValueModel buildGoneWestDateAdapter(Person person) {
- return new PropertyAspectAdapter(Person.GONE_WEST_DATE_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildGoneWestDateAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.GONE_WEST_DATE_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getGoneWestDate();
+ protected Date buildValue_() {
+ return this.subject.getGoneWestDate();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setGoneWestDate((Date) value);
+ this.subject.setGoneWestDate((Date) value);
}
};
}
- private WritablePropertyValueModel buildEyeColorAdapter(Person person) {
- return new PropertyAspectAdapter(Person.EYE_COLOR_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildEyeColorAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.EYE_COLOR_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getEyeColor();
+ protected String buildValue_() {
+ return this.subject.getEyeColor();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setEyeColor((String) value);
+ this.subject.setEyeColor((String) value);
}
};
}
- private WritablePropertyValueModel buildEvilAdapter(Person person) {
- return new PropertyAspectAdapter(Person.EVIL_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildEvilAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.EVIL_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return Boolean.valueOf(((Person) this.subject).isEvil());
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.isEvil());
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setEvil(((Boolean) value).booleanValue());
+ this.subject.setEvil(((Boolean)value).booleanValue());
}
};
}
- private WritablePropertyValueModel buildRankAdapter(Person person) {
- return new PropertyAspectAdapter(Person.RANK_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildRankAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.RANK_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return new Integer(((Person) this.subject).getRank());
+ protected Integer buildValue_() {
+ return new Integer(this.subject.getRank());
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setRank(((Integer) value).intValue());
+ this.subject.setRank(((Integer) value).intValue());
}
};
}
- private WritablePropertyValueModel buildAdventureCountAdapter(Person person) {
- return new PropertyAspectAdapter(Person.ADVENTURE_COUNT_PROPERTY, person) {
+ private WritablePropertyValueModel<Object> buildAdventureCountAdapter(Person person) {
+ return new PropertyAspectAdapter<Person, Object>(Person.ADVENTURE_COUNT_PROPERTY, person) {
@Override
- protected Object buildValue_() {
- return new Integer(((Person) this.subject).getAdventureCount());
+ protected Integer buildValue_() {
+ return new Integer(this.subject.getAdventureCount());
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setAdventureCount(((Integer) value).intValue());
+ this.subject.setAdventureCount(((Integer) value).intValue());
}
};
}
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
index ff198fde8a..d112474065 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TableModelAdapterUITest.java
@@ -16,6 +16,7 @@ import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
@@ -88,9 +89,9 @@ import org.eclipse.jpt.utility.tests.internal.model.value.swing.TableModelAdapte
* list value model (the sorted people adapter)
*/
public class TableModelAdapterUITest {
- private SimpleCollectionValueModel eyeColorsHolder;
- private WritablePropertyValueModel crowdHolder;
- private WritablePropertyValueModel selectedPersonHolder;
+ private SimpleCollectionValueModel<Object> eyeColorsHolder; // Object because it adapts to a combo-box
+ private WritablePropertyValueModel<Crowd> crowdHolder;
+ private WritablePropertyValueModel<Person> selectedPersonHolder;
private ListValueModel sortedPeopleAdapter;
private TableModel tableModel;
private ObjectListSelectionModel rowSelectionModel;
@@ -116,12 +117,12 @@ public class TableModelAdapterUITest {
this.openWindow();
}
- private SimpleCollectionValueModel buildEyeColorCollectionHolder() {
- return new SimpleCollectionValueModel(Person.getValidEyeColors());
+ private SimpleCollectionValueModel<Object> buildEyeColorCollectionHolder() {
+ return new SimpleCollectionValueModel<Object>(new ArrayList<Object>(Person.getValidEyeColors()));
}
- private WritablePropertyValueModel buildCrowdHolder() {
- return new SimplePropertyValueModel(this.buildCrowd());
+ private WritablePropertyValueModel<Crowd> buildCrowdHolder() {
+ return new SimplePropertyValueModel<Crowd>(this.buildCrowd());
}
private Crowd buildCrowd() {
@@ -151,34 +152,34 @@ public class TableModelAdapterUITest {
return crowd;
}
- private WritablePropertyValueModel buildSelectedPersonHolder() {
- return new SimplePropertyValueModel();
+ private WritablePropertyValueModel<Person> buildSelectedPersonHolder() {
+ return new SimplePropertyValueModel<Person>();
}
private ListValueModel buildSortedPeopleAdapter() {
- return new SortedListValueModelAdapter(this.buildPeopleNameAdapter());
+ return new SortedListValueModelAdapter<Person>(this.buildPeopleNameAdapter());
}
// the list will need to be re-sorted if a name changes
private ListValueModel buildPeopleNameAdapter() {
- return new ItemPropertyListValueModelAdapter(this.buildPeopleAdapter(), Person.NAME_PROPERTY);
+ return new ItemPropertyListValueModelAdapter<Person>(this.buildPeopleAdapter(), Person.NAME_PROPERTY);
}
- private CollectionValueModel buildPeopleAdapter() {
- return new CollectionAspectAdapter(this.crowdHolder, Crowd.PEOPLE_COLLECTION) {
+ private CollectionValueModel<Person> buildPeopleAdapter() {
+ return new CollectionAspectAdapter<Crowd, Person>(this.crowdHolder, Crowd.PEOPLE_COLLECTION) {
@Override
- protected Iterator iterator_() {
- return ((Crowd) this.subject).people();
+ protected Iterator<Person> iterator_() {
+ return this.subject.people();
}
@Override
protected int size_() {
- return ((Crowd) this.subject).peopleSize();
+ return this.subject.peopleSize();
}
};
}
private TableModel buildTableModel() {
- return new TableModelAdapter(this.sortedPeopleAdapter, this.buildColumnAdapter());
+ return new TableModelAdapter<Person>(this.sortedPeopleAdapter, this.buildColumnAdapter());
}
protected ColumnAdapter buildColumnAdapter() {
@@ -204,7 +205,7 @@ public class TableModelAdapterUITest {
}
void rowSelectionChanged(ListSelectionEvent e) {
- Object selection = this.rowSelectionModel.getSelectedValue();
+ Person selection = (Person) this.rowSelectionModel.selectedValue();
this.selectedPersonHolder.setValue(selection);
boolean personSelected = (selection != null);
this.removeAction.setEnabled(personSelected);
@@ -255,7 +256,7 @@ public class TableModelAdapterUITest {
SpinnerTableCellRenderer spinnerRenderer = this.buildDateSpinnerRenderer();
column.setCellRenderer(spinnerRenderer);
column.setCellEditor(new TableCellEditorAdapter(this.buildDateSpinnerRenderer()));
- rowHeight = Math.max(rowHeight, spinnerRenderer.getPreferredHeight());
+ rowHeight = Math.max(rowHeight, spinnerRenderer.preferredHeight());
// eye color column (combo-box)
// the jdk combo-box renderer looks like a text field
@@ -264,7 +265,7 @@ public class TableModelAdapterUITest {
ComboBoxTableCellRenderer eyeColorRenderer = this.buildEyeColorComboBoxRenderer();
column.setCellRenderer(eyeColorRenderer);
column.setCellEditor(new TableCellEditorAdapter(this.buildEyeColorComboBoxRenderer()));
- rowHeight = Math.max(rowHeight, eyeColorRenderer.getPreferredHeight());
+ rowHeight = Math.max(rowHeight, eyeColorRenderer.preferredHeight());
// evil (check box)
// the jdk check box renderer and editor suck - use a custom ones
@@ -272,25 +273,25 @@ public class TableModelAdapterUITest {
CheckBoxTableCellRenderer evilRenderer = new CheckBoxTableCellRenderer();
column.setCellRenderer(evilRenderer);
column.setCellEditor(new TableCellEditorAdapter(new CheckBoxTableCellRenderer()));
- rowHeight = Math.max(rowHeight, evilRenderer.getPreferredHeight());
+ rowHeight = Math.max(rowHeight, evilRenderer.preferredHeight());
// adventure count column (spinner)
column = table.getColumnModel().getColumn(PersonColumnAdapter.ADVENTURE_COUNT_COLUMN);
spinnerRenderer = this.buildNumberSpinnerRenderer();
column.setCellRenderer(spinnerRenderer);
column.setCellEditor(new TableCellEditorAdapter(this.buildNumberSpinnerRenderer()));
- rowHeight = Math.max(rowHeight, spinnerRenderer.getPreferredHeight());
+ rowHeight = Math.max(rowHeight, spinnerRenderer.preferredHeight());
table.setRowHeight(rowHeight);
return table;
}
private SpinnerTableCellRenderer buildDateSpinnerRenderer() {
- return new SpinnerTableCellRenderer(new DateSpinnerModelAdapter(new SimplePropertyValueModel()));
+ return new SpinnerTableCellRenderer(new DateSpinnerModelAdapter(new SimplePropertyValueModel<Object>()));
}
private SpinnerTableCellRenderer buildNumberSpinnerRenderer() {
- return new SpinnerTableCellRenderer(new NumberSpinnerModelAdapter(new SimplePropertyValueModel()));
+ return new SpinnerTableCellRenderer(new NumberSpinnerModelAdapter(new SimplePropertyValueModel<Number>()));
}
private ComboBoxTableCellRenderer buildEyeColorComboBoxRenderer() {
@@ -298,7 +299,7 @@ public class TableModelAdapterUITest {
}
private ComboBoxModel buildReadOnlyEyeColorComboBoxModel() {
- return new ComboBoxModelAdapter(this.eyeColorsHolder, new SimplePropertyValueModel());
+ return new ComboBoxModelAdapter(this.eyeColorsHolder, new SimplePropertyValueModel<Object>());
}
private ListCellRenderer buildEyeColorRenderer() {
@@ -443,7 +444,7 @@ public class TableModelAdapterUITest {
}
if ((eyeColor.length() == 0)) {
JOptionPane.showMessageDialog(null, "The eye color is required.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
- } else if (CollectionTools.contains((Iterator) this.eyeColorsHolder.iterator(), eyeColor)) {
+ } else if (CollectionTools.contains(this.eyeColorsHolder.iterator(), eyeColor)) {
JOptionPane.showMessageDialog(null, "The eye color already exists.", "Invalid Eye Color", JOptionPane.ERROR_MESSAGE);
} else {
return eyeColor;
@@ -532,15 +533,15 @@ public class TableModelAdapterUITest {
return new DocumentAdapter(this.buildNameAdapter());
}
- private WritablePropertyValueModel buildNameAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.NAME_PROPERTY) {
+ private WritablePropertyValueModel<String> buildNameAdapter() {
+ return new PropertyAspectAdapter<Person, String>(this.selectedPersonHolder, Person.NAME_PROPERTY) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getName();
+ protected String buildValue_() {
+ return this.subject.getName();
}
@Override
- protected void setValue_(Object value) {
- ((Person) this.subject).setName((String) value);
+ protected void setValue_(String value) {
+ this.subject.setName(value);
}
};
}
@@ -556,15 +557,15 @@ public class TableModelAdapterUITest {
return new DateSpinnerModelAdapter(this.buildBirthDateAdapter());
}
- private WritablePropertyValueModel buildBirthDateAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.BIRTH_DATE_PROPERTY) {
+ private WritablePropertyValueModel<Object> buildBirthDateAdapter() {
+ return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.BIRTH_DATE_PROPERTY) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getBirthDate();
+ protected Date buildValue_() {
+ return this.subject.getBirthDate();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setBirthDate((Date) value);
+ this.subject.setBirthDate((Date) value);
}
};
}
@@ -580,15 +581,15 @@ public class TableModelAdapterUITest {
return new DateSpinnerModelAdapter(this.buildGoneWestDateAdapter());
}
- private WritablePropertyValueModel buildGoneWestDateAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.GONE_WEST_DATE_PROPERTY) {
+ private WritablePropertyValueModel<Object> buildGoneWestDateAdapter() {
+ return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.GONE_WEST_DATE_PROPERTY) {
@Override
- protected Object buildValue_() {
- return ((Person) this.subject).getGoneWestDate();
+ protected Date buildValue_() {
+ return this.subject.getGoneWestDate();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setGoneWestDate((Date) value);
+ this.subject.setGoneWestDate((Date) value);
}
};
}
@@ -604,15 +605,15 @@ public class TableModelAdapterUITest {
return new ComboBoxModelAdapter(this.eyeColorsHolder, this.buildEyeColorAdapter());
}
- private WritablePropertyValueModel buildEyeColorAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.EYE_COLOR_PROPERTY) {
+ private WritablePropertyValueModel<Object> buildEyeColorAdapter() {
+ return new PropertyAspectAdapter<Person, Object>(this.selectedPersonHolder, Person.EYE_COLOR_PROPERTY) {
@Override
protected Object buildValue_() {
- return ((Person) this.subject).getEyeColor();
+ return this.subject.getEyeColor();
}
@Override
protected void setValue_(Object value) {
- ((Person) this.subject).setEyeColor((String) value);
+ this.subject.setEyeColor((String) value);
}
};
}
@@ -631,15 +632,15 @@ public class TableModelAdapterUITest {
return new CheckBoxModelAdapter(this.buildEvilAdapter());
}
- private WritablePropertyValueModel buildEvilAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.EVIL_PROPERTY) {
+ private WritablePropertyValueModel<Boolean> buildEvilAdapter() {
+ return new PropertyAspectAdapter<Person, Boolean>(this.selectedPersonHolder, Person.EVIL_PROPERTY) {
@Override
- protected Object buildValue_() {
- return Boolean.valueOf(((Person) this.subject).isEvil());
+ protected Boolean buildValue_() {
+ return Boolean.valueOf(this.subject.isEvil());
}
@Override
- protected void setValue_(Object value) {
- ((Person) this.subject).setEvil(((Boolean) value).booleanValue());
+ protected void setValue_(Boolean value) {
+ this.subject.setEvil(value.booleanValue());
}
};
}
@@ -655,15 +656,15 @@ public class TableModelAdapterUITest {
return new NumberSpinnerModelAdapter(this.buildRankAdapter());
}
- private WritablePropertyValueModel buildRankAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.RANK_PROPERTY) {
+ private WritablePropertyValueModel<Number> buildRankAdapter() {
+ return new PropertyAspectAdapter<Person, Number>(this.selectedPersonHolder, Person.RANK_PROPERTY) {
@Override
- protected Object buildValue_() {
- return new Integer(((Person) this.subject).getRank());
+ protected Number buildValue_() {
+ return new Integer(this.subject.getRank());
}
@Override
- protected void setValue_(Object value) {
- ((Person) this.subject).setRank(((Integer) value).intValue());
+ protected void setValue_(Number value) {
+ this.subject.setRank(value.intValue());
}
};
}
@@ -679,15 +680,15 @@ public class TableModelAdapterUITest {
return new NumberSpinnerModelAdapter(this.buildAdventureCountAdapter());
}
- private WritablePropertyValueModel buildAdventureCountAdapter() {
- return new PropertyAspectAdapter(this.selectedPersonHolder, Person.ADVENTURE_COUNT_PROPERTY) {
+ private WritablePropertyValueModel<Number> buildAdventureCountAdapter() {
+ return new PropertyAspectAdapter<Person, Number>(this.selectedPersonHolder, Person.ADVENTURE_COUNT_PROPERTY) {
@Override
- protected Object buildValue_() {
- return new Integer(((Person) this.subject).getAdventureCount());
+ protected Number buildValue_() {
+ return new Integer(this.subject.getAdventureCount());
}
@Override
- protected void setValue_(Object value) {
- ((Person) this.subject).setAdventureCount(((Integer) value).intValue());
+ protected void setValue_(Number value) {
+ this.subject.setAdventureCount(value.intValue());
}
};
}
@@ -696,14 +697,14 @@ public class TableModelAdapterUITest {
// ********** queries **********
private Crowd crowd() {
- return (Crowd) this.crowdHolder.value();
+ return this.crowdHolder.value();
}
private Person selectedPerson() {
if (this.rowSelectionModel.isSelectionEmpty()) {
return null;
}
- return (Person) this.rowSelectionModel.getSelectedValue();
+ return (Person) this.rowSelectionModel.selectedValue();
}
private void setSelectedPerson(Person person) {
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
index 1ee6544e8b..f1efabf4ac 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterTests.java
@@ -447,10 +447,10 @@ public class TreeModelAdapterTests extends TestCase {
* transform the test model children into nodes
*/
protected ListValueModel buildNodeAdapter(TestModel model) {
- return new TransformationListValueModelAdapter(this.buildChildrenAdapter(model)) {
+ return new TransformationListValueModelAdapter<TestModel, TestNode>(this.buildChildrenAdapter(model)) {
@Override
- protected Object transformItem(Object item) {
- return TestNode.this.buildChildNode((TestModel) item);
+ protected TestNode transformItem(TestModel item) {
+ return TestNode.this.buildChildNode(item);
}
};
}
@@ -463,15 +463,15 @@ public class TreeModelAdapterTests extends TestCase {
/**
* return a collection value model on the specified model's children
*/
- protected CollectionValueModel buildChildrenAdapter(TestModel model) {
- return new CollectionAspectAdapter(TestModel.CHILDREN_COLLECTION, model) {
+ protected CollectionValueModel<TestModel> buildChildrenAdapter(TestModel model) {
+ return new CollectionAspectAdapter<TestModel, TestModel>(TestModel.CHILDREN_COLLECTION, model) {
@Override
protected Iterator<TestModel> iterator_() {
- return ((TestModel) this.subject).children();
+ return this.subject.children();
}
@Override
protected int size_() {
- return ((TestModel) this.subject).childrenSize();
+ return this.subject.childrenSize();
}
};
}
@@ -611,11 +611,11 @@ public class TreeModelAdapterTests extends TestCase {
/** the list should be sorted */
@Override
protected ListValueModel buildChildrenModel(TestModel testModel) {
- return new SortedListValueModelAdapter(this.buildDisplayStringAdapter(testModel));
+ return new SortedListValueModelAdapter<TestNode>(this.buildDisplayStringAdapter(testModel));
}
/** the display string (name) of each node can change */
protected ListValueModel buildDisplayStringAdapter(TestModel testModel) {
- return new ItemPropertyListValueModelAdapter(this.buildNodeAdapter(testModel), DISPLAY_STRING_PROPERTY);
+ return new ItemPropertyListValueModelAdapter<TestNode>(this.buildNodeAdapter(testModel), DISPLAY_STRING_PROPERTY);
}
/** children are also sorted nodes */
@Override
diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
index 9e0319e34a..f8bee51a57 100644
--- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
+++ b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/model/value/swing/TreeModelAdapterUITest.java
@@ -39,6 +39,7 @@ import javax.swing.tree.TreeSelectionModel;
import org.eclipse.jpt.utility.internal.CollectionTools;
import org.eclipse.jpt.utility.internal.iterators.EnumerationIterator;
import org.eclipse.jpt.utility.internal.model.value.SimplePropertyValueModel;
+import org.eclipse.jpt.utility.internal.model.value.TreeNodeValueModel;
import org.eclipse.jpt.utility.internal.model.value.WritablePropertyValueModel;
import org.eclipse.jpt.utility.internal.model.value.swing.TreeModelAdapter;
import org.eclipse.jpt.utility.internal.swing.Displayable;
@@ -54,7 +55,7 @@ public class TreeModelAdapterUITest {
// hold the tree so we can restore its expansion state
private JTree tree;
- private WritablePropertyValueModel rootNodeHolder;
+ private WritablePropertyValueModel<TreeNodeValueModel<Object>> rootNodeHolder;
private boolean sorted;
private TreeModel treeModel;
private TreeSelectionModel treeSelectionModel;
@@ -77,8 +78,8 @@ public class TreeModelAdapterUITest {
this.openWindow();
}
- private WritablePropertyValueModel buildRootNodeHolder() {
- return new SimplePropertyValueModel(this.buildSortedRootNode());
+ private WritablePropertyValueModel<TreeNodeValueModel<Object>> buildRootNodeHolder() {
+ return new SimplePropertyValueModel<TreeNodeValueModel<Object>>(this.buildSortedRootNode());
}
private TestNode buildSortedRootNode() {
@@ -115,7 +116,7 @@ public class TreeModelAdapterUITest {
}
private TreeModel buildTreeModel() {
- return new TreeModelAdapter(this.rootNodeHolder);
+ return new TreeModelAdapter<Object>(this.rootNodeHolder);
}
private TreeSelectionModel buildTreeSelectionModel() {
@@ -225,7 +226,7 @@ public class TreeModelAdapterUITest {
if (this.treeSelectionModel.isSelectionEmpty()) {
return null;
}
- return (TestModel) this.selectedNode().value();
+ return this.selectedNode().value();
}
private TestNode rootNode() {
@@ -233,7 +234,7 @@ public class TreeModelAdapterUITest {
}
private TestModel root() {
- return (TestModel) this.rootNode().value();
+ return this.rootNode().value();
}
private Collection<TreePath> expandedPaths() {

Back to the top