|
|
|
@ -64,7 +64,10 @@ import java.io.StringReader;
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.Locale; |
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Collections; |
|
|
|
|
import java.util.Comparator; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 组合了普通公式和脚本公式的编辑器面板 |
|
|
|
@ -244,15 +247,19 @@ public class GroupFormulaPane extends BasicPane implements UIFormula, OperateLis
|
|
|
|
|
if (keyWord.length() != 0) { |
|
|
|
|
NameAndDescription[] descriptions = FunctionConstants.ALL.getDescriptions(); |
|
|
|
|
int lengthOfDes = descriptions.length; |
|
|
|
|
List<String> list = new ArrayList<String>(); |
|
|
|
|
for (int i = 0; i < lengthOfDes; i++) { |
|
|
|
|
NameAndDescription and = descriptions[i]; |
|
|
|
|
|
|
|
|
|
String functionName = and.searchResult(keyWord, findDescription); |
|
|
|
|
if (StringKit.isNotBlank(functionName)) { |
|
|
|
|
listModel.addElement(functionName); |
|
|
|
|
list.add(functionName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Collections.sort(list, new SimilarComparator(keyWord)); |
|
|
|
|
for (String name : list) { |
|
|
|
|
listModel.addElement(name); |
|
|
|
|
} |
|
|
|
|
if (!listModel.isEmpty()) { |
|
|
|
|
tipsList.setSelectedIndex(0); |
|
|
|
|
refreshDescriptionTextArea((String) listModel.getElementAt(0)); |
|
|
|
@ -773,6 +780,26 @@ public class GroupFormulaPane extends BasicPane implements UIFormula, OperateLis
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class SimilarComparator implements Comparator<String> { |
|
|
|
|
|
|
|
|
|
private String searchKey; |
|
|
|
|
|
|
|
|
|
public SimilarComparator(String searchKey) { |
|
|
|
|
this.searchKey = searchKey.toLowerCase(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int compare(String o1, String o2) { |
|
|
|
|
if (o1.toLowerCase().startsWith(searchKey)) { |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
if (o2.toLowerCase().startsWith(searchKey)) { |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
return o2.compareTo(o1); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static class TextUserObject { |
|
|
|
|
|
|
|
|
|
public TextUserObject(String text) { |
|
|
|
|