Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Fixed sorting in Datacenter/Networks subtab
......................................................................

webadmin: Fixed sorting in Datacenter/Networks subtab

Sorting now treats numeric subsequences in network names as such.

Change-Id: I552af3c1269986f8f2d957b488c7a0358360409e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=920209
Signed-off-by: Lior Vernia <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterNetworkListModel.java
1 file changed, 22 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/50/13050/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterNetworkListModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterNetworkListModel.java
index 364cc58..0823fa0 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterNetworkListModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/datacenters/DataCenterNetworkListModel.java
@@ -2,6 +2,8 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 
 import org.ovirt.engine.core.common.businessentities.storage_pool;
@@ -10,6 +12,7 @@
 import org.ovirt.engine.core.common.queries.IdQueryParameters;
 import org.ovirt.engine.core.common.queries.VdcQueryReturnValue;
 import org.ovirt.engine.core.common.queries.VdcQueryType;
+import org.ovirt.engine.core.common.utils.LexoNumericComparator;
 import org.ovirt.engine.core.compat.StringHelper;
 import org.ovirt.engine.ui.frontend.AsyncQuery;
 import org.ovirt.engine.ui.frontend.Frontend;
@@ -18,6 +21,7 @@
 import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider;
 import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel;
 import org.ovirt.engine.ui.uicommonweb.models.SearchableListModel;
+import org.ovirt.engine.ui.uicommonweb.models.hosts.HostInterfaceListModel;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
 
 @SuppressWarnings("unused")
@@ -120,8 +124,25 @@
             @Override
             public void OnSuccess(Object model, Object ReturnValue)
             {
+                ArrayList<Network> newItems = (ArrayList<Network>) 
((VdcQueryReturnValue) ReturnValue).getReturnValue();
+                Collections.sort(newItems, new Comparator<Network>() {
+                    LexoNumericComparator lexoNumeric = new 
LexoNumericComparator();
+
+                    @Override
+                    public int compare(Network net1, Network net2) {
+                        // management first
+                        if 
(net1.getName().equals(HostInterfaceListModel.ENGINE_NETWORK_NAME)) {
+                            return -1;
+                        } else if 
(net2.getName().equals(HostInterfaceListModel.ENGINE_NETWORK_NAME)) {
+                            return 1;
+                        }
+
+                        return lexoNumeric.compare(net1.getName(), 
net2.getName());
+                    }
+
+                });
                 SearchableListModel searchableListModel = 
(SearchableListModel) model;
-                searchableListModel.setItems((ArrayList<Network>) 
((VdcQueryReturnValue) ReturnValue).getReturnValue());
+                searchableListModel.setItems(newItems);
             }
         };
 


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

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

Reply via email to