Arik Hadas has uploaded a new change for review. Change subject: frontend: fluent API instead of temporary fields ......................................................................
frontend: fluent API instead of temporary fields This patch replace the usage of temporary fields with fluent API - where setters return a reference to "this" which can be used to make further calls on the return value of the setter method. Not all setters were changed in this patch of course, only those that were relevant to simplify the code which is related to run-once capability (this patch is part of few patches that were done lately to refactor the areas around run-once capability in the frontend) Change-Id: I52bfe6b084ecc0643a5a45a1fb9a1170b415ed15 Signed-off-by: Arik Hadas <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/UICommand.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/EntityModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/Model.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostInterfaceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostManagementNetworkModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/networks/NetworkTemplateListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageIsoListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageTemplateListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageVmListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/ImportTemplateModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateGeneralModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateInterfaceListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGuideModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmMonitorModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/key_value/KeyValueModel.java 27 files changed, 124 insertions(+), 117 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/13246/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/UICommand.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/UICommand.java index 3cfd6f7..59cb374 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/UICommand.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/UICommand.java @@ -1,11 +1,11 @@ package org.ovirt.engine.ui.uicommonweb; +import java.util.List; + import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicompat.ICommand; import org.ovirt.engine.ui.uicompat.ObservableCollection; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; - -import java.util.List; /** * Represents a command adapted to use in model-viewmodel pattern + binding. @@ -60,9 +60,10 @@ return privateIsDefault; } - public void setIsDefault(boolean value) + public UICommand setIsDefault(boolean value) { privateIsDefault = value; + return this; } private boolean privateIsVisible = true; @@ -84,9 +85,10 @@ return privateIsCancel; } - public void setIsCancel(boolean value) + public UICommand setIsCancel(boolean value) { privateIsCancel = value; + return this; } private String privateName; @@ -169,4 +171,16 @@ { Execute(new Object[0]); } + + @Override + public UICommand setIsChangable(boolean value) { + super.setIsSelectable(value); + return this; + } + + @Override + public UICommand setTitle(String value) { + super.setTitle(value); + return this; + } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/EntityModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/EntityModel.java index 5437862..a726680 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/EntityModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/EntityModel.java @@ -34,7 +34,7 @@ return entity; } - public void setEntity(Object value) + public EntityModel setEntity(Object value) { if (entity != value) { @@ -45,6 +45,19 @@ getEntityChangedEvent().raise(this, EventArgs.Empty); OnPropertyChanged(new PropertyChangedEventArgs("Entity")); //$NON-NLS-1$ } + return this; + } + + @Override + public EntityModel setIsChangable(boolean value) { + super.setIsSelectable(value); + return this; + } + + @Override + public EntityModel setTitle(String value) { + super.setTitle(value); + return this; } public void setEntity(Object value, boolean fireEvents) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/Model.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/Model.java index 5a0c72e..513d63c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/Model.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/Model.java @@ -172,13 +172,14 @@ return title; } - public void setTitle(String value) + public Model setTitle(String value) { if (!StringHelper.stringsEqual(title, value)) { title = value; OnPropertyChanged(new PropertyChangedEventArgs("Title")); //$NON-NLS-1$ } + return this; } private boolean isValid; @@ -260,7 +261,7 @@ return isChangable; } - public void setIsChangable(boolean value) + public Model setIsChangable(boolean value) { if (isChangable != value) { @@ -272,6 +273,7 @@ privateChangeProhibitionReason = null; } } + return this; } private String privateChangeProhibitionReason; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java index e538bf0..e068598 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java @@ -359,10 +359,10 @@ } @Override - public void setEntity(Object value) { + public EntityModel setEntity(Object value) { if (getEntity() == null) { super.setEntity(value); - return; + return this; } // Equals doesn't always has the same outcome as checking the ids of the elements. if (getEntity() instanceof IVdcQueryable) { @@ -371,16 +371,17 @@ IVdcQueryable ivdcq_entity = (IVdcQueryable) getEntity(); if (!ivdcq_value.getQueryableId().equals(ivdcq_entity.getQueryableId())) { super.setEntity(value); - return; + return this; } } } if (!getEntity().equals(value)) { super.setEntity(value); - return; + return this; } setEntity(value, false); + return this; } protected abstract String getListName(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java index db5cde8..8ffaae2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/configure/PermissionListModel.java @@ -66,18 +66,6 @@ privateRemoveCommand = value; } - @Override - public Object getEntity() - { - return super.getEntity(); - } - - @Override - public void setEntity(Object value) - { - super.setEntity(value); - } - public PermissionListModel() { setTitle(ConstantsManager.getInstance().getConstants().permissionsTitle()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java index 65c9b673..1ae4bb2 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostGeneralModel.java @@ -122,14 +122,14 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { VDS vds = (VDS) value; updateUpgradeAlert = vds == null || getEntity() == null || !vds.getId().equals(getEntity().getId()) || !vds.getStatus().equals(getEntity().getStatus()); - super.setEntity(value); + return super.setEntity(value); } // 1st column in General tab diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java index 7993cc9..5d0652e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostHardwareGeneralModel.java @@ -18,14 +18,14 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { VDS vds = (VDS) value; updateUpgradeAlert = vds == null || getEntity() == null || !vds.getId().equals(getEntity().getId()) || !vds.getStatus().equals(getEntity().getStatus()); - super.setEntity(value); + return super.setEntity(value); } private String hardwareManufacturer; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostInterfaceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostInterfaceModel.java index 78339aa..08dc26c 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostInterfaceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostInterfaceModel.java @@ -245,7 +245,7 @@ setIsToSync(new EntityModel(){ @Override - public void setEntity(Object value) { + public EntityModel setEntity(Object value) { super.setEntity(value); if (getIsToSync().getIsChangable()){ if (!(Boolean)value){ @@ -253,6 +253,7 @@ } setBootProtocolsAvailable((Boolean) value); } + return this; } }); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostManagementNetworkModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostManagementNetworkModel.java index 47ec9eb..af63e7f 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostManagementNetworkModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostManagementNetworkModel.java @@ -233,7 +233,7 @@ setIsToSync(new EntityModel(){ @Override - public void setEntity(Object value) { + public EntityModel setEntity(Object value) { super.setEntity(value); if (getIsToSync().getIsChangable()){ @@ -242,6 +242,7 @@ } setBootProtocolsAvailable((Boolean) value); } + return this; } }); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/networks/NetworkTemplateListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/networks/NetworkTemplateListModel.java index 7fd624e..003cc80 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/networks/NetworkTemplateListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/networks/NetworkTemplateListModel.java @@ -16,6 +16,7 @@ import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; import org.ovirt.engine.ui.uicommonweb.UICommand; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; import org.ovirt.engine.ui.uicommonweb.models.vms.RemoveVmTemplateInterfaceModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; @@ -64,11 +65,12 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { if (value == null || !value.equals(getEntity())) { super.setEntity(value); } + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageIsoListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageIsoListModel.java index 7a40ffd..bf680e9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageIsoListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageIsoListModel.java @@ -107,11 +107,12 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { if (value == null || !value.equals(getEntity())) { super.setEntity(value); } + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageTemplateListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageTemplateListModel.java index 6794159..e969123 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageTemplateListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageTemplateListModel.java @@ -8,6 +8,7 @@ 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.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; @@ -44,11 +45,12 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { if (value == null || !value.equals(getEntity())) { super.setEntity(value); } + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageVmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageVmListModel.java index 39337a8..3d96adc 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageVmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/storage/StorageVmListModel.java @@ -8,6 +8,7 @@ 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.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; @@ -44,11 +45,12 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { if (value == null || !value.equals(getEntity())) { super.setEntity(value); } + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/ImportTemplateModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/ImportTemplateModel.java index 934b5f0..05a6ba1 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/ImportTemplateModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/ImportTemplateModel.java @@ -42,8 +42,8 @@ ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>(); list.add(new TemplateGeneralModel() { @Override - public void setEntity(Object value) { - super.setEntity(value == null ? null : ((ImportTemplateData) value).getTemplate()); + public EntityModel setEntity(Object value) { + return super.setEntity(value == null ? null : ((ImportTemplateData) value).getTemplate()); } }); list.add(new TemplateImportInterfaceListModel()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateGeneralModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateGeneralModel.java index 5d82818..1d01425 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateGeneralModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateGeneralModel.java @@ -42,11 +42,6 @@ } } - public void setEntity(VmTemplate value) - { - super.setEntity(value); - } - private String name; public String getName() diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateInterfaceListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateInterfaceListModel.java index 605da5b..78240f7 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateInterfaceListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/templates/TemplateInterfaceListModel.java @@ -14,6 +14,7 @@ import org.ovirt.engine.ui.frontend.INewAsyncCallback; 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.SearchableListModel; import org.ovirt.engine.ui.uicommonweb.models.vms.EditTemplateInterfaceModel; import org.ovirt.engine.ui.uicommonweb.models.vms.NewTemplateInterfaceModel; @@ -216,7 +217,7 @@ } @Override - public void setEntity(Object value) { + public EntityModel setEntity(Object value) { cluster = null; super.setEntity(value); @@ -234,6 +235,7 @@ }), ((VmTemplate) getEntity()).getVdsGroupId()); } + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java index e679ad7..26a78d1 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalListModel.java @@ -699,8 +699,7 @@ private void RunOnce() { UserPortalItemModel selectedItem = (UserPortalItemModel) getSelectedItem(); - if (selectedItem == null || selectedItem.getEntity() == null) - { + if (selectedItem == null || selectedItem.getEntity() == null) { return; } @@ -713,31 +712,28 @@ model.init(); // Display protocols. - EntityModel tempVar = new EntityModel(); - tempVar.setTitle(ConstantsManager.getInstance().getConstants().VNCTitle()); - tempVar.setEntity(DisplayType.vnc); - EntityModel vncProtocol = tempVar; + EntityModel vncProtocol = new EntityModel() + .setTitle(ConstantsManager.getInstance().getConstants().VNCTitle()) + .setEntity(DisplayType.vnc); - EntityModel tempVar2 = new EntityModel(); - tempVar2.setTitle(ConstantsManager.getInstance().getConstants().spiceTitle()); - tempVar2.setEntity(DisplayType.qxl); - EntityModel qxlProtocol = tempVar2; + EntityModel qxlProtocol = new EntityModel() + .setTitle(ConstantsManager.getInstance().getConstants().spiceTitle()) + .setEntity(DisplayType.qxl); ArrayList<EntityModel> items = new ArrayList<EntityModel>(); items.add(vncProtocol); items.add(qxlProtocol); model.getDisplayProtocol().setItems(items); - model.getDisplayProtocol().setSelectedItem(vm.getDefaultDisplayType() == DisplayType.vnc ? vncProtocol - : qxlProtocol); + model.getDisplayProtocol().setSelectedItem(vm.getDefaultDisplayType() == DisplayType.vnc ? + vncProtocol : qxlProtocol); - UICommand tempVar3 = new UICommand("OnRunOnce", this); //$NON-NLS-1$ - tempVar3.setTitle(ConstantsManager.getInstance().getConstants().ok()); - tempVar3.setIsDefault(true); - model.getCommands().add(tempVar3); - UICommand tempVar4 = new UICommand("Cancel", this); //$NON-NLS-1$ - tempVar4.setTitle(ConstantsManager.getInstance().getConstants().cancel()); - tempVar4.setIsCancel(true); - model.getCommands().add(tempVar4); + model.getCommands().add(new UICommand("OnRunOnce", this) //$NON-NLS-1$ + .setTitle(ConstantsManager.getInstance().getConstants().ok()) + .setIsDefault(true)); + + model.getCommands().add(new UICommand("Cancel", this) //$NON-NLS-1$ + .setTitle(ConstantsManager.getInstance().getConstants().cancel()) + .setIsCancel(true)); } private void OnRunOnce() diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java index f8d8e81..197f295 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/ImportVmModel.java @@ -488,16 +488,16 @@ ObservableCollection<EntityModel> list = new ObservableCollection<EntityModel>(); list.add(new VmGeneralModel() { @Override - public void setEntity(Object value) { - super.setEntity(value == null ? null : ((ImportVmData) value).getVm()); + public EntityModel setEntity(Object value) { + return super.setEntity(value == null ? null : ((ImportVmData) value).getVm()); } }); list.add(new VmImportInterfaceListModel()); list.add(importDiskListModel); list.add(new VmAppListModel() { @Override - public void setEntity(Object value) { - super.setEntity(value == null ? null : ((ImportVmData) value).getVm()); + public EntityModel setEntity(Object value) { + return super.setEntity(value == null ? null : ((ImportVmData) value).getVm()); } }); setDetailModels(list); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java index 17ec33b..8a8081e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/RunOnceModel.java @@ -460,32 +460,20 @@ getSysPrepDomainName().getSelectedItemChangedEvent().addListener(this); setSysPrepSelectedDomainName(new EntityModel()); - EntityModel tempVar = new EntityModel(); - tempVar.setIsChangable(false); - setSysPrepUserName(tempVar); - EntityModel tempVar2 = new EntityModel(); - tempVar2.setIsChangable(false); - setSysPrepPassword(tempVar2); + setSysPrepUserName(new EntityModel().setIsChangable(false)); + setSysPrepPassword(new EntityModel().setIsChangable(false)); setIsSysprepEnabled(new EntityModel()); - EntityModel tempVar3 = new EntityModel(); - tempVar3.setEntity(false); - setIsVmFirstRun(tempVar3); + setIsVmFirstRun(new EntityModel().setEntity(false)); getIsVmFirstRun().getEntityChangedEvent().addListener(this); - EntityModel tempVar4 = new EntityModel(); - tempVar4.setEntity(false); - setUseAlternateCredentials(tempVar4); + setUseAlternateCredentials(new EntityModel().setEntity(false)); getUseAlternateCredentials().getEntityChangedEvent().addListener(this); setCustomProperties(new EntityModel()); setCustomPropertySheet(new KeyValueModel()); - EntityModel tempVar5 = new EntityModel(); - tempVar5.setEntity(false); - setRunAndPause(tempVar5); - EntityModel tempVar6 = new EntityModel(); - tempVar6.setEntity(false); - setRunAsStateless(tempVar6); + setRunAndPause(new EntityModel().setEntity(false)); + setRunAsStateless(new EntityModel().setEntity(false)); setDisplayConsole_Spice_IsSelected(new EntityModel()); getDisplayConsole_Spice_IsSelected().getEntityChangedEvent().addListener(this); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java index 0a383e5..ef63417 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java @@ -2137,25 +2137,28 @@ private class NotChangableForVmInPoolListModel extends ListModel { @Override - public void setIsChangable(boolean value) { + public ListModel setIsChangable(boolean value) { if (!isVmAttachedToPool()) super.setIsChangable(value); + return this; } } private class NotChangableForVmInPoolEntityModel extends EntityModel { @Override - public void setIsChangable(boolean value) { + public EntityModel setIsChangable(boolean value) { if (!isVmAttachedToPool()) super.setIsChangable(value); + return this; } } private class NotChangableForVmInPoolKeyValueModel extends KeyValueModel { @Override - public void setIsChangable(boolean value) { + public KeyValueModel setIsChangable(boolean value) { if (!isVmAttachedToPool()) super.setIsChangable(value); + return this; } } } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGuideModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGuideModel.java index 385c5a4..89f8116 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGuideModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmGuideModel.java @@ -42,11 +42,6 @@ } @Override - public void setEntity(Object value) { - super.setEntity(value); - } - - @Override protected void OnEntityChanged() { super.OnEntityChanged(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceListModel.java index cf00076..bdb2fe1 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceListModel.java @@ -20,6 +20,7 @@ import org.ovirt.engine.ui.uicommonweb.Linq; 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.SearchableListModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; @@ -321,9 +322,10 @@ } @Override - public void setEntity(Object value) { + public EntityModel setEntity(Object value) { super.setEntity(value); updateConfigValues(); + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java index 097d53f..ccb58f9 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java @@ -98,10 +98,11 @@ setMAC(new EntityModel()); setEnableMac(new EntityModel() { @Override - public void setEntity(Object value) { + public EntityModel setEntity(Object value) { super.setEntity(value); Boolean enableManualMac = (Boolean) value; getMAC().setIsChangable(enableManualMac); + return this; } }); getEnableMac().setEntity(false); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java index 42b9843..379a0ef 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmListModel.java @@ -1371,32 +1371,28 @@ model.init(); - EntityModel tempVar3 = new EntityModel(); - tempVar3.setTitle(ConstantsManager.getInstance().getConstants().VNCTitle()); - tempVar3.setEntity(DisplayType.vnc); - EntityModel vncProtocol = tempVar3; + EntityModel vncProtocol = new EntityModel() + .setTitle(ConstantsManager.getInstance().getConstants().VNCTitle()) + .setEntity(DisplayType.vnc); - EntityModel tempVar5 = new EntityModel(); - tempVar5.setTitle(ConstantsManager.getInstance().getConstants().spiceTitle()); - tempVar5.setEntity(DisplayType.qxl); - EntityModel qxlProtocol = tempVar5; + EntityModel qxlProtocol = new EntityModel() + .setTitle(ConstantsManager.getInstance().getConstants().spiceTitle()) + .setEntity(DisplayType.qxl); ArrayList<EntityModel> items = new ArrayList<EntityModel>(); items.add(vncProtocol); items.add(qxlProtocol); model.getDisplayProtocol().setItems(items); - model.getDisplayProtocol().setSelectedItem(vm.getDefaultDisplayType() == DisplayType.vnc ? vncProtocol : qxlProtocol); + model.getDisplayProtocol().setSelectedItem(vm.getDefaultDisplayType() == DisplayType.vnc ? + vncProtocol : qxlProtocol); - UICommand tempVar = new UICommand("OnRunOnce", this); //$NON-NLS-1$ - tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok()); - tempVar.setIsDefault(true); - model.getCommands().add(tempVar); - UICommand tempVar2 = new UICommand("Cancel", this); //$NON-NLS-1$ - tempVar2.setTitle(ConstantsManager.getInstance().getConstants().cancel()); - tempVar2.setIsCancel(true); - model.getCommands().add(tempVar2); + model.getCommands().add(new UICommand("OnRunOnce", this) //$NON-NLS-1$ + .setTitle(ConstantsManager.getInstance().getConstants().ok()) + .setIsDefault(true)); - model.getIsAutoAssign().setEntity(true); + model.getCommands().add(new UICommand("Cancel", this) //$NON-NLS-1$ + .setTitle(ConstantsManager.getInstance().getConstants().cancel()) + .setIsCancel(true)); } private void OnRunOnce() diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmMonitorModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmMonitorModel.java index 17cd7cb..1535761 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmMonitorModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmMonitorModel.java @@ -101,7 +101,7 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { super.setEntity(value); @@ -111,6 +111,7 @@ } else { getRefreshTimer().stop(); } + return this; } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java index 205e78b..d51a1a4 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmSnapshotListModel.java @@ -287,11 +287,11 @@ } @Override - public void setEntity(Object value) + public EntityModel setEntity(Object value) { super.setEntity(value); - UpdateIsCloneVmSupported(); + return this; } @Override 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 1f292a2..8412d27 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 @@ -83,10 +83,10 @@ } @Override - public void setEntity(Object value) { + public KeyValueModel setEntity(Object value) { if (allKeyValueMap == null) { saveEntity = value; - return; + return this; } List<KeyValueLineModel> list = new ArrayList<KeyValueLineModel>(); KeyValueLineModel lineModel; @@ -94,7 +94,7 @@ if (value != null) { String split = (String) value; if (split.isEmpty()) { - return; + return this; } String[] lines = split.split(";"); //$NON-NLS-1$ @@ -136,6 +136,7 @@ keyValueLineModel.getKeys().getSelectedItemChangedEvent().addListener(keyChangedListener); } getKeyValueLines().setItems(list); + return this; } public void setKeyValueString(List<String> lines) { -- To view, visit http://gerrit.ovirt.org/13246 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I52bfe6b084ecc0643a5a45a1fb9a1170b415ed15 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
