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 should 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 Bug-Url: https://bugzilla.redhat.com/1023952 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/VnicProfileModel.java 2 files changed, 29 insertions(+), 22 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/21032/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..15c7c00 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 @@ -38,6 +38,8 @@ public abstract class VnicProfileModel extends Model { + private static NetworkQoS emptyQos; + private EntityModel name; private EntityModel portMirroring; private KeyValueModel customPropertySheet; @@ -49,8 +51,18 @@ private ListModel network; private ListModel networkQoS; private VnicProfile vnicProfile = null; - private boolean customPropertiesVisible; + private final boolean customPropertiesVisible; private Guid dcId; + private final Guid defaultQosId; + + private static NetworkQoS getEmptyQos() { + if (emptyQos == null) { + emptyQos = new NetworkQoS(); + emptyQos.setName(ConstantsManager.getInstance().getConstants().unlimitedQoSTitle()); + emptyQos.setId(Guid.Empty); + } + return emptyQos; + } public EntityModel getName() { @@ -140,8 +152,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 +167,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 +181,7 @@ getPortMirroring().setIsChangable(isPortMirroringSupported()); initCustomPropertySheet(); - initNetworkQoSList(qosId); + initNetworkQoSList(); } protected boolean isPortMirroringSupported() { @@ -304,7 +317,7 @@ } } - private void initNetworkQoSList(final Guid selectedItemId) { + private void initNetworkQoSList() { if (getDcId() == null) { return; } @@ -317,12 +330,9 @@ { ArrayList<NetworkQoS> networkQoSes = (ArrayList<NetworkQoS>) ((VdcQueryReturnValue) ReturnValue).getReturnValue(); - NetworkQoS none = new NetworkQoS(); - none.setName(ConstantsManager.getInstance().getConstants().unlimitedQoSTitle()); - none.setId(Guid.Empty); - networkQoSes.add(0, none); + networkQoSes.add(0, getEmptyQos()); getNetworkQoS().setItems(networkQoSes); - setSelectedNetworkQoSId(selectedItemId); + setSelectedNetworkQoSId(defaultQosId); } }; @@ -345,16 +355,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); } + getNetworkQoS().setSelectedItem(getEmptyQos()); } } -- To view, visit http://gerrit.ovirt.org/21032 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8e98a1fc26ce6b32076e09a67e6a3d82f52964df Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.3 Gerrit-Owner: Lior Vernia <lver...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches