This is an automated email from the ASF dual-hosted git repository.

hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop.git


The following commit(s) were added to refs/heads/master by this push:
     new caf38f9  HOP-2930 The ContextDialog should ignore diacritics marks
     new 729d292  Merge pull request #847 from nadment/HOP-2930
caf38f9 is described below

commit caf38f9278f8a4733f9ca96bfa12238d087e79e3
Author: nadment <[email protected]>
AuthorDate: Wed Jun 2 21:38:14 2021 +0200

    HOP-2930 The ContextDialog should ignore diacritics marks
---
 .../java/org/apache/hop/core/gui/plugin/action/GuiAction.java | 10 ++++++++--
 core/src/main/java/org/apache/hop/core/util/StringUtil.java   | 11 +++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git 
a/core/src/main/java/org/apache/hop/core/gui/plugin/action/GuiAction.java 
b/core/src/main/java/org/apache/hop/core/gui/plugin/action/GuiAction.java
index 30a3485..e2d352b 100644
--- a/core/src/main/java/org/apache/hop/core/gui/plugin/action/GuiAction.java
+++ b/core/src/main/java/org/apache/hop/core/gui/plugin/action/GuiAction.java
@@ -19,7 +19,7 @@ package org.apache.hop.core.gui.plugin.action;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.hop.core.gui.plugin.IGuiActionLambda;
-
+import org.apache.hop.core.util.StringUtil;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
@@ -111,11 +111,14 @@ public class GuiAction {
     }
     return true;
   }
-
+  
   public boolean containsFilterString( String filter ) {
     if ( filter == null ) {
       return false;
     }
+
+    filter = StringUtil.removeDiacriticalMarks(filter);
+  
     if ( matchesString( name, filter ) ) {
       return true;
     }
@@ -140,6 +143,9 @@ public class GuiAction {
     if ( StringUtils.isEmpty( string ) ) {
       return false;
     }
+
+    string = StringUtil.removeDiacriticalMarks(string);
+
     // TODO: consider some fuzzy matching algorithm
     // TODO: Do a Levenshtein distance on the filter string across all valid 
string indexes 0..
     return string.toUpperCase().contains( filter.toUpperCase() );
diff --git a/core/src/main/java/org/apache/hop/core/util/StringUtil.java 
b/core/src/main/java/org/apache/hop/core/util/StringUtil.java
index 24feba5..6c1fe45 100644
--- a/core/src/main/java/org/apache/hop/core/util/StringUtil.java
+++ b/core/src/main/java/org/apache/hop/core/util/StringUtil.java
@@ -25,6 +25,7 @@ import java.text.DateFormat;
 import java.text.DateFormatSymbols;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
+import java.text.Normalizer;
 import java.text.NumberFormat;
 import java.text.SimpleDateFormat;
 import java.util.Collections;
@@ -617,4 +618,14 @@ public class StringUtil {
 
     return source.substring( 0, index );
   }
+  
+  /**
+   * Remove diacritical marks from a string (accents and cedilla) and return 
the same string withour marks.
+   * 
+   * @param source the {@link String} to clean
+   * @return the string without marks
+   */
+  public static String removeDiacriticalMarks(String source) {    
+    return Normalizer.normalize(source, 
Normalizer.Form.NFD).replaceAll("\\p{InCombiningDiacriticalMarks}+", "");
+  }
 }

Reply via email to