From 0c85389c790c74cb905e4842d40bdb58e4f86cf9 Mon Sep 17 00:00:00 2001 From: Yvan Date: Thu, 6 Aug 2020 10:42:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E8=A6=81=E4=BF=AE=E6=94=B9=EF=BC=9A?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E4=BA=86=E5=AF=B9=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E6=8E=92=E5=BA=8F=E7=9A=84=E6=AF=94=E8=BE=83?= =?UTF-8?q?=E5=99=A8=EF=BC=8C=E5=88=86=E4=B8=BA=E4=BB=A5=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E8=AF=8D=E5=BC=80=E5=A4=B4=E5=92=8C=E4=B8=8D=E4=BB=A5=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E8=AF=8D=E5=BC=80=E5=A4=B4=E4=B8=A4=E9=83=A8=E5=88=86?= =?UTF-8?q?=EF=BC=8C=E5=90=84=E8=87=AA=E4=BB=A5=E5=AD=97=E6=AF=8D=E8=A1=A8?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F=E6=8E=92=E5=88=97=EF=BC=8C=E5=85=B6=E4=B8=AD?= =?UTF-8?q?=E5=9C=A8=E4=BB=A5=E5=85=B3=E9=94=AE=E8=AF=8D=E5=BC=80=E5=A4=B4?= =?UTF-8?q?=E7=9A=84=E9=83=A8=E5=88=86=EF=BC=8C=E6=9C=80=E4=B8=BA=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=85=B3=E9=94=AE=E8=AF=8D=E7=9A=84=E6=94=BE=E5=9C=A8?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java index 96a82d228f..8b68dcdbe4 100644 --- a/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java +++ b/designer-base/src/main/java/com/fr/design/formula/FormulaPane.java @@ -1008,15 +1008,23 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula { this.searchKey = searchKey.toLowerCase(); } + /** + * 把以关键词开头的和不以关键词开头的分别按照字母表顺序排序 + * @param o1 待比较对象1 + * @param o2 待比较对象2 + * @return 比较结果,1表示 o1 > o2, -1表示 o1 < o2, 0表示 o1 = o2 + */ @Override public int compare(String o1, String o2) { - if (o1.toLowerCase().startsWith(searchKey)) { - return -1; - } - if (o2.toLowerCase().startsWith(searchKey)) { - return 1; + int result; + boolean o1StartWith = o1.toLowerCase().startsWith(searchKey); + boolean o2StartWith = o2.toLowerCase().startsWith(searchKey); + if (o1StartWith) { + result = o2StartWith ? o1.compareTo(o2) : -1; + } else { + result = o2StartWith ? 1 : o1.compareTo(o2); } - return o2.compareTo(o1); + return result; } }