Lior Vernia has uploaded a new change for review. Change subject: webadmin: Overload ListModel.setItems() with selectedItem ......................................................................
webadmin: Overload ListModel.setItems() with selectedItem Added an overload that includes an argument specifying the desired selectedItem after the items are set; previously this was being set to null, which could cause problems if the ListModel is associated with an editor that implements HasConstrainedValue (because then UiCommonEditorVisitor would override the null value and select the first item in the collection). Change-Id: Id6de644297cdd5eb965720fc64aea1a5a735ea24 Bug-Url: https://bugzilla.redhat.com/1070835 Signed-off-by: Lior Vernia <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ListModel.java 1 file changed, 18 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/26231/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ListModel.java index 6e57ba7..f0bdb4c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/ListModel.java @@ -1,5 +1,6 @@ package org.ovirt.engine.ui.uicommonweb.models; +import java.util.ArrayList; import java.util.List; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; import org.ovirt.engine.ui.uicommonweb.validation.ValidationResult; @@ -100,13 +101,17 @@ return items; } - public void setItems(Iterable<T> value) + public void setItems(Iterable<T> value) { + setItems(value, null); + } + + public void setItems(Iterable<T> value, T selectedItem) { if (items != value) { itemsChanging(value, items); items = value; - itemsChanged(); + itemsChanged(selectedItem); getItemsChangedEvent().raise(this, EventArgs.EMPTY); onPropertyChanged(new PropertyChangedEventArgs("Items")); //$NON-NLS-1$ } @@ -242,6 +247,17 @@ { } + protected void itemsChanged(T selectedItem) { + if (selectedItem == null) { + itemsChanged(); + } else { + List<T> selectedItems = new ArrayList<T>(); + selectedItems.add(selectedItem); + setSelectedItem(selectedItem); + setSelectedItems(selectedItems); + } + } + protected void itemsChanged() { // if Items are updated, SelectedItem and SelectedItems become irrelevant: -- To view, visit http://gerrit.ovirt.org/26231 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id6de644297cdd5eb965720fc64aea1a5a735ea24 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
