Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Add/Remove VNICs in Add/Edit VM dialog
......................................................................

webadmin: Add/Remove VNICs in Add/Edit VM dialog

Enabled adding/removing VNICs in the VM dialogs using
AddRemoveRowWidget.

Change-Id: Id7654d137541aec64ce19aa309021b307253171e
Signed-off-by: Lior Vernia <lver...@redhat.com>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java
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
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
9 files changed, 200 insertions(+), 117 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/19531/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
index 14a41f0..ab015b7 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationMessages.java
@@ -111,7 +111,7 @@
     @DefaultMessage("VM has 1 network interface. Assign a profile to it.")
     String assignNicsToProfilesSingular();
 
-    @DefaultMessage("VM has no network interfaces and there are no available 
profiles to choose from.")
+    @DefaultMessage("VM has no network interfaces. To add one, assign a 
profile.")
     String assignNicsNothingToAssign();
 
     @DefaultMessage("<Empty>")
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java
index 660f7fb..2254a8a 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBoxEditor.java
@@ -51,6 +51,11 @@
 
     }
 
+    @Override
+    public ListModelTypeAheadListBox<T> asWidget() {
+        return getContentWidget();
+    }
+
     public static abstract class NullSafeSuggestBoxRenderer<T> implements 
SuggestBoxRenderer<T> {
 
         private static final CommonApplicationTemplates templates = 
GWT.create(CommonApplicationTemplates.class);
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 268607a..b768397 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
@@ -1,45 +1,45 @@
 package org.ovirt.engine.ui.common.widget.profile;
 
-import java.util.Collection;
-
+import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfileView;
 import org.ovirt.engine.ui.common.idhandler.HasElementId;
 import org.ovirt.engine.ui.common.utils.ElementIdUtils;
-import org.ovirt.engine.ui.common.widget.editor.TakesConstrainedValueEditor;
+import 
org.ovirt.engine.ui.common.widget.uicommon.popup.AbstractModelBoundPopupWidget;
 import org.ovirt.engine.ui.uicommonweb.models.vms.VnicInstanceType;
+import org.ovirt.engine.ui.uicompat.Event;
+import org.ovirt.engine.ui.uicompat.EventArgs;
+import org.ovirt.engine.ui.uicompat.IEventListener;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.editor.client.IsEditor;
-import com.google.gwt.editor.client.adapters.TakesValueEditor;
+import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.event.logical.shared.HasValueChangeHandlers;
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
+import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
-import com.google.gwt.user.client.TakesValue;
-import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.Widget;
 
-public class ProfileInstanceTypeEditor extends Composite implements 
IsEditor<TakesValueEditor<VnicInstanceType>>, TakesValue<VnicInstanceType>, 
HasElementId {
+public class ProfileInstanceTypeEditor extends 
AbstractModelBoundPopupWidget<VnicInstanceType> implements 
HasValueChangeHandlers<VnicInstanceType>, HasElementId {
+
+    interface Driver extends SimpleBeanEditorDriver<VnicInstanceType, 
ProfileInstanceTypeEditor> {
+    }
+
+    private final Driver driver = GWT.create(Driver.class);
 
     interface WidgetUiBinder extends UiBinder<Widget, 
ProfileInstanceTypeEditor> {
         WidgetUiBinder uiBinder = GWT.create(WidgetUiBinder.class);
     }
 
     @UiField
+    @Path(value = "selectedItem")
     ProfileEditor profileEditor;
-    private VnicInstanceType vnicIntsanceType;
 
     private String elementId;
 
     public ProfileInstanceTypeEditor() {
         initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this));
-        ((HasValueChangeHandlers) 
profileEditor.asEditor().getSubEditor()).addValueChangeHandler(new 
ValueChangeHandler() {
-            @Override
-            public void onValueChange(ValueChangeEvent event) {
-                
profileEditor.asEditor().getSubEditor().setValue(event.getValue());
-            }
-        });
+        driver.initialize(this);
     }
 
     @Override
@@ -48,28 +48,34 @@
     }
 
     @Override
-    public void setValue(VnicInstanceType vnicInstanceType) {
-        this.vnicIntsanceType = vnicInstanceType;
-        
profileEditor.setLabel(vnicInstanceType.getNetworkInterface().getName());
-        profileEditor.asEditor().getSubEditor().setValue((VnicProfileView) 
vnicInstanceType.getSelectedItem());
-        ((TakesConstrainedValueEditor) 
profileEditor.asEditor().getSubEditor()).setAcceptableValues((Collection) 
vnicInstanceType.getItems());
-
-        profileEditor.setElementId(ElementIdUtils.createElementId(elementId, 
vnicInstanceType.getNetworkInterface()
-                .getName()));
+    public HandlerRegistration addValueChangeHandler(final 
ValueChangeHandler<VnicInstanceType> handler) {
+        return addHandler(handler, ValueChangeEvent.getType());
     }
 
     @Override
-    public VnicInstanceType getValue() {
-        // flush
-        VnicProfileView profile = (VnicProfileView) 
profileEditor.asEditor().getSubEditor().getValue();
-        vnicIntsanceType.getNetworkInterface().setVnicProfileId(profile != 
null ? profile.getId() : null);
-        vnicIntsanceType.getNetworkInterface().setNetworkName(profile != null 
? profile.getNetworkName() : null);
-        return vnicIntsanceType;
+    public void edit(final VnicInstanceType model) {
+        driver.edit(model);
+
+        final VmNetworkInterface vnic = model.getNetworkInterface();
+        String vnicName = vnic.getName();
+
+        profileEditor.setLabel(vnicName);
+        profileEditor.setElementId(ElementIdUtils.createElementId(elementId, 
vnicName));
+        model.getSelectedItemChangedEvent().addListener(new IEventListener() {
+
+            @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);
+            }
+        });
     }
 
     @Override
-    public TakesValueEditor<VnicInstanceType> asEditor() {
-        return TakesValueEditor.of(this);
+    public VnicInstanceType flush() {
+        return driver.flush();
     }
 
 }
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 69777b6..7e78769 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
@@ -1,35 +1,30 @@
 package org.ovirt.engine.ui.common.widget.profile;
 
 import com.google.gwt.core.client.GWT;
-import com.google.gwt.editor.client.IsEditor;
-import com.google.gwt.editor.client.adapters.TakesValueEditor;
-import com.google.gwt.event.logical.shared.ValueChangeHandler;
-import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.editor.client.SimpleBeanEditorDriver;
 import com.google.gwt.uibinder.client.UiBinder;
 import com.google.gwt.uibinder.client.UiField;
 import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.TakesValue;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.HasConstrainedValue;
 import com.google.gwt.user.client.ui.Label;
 import com.google.gwt.user.client.ui.Widget;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
+
+import 
org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface;
+import org.ovirt.engine.core.common.businessentities.network.VnicProfileView;
 import org.ovirt.engine.ui.common.CommonApplicationMessages;
 import org.ovirt.engine.ui.common.idhandler.HasElementId;
-import org.ovirt.engine.ui.common.widget.editor.TakesConstrainedValueEditor;
+import org.ovirt.engine.ui.common.widget.AddRemoveRowWidget;
+import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.models.ListModel;
 import org.ovirt.engine.ui.uicommonweb.models.vms.VnicInstanceType;
 
-public class ProfilesInstanceTypeEditor extends Composite implements 
IsEditor<TakesValueEditor<Object>>, TakesValue<Object>, HasElementId, 
HasConstrainedValue<Object> {
+public class ProfilesInstanceTypeEditor extends AddRemoveRowWidget<ListModel, 
VnicInstanceType, ProfileInstanceTypeEditor> implements HasElementId {
 
-    @Override
-    public HandlerRegistration 
addValueChangeHandler(ValueChangeHandler<Object> handler) {
-        // not needed - there is no selected item because all are edited
-        return null;
+    interface Driver extends SimpleBeanEditorDriver<ListModel, 
ProfilesInstanceTypeEditor> {
     }
+
+    private final Driver driver = GWT.create(Driver.class);
 
     interface WidgetUiBinder extends UiBinder<Widget, 
ProfilesInstanceTypeEditor> {
         WidgetUiBinder uiBinder = GWT.create(WidgetUiBinder.class);
@@ -37,77 +32,20 @@
 
     private String elementId = DOM.createUniqueId();
 
-    @UiField
-    FlowPanel contentPanel;
-
+    @Ignore
     @UiField
     Label headerLabel;
 
-    protected static final CommonApplicationMessages messages = 
GWT.create(CommonApplicationMessages.class);
+    private static final CommonApplicationMessages messages = 
GWT.create(CommonApplicationMessages.class);
 
-    private List<ProfileInstanceTypeEditor> editors;
+    private Iterable<VnicProfileView> vnicProfiles;
+    private List<VmNetworkInterface> vnics;
+    private int realEntryCount;
 
     public ProfilesInstanceTypeEditor() {
+        vnics = new ArrayList<VmNetworkInterface>();
         initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this));
-        editors = new ArrayList<ProfileInstanceTypeEditor>();
-    }
-
-    @Override
-    public void setValue(Object listModelValues) {
-        // not needed - there is no selected item because all are edited
-    }
-
-    @Override
-    public void setValue(Object value, boolean fireEvents) {
-        // not needed - there is no selected item because all are edited
-    }
-
-    @Override
-    public void setAcceptableValues(Collection<Object> values) {
-        editors.clear();
-        contentPanel.clear();
-
-        if (values == null || values.size() == 0) {
-            headerLabel.setText(messages.assignNicsNothingToAssign());
-            return;
-        }
-
-        for (Object value : values) {
-            ProfileInstanceTypeEditor networkEditor = new 
ProfileInstanceTypeEditor();
-            networkEditor.setElementId(elementId);
-            editors.add(networkEditor);
-            networkEditor.setValue((VnicInstanceType) value);
-            contentPanel.add(networkEditor);
-        }
-
-        if (values.size() == 1) {
-            headerLabel.setText(messages.assignNicsToProfilesSingular());
-        } else {
-            
headerLabel.setText(messages.assignNicsToProfilesPlural(values.size()));
-        }
-
-    }
-
-    public void flush() {
-        // this flushes it
-        getValue();
-    }
-
-    @Override
-    public ListModel getValue() {
-        List<VnicInstanceType> values = new ArrayList<VnicInstanceType>();
-        for (ProfileInstanceTypeEditor editor : editors) {
-            values.add(editor.getValue());
-        }
-
-        ListModel model = new ListModel();
-        model.setItems(values);
-        return model;
-    }
-
-    @Override
-    public TakesValueEditor<Object> asEditor() {
-        return TakesConstrainedValueEditor.of(this, this, this);
+        driver.initialize(this);
     }
 
     @Override
@@ -115,4 +53,105 @@
         this.elementId = elementId;
     }
 
+    public void edit(ListModel model, Iterable<VnicProfileView> vnicProfiles) {
+        driver.edit(model);
+
+        this.vnicProfiles = (vnicProfiles == null) ? new 
ArrayList<VnicProfileView>() : vnicProfiles;
+        vnics.clear();
+        realEntryCount = 0;
+        Iterable<VnicInstanceType> values = model.getItems();
+        if (values != null) {
+            for (VnicInstanceType value : values) {
+                vnics.add(value.getNetworkInterface());
+            }
+        }
+        updateHeaderLabel();
+
+        init(model);
+    }
+
+    @Override
+    public void edit(ListModel model) {
+        edit(model, null);
+    }
+
+
+    @Override
+    public ListModel flush() {
+        ListModel model = driver.flush();
+        flush(model);
+        return model;
+    }
+
+    private void updateHeaderLabel() {
+        if (realEntryCount == 0) {
+            headerLabel.setText(messages.assignNicsNothingToAssign());
+        } else if (realEntryCount == 1) {
+            headerLabel.setText(messages.assignNicsToProfilesSingular());
+        } else {
+            
headerLabel.setText(messages.assignNicsToProfilesPlural(realEntryCount));
+        }
+    }
+
+    @Override
+    protected void onAdd(VnicInstanceType value, ProfileInstanceTypeEditor 
widget) {
+        super.onAdd(value, widget);
+        vnics.add(value.getNetworkInterface());
+        if (isGhost(value)) {
+            // this will be offset when the entry is toggled to ghost
+            ++realEntryCount;
+        }
+        updateHeaderLabel();
+    }
+
+    @Override
+    protected void onRemove(VnicInstanceType value, ProfileInstanceTypeEditor 
widget) {
+        super.onRemove(value, widget);
+        vnics.remove(value.getNetworkInterface());
+        --realEntryCount;
+        updateHeaderLabel();
+    }
+
+    @Ignore
+    @Override
+    protected ProfileInstanceTypeEditor createWidget(VnicInstanceType value) {
+        VnicProfileView profile = (VnicProfileView) value.getSelectedItem();
+
+        ProfileInstanceTypeEditor item = new ProfileInstanceTypeEditor();
+        item.edit(value);
+        item.setElementId(elementId);
+
+        // small workaround due to UiCommonEditorVisitor changing null 
selected value
+        value.setSelectedItem(profile);
+
+        return item;
+    }
+
+    @Override
+    protected VnicInstanceType createGhostValue() {
+        VmNetworkInterface vnic = new VmNetworkInterface();
+        vnic.setName(AsyncDataProvider.getNewNicName(vnics));
+        vnics.add(vnic);
+        VnicInstanceType vnicWithProfile = new VnicInstanceType(vnic);
+        vnicWithProfile.setItems(vnicProfiles);
+        return vnicWithProfile;
+    }
+
+    @Override
+    protected boolean isGhost(VnicInstanceType value) {
+        return (value.getSelectedItem() == null);
+    }
+
+    @Override
+    protected void toggleGhost(VnicInstanceType value, 
ProfileInstanceTypeEditor item, boolean becomingGhost) {
+        item.profileEditor.setEnabled(!becomingGhost);
+        item.profileEditor.asWidget().setEnabled(true);
+
+        if (!becomingGhost) {
+            vnics.add(value.getNetworkInterface());
+        }
+        realEntryCount += (becomingGhost ? -1 : 1);
+        updateHeaderLabel();
+    }
+
 }
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml
index 3041088..7c93f5c 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/profile/ProfilesInstanceTypeEditor.ui.xml
@@ -2,18 +2,32 @@
 <!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent";>
 <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" 
xmlns:g="urn:import:com.google.gwt.user.client.ui">
 
-       <ui:style>
+       <ui:style 
type="org.ovirt.engine.ui.common.widget.AddRemoveRowWidget.WidgetStyle">
                .mainPanel {
                        border-top: 1px solid black;
                        float: left;
                        padding-left: 5px;
                        margin-left: 5px;
+                       width: 350px;
                }
 
                .headerLabel {
                        color: #919191;
                        padding-top: 5px;
                }
+
+               .entryStyle {
+                       width: 100%;
+               }
+
+               .buttonStyle {
+                       width: 9px;
+                       height: 11px;
+                       padding-left: 2px;
+                       padding-top: 2px;
+                       margin-top: 7px;
+                       margin-left: 50px;
+               }
        </ui:style>
 
        <g:FlowPanel addStyleNames="{style.mainPanel}" >
diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
index f2a4250..7d3f17b 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/AbstractVmPopupWidget.java
@@ -179,8 +179,7 @@
     public Panel logicalNetworksEditorPanel;
 
     @UiField
-    @Path(value = "nicsWithLogicalNetworks.selectedItem")
-    @WithElementId("networksEditor")
+    @Ignore
     public ProfilesInstanceTypeEditor profilesInstanceTypeEditor;
 
     @UiField
@@ -1161,6 +1160,15 @@
             }
         });
 
+        profilesInstanceTypeEditor.edit(object.getNicsWithLogicalNetworks(), 
object.getVnicProfiles().getItems());
+        
object.getNicsWithLogicalNetworks().getItemsChangedEvent().addListener(new 
IEventListener() {
+
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                
profilesInstanceTypeEditor.edit(object.getNicsWithLogicalNetworks(), 
object.getVnicProfiles()
+                        .getItems());
+            }
+        });
     }
 
     /**
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index d037005..aad08e7 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -2920,7 +2920,7 @@
         return diskInterfaces;
     }
 
-    public static String getNewNicName(ArrayList<VmNetworkInterface> 
existingInterfaces)
+    public static String getNewNicName(List<VmNetworkInterface> 
existingInterfaces)
     {
         int maxIfaceNumber = 0;
         if (existingInterfaces != null)
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index 8124329..21209eb 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -110,6 +110,16 @@
         this.dataCenterWithClustersList = dataCenterWithClustersList;
     }
 
+    private ListModel vnicProfiles;
+
+    public ListModel getVnicProfiles() {
+        return vnicProfiles;
+    }
+
+    private void setVnicProfiles(ListModel vnicProfiles) {
+        this.vnicProfiles = vnicProfiles;
+    }
+
     private ListModel nicsWithLogicalNetworks;
 
     public ListModel getNicsWithLogicalNetworks() {
@@ -1145,6 +1155,7 @@
         this.behavior = behavior;
         this.behavior.setModel(this);
 
+        setVnicProfiles(new ListModel());
         setNicsWithLogicalNetworks(new ListModel());
         setAdvancedMode(new EntityModel(false));
         setStorageDomain(new NotChangableForVmInPoolListModel());
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
index b0f1046..a897f69 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmModelBehaviorBase.java
@@ -1040,11 +1040,11 @@
         for (VmNetworkInterface nic : nics) {
             final VnicInstanceType vnicInstanceType = new 
VnicInstanceType(nic);
             vnicInstanceType.setItems(profiles);
-            behavior.initSelectedProfile(vnicInstanceType,
-                    vnicInstanceType.getNetworkInterface());
+            behavior.initSelectedProfile(vnicInstanceType, 
vnicInstanceType.getNetworkInterface());
             vnicInstanceTypes.add(vnicInstanceType);
         }
 
+        getModel().getVnicProfiles().setItems(profiles);
         getModel().getNicsWithLogicalNetworks().setItems(vnicInstanceTypes);
         
getModel().getNicsWithLogicalNetworks().setSelectedItem(Linq.firstOrDefault(vnicInstanceTypes));
     }


-- 
To view, visit http://gerrit.ovirt.org/19531
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id7654d137541aec64ce19aa309021b307253171e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <lver...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to