Lior Vernia has uploaded a new change for review. Change subject: webadmin: Only update VM interfaces upon flush ......................................................................
webadmin: Only update VM interfaces upon flush Previously they were being updated as the widget was being edited, which upon initialization of the widget could overwrite valuable information (information had only been fetched once, but widget initialization could occur multiple times due to the cluster changing only after the VM dialog is opened). Change-Id: Icab490183dd25941d3cb7611fc164977780f38bd Bug-Url: https://bugzilla.redhat.com/1070835 Signed-off-by: Lior Vernia <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.java 2 files changed, 20 insertions(+), 10 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/25619/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java index b768397..feba284 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfileInstanceTypeEditor.java @@ -56,8 +56,7 @@ public void edit(final VnicInstanceType model) { driver.edit(model); - final VmNetworkInterface vnic = model.getNetworkInterface(); - String vnicName = vnic.getName(); + String vnicName = model.getNetworkInterface().getName(); profileEditor.setLabel(vnicName); profileEditor.setElementId(ElementIdUtils.createElementId(elementId, vnicName)); @@ -65,9 +64,6 @@ @Override public void eventRaised(Event ev, Object sender, EventArgs args) { - VnicProfileView profile = (VnicProfileView) model.getSelectedItem(); - vnic.setVnicProfileId(profile != null ? profile.getId() : null); - vnic.setNetworkName(profile != null ? profile.getNetworkName() : null); ValueChangeEvent.fire(ProfileInstanceTypeEditor.this, model); } }); @@ -75,7 +71,12 @@ @Override public VnicInstanceType flush() { - return driver.flush(); + VnicInstanceType model = driver.flush(); + VmNetworkInterface vnic = model.getNetworkInterface(); + VnicProfileView profile = (VnicProfileView) model.getSelectedItem(); + vnic.setVnicProfileId(profile != null ? profile.getId() : null); + vnic.setNetworkName(profile != null ? profile.getNetworkName() : null); + return model; } } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.java index 0ef1443..049d815 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.java @@ -45,10 +45,12 @@ private ListModel profilesModel; private IEventListener vnicsChangedListener; private Iterable<VnicProfileView> vnicProfiles; + private List<ProfileInstanceTypeEditor> widgets; private List<VmNetworkInterface> vnics; private int realEntryCount; public ProfilesInstanceTypeEditor() { + widgets = new ArrayList<ProfileInstanceTypeEditor>(); vnics = new ArrayList<VmNetworkInterface>(); initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); driver.initialize(this); @@ -82,6 +84,7 @@ vnicProfiles = new ArrayList<VnicProfileView>(); } + widgets.clear(); vnics.clear(); realEntryCount = 0; Iterable<VnicInstanceType> values = vnicsModel.getItems(); @@ -107,6 +110,10 @@ @Override public ListModel flush() { + for (ProfileInstanceTypeEditor widget : widgets) { + widget.flush(); + } + vnicsModel.getItemsChangedEvent().removeListener(vnicsChangedListener); // remove to avoid calling init() here flush(vnicsModel); vnicsModel.getItemsChangedEvent().addListener(vnicsChangedListener); // put back in case dialog wasn't closed @@ -127,6 +134,7 @@ @Override protected void onAdd(VnicInstanceType value, ProfileInstanceTypeEditor widget) { super.onAdd(value, widget); + widgets.add(widget); vnics.add(value.getNetworkInterface()); if (isGhost(value)) { // this will be offset when the entry is toggled to ghost @@ -138,6 +146,7 @@ @Override protected void onRemove(VnicInstanceType value, ProfileInstanceTypeEditor widget) { super.onRemove(value, widget); + widgets.remove(widget); vnics.remove(value.getNetworkInterface()); --realEntryCount; updateHeaderLabel(); @@ -148,14 +157,14 @@ protected ProfileInstanceTypeEditor createWidget(VnicInstanceType value) { VnicProfileView profile = (VnicProfileView) value.getSelectedItem(); - ProfileInstanceTypeEditor item = new ProfileInstanceTypeEditor(); - item.edit(value); - item.setElementId(elementId); + ProfileInstanceTypeEditor widget = new ProfileInstanceTypeEditor(); + widget.edit(value); + widget.setElementId(elementId); // small workaround due to UiCommonEditorVisitor changing null selected value value.setSelectedItem(profile); - return item; + return widget; } @Override -- To view, visit http://gerrit.ovirt.org/25619 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icab490183dd25941d3cb7611fc164977780f38bd Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
