Alexander Wels has uploaded a new change for review.

Change subject: webadmin: Fix sorting issue with new grouped list box
......................................................................

webadmin: Fix sorting issue with new grouped list box

- Fixed issue where items were being added to the underlying list
  box and then sorted in the display in a different order. This
  caused the wrong selected item to be used during save.

Change-Id: I521c1ac3eaf0dc1dbc78acddd7301ab3dc4f1490
Signed-off-by: Alexander Wels <aw...@redhat.com>
---
M 
frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/GroupedListModelListBox.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java
2 files changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/42104/1

diff --git 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/GroupedListModelListBox.java
 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/GroupedListModelListBox.java
index 128cc44..76d9e42 100644
--- 
a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/GroupedListModelListBox.java
+++ 
b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/editor/GroupedListModelListBox.java
@@ -2,11 +2,14 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 
 import org.gwtbootstrap3.client.ui.constants.Styles;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.OptGroupElement;
@@ -93,7 +96,7 @@
     public void setAcceptableValues(Collection<T> newValues) {
         if (newValues instanceof List) {
             List<T> sortedValues = (List<T>) newValues;
-
+            Collections.sort(sortedValues, getComparator());
             //Get the internal state of the ValueListBox correct.
             super.setAcceptableValues(sortedValues);
             //Store the current selected index.
@@ -140,6 +143,8 @@
      */
     public abstract String getGroupLabel(T model);
 
+    public abstract Comparator<T> getComparator();
+
     /**
      * Get the {@code ListBox} widget.
      * @return The widget.
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java
index 3677b2a..2bb94e0 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java
@@ -573,6 +573,10 @@
                 return messages.hostDataCenter(model.getStoragePoolName());
             }
 
+            public Comparator<VDSGroup> getComparator() {
+                return new DataCenterClusterComparator();
+            }
+
             /**
              * Comparator that sorts on data center name first, and then 
cluster name. Ignoring case.
              */


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I521c1ac3eaf0dc1dbc78acddd7301ab3dc4f1490
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alexander Wels <aw...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to