|
|
|
@ -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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|