8 changed files with 187 additions and 54 deletions
@ -1,15 +1,28 @@
|
||||
package com.fr.solution.plugin.design.formula.compat; |
||||
|
||||
import com.fr.design.formula.AbstractNameAndDescription; |
||||
import com.fr.stable.script.FunctionDef; |
||||
|
||||
/** |
||||
* 函数名和描述 |
||||
* |
||||
* @author Kalven |
||||
* @version 10.0 |
||||
* Created by Kalven on 2019/8/31 |
||||
*/ |
||||
public class FunctionDefNAD extends com.fr.design.formula.FunctionDefNAD { |
||||
public FunctionDefNAD(FunctionDef functionDef) { |
||||
super(functionDef); |
||||
public class FunctionDefNAD extends AbstractNameAndDescription { |
||||
|
||||
private FunctionDef def; |
||||
|
||||
public FunctionDefNAD(FunctionDef def) { |
||||
this.def = def; |
||||
} |
||||
|
||||
public String getName() { |
||||
return this.def == null ? "" : this.def.getName(); |
||||
} |
||||
|
||||
public String getDesc() { |
||||
return this.def == null ? "" : this.def.getDescription(); |
||||
} |
||||
} |
||||
|
@ -0,0 +1,51 @@
|
||||
package com.fr.solution.plugin.design.formula.compat; |
||||
|
||||
import com.fr.design.formula.AbstractNameAndDescription; |
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.script.CalculatorEmbeddedFunction; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.script.Function; |
||||
|
||||
import java.util.Locale; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-03 |
||||
*/ |
||||
public class FunctionNAD extends AbstractNameAndDescription { |
||||
|
||||
private Function fn; |
||||
|
||||
FunctionNAD(Function fn) { |
||||
this.fn = fn; |
||||
} |
||||
|
||||
public String getName() { |
||||
return fn == null ? StringUtils.EMPTY : fn.getClass().getSimpleName(); |
||||
} |
||||
|
||||
public String getDesc() { |
||||
if (fn == null) { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
Locale locale = GeneralContext.getLocale(); |
||||
String describtion = fn.getDescription(locale); |
||||
if (describtion.startsWith(CalculatorEmbeddedFunction.LOCALE_PREFIX)) { |
||||
return Locale.CHINA.equals(locale) ? fn.getCN() : fn.getEN(); |
||||
} |
||||
|
||||
return describtion; |
||||
} |
||||
|
||||
@Override |
||||
public String searchResult(String keyWord, boolean findDescription) { |
||||
String functionName = getName(); |
||||
String des = getDesc(); |
||||
if (findDescription && des.contains(keyWord)) { |
||||
return functionName; |
||||
} else { |
||||
return super.searchResult(keyWord, findDescription); |
||||
} |
||||
} |
||||
} |
@ -1,16 +1,42 @@
|
||||
package com.fr.solution.plugin.design.formula.compat; |
||||
|
||||
import com.fr.design.formula.FunctionGroup; |
||||
import com.fr.design.formula.NameAndDescription; |
||||
import com.fr.stable.script.Function; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.Arrays; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* 名称对应的函数列表 |
||||
* |
||||
* @author Kalven |
||||
* @version 10.0 |
||||
* Created by Kalven on 2019/8/31 |
||||
*/ |
||||
public class NameAndFunctionList extends com.fr.design.formula.NameAndFunctionList { |
||||
public NameAndFunctionList(String name, Function[] fns) { |
||||
super(name, fns); |
||||
public class NameAndFunctionList implements FunctionGroup { |
||||
|
||||
protected String name; |
||||
protected List<Function> fnList = new ArrayList<>(); |
||||
|
||||
public NameAndFunctionList(String var1, Function[] var2) { |
||||
this.name = var1; |
||||
this.fnList.addAll(Arrays.asList(var2)); |
||||
} |
||||
|
||||
public String getGroupName() { |
||||
return this.name; |
||||
} |
||||
|
||||
public NameAndDescription[] getDescriptions() { |
||||
NameAndDescription[] var1 = new NameAndDescription[this.fnList.size()]; |
||||
|
||||
for (int var2 = 0; var2 < var1.length; ++var2) { |
||||
var1[var2] = new FunctionNAD(this.fnList.get(var2)); |
||||
} |
||||
|
||||
return var1; |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue