Browse Source

Merge pull request #655 in BA/design from ~HUGH/design:release to release

* commit '6a8b12b3b109de89384b1b5de118bfb7e9d1525d':
  遗漏了一个地方
  之前接口开得有问题,部署时算子初始化会出错【读不到函数,因为依赖中有designer的类】
  更改接口,分离原来的方法,单独成接口,为了方便算子生成时获取分组接口里面的函数。没有动FinctionGroup这个接口,因为动这里牵扯太广了,单独做一个接口专职获取公式就好
master
superman 8 years ago
parent
commit
1243b1c491
  1. 12
      designer_base/src/com/fr/design/formula/FormulaPane.java
  2. 50
      designer_base/src/com/fr/design/formula/FunctionConstants.java
  3. 4
      designer_base/src/com/fr/design/formula/FunctionGroup.java
  4. 38
      designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java

12
designer_base/src/com/fr/design/formula/FormulaPane.java

@ -22,10 +22,8 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.parser.FRLexer;
import com.fr.parser.FRParser;
import com.fr.plugin.ExtraClassManager;
import com.fr.stable.ProductConstants;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Expression;
import javax.swing.*;
@ -618,13 +616,9 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{
functionTypeListModel.addElement(FunctionConstants.ALL);
functionTypeListModel.addElement(FunctionConstants.CUSTOM);
functionTypeListModel.addElement(FunctionConstants.PLUGIN);
//hugh:自定义函数分组
Set<Mutable> groups = ExtraClassManager.getInstance().getArray(FunctionGroup.MARK_STRING);
if(!groups.isEmpty()){
for(Mutable group : groups){
functionTypeListModel.addElement(group);
}
}
//hugh: 从函数分组插件中添加分组
FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel);
}
private void initFunctionNameListCellRenderer(){

50
designer_base/src/com/fr/design/formula/FunctionConstants.java

@ -11,6 +11,7 @@ import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.fun.FunctionDefContainer;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef;
@ -24,8 +25,49 @@ import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.swing.DefaultListModel;
public abstract class FunctionConstants {
/**
* 将函数分组插件中的函数添加到对应的列表中
* @param listModel
*/
public static void addFunctionGroupFromPlugins(DefaultListModel listModel){
//hugh:自定义函数分组
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
listModel.addElement(createFunctionGroup((FunctionDefContainer)container));
}
}
}
/**
* 创建一个新的分组
* @param container
* @return
*/
private static FunctionGroup createFunctionGroup(final FunctionDefContainer container){
return new FunctionGroup() {
@Override
public String getGroupName() {
return container.getGroupName();
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionDef[] fs = container.getFunctionDefs();
int count = fs.length;
FunctionDefNAD[] nads = new FunctionDefNAD[count];
for (int i = 0; i < count; i ++) {
nads[i] = new FunctionDefNAD(fs[i]);
}
return nads;
}
};
}
public static FunctionGroup PLUGIN = new FunctionGroup() {
@Override
public String getGroupName() {
@ -98,10 +140,10 @@ public abstract class FunctionConstants {
Collections.addAll(all, PLUGIN.getDescriptions());
Collections.addAll(all, CUSTOM.getDescriptions());
//hugh:自定义函数分组
Set<Mutable> groups = ExtraClassManager.getInstance().getArray(FunctionGroup.MARK_STRING);
if(!groups.isEmpty()){
for(Mutable group : groups){
Collections.addAll(all, ((FunctionGroup)group).getDescriptions());
Set<Mutable> containers = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING);
if(!containers.isEmpty()){
for(Mutable container : containers){
Collections.addAll(all,createFunctionGroup(((FunctionDefContainer)container)).getDescriptions());
}
}
java.util.Collections.sort(all, NameAndDescriptionComparator);

4
designer_base/src/com/fr/design/formula/FunctionGroup.java

@ -2,10 +2,6 @@ package com.fr.design.formula;
public interface FunctionGroup {
int CURRENT_LEVEL = 1;
String MARK_STRING = "FunctionGroup";
String getGroupName();
NameAndDescription[] getDescriptions();
}

38
designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java

@ -1,38 +0,0 @@
package com.fr.design.fun.impl;
import com.fr.design.formula.FunctionDefNAD;
import com.fr.design.formula.FunctionGroup;
import com.fr.design.formula.NameAndDescription;
import com.fr.stable.fun.mark.API;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.FunctionDef;
@API(level = FunctionGroup.CURRENT_LEVEL)
public abstract class AbstractFunctionGroup implements Mutable, FunctionGroup {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
@Override
public String mark4Provider() {
return getClass().getName();
}
@Override
public NameAndDescription[] getDescriptions() {
FunctionDef[] funcs = getFunctionDefs();
int count = funcs.length;
FunctionDefNAD[] nads = new FunctionDefNAD[count];
for (int i = 0; i < count; i ++) {
nads[i] = new FunctionDefNAD(funcs[i]);
}
return nads;
}
public FunctionDef[] getFunctionDefs(){
return new FunctionDef[0];
}
}
Loading…
Cancel
Save