MISC: fix a bug of processing wildcard on filter dialog
authorGun Kim <gune.kim@samsung.com>
Wed, 21 Sep 2016 10:28:33 +0000 (19:28 +0900)
committerGun Kim <gune.kim@samsung.com>
Wed, 21 Sep 2016 10:33:43 +0000 (19:33 +0900)
When * is located right after backslash, filter worked incorrectly.
Fix it.

Change-Id: Idf2126e26dbcaa445033090c72905327b6bf3370
Signed-off-by: Gun Kim <gune.kim@samsung.com>
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/FilteredList.java
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/misc/StringMatcher.java

index a9c9339..599a69b 100644 (file)
@@ -9,13 +9,17 @@
  *   IBM Corporation - initial API and implementation
  *   Sebastian Davids <sdavids@gmx.de> - Fix for bug 19346 - Dialog font should be activated and used by other components.
  *******************************************************************************/
+/*
+ * 2016-09-21 Gun Kim gune.kim@samsung.com
+ * Modification by S-Core Co., Ltd.
+ * 1. fix a bug of processing wildcard
+ */
 package org.eclipse.ui.dialogs;
 
 import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.Vector;
-
 import org.eclipse.core.runtime.Assert;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
@@ -83,14 +87,41 @@ public class FilteredList extends Composite {
                @Override
                public void setFilter(String pattern, boolean ignoreCase,
                                boolean ignoreWildCards) {
-                       fMatcher = new StringMatcher(pattern + '*', ignoreCase,
+                       /* Tizen */
+                       fMatcher = new StringMatcher(getPattern(pattern), ignoreCase,
                                        ignoreWildCards);
+                       // fMatcher = new StringMatcher(pattern + '*', ignoreCase,
+                       // ignoreWildCards);
+                       /* ===== */
                }
 
                @Override
                public boolean match(Object element) {
                        return fMatcher.match(fLabelProvider.getText(element));
                }
+
+               /* Tizen */
+               private String getPattern(String originPattern) {
+                       int length = originPattern.length();
+                       int backSlashCount = 0;
+                       while (length > 1) {
+                               if (originPattern.charAt(length - 1) == '\\') {
+                                       length--;
+                                       backSlashCount++;
+                               } else {
+                                       break;
+                               }
+                       }
+
+                       if (backSlashCount % 2 == 0) {
+                               return originPattern + "*"; //$NON-NLS-1$
+                       } else {
+                               // In this case, "*" isn't wildcard, it is just "*" literally
+                               // So, add "\\*" instead of "*" to use "*" as wildcard
+                               return originPattern + "\\*"; //$NON-NLS-1$
+                       }
+               }
+               /* ===== */
        }
 
        private Table fList;
index 3f8cd8f..e4489ef 100644 (file)
@@ -8,6 +8,11 @@
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *******************************************************************************/
+/*
+ * 2016-09-21 Gun Kim gune.kim@samsung.com
+ * Modification by S-Core Co., Ltd.
+ * 1. fix a bug of processing wildcard
+ */
 package org.eclipse.ui.internal.misc;
 
 import java.util.Vector;
@@ -279,9 +284,24 @@ public class StringMatcher {
                }
         if (fPattern.endsWith("*")) {//$NON-NLS-1$
             /* make sure it's not an escaped wildcard */
-            if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
-                fHasTrailingStar = true;
-            }
+                       /* Tizen */
+                       int length = fLength;
+                       int backSlashCount = 0;
+                       while (length > 1) {
+                               if (fPattern.charAt(length - 2) == '\\') {
+                                       length--;
+                                       backSlashCount++;
+                               } else {
+                                       break;
+                               }
+                       }
+                       if (backSlashCount % 2 == 0) {
+                               fHasTrailingStar = true;
+                       }
+                       // if (fLength > 1 && fPattern.charAt(fLength - 2) != '\\') {
+                       // fHasTrailingStar = true;
+                       // }
+                       /* ===== */
         }
 
         Vector temp = new Vector();