Tomas Jelinek has uploaded a new change for review.

Change subject: frontend: pool dialog templates not updated accordint to DC
......................................................................

frontend: pool dialog templates not updated accordint to DC

If the DC has been changed the templates have not been updated.
There were two issues which caused this:

1: the list of templates has not been updated after the DC has been
   changed

2: the ListModelTypeAheadListBox handled the setValue() differently
   than other ListModelListBox. The ListModelListBox if gets a
   value in setValue() which is not part of the acceptable values
   adds it as one of them (in ValueListBox.updateListBox()).
   The ListModelTypeAheadListBox have ignored this values as incorrect
   ones. The problem is that UiCommonEditorVisitor firts calls the
   setValue() and than the setAcceptableValues() which works correctly
   only the first time. Fixed by aligning the ListModelTypeAheadListBox
   to work the same as the ListModelListBox.

Bug-Url: https://bugzilla.redhat.com/987819
Signed-off-by: Tomas Jelinek <[email protected]>
Change-Id: I0ab81ee7165f9855de3d843fcf7ead0fc3db512a
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewPoolModelBehavior.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
3 files changed, 12 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/71/18171/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
index 5d041a0..ac53ccb 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/ListModelTypeAheadListBox.java
@@ -209,11 +209,13 @@
     }
 
     public void setValue(T value) {
-        super.setValue(asValidValue(value));
+        addToValidValuesIfNeeded(value);
+        super.setValue(value);
     }
 
     public void setValue(T value, boolean fireEvents) {
-        super.setValue(asValidValue(value), fireEvents);
+        addToValidValuesIfNeeded(value);
+        super.setValue(value, fireEvents);
     }
 
     @Override
@@ -225,24 +227,18 @@
         return null;
     }
 
-    private T asValidValue(T valueCandidate) {
-        // not yet inited - accept everything
-        if (acceptableValues.size() == 0) {
-            return valueCandidate;
+    private void addToValidValuesIfNeeded(T value) {
+        if (!acceptableValues.contains(value)) {
+            acceptableValues.add(value);
         }
 
-        // it is one of the correct values
-        if (acceptableValues.contains(valueCandidate)) {
-            return valueCandidate;
-        }
-
-        // not correct value - return to the previous one
-        return getValue();
     }
 
     @Override
     public void setAcceptableValues(Collection<T> acceptableValues) {
         this.acceptableValues = acceptableValues;
+        T selected = getValue();
+        addToValidValuesIfNeeded(selected);
         RenderableSuggestOracle<T> suggestOracle = 
(RenderableSuggestOracle<T>) suggestBox.getSuggestOracle();
         suggestOracle.setData(acceptableValues);
     }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewPoolModelBehavior.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewPoolModelBehavior.java
index 43dcbe9..decf45c 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewPoolModelBehavior.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/NewPoolModelBehavior.java
@@ -5,6 +5,7 @@
 import org.ovirt.engine.core.common.businessentities.DisplayType;
 import org.ovirt.engine.core.common.businessentities.VmBase;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
+import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.ui.uicommonweb.Linq;
 import org.ovirt.engine.ui.uicommonweb.models.ListModel;
 import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemModel;
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
index 3645295..5e5cd32 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/PoolModelBehaviorBase.java
@@ -69,8 +69,6 @@
                                 model.setDataCentersAndClusters(model,
                                         dataCenters,
                                         (List<VDSGroup>) returnValue, null);
-
-                                initTemplate();
                                 initCdImage();
                                 
getPoolModelBehaviorInitializedEvent().raise(this, EventArgs.Empty);
                             }
@@ -199,6 +197,7 @@
         }
         updateMemoryBalloon();
         updateCpuSharesAvailability();
+        updateTemplate();
     }
 
     @Override
@@ -226,7 +225,7 @@
                 .setEntity((int) ((Integer) 
getModel().getMemSize().getEntity() * overCommitFactor));
     }
 
-    private void initTemplate()
+    private void updateTemplate()
     {
         StoragePool dataCenter = getModel().getSelectedDataCenter();
         if (dataCenter == null) {


-- 
To view, visit http://gerrit.ovirt.org/18171
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ab81ee7165f9855de3d843fcf7ead0fc3db512a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Tomas Jelinek <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to