Alona Kaplan has uploaded a new change for review. Change subject: webadmin: add profiles tab to add/edit network dialogs ......................................................................
webadmin: add profiles tab to add/edit network dialogs The tab will enable removing exsisting profiles and adding new profiles to the network. In this phase the user will be able to set just the name and the public use properties if each profile. Change-Id: I1b88f0458862e136e5ff035883cb044ef1e896b5 Signed-off-by: Alona Kaplan <alkap...@redhat.com> --- 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/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 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/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.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/AbstractNetworkPopupView.ui.xml A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml 15 files changed, 548 insertions(+), 36 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/99/17499/1 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 6655597..874d33a 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 @@ -3159,7 +3159,7 @@ { if (source == null) { - return new ArrayList<VnicProfile>(); + return new ArrayList<VnicProfileView>(); } return source; } 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 fb40e04d..23e5341 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 @@ -1,16 +1,32 @@ package org.ovirt.engine.ui.uicommonweb.models.datacenters; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + import org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.network.Network; +import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; +import org.ovirt.engine.core.compat.Guid; +import org.ovirt.engine.ui.frontend.AsyncQuery; import org.ovirt.engine.ui.frontend.Frontend; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.EditVnicProfileModel; +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.FrontendActionAsyncResult; +import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult; import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback; +import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback; public class EditNetworkModel extends NetworkModel { + + private List<VnicProfileModel> originalProfileModels = new ArrayList<VnicProfileModel>(); public EditNetworkModel(Network network, ListModel sourceListModel) { super(network, sourceListModel); @@ -59,6 +75,35 @@ } @Override + protected void initProfiles() { + AsyncQuery profilesQuery = new AsyncQuery(); + profilesQuery.asyncCallback = new INewAsyncCallback() { + + @Override + 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, false); + profilesModels.add(editModel); + + editModel.getName().setIsChangable(false); + editModel.getPublicUse().setIsChangable(false); + + } + if (profilesModels.isEmpty()){ + profilesModels.add(new NewVnicProfileModel(getSourceListModel(), + getSelectedDc().getcompatibility_version(), false)); + } + getProfiles().setItems(profilesModels); + originalProfileModels = profilesModels; + } + }; + AsyncDataProvider.getVnicProfilesByNetworkId(profilesQuery, getNetwork().getId()); + } + + @Override protected void onExportChanged() { if ((Boolean) getExport().getEntity()) { getHasVLanTag().setIsChangable(false); @@ -84,4 +129,41 @@ }, null); } + + @Override + protected void performProfilesActions(final Guid networkGuid) { + + List<VnicProfileModel> profileModels = (List<VnicProfileModel>) getProfiles().getItems(); + List<VnicProfileModel> profileModelsToRemove = new ArrayList<VnicProfileModel>(profileModels); + profileModelsToRemove.removeAll(profileModels); + + final List<VnicProfileModel> profileModelsToAdd = new ArrayList<VnicProfileModel>(); + + for (VnicProfileModel profileModel : profileModels) { + if (profileModel instanceof NewVnicProfileModel) { + profileModelsToAdd.add(profileModel); + } + } + startProgress(null); + + performVnicProfileAction(VdcActionType.RemoveVnicProfile, + profileModelsToRemove, + new IFrontendMultipleActionAsyncCallback() { + + @Override + public void executed(FrontendMultipleActionAsyncResult result) { + performVnicProfileAction(VdcActionType.AddVnicProfile, + profileModelsToAdd, + new IFrontendMultipleActionAsyncCallback() { + + @Override + public void executed(FrontendMultipleActionAsyncResult result) { + stopProgress(); + cancel(); + } + }, networkGuid); + } + }, networkGuid); + } + } 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 cbd5dc9..ee1cf50 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 @@ -1,15 +1,24 @@ package org.ovirt.engine.ui.uicommonweb.models.datacenters; +import java.util.ArrayList; +import java.util.List; + +import org.ovirt.engine.core.common.action.VdcActionParametersBase; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VnicProfileParameters; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.network.Network; +import org.ovirt.engine.core.common.businessentities.network.VnicProfile; import org.ovirt.engine.core.common.queries.ConfigurationValues; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.StringHelper; +import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; 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.VnicProfileModel; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; import org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation; import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation; @@ -20,6 +29,7 @@ import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; import org.ovirt.engine.ui.uicompat.IEventListener; +import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback; public abstract class NetworkModel extends Model { @@ -42,6 +52,7 @@ private boolean isSupportBridgesReportByVDSM = false; private boolean mtuOverrideSupported = false; private ListModel privateDataCenters; + private ListModel profiles; private final Network network; private final ListModel sourceListModel; @@ -109,6 +120,8 @@ EntityModel publicUse = new EntityModel(); publicUse.setEntity(true); setPublicUse(publicUse); + + setProfiles(new ListModel()); // Update changeability according to initial values onExportChanged(); @@ -286,6 +299,16 @@ privateDataCenters = value; } + public ListModel getProfiles() + { + return profiles; + } + + private void setProfiles(ListModel value) + { + profiles = value; + } + public Network getNetwork() { return network; } @@ -329,7 +352,7 @@ getMtu().validateEntity(new IValidation[] { new NotEmptyValidation(), tempVar5 }); } - getExternalProviders().validateSelectedItem(new IValidation [] { new NotEmptyValidation() }); + getExternalProviders().validateSelectedItem(new IValidation[] { new NotEmptyValidation() }); return getName().getIsValid() && getVLanTag().getIsValid() && getDescription().getIsValid() && getMtu().getIsValid() && getExternalProviders().getIsValid() && getComment().getIsValid(); @@ -357,6 +380,8 @@ setMTUOverrideSupported(isMTUOverrideSupported); onExportChanged(); + + initProfiles(); } protected void addCommands() { @@ -394,6 +419,10 @@ { network.setVlanId(Integer.parseInt(getVLanTag().getEntity().toString())); } + + for (VnicProfileModel profileModel : (List<VnicProfileModel>) getProfiles().getItems()) { + profileModel.flush(); + } } protected abstract void executeSave(); @@ -401,12 +430,36 @@ protected void postSaveAction(Guid networkGuid, boolean succeeded) { if (succeeded) { - cancel(); + performProfilesActions(networkGuid); } stopProgress(); } - private void cancel() { + protected abstract void performProfilesActions(Guid networkGuid); + + protected void performVnicProfileAction(VdcActionType action, + List<VnicProfileModel> profileModels, + IFrontendMultipleActionAsyncCallback callback, Guid networkGuid) { + if (profileModels.isEmpty()) { + callback.executed(null); + } + + networkGuid = networkGuid == null ? getNetwork().getId() : networkGuid; + ArrayList<VdcActionParametersBase> paramlist = new ArrayList<VdcActionParametersBase>(); + for (VnicProfileModel profileModel : profileModels) + { + if (!StringHelper.isNullOrEmpty(profileModel.getProfile().getName())) { + VnicProfile vnicProfile = profileModel.getProfile(); + vnicProfile.setNetworkId(networkGuid); + VdcActionParametersBase parameters = new VnicProfileParameters(vnicProfile); + paramlist.add(parameters); + } + } + + Frontend.RunMultipleAction(action, paramlist, callback, null); + } + + void cancel() { sourceListModel.setWindow(null); sourceListModel.setConfirmWindow(null); } @@ -448,6 +501,8 @@ protected abstract void initIsVm(); + protected abstract void initProfiles(); + protected abstract void onExportChanged(); private void updateVlanTagChangeability() { 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 2594d7a..9b6f6be 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 @@ -1,6 +1,7 @@ package org.ovirt.engine.ui.uicommonweb.models.datacenters; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.ovirt.engine.core.common.action.AddNetworkStoragePoolParameters; @@ -19,9 +20,13 @@ import org.ovirt.engine.ui.frontend.INewAsyncCallback; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; import org.ovirt.engine.ui.uicommonweb.models.ListModel; +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.FrontendActionAsyncResult; +import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult; import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback; +import org.ovirt.engine.ui.uicompat.IFrontendMultipleActionAsyncCallback; public class NewNetworkModel extends NetworkModel { @@ -93,6 +98,14 @@ @Override protected void initIsVm() { getIsVmNetwork().setEntity(true); + } + + @Override + protected void initProfiles() { + List<VnicProfileModel> profiles = new LinkedList<VnicProfileModel>(); + + profiles.add(new NewVnicProfileModel(getSourceListModel(), getSelectedDc().getcompatibility_version(), false)); + getProfiles().setItems(profiles); } @Override @@ -188,4 +201,18 @@ } return clusterToAttach; } + + @Override + protected void performProfilesActions(Guid networkGuid) { + performVnicProfileAction(VdcActionType.AddVnicProfile, + (List<VnicProfileModel>) getProfiles().getItems(), + new IFrontendMultipleActionAsyncCallback() { + @Override + public void executed(FrontendMultipleActionAsyncResult result) { + stopProgress(); + cancel(); + + } + }, networkGuid); + } } 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 f242966..f993597 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 @@ -9,21 +9,22 @@ public class EditVnicProfileModel extends VnicProfileModel { - private VnicProfile profile; - - public EditVnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion, VnicProfile profile) { - super(sourceModel, dcCompatibilityVersion); + public EditVnicProfileModel(EntityModel sourceModel, + Version dcCompatibilityVersion, + VnicProfile profile, + boolean customPropertiesVisible) { + super(sourceModel, dcCompatibilityVersion, customPropertiesVisible); setTitle(ConstantsManager.getInstance().getConstants().vnicProfileTitle()); setHashName("edit_vnic_profile"); //$NON-NLS-1$ - this.profile = profile; + setProfile(profile); getName().setEntity(profile.getName()); getPortMirroring().setEntity(getProfile().isPortMirroring()); } - public VnicProfile getProfile() { - return profile; + public EditVnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion, VnicProfile profile) { + this(sourceModel, dcCompatibilityVersion, profile, true); } @Override 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 ee7efa7..adeee45 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 @@ -1,24 +1,22 @@ package org.ovirt.engine.ui.uicommonweb.models.profiles; import org.ovirt.engine.core.common.action.VdcActionType; -import org.ovirt.engine.core.common.businessentities.network.VnicProfile; import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; public class NewVnicProfileModel extends VnicProfileModel { - public NewVnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion) { - super(sourceModel, dcCompatibilityVersion); + public NewVnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion, boolean customPropertiesVisible) { + super(sourceModel, dcCompatibilityVersion, customPropertiesVisible); setTitle(ConstantsManager.getInstance().getConstants().vnicProfileTitle()); setHashName("new_vnic_profile"); //$NON-NLS-1$ getPortMirroring().setEntity(false); } - public VnicProfile getProfile() { - // no profile for new - return null; + public NewVnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion) { + this(sourceModel, dcCompatibilityVersion, true); } @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 f5c5b37..edbc64b 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 @@ -42,6 +42,8 @@ private final Version dcCompatibilityVersion; private final boolean customPropertiesSupported; private ListModel network; + private VnicProfile vnicProfile = null; + private boolean customPropertiesVisible; public EntityModel getName() { @@ -95,9 +97,18 @@ return sourceModel; } - public VnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion) { + public void setProfile(VnicProfile vnicProfile) { + this.vnicProfile = vnicProfile; + } + + public VnicProfile getProfile() { + return vnicProfile; + } + + public VnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion, boolean customPropertiesVisible) { this.sourceModel = sourceModel; this.dcCompatibilityVersion = dcCompatibilityVersion; + this.customPropertiesVisible = customPropertiesVisible; customPropertiesSupported = (Boolean) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.SupportCustomDeviceProperties, @@ -114,6 +125,10 @@ initCustomPropertySheet(); initCommands(); + } + + public VnicProfileModel(EntityModel sourceModel, Version dcCompatibilityVersion) { + this(sourceModel, dcCompatibilityVersion, true); } protected boolean isPortMirroringSupported() { @@ -146,23 +161,13 @@ return; } - VnicProfile profile = getProfile(); - - if (profile == null) { - profile = new VnicProfile(); - } - // Save changes. - profile.setName((String) getName().getEntity()); - Network network = (Network) getNetwork().getSelectedItem(); - profile.setNetworkId(network != null ? network.getId() : null); - profile.setPortMirroring((Boolean) getPortMirroring().getEntity()); - profile.setCustomProperties(KeyValueModel.convertProperties(getCustomPropertySheet().getEntity())); + flush(); startProgress(null); Frontend.RunAction(getVdcActionType(), - new VnicProfileParameters(profile), + new VnicProfileParameters(vnicProfile), new IFrontendActionAsyncCallback() { @Override public void executed(FrontendActionAsyncResult result) { @@ -176,6 +181,22 @@ } }, this); + } + + public void flush() { + if (vnicProfile == null) { + vnicProfile = new VnicProfile(); + } + vnicProfile.setName((String) getName().getEntity()); + Network network = (Network) getNetwork().getSelectedItem(); + vnicProfile.setNetworkId(network != null ? network.getId() : null); + vnicProfile.setPortMirroring((Boolean) getPortMirroring().getEntity()); + + if (customPropertiesVisible) { + vnicProfile.setCustomProperties(KeyValueModel.convertProperties(getCustomPropertySheet().getEntity())); + } else { + vnicProfile.setCustomProperties(null); + } } private void cancel() @@ -199,6 +220,10 @@ } private void initCustomPropertySheet() { + if (!customPropertiesVisible) { + return; + } + if (customPropertiesSupported) { GetDeviceCustomPropertiesParameters params = new GetDeviceCustomPropertiesParameters(); params.setVersion(getDcCompatibilityVersion()); @@ -238,8 +263,6 @@ return getName().getIsValid() && getCustomPropertySheet().validate(); } - - public abstract VnicProfile getProfile(); protected abstract void initCustomProperties(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java index 2291d40..ae0de1d 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java @@ -281,7 +281,7 @@ } for (KeyValueLineModel keyValueLineModel : (List<KeyValueLineModel>) getKeyValueLines().getItems()) { String key = (String) keyValueLineModel.getKeys().getSelectedItem(); - if (key.equals(NO_KEYS) || key.equals(SELECT_KEY)) { + if (key == null || key.equals(NO_KEYS) || key.equals(SELECT_KEY)) { continue; } builder.append(key); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index 0c77d21..7865aa9 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -184,6 +184,9 @@ @DefaultStringValue("Export") String exportLabel(); + @DefaultStringValue("vNic Profiles") + String profilesLabel(); + @DefaultStringValue("Create on external provider") String exportCheckboxLabel(); @@ -1054,6 +1057,9 @@ @DefaultStringValue("Cluster") String clusterTabNetworkPopup(); + + @DefaultStringValue("Profiles") + String profilesTabNetworkPopup(); @DefaultStringValue("General") String networkGeneralSubTabLabel(); @@ -2848,6 +2854,9 @@ @DefaultStringValue("Allow all users to use this Profile") String profilePublicUseLabel(); + @DefaultStringValue("Public") + String profilePublicUseInstanceTypeLabel(); + @DefaultStringValue("Some hosts in this cluster have the console address overridden and some not. For details please see the Hosts subtab") String consolePartiallyOverridden(); 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 f5b695b..7502c1a 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 @@ -27,6 +27,7 @@ import org.ovirt.engine.ui.webadmin.ApplicationTemplates; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.AbstractNetworkPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.widget.table.column.CheckboxHeader; +import org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfilesEditor; import com.google.gwt.cell.client.Cell.Context; import com.google.gwt.cell.client.FieldUpdater; @@ -132,6 +133,10 @@ public EntityModelTextBoxEditor networkLabel; @UiField + @Path(value = "profiles.selectedItem") + public VnicProfilesEditor profilesEditor; + + @UiField @Ignore public DialogTab generalTab; @@ -139,8 +144,16 @@ @Ignore public DialogTab clusterTab; - @Inject - public AbstractNetworkPopupView(EventBus eventBus, ApplicationResources resources, + @UiField + @Ignore + public DialogTab profilesTab; + + @UiField + @Ignore + public Label profilesLabel; + + @Inject + public AbstractNetworkPopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants, ApplicationTemplates templates) { super(eventBus, resources); // Initialize Editors @@ -171,6 +184,7 @@ protected void localize(ApplicationConstants constants) { generalTab.setLabel(constants.generalTabNetworkPopup()); clusterTab.setLabel(constants.clusterTabNetworkPopup()); + profilesTab.setLabel(constants.profilesTabNetworkPopup()); dataCenterEditor.setLabel(constants.networkPopupDataCenterLabel()); assignLabel.setText(constants.networkPopupAssignLabel()); @@ -185,9 +199,11 @@ vlanTagging.setLabel(constants.enableVlanTagLabel()); hasMtuEditor.setLabel(constants.overrideMtuLabel()); publicUseEditor.setLabel(constants.networkPublicUseLabel()); + + profilesLabel.setText(constants.profilesLabel()); } - protected void addStyles() { + protected void addStyles() { vlanTag.addContentWidgetStyleName(style.vlanEditor()); mtuEditor.addContentWidgetStyleName(style.mtuEditor()); isVmNetworkEditor.addContentWidgetStyleName(style.checkBox()); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.ui.xml index 58413ba..a3d4b1d 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/AbstractNetworkPopupView.ui.xml @@ -3,6 +3,7 @@ <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" xmlns:we="urn:import:org.ovirt.engine.ui.webadmin.widget.editor" + xmlns:v="urn:import:org.ovirt.engine.ui.webadmin.widget.vnicProfile" xmlns:t="urn:import:org.ovirt.engine.ui.common.widget.dialog.tab"> <ui:with field='constants' type='org.ovirt.engine.ui.webadmin.ApplicationConstants' /> @@ -112,6 +113,16 @@ </t:content> </t:DialogTab> </t:tab> + <t:tab> + <t:DialogTab ui:field="profilesTab"> + <t:content> + <g:FlowPanel> + <g:Label ui:field="profilesLabel" addStyleNames="{style.mainLabel}" /> + <v:VnicProfilesEditor ui:field="profilesEditor" /> + </g:FlowPanel> + </t:content> + </t:DialogTab> + </t:tab> </t:DialogTabPanel> </d:content> </d:SimpleDialogPanel> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.java new file mode 100644 index 0000000..51cb666 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.java @@ -0,0 +1,76 @@ +package org.ovirt.engine.ui.webadmin.widget.vnicProfile; + +import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.idhandler.WithElementId; +import org.ovirt.engine.ui.common.widget.editor.EntityModelCheckBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxOnlyEditor; +import org.ovirt.engine.ui.common.widget.uicommon.popup.AbstractModelBoundPopupWidget; +import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfileWidget.ViewIdHandler; +import org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfilesEditor.WidgetStyle; +import org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfilesEditor.WidgetUiBinder; +import org.ovirt.engine.ui.common.widget.Align; + +import com.google.gwt.core.client.GWT; +import com.google.gwt.editor.client.SimpleBeanEditorDriver; +import com.google.gwt.resources.client.CssResource; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Widget; + +public class VnicProfileWidget extends AbstractModelBoundPopupWidget<VnicProfileModel> { + + interface Driver extends SimpleBeanEditorDriver<VnicProfileModel, VnicProfileWidget> { + } + + interface WidgetUiBinder extends UiBinder<Widget, VnicProfileWidget> { + WidgetUiBinder uiBinder = GWT.create(WidgetUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<VnicProfileWidget> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + @UiField + @Path("name.entity") + @WithElementId("name") + EntityModelTextBoxOnlyEditor nameEditor; + + @UiField(provided = true) + @Path(value = "publicUse.entity") + public EntityModelCheckBoxEditor publicUseEditor; + + private VnicProfileModel vnicProfileModel; + + @UiField + WidgetStyle style; + + private final Driver driver = GWT.create(Driver.class); + + private final static ApplicationConstants constants = GWT.create(ApplicationConstants.class); + + public VnicProfileWidget() { + publicUseEditor = new EntityModelCheckBoxEditor(Align.RIGHT); + initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); + publicUseEditor.setLabel(constants.profilePublicUseInstanceTypeLabel()); + publicUseEditor.addContentWidgetStyleName(style.publicUse()); + ViewIdHandler.idHandler.generateAndSetIds(this); + driver.initialize(this); + } + + @Override + public void edit(VnicProfileModel object) { + driver.edit(object); + } + + @Override + public VnicProfileModel flush() { + return driver.flush(); + } + + interface WidgetStyle extends CssResource { + String publicUse(); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml new file mode 100644 index 0000000..a809269 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfileWidget.ui.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!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" + xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor"> + + <ui:style type="org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfileWidget.WidgetStyle" > + .publicUse { + width: 75px; + } + </ui:style> + <g:HorizontalPanel> + <e:EntityModelTextBoxOnlyEditor ui:field="nameEditor" /> + <e:EntityModelCheckBoxEditor ui:field="publicUseEditor"/> + </g:HorizontalPanel> + +</ui:UiBinder> 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 new file mode 100644 index 0000000..58e3588 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.java @@ -0,0 +1,155 @@ +package org.ovirt.engine.ui.webadmin.widget.vnicProfile; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.ovirt.engine.ui.common.CommonApplicationMessages; +import org.ovirt.engine.ui.common.CommonApplicationResources; +import org.ovirt.engine.ui.common.widget.editor.TakesConstrainedValueEditor; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.NewVnicProfileModel; +import org.ovirt.engine.ui.uicommonweb.models.profiles.VnicProfileModel; + +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.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; +import com.google.gwt.event.logical.shared.ValueChangeHandler; +import com.google.gwt.event.shared.HandlerRegistration; +import com.google.gwt.resources.client.CssResource; +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.FlowPanel; +import com.google.gwt.user.client.ui.HasConstrainedValue; +import com.google.gwt.user.client.ui.HorizontalPanel; +import com.google.gwt.user.client.ui.Image; +import com.google.gwt.user.client.ui.PushButton; +import com.google.gwt.user.client.ui.Widget; + +public class VnicProfilesEditor extends Composite implements IsEditor<TakesValueEditor<Object>>, TakesValue<Object>, HasConstrainedValue<Object> { + + @Override + public HandlerRegistration addValueChangeHandler(ValueChangeHandler<Object> handler) { + // not needed - there is no selected item because all are edited + return null; + } + + interface WidgetUiBinder extends UiBinder<Widget, VnicProfilesEditor> { + WidgetUiBinder uiBinder = GWT.create(WidgetUiBinder.class); + } + + @UiField + FlowPanel contentPanel; + + @UiField + WidgetStyle style; + + protected static final CommonApplicationMessages messages = GWT.create(CommonApplicationMessages.class); + protected static final CommonApplicationResources resources = GWT.create(CommonApplicationResources.class); + + private List<VnicProfileWidget> editors; + + public VnicProfilesEditor() { + initWidget(WidgetUiBinder.uiBinder.createAndBindUi(this)); + editors = new ArrayList<VnicProfileWidget>(); + } + + @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) { + if (values == null) { + return; + } + + editors.clear(); + contentPanel.clear(); + + int numOfProfiles = values.size(); + + for (final Object value : values) { + VnicProfileWidget vnicProfileWidget = new VnicProfileWidget(); + editors.add(vnicProfileWidget); + vnicProfileWidget.edit((VnicProfileModel) value); + + final HorizontalPanel profilePanel = new HorizontalPanel(); + + PushButton addButton = new PushButton(new Image(resources.increaseIcon())); + PushButton remvoeButton = new PushButton(new Image(resources.decreaseIcon())); + addButton.addStyleName(style.addButtonStyle()); + remvoeButton.addStyleName(style.removeButtonStyle()); + profilePanel.add(vnicProfileWidget); + profilePanel.add(addButton); + profilePanel.add(remvoeButton); + + addButton.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + List models = (List<VnicProfileModel>) getValue().getItems(); + VnicProfileModel existingProfileModel = (VnicProfileModel) value; + models.add(models.indexOf(existingProfileModel) + 1, + new NewVnicProfileModel(existingProfileModel.getSourceModel(), + existingProfileModel.getDcCompatibilityVersion())); + setAcceptableValues(models); + } + }); + + remvoeButton.addClickHandler(new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + List models = (List<VnicProfileModel>) getValue().getItems(); + models.remove(value); + setAcceptableValues(models); + } + }); + + profilePanel.addStyleName(style.profilePanel()); + + contentPanel.add(profilePanel); + } + } + + public void flush() { + // this flushes it + getValue(); + } + + @Override + public ListModel getValue() { + List<VnicProfileModel> values = new LinkedList<VnicProfileModel>(); + for (VnicProfileWidget editor : editors) { + values.add(editor.flush()); + } + + ListModel model = new ListModel(); + model.setItems(values); + return model; + } + + @Override + public TakesValueEditor<Object> asEditor() { + return TakesConstrainedValueEditor.of(this, this, this); + } + + interface WidgetStyle extends CssResource { + String addButtonStyle(); + + String removeButtonStyle(); + + String profilePanel(); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml new file mode 100644 index 0000000..2c2391b --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/widget/vnicProfile/VnicProfilesEditor.ui.xml @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!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 type="org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfilesEditor.WidgetStyle"> + .mainPanel { + float: left; + padding-left: 5px; + margin-left: 5px; + } + + .profilePanel { + width: 100%; + padding-bottom: 3px; + } + + .addButtonStyle { + margin-right: 7px; + width: 9px; + height: 10px; + padding-left: 2px; + padding-top: 2px; + margin-top: 4px; + margin-left: 8px; + } + + .removeButtonStyle { + margin-right: 7px; + width: 9px; + height: 10px; + padding-left: 2px; + padding-top: 2px; + margin-top: 4px; + } + + </ui:style> + + <g:FlowPanel addStyleNames="{style.mainPanel}" > + <g:FlowPanel ui:field="contentPanel" /> + </g:FlowPanel> + +</ui:UiBinder> -- To view, visit http://gerrit.ovirt.org/17499 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1b88f0458862e136e5ff035883cb044ef1e896b5 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches