diff --git a/designer_base/src/com/fr/design/formula/AbstractFunctionGroup.java b/designer_base/src/com/fr/design/formula/AbstractFunctionGroup.java new file mode 100644 index 000000000..c8a80f809 --- /dev/null +++ b/designer_base/src/com/fr/design/formula/AbstractFunctionGroup.java @@ -0,0 +1,30 @@ +package com.fr.design.formula; + +import com.fr.stable.fun.mark.API; +import com.fr.stable.script.FunctionDef; + +@API(level = FunctionGroupDefineProvider.CURRENT_LEVEL) +public abstract class AbstractFunctionGroup implements FunctionGroupDefineProvider { + + @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; + } + +} diff --git a/designer_base/src/com/fr/design/formula/FormulaPane.java b/designer_base/src/com/fr/design/formula/FormulaPane.java index d7e3f21be..d2910fa96 100644 --- a/designer_base/src/com/fr/design/formula/FormulaPane.java +++ b/designer_base/src/com/fr/design/formula/FormulaPane.java @@ -22,8 +22,10 @@ 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.*; @@ -32,10 +34,12 @@ import javax.swing.event.ListSelectionListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.*; + import java.awt.*; import java.awt.event.*; import java.io.*; import java.util.Locale; +import java.util.Set; /** * 公式编辑面板 * @editor zhou @@ -581,7 +585,13 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ functionTypeListModel.addElement(FunctionConstants.ALL); functionTypeListModel.addElement(FunctionConstants.CUSTOM); functionTypeListModel.addElement(FunctionConstants.PLUGIN); - + //hugh:自定义函数分组 + Set groups = ExtraClassManager.getInstance().getArray(FunctionGroupDefineProvider.MARK_STRING); + if(!groups.isEmpty()){ + for(Mutable group : groups){ + functionTypeListModel.addElement(group); + } + } functionTypeList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { diff --git a/designer_base/src/com/fr/design/formula/FunctionConstants.java b/designer_base/src/com/fr/design/formula/FunctionConstants.java index cfb983dd7..d33ad58e8 100644 --- a/designer_base/src/com/fr/design/formula/FunctionConstants.java +++ b/designer_base/src/com/fr/design/formula/FunctionConstants.java @@ -11,6 +11,8 @@ 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.FunctionGroupDefineProvider; +import com.fr.stable.fun.mark.Mutable; import com.fr.stable.script.Function; import com.fr.stable.script.FunctionDef; @@ -96,7 +98,13 @@ public abstract class FunctionConstants { } Collections.addAll(all, PLUGIN.getDescriptions()); Collections.addAll(all, CUSTOM.getDescriptions()); - + //hugh:自定义函数分组 + Set groups = ExtraClassManager.getInstance().getArray(FunctionGroupDefineProvider.MARK_STRING); + if(!groups.isEmpty()){ + for(Mutable group : groups){ + Collections.addAll(all, ((FunctionGroup)group).getDescriptions()); + } + } java.util.Collections.sort(all, NameAndDescriptionComparator); return all.toArray(new NameAndDescription[all.size()]); diff --git a/designer_base/src/com/fr/design/formula/FunctionGroupDefineProvider.java b/designer_base/src/com/fr/design/formula/FunctionGroupDefineProvider.java new file mode 100644 index 000000000..671a07fc7 --- /dev/null +++ b/designer_base/src/com/fr/design/formula/FunctionGroupDefineProvider.java @@ -0,0 +1,12 @@ +package com.fr.design.formula; + +import com.fr.design.formula.FunctionGroup; +import com.fr.stable.fun.mark.Mutable; +import com.fr.stable.script.FunctionDef; + +public interface FunctionGroupDefineProvider extends Mutable,FunctionGroup{ + int CURRENT_LEVEL = 1; + String MARK_STRING = "FunctionGroupDefineProvider"; + + public FunctionDef[] getFunctionDefs(); +}