Lior Vernia has uploaded a new change for review. Change subject: webadmin: Refactored Network QoS frontend code ......................................................................
webadmin: Refactored Network QoS frontend code Extracted the part concerned with the actual QoS values into BaseNetworkQosModel and NetworkQoSpopupView, to be reusable from an "anonymous" context (where name and DC are irrelevant). Change-Id: I757d43302799cd5fc4c3006377a86c2841f39ea5 Signed-off-by: Lior Vernia <[email protected]> --- A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/BaseNetworkQosModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkQoSModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQoSModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQosParametersModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkQoSModel.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.ui.xml A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.ui.xml 9 files changed, 409 insertions(+), 351 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/22798/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/BaseNetworkQosModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/BaseNetworkQosModel.java new file mode 100644 index 0000000..17bc06b --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/BaseNetworkQosModel.java @@ -0,0 +1,78 @@ +package org.ovirt.engine.ui.uicommonweb.models.datacenters; + +import org.ovirt.engine.core.common.businessentities.network.NetworkQoS; +import org.ovirt.engine.core.common.queries.ConfigurationValues; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicommonweb.models.Model; + +public class BaseNetworkQosModel extends Model { + + private NetworkQosParametersModel inbound; + private NetworkQosParametersModel outbound; + + protected NetworkQoS networkQoS = new NetworkQoS(); + + public NetworkQosParametersModel getInbound() { + return inbound; + } + + public void setInbound(NetworkQosParametersModel inbound) { + this.inbound = inbound; + } + + public NetworkQosParametersModel getOutbound() { + return outbound; + } + + public void setOutbound(NetworkQosParametersModel outbound) { + this.outbound = outbound; + } + + public BaseNetworkQosModel() { + setInbound(new NetworkQosParametersModel()); + setOutbound(new NetworkQosParametersModel()); + getInbound().getAverage() + .setEntity((Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSInboundAverageDefaultValue)); + getInbound().getPeak() + .setEntity((Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSInboundPeakDefaultValue)); + getInbound().getBurst() + .setEntity((Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSInboundBurstDefaultValue)); + getOutbound().getAverage() + .setEntity((Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSOutboundAverageDefaultValue)); + getOutbound().getPeak() + .setEntity((Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSOutboundPeakDefaultValue)); + getOutbound().getBurst() + .setEntity((Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSOutboundBurstDefaultValue)); + } + + protected boolean validate() { + getInbound().validate(); + getOutbound().validate(); + + setIsValid(getInbound().getIsValid() && getOutbound().getIsValid()); + return getIsValid(); + } + + protected void flush() { + if (getInbound().getIsChangable()) { + networkQoS.setInboundAverage(getInbound().getAverage().getEntity()); + networkQoS.setInboundPeak(getInbound().getPeak().getEntity()); + networkQoS.setInboundBurst(getInbound().getBurst().getEntity()); + } else { + networkQoS.setInboundAverage(null); + networkQoS.setInboundPeak(null); + networkQoS.setInboundBurst(null); + } + + if (getOutbound().getIsChangable()) { + networkQoS.setOutboundAverage(getOutbound().getAverage().getEntity()); + networkQoS.setOutboundPeak(getOutbound().getPeak().getEntity()); + networkQoS.setOutboundBurst(getOutbound().getBurst().getEntity()); + } else { + networkQoS.setOutboundAverage(null); + networkQoS.setOutboundPeak(null); + networkQoS.setOutboundBurst(null); + } + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkQoSModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkQoSModel.java index 82a37b7..e25b2a4 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkQoSModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/EditNetworkQoSModel.java @@ -1,6 +1,5 @@ package org.ovirt.engine.ui.uicommonweb.models.datacenters; - import org.ovirt.engine.core.common.action.NetworkQoSParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; @@ -25,24 +24,24 @@ setHashName("edit_network_qos"); //$NON-NLS-1$ getName().setEntity(networkQoS.getName()); - if(networkQoS.getInboundAverage() == null + if (networkQoS.getInboundAverage() == null || networkQoS.getInboundPeak() == null || networkQoS.getInboundBurst() == null) { - getInboundEnabled().setEntity(Boolean.FALSE); + getInbound().setIsChangable(false); } else { - getInboundAverage().setEntity(networkQoS.getInboundAverage().toString()); - getInboundPeak().setEntity(networkQoS.getInboundPeak().toString()); - getInboundBurst().setEntity(networkQoS.getInboundBurst().toString()); + getInbound().getAverage().setEntity(networkQoS.getInboundAverage()); + getInbound().getPeak().setEntity(networkQoS.getInboundPeak()); + getInbound().getBurst().setEntity(networkQoS.getInboundBurst()); } - if(networkQoS.getOutboundAverage() == null + if (networkQoS.getOutboundAverage() == null || networkQoS.getOutboundPeak() == null || networkQoS.getOutboundBurst() == null) { - getOutboundEnabled().setEntity(Boolean.FALSE); + getOutbound().setIsChangable(false); } else { - getOutboundAverage().setEntity(networkQoS.getOutboundAverage().toString()); - getOutboundPeak().setEntity(networkQoS.getOutboundPeak().toString()); - getOutboundBurst().setEntity(networkQoS.getOutboundBurst().toString()); + getOutbound().getAverage().setEntity(networkQoS.getOutboundAverage()); + getOutbound().getPeak().setEntity(networkQoS.getOutboundPeak()); + getOutbound().getBurst().setEntity(networkQoS.getOutboundBurst()); } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQoSModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQoSModel.java index f47860f..c706f66 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQoSModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQoSModel.java @@ -1,25 +1,19 @@ package org.ovirt.engine.ui.uicommonweb.models.datacenters; - import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.network.NetworkQoS; -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.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.validation.AsciiNameValidation; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; -import org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; import org.ovirt.engine.ui.uicompat.ConstantsManager; -import org.ovirt.engine.ui.uicompat.Event; -import org.ovirt.engine.ui.uicompat.EventArgs; -public abstract class NetworkQoSModel extends Model { +public abstract class NetworkQoSModel extends BaseNetworkQosModel { public static NetworkQoS EMPTY_QOS; @@ -30,68 +24,26 @@ } private final Model sourceModel; - private ListModel dataCenters; - - private EntityModel name; - private EntityModel inboundAverage; - private EntityModel inboundPeak; - private EntityModel inboundBurst; - private EntityModel outboundAverage; - private EntityModel outboundPeak; - private EntityModel outboundBurst; - private EntityModel inboundEnabled; - private EntityModel outboundEnabled; - - protected NetworkQoS networkQoS = new NetworkQoS(); + private ListModel<StoragePool> dataCenters; + private EntityModel<String> name; public NetworkQoSModel(Model sourceModel, StoragePool dataCenter) { this.sourceModel = sourceModel; - setName(new EntityModel()); - setDataCenters(new ListModel()); + setName(new EntityModel<String>()); + setDataCenters(new ListModel<StoragePool>()); getDataCenters().setSelectedItem(dataCenter); getDataCenters().setIsChangable(false); - setInboundAverage(new EntityModel(AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSInboundAverageDefaultValue))); - setInboundPeak(new EntityModel(AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSInboundPeakDefaultValue))); - setInboundBurst(new EntityModel(AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSInboundBurstDefaultValue))); - setOutboundAverage(new EntityModel(AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSOutboundAverageDefaultValue))); - setOutboundPeak(new EntityModel(AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSOutboundPeakDefaultValue))); - setOutboundBurst(new EntityModel(AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.QoSOutboundBurstDefaultValue))); addCommands(); - setInboundEnabled(new EntityModel(Boolean.TRUE)); - setOutboundEnabled(new EntityModel(Boolean.TRUE)); - getInboundEnabled().getEntityChangedEvent().addListener(this); - getOutboundEnabled().getEntityChangedEvent().addListener(this); } - public boolean validate() { + @Override + protected boolean validate() { + super.validate(); getName().validateEntity(new IValidation[] { new NotEmptyValidation(), new AsciiNameValidation() }); - getInboundAverage().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, - (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxAverageNetworkQoSValue))}); - getInboundPeak().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, - (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxPeakNetworkQoSValue))}); - getInboundBurst().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, - (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxBurstNetworkQoSValue))}); - getOutboundAverage().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, - (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxAverageNetworkQoSValue))}); - getOutboundPeak().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, - (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxPeakNetworkQoSValue))}); - getOutboundBurst().validateEntity(new IValidation[] { new NotEmptyValidation(), new IntegerValidation(0, - (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxBurstNetworkQoSValue))}); - boolean inboundDisabled = Boolean.FALSE.equals(getInboundEnabled().getEntity()); - boolean outboundDisabled = Boolean.FALSE.equals(getOutboundEnabled().getEntity()); - - return getName().getIsValid() - && (inboundDisabled - || (getInboundAverage().getIsValid() - && getInboundPeak().getIsValid() - && getInboundBurst().getIsValid())) - && (outboundDisabled || - (getOutboundAverage().getIsValid() - && getOutboundPeak().getIsValid() - && getOutboundBurst().getIsValid())); + setIsValid(getIsValid() && getName().getIsValid()); + return getIsValid(); } - protected void addCommands() { UICommand tempVar2 = new UICommand("OnSave", this); //$NON-NLS-1$ @@ -105,35 +57,14 @@ } public StoragePool getSelectedDc() { - return (StoragePool) getDataCenters().getSelectedItem(); + return getDataCenters().getSelectedItem(); } - public void flush() { + @Override + protected void flush() { + super.flush(); networkQoS.setName((String) getName().getEntity()); networkQoS.setStoragePoolId(((StoragePool)getDataCenters().getSelectedItem()).getId()); - - boolean inboundEnabled = Boolean.TRUE.equals(getInboundEnabled().getEntity()); - boolean outboundEnabled = Boolean.TRUE.equals(getOutboundEnabled().getEntity()); - - if (inboundEnabled) { - networkQoS.setInboundAverage(Integer.parseInt(getInboundAverage().getEntity().toString())); - networkQoS.setInboundPeak(Integer.parseInt(getInboundPeak().getEntity().toString())); - networkQoS.setInboundBurst(Integer.parseInt( getInboundBurst().getEntity().toString())); - } else { - networkQoS.setInboundAverage(null); - networkQoS.setInboundPeak(null); - networkQoS.setInboundBurst(null); - } - - if (outboundEnabled) { - networkQoS.setOutboundAverage(Integer.parseInt(getOutboundAverage().getEntity().toString())); - networkQoS.setOutboundPeak(Integer.parseInt(getOutboundPeak().getEntity().toString())); - networkQoS.setOutboundBurst(Integer.parseInt(getOutboundBurst().getEntity().toString())); - } else { - networkQoS.setOutboundAverage(null); - networkQoS.setOutboundPeak(null); - networkQoS.setOutboundBurst(null); - } } protected abstract void executeSave(); @@ -159,38 +90,11 @@ public void executeCommand(UICommand command) { super.executeCommand(command); - if (StringHelper.stringsEqual(command.getName(), "OnSave")) //$NON-NLS-1$ - { + if (StringHelper.stringsEqual(command.getName(), "OnSave")) { //$NON-NLS-1$ onSave(); - } else if (StringHelper.stringsEqual(command.getName(), "Cancel")) //$NON-NLS-1$ - { + } else if (StringHelper.stringsEqual(command.getName(), "Cancel")) { //$NON-NLS-1$ cancel(); } - } - - @Override - public void eventRaised(Event ev, Object sender, EventArgs args) { - super.eventRaised(ev, sender, args); - - if (getInboundEnabled().equals(sender)) { - updateInboundAvailability(); - } else if (getOutboundEnabled().equals(sender)) { - updateOutboundAvailability(); - } - } - - private void updateOutboundAvailability() { - boolean enabled = Boolean.TRUE.equals(getOutboundEnabled().getEntity()); - getOutboundAverage().setIsChangable(enabled); - getOutboundPeak().setIsChangable(enabled); - getOutboundBurst().setIsChangable(enabled); - } - - private void updateInboundAvailability() { - boolean enabled = Boolean.TRUE.equals(getInboundEnabled().getEntity()); - getInboundAverage().setIsChangable(enabled); - getInboundPeak().setIsChangable(enabled); - getInboundBurst().setIsChangable(enabled); } protected void postSaveAction(boolean succeeded) { @@ -200,83 +104,19 @@ stopProgress(); } - public ListModel getDataCenters() { + public ListModel<StoragePool> getDataCenters() { return dataCenters; } - public void setDataCenters(ListModel dataCenters) { + public void setDataCenters(ListModel<StoragePool> dataCenters) { this.dataCenters = dataCenters; } - public EntityModel getName() { + public EntityModel<String> getName() { return name; } - public void setName(EntityModel name) { + public void setName(EntityModel<String> name) { this.name = name; - } - - public EntityModel getInboundAverage() { - return inboundAverage; - } - - public void setInboundAverage(EntityModel inboundAverage) { - this.inboundAverage = inboundAverage; - } - - public EntityModel getInboundPeak() { - return inboundPeak; - } - - public void setInboundPeak(EntityModel inboundPeak) { - this.inboundPeak = inboundPeak; - } - - public EntityModel getInboundBurst() { - return inboundBurst; - } - - public void setInboundBurst(EntityModel inboundBurst) { - this.inboundBurst = inboundBurst; - } - - public EntityModel getOutboundAverage() { - return outboundAverage; - } - - public void setOutboundAverage(EntityModel outboundAverage) { - this.outboundAverage = outboundAverage; - } - - public EntityModel getOutboundPeak() { - return outboundPeak; - } - - public void setOutboundPeak(EntityModel outboundPeak) { - this.outboundPeak = outboundPeak; - } - - public EntityModel getOutboundBurst() { - return outboundBurst; - } - - public void setOutboundBurst(EntityModel outboundBurst) { - this.outboundBurst = outboundBurst; - } - - public EntityModel getInboundEnabled() { - return inboundEnabled; - } - - public void setInboundEnabled(EntityModel inboundEnabled) { - this.inboundEnabled = inboundEnabled; - } - - public EntityModel getOutboundEnabled() { - return outboundEnabled; - } - - public void setOutboundEnabled(EntityModel outboundEnabled) { - this.outboundEnabled = outboundEnabled; } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQosParametersModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQosParametersModel.java new file mode 100644 index 0000000..4baa6f0 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NetworkQosParametersModel.java @@ -0,0 +1,78 @@ +package org.ovirt.engine.ui.uicommonweb.models.datacenters; + +import org.ovirt.engine.core.common.queries.ConfigurationValues; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicommonweb.models.Model; +import org.ovirt.engine.ui.uicommonweb.validation.IValidation; +import org.ovirt.engine.ui.uicommonweb.validation.IntegerValidation; +import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; + +public class NetworkQosParametersModel extends Model { + + private EntityModel<Integer> average; + private EntityModel<Integer> peak; + private EntityModel<Integer> burst; + + public EntityModel<Integer> getAverage() { + return average; + } + + private void setAverage(EntityModel<Integer> average) { + this.average = average; + } + + public EntityModel<Integer> getPeak() { + return peak; + } + + private void setPeak(EntityModel<Integer> peak) { + this.peak = peak; + } + + public EntityModel<Integer> getBurst() { + return burst; + } + + private void setBurst(EntityModel<Integer> burst) { + this.burst = burst; + } + + public NetworkQosParametersModel() { + setAverage(new EntityModel<Integer>()); + setPeak(new EntityModel<Integer>()); + setBurst(new EntityModel<Integer>()); + } + + public boolean validate() { + if (!getIsChangable()) { + return true; + } + + getAverage().validateEntity(new IValidation[] { + new NotEmptyValidation(), + new IntegerValidation(0, + (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxAverageNetworkQoSValue)) }); + getPeak().validateEntity(new IValidation[] { + new NotEmptyValidation(), + new IntegerValidation(0, + (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxPeakNetworkQoSValue)) }); + getBurst().validateEntity(new IValidation[] { + new NotEmptyValidation(), + new IntegerValidation(0, + (Integer) AsyncDataProvider.getConfigValuePreConverted(ConfigurationValues.MaxBurstNetworkQoSValue)) }); + + setIsValid(getAverage().getIsValid() && getPeak().getIsValid() && getBurst().getIsValid()); + return getIsValid(); + } + + @Override + public Model setIsChangable(boolean value) { + getAverage().setIsChangable(value); + getPeak().setIsChangable(value); + getBurst().setIsChangable(value); + + return super.setIsChangable(value); + } + +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkQoSModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkQoSModel.java index f61d764..35e0cca 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkQoSModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/NewNetworkQoSModel.java @@ -1,6 +1,5 @@ package org.ovirt.engine.ui.uicommonweb.models.datacenters; - import org.ovirt.engine.core.common.action.NetworkQoSParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; @@ -21,7 +20,6 @@ setTitle(ConstantsManager.getInstance().getConstants().newNetworkQoSTitle()); setHashName("new_network_qos"); //$NON-NLS-1$ } - @Override protected void executeSave() { diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.java index c48bf7b..cf000ff 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.java @@ -1,16 +1,12 @@ package org.ovirt.engine.ui.webadmin.section.main.view.popup.networkQoS; - import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; 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; import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; -import org.ovirt.engine.ui.common.widget.editor.EntityModelCheckBoxEditor; -import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxEditor; -import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxOnlyEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor; import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer; import org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkQoSModel; import org.ovirt.engine.ui.webadmin.ApplicationConstants; @@ -20,71 +16,27 @@ import com.google.gwt.core.client.GWT; import com.google.gwt.editor.client.SimpleBeanEditorDriver; import com.google.gwt.event.shared.EventBus; -import com.google.gwt.resources.client.CssResource; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; import com.google.inject.Inject; - public class NetworkQoSPopupView extends AbstractModelBoundPopupView<NetworkQoSModel> implements NetworkQoSPopupPresenterWidget.ViewDef { - - @UiField - WidgetStyle style; @UiField(provided = true) @Path(value = "dataCenters.selectedItem") @WithElementId - ListModelListBoxEditor<Object> dataCenterEditor; + ListModelListBoxEditor<StoragePool> dataCenterEditor; @UiField @Path(value = "name.entity") @WithElementId - EntityModelTextBoxEditor nameEditor; + StringEntityModelTextBoxEditor nameEditor; @UiField(provided = true) - @Path(value = "inboundEnabled.entity") + @Ignore @WithElementId - EntityModelCheckBoxEditor inboundEnabled; - - @UiField(provided = true) - @Path(value = "outboundEnabled.entity") - @WithElementId - EntityModelCheckBoxEditor outboundEnabled; - - @UiField - @Path(value = "inboundAverage.entity") - @WithElementId - EntityModelTextBoxOnlyEditor inboundAverageEditor; - - @UiField - @Path(value = "inboundPeak.entity") - @WithElementId - EntityModelTextBoxOnlyEditor inboundPeakEditor; - - @UiField - @Path(value = "inboundBurst.entity") - @WithElementId - EntityModelTextBoxOnlyEditor inboundBurstEditor; - - @UiField - @Path(value = "outboundAverage.entity") - @WithElementId - EntityModelTextBoxOnlyEditor outboundAverageEditor; - - @UiField - @Path(value = "outboundPeak.entity") - @WithElementId - EntityModelTextBoxOnlyEditor outboundPeakEditor; - - @UiField - @Path(value = "outboundBurst.entity") - @WithElementId - EntityModelTextBoxOnlyEditor outboundBurstEditor; - - - - private NetworkQoSModel model; + NetworkQosWidget qosWidget; interface Driver extends SimpleBeanEditorDriver<NetworkQoSModel, NetworkQoSPopupView> { } @@ -103,61 +55,38 @@ public NetworkQoSPopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) { super(eventBus, resources); initListBoxEditors(); - inboundEnabled = new EntityModelCheckBoxEditor(Align.RIGHT); - outboundEnabled = new EntityModelCheckBoxEditor(Align.RIGHT); + qosWidget = new NetworkQosWidget(constants); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); ViewIdHandler.idHandler.generateAndSetIds(this); localize(constants); driver.initialize(this); - setStyle(); - } - - private void setStyle() { - inboundAverageEditor.setContentWidgetStyleName(style.valueWidth()); - inboundPeakEditor.setContentWidgetStyleName(style.valueWidth()); - inboundBurstEditor.setContentWidgetStyleName(style.valueWidth()); - outboundAverageEditor.setContentWidgetStyleName(style.valueWidth()); - outboundPeakEditor.setContentWidgetStyleName(style.valueWidth()); - outboundBurstEditor.setContentWidgetStyleName(style.valueWidth()); } private void initListBoxEditors() { - dataCenterEditor = new ListModelListBoxEditor<Object>(new NullSafeRenderer<Object>() { + dataCenterEditor = new ListModelListBoxEditor<StoragePool>(new NullSafeRenderer<StoragePool>() { @Override - public String renderNullSafe(Object object) { - return ((StoragePool) object).getName(); + public String renderNullSafe(StoragePool dataCenter) { + return dataCenter.getName(); } }); } - void localize(ApplicationConstants constants) { + private void localize(ApplicationConstants constants) { nameEditor.setLabel(constants.networkQoSName()); dataCenterEditor.setLabel(constants.dataCenterNetworkQoSPopup()); - inboundEnabled.setLabel(constants.inboundLabelQoSPopup()); - outboundEnabled.setLabel(constants.outboundLabelQoSPopup()); - inboundAverageEditor.setTitle(constants.averageNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); - inboundPeakEditor.setTitle(constants.peakNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); - inboundBurstEditor.setTitle(constants.burstNetworkQoSPopup() + constants.inMegabytesNetworkQoSPopup()); - outboundAverageEditor.setTitle(constants.averageNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); - outboundPeakEditor.setTitle(constants.peakNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); - outboundBurstEditor.setTitle(constants.burstNetworkQoSPopup() + constants.inMegabytesNetworkQoSPopup()); } @Override public void edit(NetworkQoSModel object) { - this.model = object; + qosWidget.edit(object); driver.edit(object); } @Override public NetworkQoSModel flush() { + qosWidget.flush(); return driver.flush(); } - - - interface WidgetStyle extends CssResource { - String valueWidth(); - } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.ui.xml index 6fbb769..3db9699 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQoSPopupView.ui.xml @@ -1,36 +1,14 @@ <?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:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" - xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor"> - <ui:with field='constants' type='org.ovirt.engine.ui.webadmin.ApplicationConstants' /> + 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:ge="urn:import:org.ovirt.engine.ui.common.widget.editor.generic" + xmlns:n="urn:import:org.ovirt.engine.ui.webadmin.section.main.view.popup.networkQoS"> - <ui:style type="org.ovirt.engine.ui.webadmin.section.main.view.popup.networkQoS.NetworkQoSPopupView.WidgetStyle"> + <ui:style> .topDecorator { background-color: #D3D3D3; margin: 5px; - } - .labelStyle { - font-weight: bold; - width: 90%; - padding-left: 5px; - } - .mbpsLabel { - text-align: right; - font-size: smaller; - color: gray; - } - .valueWidth { - width: 60px; - padding-left: 5px; - } - .valuePanelStyle { - padding-left: 30px; - width: 120px; - } - .textBoxLabelStyle { - padding-left: 5px; } </ui:style> @@ -39,56 +17,9 @@ <g:FlowPanel> <g:FlowPanel addStyleNames="{style.topDecorator}"> <e:ListModelListBoxEditor ui:field="dataCenterEditor" /> - <e:EntityModelTextBoxEditor ui:field="nameEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="nameEditor" /> </g:FlowPanel> - <e:EntityModelCheckBoxEditor addStyleNames="{style.labelStyle}" ui:field="inboundEnabled"/> - <g:HorizontalPanel> - <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> - <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.averageNetworkQoSPopup}"/> - <g:VerticalPanel> - <e:EntityModelTextBoxOnlyEditor ui:field="inboundAverageEditor" /> - <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> - </g:VerticalPanel> - </g:VerticalPanel> - <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> - <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.peakNetworkQoSPopup}"/> - <g:VerticalPanel> - <e:EntityModelTextBoxOnlyEditor ui:field="inboundPeakEditor" /> - <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> - </g:VerticalPanel> - </g:VerticalPanel> - <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> - <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.burstNetworkQoSPopup}"/> - <g:VerticalPanel> - <e:EntityModelTextBoxOnlyEditor ui:field="inboundBurstEditor" /> - <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbLabelQoSPopup}"/> - </g:VerticalPanel> - </g:VerticalPanel> - </g:HorizontalPanel> - <e:EntityModelCheckBoxEditor addStyleNames="{style.labelStyle}" ui:field="outboundEnabled"/> - <g:HorizontalPanel> - <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> - <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.averageNetworkQoSPopup}"/> - <g:VerticalPanel> - <e:EntityModelTextBoxOnlyEditor ui:field="outboundAverageEditor" /> - <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> - </g:VerticalPanel> - </g:VerticalPanel> - <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> - <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.peakNetworkQoSPopup}"/> - <g:VerticalPanel> - <e:EntityModelTextBoxOnlyEditor ui:field="outboundPeakEditor" /> - <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> - </g:VerticalPanel> - </g:VerticalPanel> - <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> - <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.burstNetworkQoSPopup}"/> - <g:VerticalPanel> - <e:EntityModelTextBoxOnlyEditor ui:field="outboundBurstEditor" /> - <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbLabelQoSPopup}"/> - </g:VerticalPanel> - </g:VerticalPanel> - </g:HorizontalPanel> + <n:NetworkQosWidget ui:field="qosWidget" /> </g:FlowPanel> </d:content> </d:SimpleDialogPanel> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.java new file mode 100644 index 0000000..2185654 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.java @@ -0,0 +1,122 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.networkQoS; + +import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.idhandler.WithElementId; +import org.ovirt.engine.ui.common.widget.Align; +import org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.generic.IntegerEntityModelTextBoxOnlyEditor; +import org.ovirt.engine.ui.common.widget.uicommon.popup.AbstractModelBoundPopupWidget; +import org.ovirt.engine.ui.uicommonweb.models.datacenters.BaseNetworkQosModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; + +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.FlowPanel; + +public class NetworkQosWidget extends AbstractModelBoundPopupWidget<BaseNetworkQosModel> { + + interface Driver extends SimpleBeanEditorDriver<BaseNetworkQosModel, NetworkQosWidget> { + } + + private final Driver driver = GWT.create(Driver.class); + + interface ViewUiBinder extends UiBinder<FlowPanel, NetworkQosWidget> { + ViewUiBinder uiBinder = GWT.create(ViewUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<NetworkQosWidget> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + interface WidgetStyle extends CssResource { + String valueWidth(); + } + + @UiField + WidgetStyle style; + + @UiField(provided = true) + @Path(value = "inbound.isChangable") + @WithElementId + EntityModelCheckBoxEditor inboundEnabled; + + @UiField(provided = true) + @Path(value = "outbound.isChangable") + @WithElementId + EntityModelCheckBoxEditor outboundEnabled; + + @UiField + @Path(value = "inbound.average.entity") + @WithElementId + IntegerEntityModelTextBoxOnlyEditor inboundAverageEditor; + + @UiField + @Path(value = "inbound.peak.entity") + @WithElementId + IntegerEntityModelTextBoxOnlyEditor inboundPeakEditor; + + @UiField + @Path(value = "inbound.burst.entity") + @WithElementId + IntegerEntityModelTextBoxOnlyEditor inboundBurstEditor; + + @UiField + @Path(value = "outbound.average.entity") + @WithElementId + IntegerEntityModelTextBoxOnlyEditor outboundAverageEditor; + + @UiField + @Path(value = "outbound.peak.entity") + @WithElementId + IntegerEntityModelTextBoxOnlyEditor outboundPeakEditor; + + @UiField + @Path(value = "outbound.burst.entity") + @WithElementId + IntegerEntityModelTextBoxOnlyEditor outboundBurstEditor; + + public NetworkQosWidget(ApplicationConstants constants) { + inboundEnabled = new EntityModelCheckBoxEditor(Align.RIGHT); + outboundEnabled = new EntityModelCheckBoxEditor(Align.RIGHT); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + ViewIdHandler.idHandler.generateAndSetIds(this); + + setStyle(); + localize(constants); + driver.initialize(this); + } + + private void setStyle() { + inboundAverageEditor.setContentWidgetStyleName(style.valueWidth()); + inboundPeakEditor.setContentWidgetStyleName(style.valueWidth()); + inboundBurstEditor.setContentWidgetStyleName(style.valueWidth()); + outboundAverageEditor.setContentWidgetStyleName(style.valueWidth()); + outboundPeakEditor.setContentWidgetStyleName(style.valueWidth()); + outboundBurstEditor.setContentWidgetStyleName(style.valueWidth()); + } + + private void localize(ApplicationConstants constants) { + inboundEnabled.setLabel(constants.inboundLabelQoSPopup()); + outboundEnabled.setLabel(constants.outboundLabelQoSPopup()); + inboundAverageEditor.setTitle(constants.averageNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); + inboundPeakEditor.setTitle(constants.peakNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); + inboundBurstEditor.setTitle(constants.burstNetworkQoSPopup() + constants.inMegabytesNetworkQoSPopup()); + outboundAverageEditor.setTitle(constants.averageNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); + outboundPeakEditor.setTitle(constants.peakNetworkQoSPopup() + constants.inMegabitsNetworkQoSPopup()); + outboundBurstEditor.setTitle(constants.burstNetworkQoSPopup() + constants.inMegabytesNetworkQoSPopup()); + } + + @Override + public void edit(BaseNetworkQosModel object) { + driver.edit(object); + } + + @Override + public BaseNetworkQosModel flush() { + return driver.flush(); + } + +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.ui.xml new file mode 100644 index 0000000..aca914e --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/networkQoS/NetworkQosWidget.ui.xml @@ -0,0 +1,83 @@ +<?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:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" + xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor.generic"> + <ui:with field='constants' type='org.ovirt.engine.ui.webadmin.ApplicationConstants' /> + + <ui:style type="org.ovirt.engine.ui.webadmin.section.main.view.popup.networkQoS.NetworkQosWidget.WidgetStyle"> + .labelStyle { + font-weight: bold; + width: 90%; + padding-left: 5px; + } + .mbpsLabel { + text-align: right; + font-size: smaller; + color: gray; + } + .valueWidth { + width: 60px; + padding-left: 5px; + } + .valuePanelStyle { + padding-left: 30px; + width: 120px; + } + .textBoxLabelStyle { + padding-left: 5px; + } + </ui:style> + + <g:FlowPanel> + <e:EntityModelCheckBoxEditor addStyleNames="{style.labelStyle}" ui:field="inboundEnabled"/> + <g:HorizontalPanel> + <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> + <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.averageNetworkQoSPopup}"/> + <g:VerticalPanel> + <e:IntegerEntityModelTextBoxOnlyEditor ui:field="inboundAverageEditor" /> + <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> + </g:VerticalPanel> + </g:VerticalPanel> + <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> + <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.peakNetworkQoSPopup}"/> + <g:VerticalPanel> + <e:IntegerEntityModelTextBoxOnlyEditor ui:field="inboundPeakEditor" /> + <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> + </g:VerticalPanel> + </g:VerticalPanel> + <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> + <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.burstNetworkQoSPopup}"/> + <g:VerticalPanel> + <e:IntegerEntityModelTextBoxOnlyEditor ui:field="inboundBurstEditor" /> + <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbLabelQoSPopup}"/> + </g:VerticalPanel> + </g:VerticalPanel> + </g:HorizontalPanel> + <e:EntityModelCheckBoxEditor addStyleNames="{style.labelStyle}" ui:field="outboundEnabled"/> + <g:HorizontalPanel> + <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> + <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.averageNetworkQoSPopup}"/> + <g:VerticalPanel> + <e:IntegerEntityModelTextBoxOnlyEditor ui:field="outboundAverageEditor" /> + <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> + </g:VerticalPanel> + </g:VerticalPanel> + <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> + <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.peakNetworkQoSPopup}"/> + <g:VerticalPanel> + <e:IntegerEntityModelTextBoxOnlyEditor ui:field="outboundPeakEditor" /> + <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbpsLabelQoSPopup}"/> + </g:VerticalPanel> + </g:VerticalPanel> + <g:VerticalPanel addStyleNames="{style.valuePanelStyle}"> + <g:Label addStyleNames="{style.textBoxLabelStyle}" text="{constants.burstNetworkQoSPopup}"/> + <g:VerticalPanel> + <e:IntegerEntityModelTextBoxOnlyEditor ui:field="outboundBurstEditor" /> + <g:Label addStyleNames="{style.mbpsLabel}" text="{constants.mbLabelQoSPopup}"/> + </g:VerticalPanel> + </g:VerticalPanel> + </g:HorizontalPanel> + </g:FlowPanel> + +</ui:UiBinder> \ No newline at end of file -- To view, visit http://gerrit.ovirt.org/22798 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I757d43302799cd5fc4c3006377a86c2841f39ea5 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
