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 <rnach...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/CheckBoxGroup.java 1 file changed, 17 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/98/40798/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 2a61069..a197389 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 @@ -145,6 +145,15 @@ */ @Override public void setValue(List<T> value, boolean fireEvents) { + List<T> selectedItems = getValue(); + if (value == selectedItems + || (selectedItems != null && selectedItems.equals(value))) { + return; + } + clearAllSelections(); + if(value == null){ + return; + } for (T currentvalue : value) { if (checkBoxes.containsKey(currentvalue)) { checkBoxes.get(currentvalue).setValue(true); @@ -168,6 +177,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 +189,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, false); + } } } -- To view, visit https://gerrit.ovirt.org/40798 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4f1d371d6c6cbecad9642641d762e954016105d Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ramesh N <rnach...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches