Lior Vernia has uploaded a new change for review. Change subject: webadmin: Refactoring in VnicProfilesEditor ......................................................................
webadmin: Refactoring in VnicProfilesEditor Replaced the non-standard edit() method with the standard one, that had been previously marked as deprecated. This required introducing a new class NetworkProfilesModel, but it's better practice (now developers don't have to be trusted to use the "correct" edit() method). Also took the chance to parameterize all the related ListModel instances, as the class is now generic. Change-Id: Id8b101f869d90d5e10636ac70e653376dc29f72d Signed-off-by: Lior Vernia <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkModel.java 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 A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NetworkProfilesModel.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 M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/AbstractNetworkPopupPresenterWidget.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/NewNetworkPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/datacenter/EditNetworkPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java 13 files changed, 108 insertions(+), 134 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/29/21629/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java index cedeb4f..ea2f372 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/AddRemoveRowWidget.java @@ -39,7 +39,7 @@ * @param <V> * the type of widget used to display each value. */ -public abstract class AddRemoveRowWidget<M extends ListModel, T, V extends Widget & HasValueChangeHandlers<T>> extends AbstractModelBoundPopupWidget<M> { +public abstract class AddRemoveRowWidget<M extends ListModel<T>, T, V extends Widget & HasValueChangeHandlers<T>> extends AbstractModelBoundPopupWidget<M> { public interface WidgetStyle extends CssResource { String buttonStyle(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java index d50efac..acbaa17 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkModel.java @@ -85,7 +85,7 @@ } @Override - protected void initProfiles() { + protected void updateProfiles() { AsyncQuery profilesQuery = new AsyncQuery(); profilesQuery.asyncCallback = new INewAsyncCallback() { @@ -93,9 +93,7 @@ public void onSuccess(Object model, Object returnValue) { List<VnicProfileModel> profilesModels = new LinkedList<VnicProfileModel>(); for (VnicProfileView profileView : (List<VnicProfileView>) returnValue) { - VnicProfileModel editModel = new EditVnicProfileModel(getSourceListModel(), - getSelectedDc().getcompatibility_version(), - profileView, getSelectedDc().getId(), false); + VnicProfileModel editModel = new EditVnicProfileModel(profileView); NetworkQoS networkQoS = new NetworkQoS(); networkQoS.setName(profileView.getNetworkQosName() == null @@ -107,12 +105,14 @@ profilesModels.add(editModel); editModel.getName().setIsChangable(false); } - originalProfileModels.clear(); - originalProfileModels.addAll(profilesModels); + originalProfileModels.addAll(profilesModels); if (profilesModels.isEmpty() && !(Boolean) getIsVmNetwork().getEntity()) { - profilesModels.add(getDefaultProfile()); + profilesModels.add(createDefaultProfile()); } + + getProfiles().updateDcId(getSelectedDc().getId()); + getProfiles().setDefaultProfile(getDefaultProfile()); getProfiles().setItems(profilesModels); } }; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkModel.java index c2f1cda..43ad970 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkModel.java @@ -21,6 +21,7 @@ import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.Model; +import org.ovirt.engine.ui.uicommonweb.models.profiles.NetworkProfilesModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; @@ -55,7 +56,7 @@ private boolean isSupportBridgesReportByVDSM = false; private boolean mtuOverrideSupported = false; private ListModel privateDataCenters; - private ListModel profiles; + private NetworkProfilesModel profiles; private final Network network; private final ListModel sourceListModel; private VnicProfileModel defaultProfile; @@ -125,7 +126,7 @@ EntityModel publicUse = new EntityModel(); publicUse.setEntity(true); - setProfiles(new ListModel()); + setProfiles(new NetworkProfilesModel()); // Update changeability according to initial values onExportChanged(); @@ -311,12 +312,12 @@ privateDataCenters = value; } - public ListModel getProfiles() + public NetworkProfilesModel getProfiles() { return profiles; } - private void setProfiles(ListModel value) + private void setProfiles(NetworkProfilesModel value) { profiles = value; } @@ -330,41 +331,40 @@ } public VnicProfileModel getDefaultProfile() { - if (defaultProfile == null) { - defaultProfile = createDefaultProfile(); - } return defaultProfile; } - private VnicProfileModel createDefaultProfile() { - final NewVnicProfileModel newModel = - new NewVnicProfileModel(getSourceListModel(), getSelectedDc().getcompatibility_version(), false, - getSelectedDc().getId()); + protected VnicProfileModel createDefaultProfile() { + if (defaultProfile != null) { + return defaultProfile; + } + + defaultProfile = new NewVnicProfileModel(); // make sure default profile's name is in sync with network's name - newModel.getName().setEntity(getName().getEntity()); + defaultProfile.getName().setEntity(getName().getEntity()); final IEventListener networkNameListener = new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { - newModel.getName().setEntity(getName().getEntity()); + defaultProfile.getName().setEntity(getName().getEntity()); } }; getName().getEntityChangedEvent().addListener(networkNameListener); // if user overrides default name, stop tracking network's name - newModel.getName().getEntityChangedEvent().addListener(new IEventListener() { + defaultProfile.getName().getEntityChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { - if (!newModel.getName().getEntity().equals(getName().getEntity())) { + if (!defaultProfile.getName().getEntity().equals(getName().getEntity())) { getName().getEntityChangedEvent().removeListener(networkNameListener); - newModel.getName().getEntityChangedEvent().removeListener(this); + defaultProfile.getName().getEntityChangedEvent().removeListener(this); } } }); - return newModel; + return defaultProfile; } public boolean validate() @@ -440,7 +440,7 @@ onExportChanged(); - initProfiles(); + updateProfiles(); } protected void addCommands() { @@ -479,7 +479,7 @@ network.setVlanId(Integer.parseInt(getVLanTag().getEntity().toString())); } - for (VnicProfileModel profileModel : (List<VnicProfileModel>) getProfiles().getItems()) { + for (VnicProfileModel profileModel : getProfiles().getItems()) { profileModel.flush(); } } @@ -568,7 +568,7 @@ protected abstract void selectExternalProvider(); - protected abstract void initProfiles(); + protected abstract void updateProfiles(); protected abstract void onExportChanged(); 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 cff3faf..fdfc2f8 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 @@ -51,6 +51,11 @@ private void init() { setTitle(ConstantsManager.getInstance().getConstants().newLogicalNetworkTitle()); setHashName("new_logical_network"); //$NON-NLS-1$ + + List<VnicProfileModel> profiles = new LinkedList<VnicProfileModel>(); + profiles.add(createDefaultProfile()); + getProfiles().setItems(profiles); + getProfiles().setDefaultProfile(getDefaultProfile()); } @Override @@ -107,19 +112,8 @@ } @Override - protected void initProfiles() { - 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(getDefaultProfile()); - 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(), getSelectedDc().getId()); - } - } + protected void updateProfiles() { + getProfiles().updateDcId(getSelectedDc().getId()); } @Override 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 8051aeef..95a1711 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 @@ -31,6 +31,10 @@ this(sourceModel, dcCompatibilityVersion, profile, dcId, true); } + public EditVnicProfileModel(VnicProfile profile) { + this(null, null, profile, null, false); + } + @Override protected void initCustomProperties() { getCustomPropertySheet().setEntity(KeyValueModel diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NetworkProfilesModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NetworkProfilesModel.java new file mode 100644 index 0000000..60ce706 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/profiles/NetworkProfilesModel.java @@ -0,0 +1,31 @@ +package org.ovirt.engine.ui.uicommonweb.models.profiles; + +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; + +public class NetworkProfilesModel extends ListModel<VnicProfileModel> { + + private EntityModel<Guid> dcId = new EntityModel<Guid>(); + private VnicProfileModel defaultProfile; + + public EntityModel<Guid> getDcId() { + return dcId; + } + + public void updateDcId(Guid dcId) { + for (VnicProfileModel profile : getItems()) { + profile.initNetworkQoSList(dcId); + } + getDcId().setEntity(dcId); + } + + public VnicProfileModel getDefaultProfile() { + return defaultProfile; + } + + public void setDefaultProfile(VnicProfileModel defaultProfile) { + this.defaultProfile = defaultProfile; + } + +} 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 c8de1d2..3e511d9 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 @@ -24,8 +24,8 @@ this(sourceModel, dcCompatibilityVersion, true, dcId); } - public NewVnicProfileModel(Version dcCompatibilityVersion, Guid dcId) { - this(null, dcCompatibilityVersion, dcId); + public NewVnicProfileModel() { + this(null, null, false, null); } @Override 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 8cc6b13..a12f7c7 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,12 +44,10 @@ private EntityModel publicUse; private EntityModel description; private final EntityModel sourceModel; - private Version dcCompatibilityVersion; private ListModel network; private ListModel networkQoS; private VnicProfile vnicProfile = null; private final boolean customPropertiesVisible; - private Guid dcId; private final Guid defaultQosId; private static NetworkQoS getEmptyQos() { @@ -105,20 +103,12 @@ this.description = description; } - public Version getDcCompatibilityVersion() { - return dcCompatibilityVersion; - } - public ListModel getNetwork() { return network; } public void setNetwork(ListModel network) { this.network = network; - } - - public EntityModel getSourceModel() { - return sourceModel; } public void setProfile(VnicProfile vnicProfile) { @@ -135,14 +125,6 @@ public void setNetworkQoS(ListModel networkQoS) { this.networkQoS = networkQoS; - } - - public Guid getDcId() { - return dcId; - } - - public void setDcId(Guid dcId) { - this.dcId = dcId; } public VnicProfileModel(EntityModel sourceModel, @@ -164,16 +146,9 @@ setPublicUse(publicUse); setDescription(new EntityModel()); - updateDc(dcCompatibilityVersion, dcId); + initCustomPropertySheet(dcCompatibilityVersion); + initNetworkQoSList(dcId); initCommands(); - } - - public void updateDc(Version dcCompatibilityVersion, Guid dcId) { - this.dcCompatibilityVersion = dcCompatibilityVersion; - this.dcId = dcId; - - initCustomPropertySheet(); - initNetworkQoSList(); } protected void initCommands() { @@ -264,13 +239,13 @@ } } - private void initCustomPropertySheet() { + private void initCustomPropertySheet(Version dcCompatibilityVersion) { if (!customPropertiesVisible) { return; } GetDeviceCustomPropertiesParameters params = new GetDeviceCustomPropertiesParameters(); - params.setVersion(getDcCompatibilityVersion()); + params.setVersion(dcCompatibilityVersion); params.setDeviceType(VmDeviceGeneralType.INTERFACE); startProgress(null); Frontend.RunQuery(VdcQueryType.GetDeviceCustomProperties, @@ -298,8 +273,8 @@ })); } - private void initNetworkQoSList() { - if (getDcId() == null) { + public void initNetworkQoSList(Guid dcId) { + if (dcId == null) { return; } @@ -317,7 +292,7 @@ } }; - IdQueryParameters queryParams = new IdQueryParameters(getDcId()); + IdQueryParameters queryParams = new IdQueryParameters(dcId); Frontend.RunQuery(VdcQueryType.GetAllNetworkQosByStoragePoolId, queryParams, _asyncQuery); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/AbstractNetworkPopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/AbstractNetworkPopupPresenterWidget.java index fc8e780..c7f359f 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/AbstractNetworkPopupPresenterWidget.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/AbstractNetworkPopupPresenterWidget.java @@ -1,12 +1,7 @@ package org.ovirt.engine.ui.webadmin.section.main.presenter.popup; -import org.ovirt.engine.core.common.businessentities.StoragePool; -import org.ovirt.engine.core.compat.Guid; -import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; -import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkModel; -import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel; import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; import org.ovirt.engine.ui.uicompat.IEventListener; @@ -24,8 +19,6 @@ void updateVisibility(); void toggleProfilesVisibility(boolean visible); - - void editProfiles(ListModel profiles, Version dcCompatibilityVersion, Guid dcId, VnicProfileModel defaultProfile); } public AbstractNetworkPopupPresenterWidget(EventBus eventBus, V view) { @@ -55,17 +48,6 @@ @Override public void eventRaised(Event ev, Object sender, EventArgs args) { getView().toggleProfilesVisibility((Boolean) model.getIsVmNetwork().getEntity()); - } - }); - - model.getDataCenters().getSelectedItemChangedEvent().addListener(new IEventListener() { - @Override - public void eventRaised(Event ev, Object sender, EventArgs args) { - StoragePool dc = model.getSelectedDc(); - getView().editProfiles(model.getProfiles(), - dc.getcompatibility_version(), - dc.getId(), - model.getDefaultProfile()); } }); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.java index b0d8489..9cf6068 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.java @@ -4,8 +4,6 @@ import org.ovirt.engine.core.common.businessentities.Provider; import org.ovirt.engine.core.common.businessentities.StoragePool; -import org.ovirt.engine.core.compat.Guid; -import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.common.idhandler.WithElementId; import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView; import org.ovirt.engine.ui.common.widget.Align; @@ -25,7 +23,6 @@ import org.ovirt.engine.ui.uicommonweb.models.ListModel; import org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkClusterModel; import org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkModel; -import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel; import org.ovirt.engine.ui.webadmin.ApplicationConstants; import org.ovirt.engine.ui.webadmin.ApplicationResources; import org.ovirt.engine.ui.webadmin.ApplicationTemplates; @@ -365,6 +362,11 @@ } @Override + public void edit(T model) { + profilesEditor.edit(model.getProfiles()); + } + + @Override public T flush() { profilesEditor.flush(); return null; @@ -378,15 +380,6 @@ @Override public void toggleProfilesVisibility(boolean visible) { profilesTab.setVisible(visible); - } - - @Override - public void editProfiles(ListModel profiles, - Version dcCompatibilityVersion, - Guid dcId, - VnicProfileModel defaultProfile) { - - profilesEditor.edit(profiles, dcCompatibilityVersion, dcId, defaultProfile); } interface WidgetStyle extends CssResource { diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/NewNetworkPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/NewNetworkPopupView.java index 913ff47..5f49835 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/NewNetworkPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/NewNetworkPopupView.java @@ -41,6 +41,7 @@ @Override public void edit(NewNetworkModel object) { + super.edit(object); driver.edit(object); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/datacenter/EditNetworkPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/datacenter/EditNetworkPopupView.java index 33d1805..3e7974d 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/datacenter/EditNetworkPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/datacenter/EditNetworkPopupView.java @@ -37,6 +37,7 @@ @Override public void edit(EditNetworkModel object) { + super.edit(object); driver.edit(object); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java index 2d70d7a..95b5c1b 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java @@ -1,57 +1,48 @@ package org.ovirt.engine.ui.webadmin.widget.vnicProfile; import org.ovirt.engine.core.compat.Guid; -import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.common.widget.AddRemoveRowWidget; -import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.NetworkProfilesModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel; import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel; +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.SimpleBeanEditorDriver; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.user.client.ui.Widget; -public class VnicProfilesEditor extends AddRemoveRowWidget<ListModel, VnicProfileModel, VnicProfileWidget> { - - interface Driver extends SimpleBeanEditorDriver<ListModel, VnicProfilesEditor> { - } - - private final Driver driver = GWT.create(Driver.class); +public class VnicProfilesEditor extends AddRemoveRowWidget<NetworkProfilesModel, VnicProfileModel, VnicProfileWidget> { interface WidgetUiBinder extends UiBinder<Widget, VnicProfilesEditor> { WidgetUiBinder uiBinder = GWT.create(WidgetUiBinder.class); } - private Version dcCompatibilityVersion; private Guid dcId; private VnicProfileModel defaultProfile; public VnicProfilesEditor() { initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); - driver.initialize(this); } - public void edit(ListModel model, Version dcCompatibilityVersion, Guid dcId, VnicProfileModel defaultProfile) { - driver.edit(model); - this.dcCompatibilityVersion = dcCompatibilityVersion; - this.dcId = dcId; - this.defaultProfile = defaultProfile; - super.edit(model); - } - - /** - * @deprecated Please use {@link #edit(ListModel, Version, Guid, VnicProfileModel)} instead. - **/ - @Deprecated @Override - public void edit(ListModel model) { - edit(model, dcCompatibilityVersion, dcId, defaultProfile); + protected void init(NetworkProfilesModel model) { + dcId = model.getDcId().getEntity(); + defaultProfile = model.getDefaultProfile(); + super.init(model); } - public ListModel flush() { - super.flush(); - return driver.flush(); + @Override + public void edit(final NetworkProfilesModel model) { + super.edit(model); + model.getDcId().getEntityChangedEvent().addListener(new IEventListener() { + + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + init(model); + } + }); } @Override @@ -63,7 +54,9 @@ @Override protected VnicProfileModel createGhostValue() { - return new NewVnicProfileModel(dcCompatibilityVersion, dcId); + VnicProfileModel profile = new NewVnicProfileModel(); + profile.initNetworkQoSList(dcId); + return profile; } @Override -- To view, visit http://gerrit.ovirt.org/21629 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id8b101f869d90d5e10636ac70e653376dc29f72d 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
