NPE fixed when Data Collection Editor is sorted by template name
authorAlex Kirhenshtein <alk@netxms.org>
Wed, 21 Aug 2013 07:49:41 +0000 (07:49 +0000)
committerAlex Kirhenshtein <alk@netxms.org>
Wed, 21 Aug 2013 07:49:41 +0000 (07:49 +0000)
src/java/netxms-eclipse/DataCollection/src/org/netxms/ui/eclipse/datacollection/views/helpers/DciComparator.java

index 1c23299..ff7c310 100644 (file)
@@ -75,7 +75,28 @@ public class DciComparator extends ViewerComparator
                        case DataCollectionEditor.COLUMN_TEMPLATE:\r
                                final String text1 = labelProvider.getColumnText(e1, column);\r
                                final String text2 = labelProvider.getColumnText(e2, column);\r
-                               result = text1.compareToIgnoreCase(text2);\r
+                               if (text1 != null && text2 != null)\r
+                               {\r
+                                       result = text1.compareToIgnoreCase(text2);\r
+                               }\r
+                               else\r
+                               {\r
+                                       if (text1 == null)\r
+                                       {\r
+                                               if (text2 == null)\r
+                                               {\r
+                                                       result = 0;\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       result = -1;\r
+                                               }\r
+                                       }\r
+                                       else\r
+                                       {\r
+                                               result = 1;\r
+                                       }\r
+                               }\r
                                break;\r
                        default:\r
                                result = 0;\r