private HashMap<Object, Object> defaultPropertyValues;
+ private int nextGeneratedItemId = 1;
+
/* Container constructors */
public IndexedContainer() {
public Object addItem() {
// Creates a new id
- final Object id = new Object();
+ final Object id = generateId();
// Adds the Item into container
addItem(id);
public Object addItemAfter(Object previousItemId) {
// Creates a new id
- final Object id = new Object();
+ final Object id = generateId();
return addItemAfter(previousItemId, id);
}
public Object addItemAt(int index) {
// Creates a new id
- final Object id = new Object();
+ final Object id = generateId();
// Adds the Item into container
addItemAt(index, id);
return id;
}
+ private Serializable generateId() {
+ return new Integer(nextGeneratedItemId++);
+ }
+
/* Event notifiers */
/**
newField.setItemCaptionPropertyId("desc");
for (int i = 0; i < values.length; i++) {
Object id = values[i];
+ final Item item;
if (id == null) {
- id = new Object();
+ id = newField.addItem();
+ item = newField.getItem(id);
newField.setNullSelectionItemId(id);
+ } else {
+ item = newField.addItem(id);
}
- final Item item = newField.addItem(id);
+
if (item != null) {
item.getItemProperty("desc").setValue(
descriptions[i].toString());