Browse Source

之前接口开得有问题,部署时算子初始化会出错【读不到函数,因为依赖中有designer的类】

master
hugh 8 years ago
parent
commit
dcb837a721
  1. 13
      designer_base/src/com/fr/design/formula/FormulaPane.java
  2. 43
      designer_base/src/com/fr/design/formula/FunctionConstants.java
  3. 40
      designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java

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

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

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

@ -7,11 +7,11 @@ import com.fr.function.*;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.plugin.ExtraClassManager; import com.fr.plugin.ExtraClassManager;
import com.fr.script.FunctionDefContainer;
import com.fr.stable.EncodeConstants; import com.fr.stable.EncodeConstants;
import com.fr.stable.OperatingSystem; import com.fr.stable.OperatingSystem;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.fun.FunctionDefContainer;
import com.fr.stable.fun.mark.Mutable; import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.Function; import com.fr.stable.script.Function;
import com.fr.stable.script.FunctionDef; import com.fr.stable.script.FunctionDef;
@ -25,8 +25,49 @@ import java.util.*;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import javax.swing.DefaultListModel;
public abstract class FunctionConstants { 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() { public static FunctionGroup PLUGIN = new FunctionGroup() {
@Override @Override
public String getGroupName() { public String getGroupName() {

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

@ -1,40 +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.script.FunctionDefContainer;
import com.fr.stable.fun.mark.API;
import com.fr.stable.fun.mark.Mutable;
import com.fr.stable.script.FunctionDef;
@API(level = FunctionDefContainer.CURRENT_LEVEL)
public abstract class AbstractFunctionGroup implements Mutable, FunctionGroup,FunctionDefContainer {
@Override
public int currentAPILevel() {
return FunctionDefContainer.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;
}
@Override
public FunctionDef[] getFunctionDefs(){
return new FunctionDef[0];
}
}
Loading…
Cancel
Save