object filter by comments improved
authorVictor Kirhenshtein <victor@netxms.org>
Thu, 4 May 2017 08:29:31 +0000 (11:29 +0300)
committerVictor Kirhenshtein <victor@netxms.org>
Thu, 4 May 2017 08:29:31 +0000 (11:29 +0300)
src/java/netxms-eclipse/ObjectBrowser/src/org/netxms/ui/eclipse/objectbrowser/widgets/internal/ObjectFilter.java
src/server/core/.project
webui/webapp/ObjectBrowser/src/org/netxms/ui/eclipse/objectbrowser/widgets/internal/ObjectFilter.java

index 32cd89e..c149ac6 100644 (file)
@@ -86,8 +86,8 @@ public class ObjectFilter extends ViewerFilter
                
                switch(mode)
                {
-                       case NAME:
-                               return usePatternMatching ? Glob.matchIgnoreCase(filterString, object.getObjectName()) : object.getObjectName().toLowerCase().contains(filterString);
+         case COMMENTS:
+            return object.getComments().toLowerCase().contains(filterString);
                        case IP_ADDRESS:
                           if (object instanceof AbstractNode)
                           {
@@ -115,6 +115,8 @@ public class ObjectFilter extends ViewerFilter
                return ((AccessPoint)object).getIpAddress().getHostAddress().startsWith(filterString);
             }
                           return false;
+         case NAME:
+            return usePatternMatching ? Glob.matchIgnoreCase(filterString, object.getObjectName()) : object.getObjectName().toLowerCase().contains(filterString);
                        case OBJECT_ID:
                           if (object instanceof AbstractObject)
                           {
@@ -122,8 +124,6 @@ public class ObjectFilter extends ViewerFilter
                              return String.valueOf(objectID).startsWith(filterString);
                           }
             return false;
-                       case COMMENTS:
-                               return object.getComments().toLowerCase().contains(filterString.toLowerCase());
                }
                
                return false;
@@ -180,7 +180,10 @@ public class ObjectFilter extends ViewerFilter
                        if (filterString.charAt(0) == '/')
                        {
                                mode = COMMENTS;
-                               this.filterString = filterString.substring(1);
+            String newFilterString = filterString.substring(1).toLowerCase();
+            if ((this.filterString != null) && newFilterString.startsWith(this.filterString))
+               fullSearch = false;
+            this.filterString = newFilterString;
                        }
                        else if (filterString.charAt(0) == '>')
                        {
@@ -203,9 +206,8 @@ public class ObjectFilter extends ViewerFilter
                                else
                                {
                                        String newFilterString = filterString.toLowerCase();
-                                       if (this.filterString != null)
-                                               if (newFilterString.startsWith(this.filterString))
-                                                       fullSearch = false;
+                                       if ((this.filterString != null) && newFilterString.startsWith(this.filterString))
+                                          fullSearch = false;
                                        this.filterString = newFilterString;
                                }
                        }
index d93d8fa..5d143d5 100644 (file)
@@ -31,7 +31,7 @@
        </natures>
        <filteredResources>
                <filter>
-                       <id>1441111444319</id>
+                       <id>1493841260620</id>
                        <name></name>
                        <type>6</type>
                        <matcher>
@@ -40,7 +40,7 @@
                        </matcher>
                </filter>
                <filter>
-                       <id>1441111444325</id>
+                       <id>1493841260623</id>
                        <name></name>
                        <type>6</type>
                        <matcher>
                                <arguments>1.0-name-matches-false-false-*.la</arguments>
                        </matcher>
                </filter>
+               <filter>
+                       <id>1493841260627</id>
+                       <name></name>
+                       <type>6</type>
+                       <matcher>
+                               <id>org.eclipse.ui.ide.multiFilter</id>
+                               <arguments>1.0-name-matches-false-false-*.o</arguments>
+                       </matcher>
+               </filter>
        </filteredResources>
 </projectDescription>
index 6085efb..c149ac6 100644 (file)
@@ -86,8 +86,8 @@ public class ObjectFilter extends ViewerFilter
                
                switch(mode)
                {
-                       case NAME:
-                               return usePatternMatching ? Glob.matchIgnoreCase(filterString, object.getObjectName()) : object.getObjectName().toLowerCase().contains(filterString);
+         case COMMENTS:
+            return object.getComments().toLowerCase().contains(filterString);
                        case IP_ADDRESS:
                           if (object instanceof AbstractNode)
                           {
@@ -115,6 +115,8 @@ public class ObjectFilter extends ViewerFilter
                return ((AccessPoint)object).getIpAddress().getHostAddress().startsWith(filterString);
             }
                           return false;
+         case NAME:
+            return usePatternMatching ? Glob.matchIgnoreCase(filterString, object.getObjectName()) : object.getObjectName().toLowerCase().contains(filterString);
                        case OBJECT_ID:
                           if (object instanceof AbstractObject)
                           {
@@ -122,8 +124,6 @@ public class ObjectFilter extends ViewerFilter
                              return String.valueOf(objectID).startsWith(filterString);
                           }
             return false;
-                       case COMMENTS:
-                               return object.getComments().toLowerCase().contains(filterString);
                }
                
                return false;
@@ -180,7 +180,10 @@ public class ObjectFilter extends ViewerFilter
                        if (filterString.charAt(0) == '/')
                        {
                                mode = COMMENTS;
-                               this.filterString = filterString.substring(1);
+            String newFilterString = filterString.substring(1).toLowerCase();
+            if ((this.filterString != null) && newFilterString.startsWith(this.filterString))
+               fullSearch = false;
+            this.filterString = newFilterString;
                        }
                        else if (filterString.charAt(0) == '>')
                        {
@@ -203,9 +206,8 @@ public class ObjectFilter extends ViewerFilter
                                else
                                {
                                        String newFilterString = filterString.toLowerCase();
-                                       if (this.filterString != null)
-                                               if (newFilterString.startsWith(this.filterString))
-                                                       fullSearch = false;
+                                       if ((this.filterString != null) && newFilterString.startsWith(this.filterString))
+                                          fullSearch = false;
                                        this.filterString = newFilterString;
                                }
                        }