Ramesh N has uploaded a new change for review.

Change subject: webadmin: fix NPE and visibility issues in CheckBoxGroup
......................................................................

webadmin: fix NPE and visibility issues in CheckBoxGroup

 Fixing the NPE issue in setValue() and items clearning issue
setAcceptableValues() of CheckBoxGroup

Change-Id: Ia4f1d371d6c6cbecad9642641d762e954016105d
Signed-off-by: Ramesh Nachimuthu <[email protected]>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
1 file changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/26/41026/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
index 957d636..e02dc9c 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java
@@ -7,6 +7,8 @@
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.ovirt.engine.core.common.utils.ListUtils;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
@@ -145,6 +147,15 @@
      */
     @Override
     public void setValue(List<T> value, boolean fireEvents) {
+        List<T> selectedItems = getValue();
+        if (value == selectedItems
+                || (selectedItems != null && value != null && 
ListUtils.listsEqual(selectedItems, value))) {
+            return;
+        }
+        clearAllSelections();
+        if(value == null){
+            return;
+        }
         for (T currentvalue : value) {
             if (checkBoxes.containsKey(currentvalue)) {
                 checkBoxes.get(currentvalue).setValue(true);
@@ -168,6 +179,9 @@
      */
     @Override
     public void setAcceptableValues(Collection<List<T>> values) {
+        List<T> seletedItems = getValue();
+        wrapperPanel.clear();
+        checkBoxes.clear();
         if (values.isEmpty()) {
             throw new IllegalArgumentException("Widget has nothing to 
do");//$NON-NLS-1$
         }
@@ -177,12 +191,15 @@
                 addCheckBox(currentValue);
             }
         }
-        showCheckBoxes();
+        showCheckBoxes(seletedItems);
     }
 
-    private void showCheckBoxes() {
+    private void showCheckBoxes(List<T> seletedItems) {
         for (Entry<T, CheckBox> currentEntry : checkBoxes.entrySet()) {
             wrapperPanel.add(currentEntry.getValue());
+            if (seletedItems.contains(currentEntry.getKey())) {
+                currentEntry.getValue().setValue(true);
+            }
         }
     }
 


-- 
To view, visit https://gerrit.ovirt.org/41026
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia4f1d371d6c6cbecad9642641d762e954016105d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5-gluster
Gerrit-Owner: Ramesh N <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to