From 406c5e7d1b1e3dde18c605c3f0abfd0f79537c60 Mon Sep 17 00:00:00 2001 From: hugh Date: Sat, 14 Jan 2017 10:59:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E5=88=86=E7=A6=BB=E5=8E=9F=E6=9D=A5=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=8D=95=E7=8B=AC=E6=88=90=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=8C=E4=B8=BA=E4=BA=86=E6=96=B9=E4=BE=BF=E7=AE=97=E5=AD=90?= =?UTF-8?q?=E7=94=9F=E6=88=90=E6=97=B6=E8=8E=B7=E5=8F=96=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E9=87=8C=E9=9D=A2=E7=9A=84=E5=87=BD=E6=95=B0?= =?UTF-8?q?=E3=80=82=E6=B2=A1=E6=9C=89=E5=8A=A8FinctionGroup=E8=BF=99?= =?UTF-8?q?=E4=B8=AA=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=9B=A0=E4=B8=BA=E5=8A=A8?= =?UTF-8?q?=E8=BF=99=E9=87=8C=E7=89=B5=E6=89=AF=E5=A4=AA=E5=B9=BF=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E5=8D=95=E7=8B=AC=E5=81=9A=E4=B8=80=E4=B8=AA=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=B8=93=E8=81=8C=E8=8E=B7=E5=8F=96=E5=85=AC=E5=BC=8F?= =?UTF-8?q?=E5=B0=B1=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/formula/FormulaPane.java | 3 ++- .../src/com/fr/design/formula/FunctionConstants.java | 3 ++- .../src/com/fr/design/formula/FunctionGroup.java | 4 ---- .../src/com/fr/design/fun/impl/AbstractFunctionGroup.java | 8 +++++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/designer_base/src/com/fr/design/formula/FormulaPane.java b/designer_base/src/com/fr/design/formula/FormulaPane.java index 260ca917b..e33a9414d 100644 --- a/designer_base/src/com/fr/design/formula/FormulaPane.java +++ b/designer_base/src/com/fr/design/formula/FormulaPane.java @@ -23,6 +23,7 @@ import com.fr.general.Inter; import com.fr.parser.FRLexer; import com.fr.parser.FRParser; import com.fr.plugin.ExtraClassManager; +import com.fr.script.FunctionDefContainer; import com.fr.stable.ProductConstants; import com.fr.stable.StringUtils; import com.fr.stable.fun.mark.Mutable; @@ -619,7 +620,7 @@ public class FormulaPane extends BasicPane implements KeyListener, UIFormula{ functionTypeListModel.addElement(FunctionConstants.CUSTOM); functionTypeListModel.addElement(FunctionConstants.PLUGIN); //hugh:自定义函数分组 - Set groups = ExtraClassManager.getInstance().getArray(FunctionGroup.MARK_STRING); + Set groups = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); if(!groups.isEmpty()){ for(Mutable group : groups){ functionTypeListModel.addElement(group); diff --git a/designer_base/src/com/fr/design/formula/FunctionConstants.java b/designer_base/src/com/fr/design/formula/FunctionConstants.java index 372409583..1194418e7 100644 --- a/designer_base/src/com/fr/design/formula/FunctionConstants.java +++ b/designer_base/src/com/fr/design/formula/FunctionConstants.java @@ -7,6 +7,7 @@ import com.fr.function.*; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.plugin.ExtraClassManager; +import com.fr.script.FunctionDefContainer; import com.fr.stable.EncodeConstants; import com.fr.stable.OperatingSystem; import com.fr.stable.StableUtils; @@ -98,7 +99,7 @@ public abstract class FunctionConstants { Collections.addAll(all, PLUGIN.getDescriptions()); Collections.addAll(all, CUSTOM.getDescriptions()); //hugh:自定义函数分组 - Set groups = ExtraClassManager.getInstance().getArray(FunctionGroup.MARK_STRING); + Set groups = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); if(!groups.isEmpty()){ for(Mutable group : groups){ Collections.addAll(all, ((FunctionGroup)group).getDescriptions()); diff --git a/designer_base/src/com/fr/design/formula/FunctionGroup.java b/designer_base/src/com/fr/design/formula/FunctionGroup.java index b2d181b12..4764454ed 100644 --- a/designer_base/src/com/fr/design/formula/FunctionGroup.java +++ b/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(); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java b/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java index 674339362..bd6a0c636 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java @@ -3,17 +3,18 @@ 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 = FunctionGroup.CURRENT_LEVEL) -public abstract class AbstractFunctionGroup implements Mutable, FunctionGroup { +@API(level = FunctionDefContainer.CURRENT_LEVEL) +public abstract class AbstractFunctionGroup implements Mutable, FunctionGroup,FunctionDefContainer { @Override public int currentAPILevel() { - return CURRENT_LEVEL; + return FunctionDefContainer.CURRENT_LEVEL; } @Override @@ -32,6 +33,7 @@ public abstract class AbstractFunctionGroup implements Mutable, FunctionGroup { return nads; } + @Override public FunctionDef[] getFunctionDefs(){ return new FunctionDef[0]; } From dcb837a7218faa05742542619248fdaa2ead8060 Mon Sep 17 00:00:00 2001 From: hugh Date: Sat, 14 Jan 2017 13:51:34 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=B9=8B=E5=89=8D=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E5=BC=80=E5=BE=97=E6=9C=89=E9=97=AE=E9=A2=98=EF=BC=8C=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E6=97=B6=E7=AE=97=E5=AD=90=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E4=BC=9A=E5=87=BA=E9=94=99=E3=80=90=E8=AF=BB=E4=B8=8D=E5=88=B0?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E5=9B=A0=E4=B8=BA=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E4=B8=AD=E6=9C=89designer=E7=9A=84=E7=B1=BB=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/formula/FormulaPane.java | 13 ++---- .../fr/design/formula/FunctionConstants.java | 43 ++++++++++++++++++- .../fun/impl/AbstractFunctionGroup.java | 40 ----------------- 3 files changed, 45 insertions(+), 51 deletions(-) delete mode 100644 designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java diff --git a/designer_base/src/com/fr/design/formula/FormulaPane.java b/designer_base/src/com/fr/design/formula/FormulaPane.java index e33a9414d..9aec1972a 100644 --- a/designer_base/src/com/fr/design/formula/FormulaPane.java +++ b/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.parser.FRLexer; import com.fr.parser.FRParser; -import com.fr.plugin.ExtraClassManager; -import com.fr.script.FunctionDefContainer; 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.*; @@ -619,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 groups = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); - if(!groups.isEmpty()){ - for(Mutable group : groups){ - functionTypeListModel.addElement(group); - } - } + + //hugh: 从函数分组插件中添加分组 + FunctionConstants.addFunctionGroupFromPlugins(functionTypeListModel); } private void initFunctionNameListCellRenderer(){ diff --git a/designer_base/src/com/fr/design/formula/FunctionConstants.java b/designer_base/src/com/fr/design/formula/FunctionConstants.java index 1194418e7..0575f8950 100644 --- a/designer_base/src/com/fr/design/formula/FunctionConstants.java +++ b/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.Inter; import com.fr.plugin.ExtraClassManager; -import com.fr.script.FunctionDefContainer; 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; @@ -25,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 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() { diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java b/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java deleted file mode 100644 index bd6a0c636..000000000 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFunctionGroup.java +++ /dev/null @@ -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]; - } -} From 6a8b12b3b109de89384b1b5de118bfb7e9d1525d Mon Sep 17 00:00:00 2001 From: hugh Date: Sat, 14 Jan 2017 13:57:15 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=81=97=E6=BC=8F=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=9C=B0=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/formula/FunctionConstants.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/formula/FunctionConstants.java b/designer_base/src/com/fr/design/formula/FunctionConstants.java index 0575f8950..8a0675897 100644 --- a/designer_base/src/com/fr/design/formula/FunctionConstants.java +++ b/designer_base/src/com/fr/design/formula/FunctionConstants.java @@ -140,10 +140,10 @@ public abstract class FunctionConstants { Collections.addAll(all, PLUGIN.getDescriptions()); Collections.addAll(all, CUSTOM.getDescriptions()); //hugh:自定义函数分组 - Set groups = ExtraClassManager.getInstance().getArray(FunctionDefContainer.MARK_STRING); - if(!groups.isEmpty()){ - for(Mutable group : groups){ - Collections.addAll(all, ((FunctionGroup)group).getDescriptions()); + Set 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);