Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Display default vNIC profile in tab
......................................................................

webadmin: Display default vNIC profile in tab

The user currently has no way of knowing we're intending to create
this profile, so now by default it's shown in the list of profiles to
be created for a network being added.

Change-Id: Iaa7b46a5cfd262bfdb9915993af0a1e524362055
Signed-off-by: Lior Vernia <lver...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewVnicProfileModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
4 files changed, 59 insertions(+), 34 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/19901/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkModel.java
index 5fe1bc7..d791e40 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkModel.java
@@ -25,8 +25,11 @@
 import org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel;
 import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
+import org.ovirt.engine.ui.uicompat.Event;
+import org.ovirt.engine.ui.uicompat.EventArgs;
 import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult;
 import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult;
+import org.ovirt.engine.ui.uicompat.IEventListener;
 import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback;
 import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback;
 
@@ -110,13 +113,35 @@
 
     @Override
     protected void initProfiles() {
-        List<VnicProfileModel> profiles = new LinkedList<VnicProfileModel>();
+        Iterable<VnicProfileModel> existingProfiles = getProfiles().getItems();
+        if (existingProfiles == null) {
+            // first run (dialog has just been opened and default DC chosen), 
create default entry
+            List<VnicProfileModel> profiles = new 
LinkedList<VnicProfileModel>();
+            profiles.add(createDefaultProfile());
+            getProfiles().setItems(profiles);
+        } else {
+            // not first run (user picked different DC), want to keep existing 
entries and update DC-related properties
+            for (VnicProfileModel profile : existingProfiles) {
+                profile.updateDc(getSelectedDc().getcompatibility_version(), 
false, getSelectedDc().getId(), null);
+            }
+        }
+    }
 
-        NewVnicProfileModel newModel =
+    private VnicProfileModel createDefaultProfile() {
+        final NewVnicProfileModel newModel =
                 new NewVnicProfileModel(getSourceListModel(), 
getSelectedDc().getcompatibility_version(), false,
                         getSelectedDc().getId());
-        profiles.add(newModel);
-        getProfiles().setItems(profiles);
+
+        // make sure default profile's name is in sync with network's name
+        getName().getEntityChangedEvent().addListener(new IEventListener() {
+
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                newModel.getName().setEntity(getName().getEntity());
+            }
+        });
+
+        return newModel;
     }
 
     @Override
@@ -151,16 +176,7 @@
 
         final AddNetworkStoragePoolParameters parameters =
                 new AddNetworkStoragePoolParameters(getSelectedDc().getId(), 
getNetwork());
-
-        boolean hasProfiles = false;
-        for (VnicProfileModel profileModel : ((List<VnicProfileModel>) 
getProfiles().getItems())) {
-            if 
(!StringHelper.isNullOrEmpty(profileModel.getProfile().getName())) {
-                hasProfiles = true;
-                break;
-            }
-        }
-
-        parameters.setVnicProfileRequired(!hasProfiles);
+        parameters.setVnicProfileRequired(false);
 
         // New network
         if ((Boolean) getExport().getEntity()) {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
index d06dc84..8051aeef 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/EditVnicProfileModel.java
@@ -15,7 +15,7 @@
             VnicProfile profile,
             Guid dcId,
             boolean customPropertiesVisible) {
-        super(sourceModel, dcCompatibilityVersion, customPropertiesVisible, 
dcId);
+        super(sourceModel, dcCompatibilityVersion, customPropertiesVisible, 
dcId, profile.getNetworkQosId());
         
setTitle(ConstantsManager.getInstance().getConstants().vnicProfileTitle());
         setHashName("edit_vnic_profile"); //$NON-NLS-1$
 
@@ -24,7 +24,6 @@
         getName().setEntity(profile.getName());
         getDescription().setEntity(profile.getDescription());
         getPortMirroring().setEntity(getProfile().isPortMirroring());
-        initNetworkQoSList(getProfile().getNetworkQosId());
         getPublicUse().setIsAvailable(false);
     }
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewVnicProfileModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewVnicProfileModel.java
index 9224abf..709463b 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewVnicProfileModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NewVnicProfileModel.java
@@ -10,12 +10,13 @@
 
 public class NewVnicProfileModel extends VnicProfileModel {
 
-    public NewVnicProfileModel(EntityModel sourceModel, Version 
dcCompatibilityVersion, boolean customPropertiesVisible,
-                               Guid dcId) {
-        super(sourceModel, dcCompatibilityVersion, customPropertiesVisible, 
dcId);
+    public NewVnicProfileModel(EntityModel sourceModel,
+            Version dcCompatibilityVersion,
+            boolean customPropertiesVisible,
+            Guid dcId) {
+        super(sourceModel, dcCompatibilityVersion, customPropertiesVisible, 
dcId, null);
         
setTitle(ConstantsManager.getInstance().getConstants().vnicProfileTitle());
         setHashName("new_vnic_profile"); //$NON-NLS-1$
-        initNetworkQoSList(null);
         getPortMirroring().setEntity(false);
     }
 
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
index 9784fe2..2bede08 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/VnicProfileModel.java
@@ -44,8 +44,8 @@
     private EntityModel publicUse;
     private EntityModel description;
     private final EntityModel sourceModel;
-    private final Version dcCompatibilityVersion;
-    private final boolean customPropertiesSupported;
+    private Version dcCompatibilityVersion;
+    private boolean customPropertiesSupported;
     private ListModel network;
     private ListModel networkQoS;
     private VnicProfile vnicProfile = null;
@@ -136,16 +136,12 @@
         this.dcId = dcId;
     }
 
-    public VnicProfileModel(EntityModel sourceModel, Version 
dcCompatibilityVersion, boolean customPropertiesVisible,
-                            Guid dcId) {
+    public VnicProfileModel(EntityModel sourceModel,
+            Version dcCompatibilityVersion,
+            boolean customPropertiesVisible,
+            Guid dcId,
+            Guid qosId) {
         this.sourceModel = sourceModel;
-        this.dcCompatibilityVersion = dcCompatibilityVersion;
-        this.customPropertiesVisible = customPropertiesVisible;
-        this.dcId = dcId;
-
-        customPropertiesSupported =
-                (Boolean) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.SupportCustomDeviceProperties,
-                        dcCompatibilityVersion.toString());
 
         setName(new EntityModel());
         setNetwork(new ListModel());
@@ -156,10 +152,23 @@
         publicUse.setEntity(true);
         setPublicUse(publicUse);
         setDescription(new EntityModel());
+
+        updateDc(dcCompatibilityVersion, customPropertiesVisible, dcId, qosId);
+        initCommands();
+    }
+
+    public void updateDc(Version dcCompatibilityVersion, boolean 
customPropertiesVisible, Guid dcId, Guid qosId) {
+        this.dcCompatibilityVersion = dcCompatibilityVersion;
+        this.customPropertiesVisible = customPropertiesVisible;
+        this.dcId = dcId;
+
+        customPropertiesSupported =
+                (Boolean) 
AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.SupportCustomDeviceProperties,
+                        dcCompatibilityVersion.toString());
+
         getPortMirroring().setIsChangable(isPortMirroringSupported());
         initCustomPropertySheet();
-
-        initCommands();
+        initNetworkQoSList(qosId);
     }
 
     protected boolean isPortMirroringSupported() {
@@ -295,7 +304,7 @@
         }
     }
 
-    public void initNetworkQoSList(final Guid selectedItemId) {
+    private void initNetworkQoSList(final Guid selectedItemId) {
         if (getDcId() == null) {
             return;
         }


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa7b46a5cfd262bfdb9915993af0a1e524362055
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