Lior Vernia has uploaded a new change for review. Change subject: webadmin: Small refactoring to simplify VnicProfileModel ......................................................................
webadmin: Small refactoring to simplify VnicProfileModel It wasn't really clear what exactly dcId and dcCompatibilityVersion were affecting, whereas customPropertiesVisible was passed around as a parameter when it really shoul only be set when the VnicProfileModel is constructed. Also theoretically improved the behavior of selecting a QoS configuration from the list. Currently when editing a network the DC can't be changed, but if that is enabled in the future, then if the DC will be switched and then switched back, the original QoS selection will be salvaged. Change-Id: I8e98a1fc26ce6b32076e09a67e6a3d82f52964df Signed-off-by: Lior Vernia <[email protected]> --- 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/VnicProfileModel.java 2 files changed, 17 insertions(+), 18 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/49/20749/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 2830021..101b749 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 @@ -117,7 +117,7 @@ } 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); + profile.updateDc(getSelectedDc().getcompatibility_version(), getSelectedDc().getId()); } } } 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 7def287..854bae7 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 @@ -49,8 +49,9 @@ private ListModel network; private ListModel networkQoS; private VnicProfile vnicProfile = null; - private boolean customPropertiesVisible; + private final boolean customPropertiesVisible; private Guid dcId; + private final Guid defaultQosId; public EntityModel getName() { @@ -140,8 +141,10 @@ Version dcCompatibilityVersion, boolean customPropertiesVisible, Guid dcId, - Guid qosId) { + Guid defaultQosId) { this.sourceModel = sourceModel; + this.customPropertiesVisible = customPropertiesVisible; + this.defaultQosId = defaultQosId; setName(new EntityModel()); setNetwork(new ListModel()); @@ -153,13 +156,12 @@ setPublicUse(publicUse); setDescription(new EntityModel()); - updateDc(dcCompatibilityVersion, customPropertiesVisible, dcId, qosId); + updateDc(dcCompatibilityVersion, dcId); initCommands(); } - public void updateDc(Version dcCompatibilityVersion, boolean customPropertiesVisible, Guid dcId, Guid qosId) { + public void updateDc(Version dcCompatibilityVersion, Guid dcId) { this.dcCompatibilityVersion = dcCompatibilityVersion; - this.customPropertiesVisible = customPropertiesVisible; this.dcId = dcId; customPropertiesSupported = @@ -168,7 +170,7 @@ getPortMirroring().setIsChangable(isPortMirroringSupported()); initCustomPropertySheet(); - initNetworkQoSList(qosId); + initNetworkQoSList(); } protected boolean isPortMirroringSupported() { @@ -304,7 +306,7 @@ } } - private void initNetworkQoSList(final Guid selectedItemId) { + private void initNetworkQoSList() { if (getDcId() == null) { return; } @@ -322,7 +324,7 @@ none.setId(Guid.Empty); networkQoSes.add(0, none); getNetworkQoS().setItems(networkQoSes); - setSelectedNetworkQoSId(selectedItemId); + setSelectedNetworkQoSId(defaultQosId); } }; @@ -345,16 +347,13 @@ return new VnicProfileParameters(vnicProfile); } - public void setSelectedNetworkQoSId(Guid networkQoSId) { - if (networkQoSId != null) { - for (Object item : getNetworkQoS().getItems()) { - if (((NetworkQoS)item).getId().equals(networkQoSId)) { - getNetworkQoS().setSelectedItem(item); - break; - } + private void setSelectedNetworkQoSId(Guid networkQoSId) { + for (Object item : getNetworkQoS().getItems()) { + if (((NetworkQoS) item).getId().equals(networkQoSId)) { + getNetworkQoS().setSelectedItem(item); + return; } - } else { - setSelectedNetworkQoSId(Guid.Empty); } + setSelectedNetworkQoSId(Guid.Empty); } } -- To view, visit http://gerrit.ovirt.org/20749 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e98a1fc26ce6b32076e09a67e6a3d82f52964df Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Lior Vernia <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
