From 36979667ed7efdced2fa13c0b3b8efb3f3932e5e Mon Sep 17 00:00:00 2001 From: Kalven Date: Sat, 31 Aug 2019 03:47:30 +0800 Subject: [PATCH 01/13] =?UTF-8?q?KERNEL-1117=20=E6=A0=B9=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=A2=9E=E5=8A=A0=E4=BA=86fineKit=E7=9A=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=96=87=E4=BB=B6=EF=BC=8C=E5=85=B6=E4=B8=AD=E5=8D=95?= =?UTF-8?q?=E4=BE=8B=E6=A8=A1=E5=BC=8F=E8=BF=94=E5=9B=9E=E5=8D=95=E4=BE=8B?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95=E6=B2=A1=E6=9C=89=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/base/ParameterHelperKit.java | 21 + .../com/fanruan/api/base/ScriptFormula.java | 17 + .../com/fanruan/api/cal/ScriptFactoryKit.java | 20 + .../cal/namespace/ParameterMapNameSpace.java | 14 + .../SimpleCellValueNameSpaceKit.java | 13 + .../api/design/ui/component/UIRadioPane.java | 10 + .../component/textarea/RSyntaxTextArea.java | 7 + .../ui/container/DialogActionAdapter.java | 3 + .../ui/container/FurtherBasicBeanPane.java | 8 + .../ui/container/HistoryTemplateListPane.java | 7 + .../ui/container/ParameterInputPane.java | 16 + .../api/design/ui/dialog/BasicDialog.java | 37 ++ .../design/ui/layout/FRGUIPaneFactoryKit.java | 31 ++ .../fanruan/api/design/ui/list/QuickList.java | 12 + .../ui/mainframe/DesignerContextKit.java | 14 + src/main/java/com/fanruan/api/io/IOFile.java | 7 + src/main/java/com/fanruan/api/log/LogKit.java | 9 + .../fanruan/api/macro/ProductConstants.java | 14 + .../com/fanruan/api/structure/Expression.java | 7 + .../com/fanruan/api/structure/Formula.java | 14 + .../com/fanruan/api/structure/Parameter.java | 18 + .../java/com/fanruan/api/util/ContextKit.java | 16 + .../java/com/fanruan/api/util/InterKit.java | 15 + .../api/base/ParameterHelperKitTest.java | 21 + .../fanruan/api/session/SessionKitTest.java | 372 +++++++++--------- .../com/fanruan/api/util/ContextKitTest.java | 20 + .../com/fanruan/api/util/InterKitTest.java | 13 + 27 files changed, 570 insertions(+), 186 deletions(-) create mode 100644 src/main/java/com/fanruan/api/base/ParameterHelperKit.java create mode 100644 src/main/java/com/fanruan/api/base/ScriptFormula.java create mode 100644 src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java create mode 100644 src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java create mode 100644 src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIRadioPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java create mode 100644 src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java create mode 100644 src/main/java/com/fanruan/api/design/ui/list/QuickList.java create mode 100644 src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java create mode 100644 src/main/java/com/fanruan/api/io/IOFile.java create mode 100644 src/main/java/com/fanruan/api/macro/ProductConstants.java create mode 100644 src/main/java/com/fanruan/api/structure/Expression.java create mode 100644 src/main/java/com/fanruan/api/structure/Formula.java create mode 100644 src/main/java/com/fanruan/api/structure/Parameter.java create mode 100644 src/main/java/com/fanruan/api/util/ContextKit.java create mode 100644 src/main/java/com/fanruan/api/util/InterKit.java create mode 100644 src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/ContextKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/InterKitTest.java diff --git a/src/main/java/com/fanruan/api/base/ParameterHelperKit.java b/src/main/java/com/fanruan/api/base/ParameterHelperKit.java new file mode 100644 index 0000000..3c7c05b --- /dev/null +++ b/src/main/java/com/fanruan/api/base/ParameterHelperKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.base; + +import com.fr.base.Parameter; +import com.fr.base.ParameterHelper; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/30 + */ +public class ParameterHelperKit { + /** + * 从字符串中分析中有哪些需要的参数 + * @param text 待分析字符串 + * @param hasColumnRow 是否需要分析格子类型的参数 + * @return 字符串中包含的参数集合 + */ + public static Parameter[] analyze4Parameters(String text, boolean hasColumnRow) { + return ParameterHelper.analyze4Parameters(text, hasColumnRow); + } +} diff --git a/src/main/java/com/fanruan/api/base/ScriptFormula.java b/src/main/java/com/fanruan/api/base/ScriptFormula.java new file mode 100644 index 0000000..59a0124 --- /dev/null +++ b/src/main/java/com/fanruan/api/base/ScriptFormula.java @@ -0,0 +1,17 @@ +package com.fanruan.api.base; + +/** + * 使用script语言的脚本公式 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/30 + */ +public class ScriptFormula extends com.fr.base.ScriptFormula { + public ScriptFormula() { + super(); + } + + public ScriptFormula(String text) { + super(text); + } +} diff --git a/src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java b/src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java new file mode 100644 index 0000000..cb1dc06 --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java @@ -0,0 +1,20 @@ +package com.fanruan.api.cal; + +import com.fr.script.ScriptFactory; + +import javax.script.ScriptEngine; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/30 + */ +public class ScriptFactoryKit { + /** + * 单例模式,获取ScriptEngine对象 + * @return ScriptEngine对象 + */ + public static ScriptEngine newSingletonScriptEngine() { + return ScriptFactory.newSingletonScriptEngine(); + } +} diff --git a/src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java b/src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java new file mode 100644 index 0000000..8db7394 --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java @@ -0,0 +1,14 @@ +package com.fanruan.api.cal.namespace; + +import java.util.Map; + +public class ParameterMapNameSpace { + /** + * 根据参数映射创建一个参数命名空间 + * @param map 参数名和参数值的映射 + * @return 参数命名空间 + */ + public static com.fr.base.ParameterMapNameSpace create(Map map) { + return com.fr.base.ParameterMapNameSpace.create(map); + } +} diff --git a/src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java b/src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java new file mode 100644 index 0000000..83423cf --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java @@ -0,0 +1,13 @@ +package com.fanruan.api.cal.namespace; + +import com.fr.report.core.namespace.SimpleCellValueNameSpace; + +public class SimpleCellValueNameSpaceKit { + /** + * 单例模式,SimpleCellValueNameSpace + * @return SimpleCellValueNameSpace实例对象 + */ + public static SimpleCellValueNameSpace getInstance() { + return SimpleCellValueNameSpace.getInstance(); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIRadioPane.java b/src/main/java/com/fanruan/api/design/ui/component/UIRadioPane.java new file mode 100644 index 0000000..18a02d1 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIRadioPane.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.component; + +/** + * 可以存放按钮组件的容器 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/30 + */ +public abstract class UIRadioPane extends com.fr.design.gui.frpane.UIRadioPane { +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java b/src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java new file mode 100644 index 0000000..0fb41d8 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java @@ -0,0 +1,7 @@ +package com.fanruan.api.design.ui.component.textarea; + +/** + * 公式输入的文本框 + */ +public class RSyntaxTextArea extends com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea { +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java b/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java index d624c63..a6ef245 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java +++ b/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java @@ -1,5 +1,8 @@ package com.fanruan.api.design.ui.container; +/** + * 定义弹窗适配器,可以监听事件实现弹框功能 + */ public class DialogActionAdapter extends com.fr.design.dialog.DialogActionAdapter { public DialogActionAdapter() { diff --git a/src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java b/src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java new file mode 100644 index 0000000..34df3cb --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java @@ -0,0 +1,8 @@ +package com.fanruan.api.design.ui.container; + +/** + * 对基本的容器做了进一步封装,提供了通用的方法 + * @param + */ +public abstract class FurtherBasicBeanPane extends com.fr.design.beans.FurtherBasicBeanPane { +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java b/src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java new file mode 100644 index 0000000..50f6f81 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java @@ -0,0 +1,7 @@ +package com.fanruan.api.design.ui.container; + +/** + * 存放历史模板的列表容器 + */ +public class HistoryTemplateListPane extends com.fr.design.file.HistoryTemplateListPane { +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java b/src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java new file mode 100644 index 0000000..6b505ad --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java @@ -0,0 +1,16 @@ +package com.fanruan.api.design.ui.container; + +import com.fr.stable.ParameterProvider; + +/** + * 用于输入参数的容器 + */ +public class ParameterInputPane extends com.fr.design.parameter.ParameterInputPane { + public ParameterInputPane(ParameterProvider[] parameters) { + super(parameters); + } + + public ParameterInputPane(ParameterProvider[] parameters, boolean allowBlank) { + super(parameters, allowBlank); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java b/src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java new file mode 100644 index 0000000..c95d0bc --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java @@ -0,0 +1,37 @@ +package com.fanruan.api.design.ui.dialog; + +import com.fr.design.dialog.BasicPane; + +import java.awt.*; + +/** + * 对话框的抽象类 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/30 + */ +public abstract class BasicDialog extends com.fr.design.dialog.BasicDialog { + public BasicDialog(Frame frame) { + super(frame); + } + + public BasicDialog(Dialog dialog) { + super(dialog); + } + + public BasicDialog(Frame frame, BasicPane pane) { + super(frame, pane); + } + + public BasicDialog(Dialog dialog, BasicPane pane) { + super(dialog, pane); + } + + public BasicDialog(Frame frame, BasicPane pane, boolean isNeedButtonPane) { + super(frame, pane, isNeedButtonPane); + } + + public BasicDialog(Dialog dialog, BasicPane pane, boolean isNeedButtonPane) { + super(dialog, pane, isNeedButtonPane); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java b/src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java new file mode 100644 index 0000000..e04a1d5 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java @@ -0,0 +1,31 @@ +package com.fanruan.api.design.ui.layout; + +import javax.swing.*; +import java.awt.*; + + +public class FRGUIPaneFactoryKit { + /** + * 创建边框面板S + * @return JPanel对象 + */ + public static JPanel createBorderLayout_S_Pane() { + return com.fr.design.layout.FRGUIPaneFactory.createBorderLayout_S_Pane(); + } + + /** + * 创建一个靠左流式布局,正常流式内嵌 + * @return JPanel对象 + */ + public static JPanel createNormalFlowInnerContainer_S_Pane() { + return com.fr.design.layout.FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + } + + /** + * 创建一个边框布局 + * @return LayoutManager对象 + */ + public static LayoutManager createBorderLayout() { + return com.fr.design.layout.FRGUIPaneFactory.createBorderLayout(); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/list/QuickList.java b/src/main/java/com/fanruan/api/design/ui/list/QuickList.java new file mode 100644 index 0000000..aa4571e --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/list/QuickList.java @@ -0,0 +1,12 @@ +package com.fanruan.api.design.ui.list; + +import javax.swing.*; + +/** + * 支持键盘输入快速查找项的JList + */ +public class QuickList extends com.fr.design.gui.ilist.QuickList { + public QuickList(ListModel listModel) { + super(listModel); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java b/src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java new file mode 100644 index 0000000..ee9c21b --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java @@ -0,0 +1,14 @@ +package com.fanruan.api.design.ui.mainframe; + +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; + +public class DesignerContextKit { + /** + * 单例模式,返回DesignerFrame对象 + * @return DesignerFrame对象 + */ + public static DesignerFrame getDesignerFrame() { + return DesignerContext.getDesignerFrame(); + } +} diff --git a/src/main/java/com/fanruan/api/io/IOFile.java b/src/main/java/com/fanruan/api/io/IOFile.java new file mode 100644 index 0000000..b7e15b4 --- /dev/null +++ b/src/main/java/com/fanruan/api/io/IOFile.java @@ -0,0 +1,7 @@ +package com.fanruan.api.io; + +/** + * 需要进行XML读写的类,该类是数据源类的一个子类 + */ +public abstract class IOFile extends com.fr.base.io.IOFile { +} diff --git a/src/main/java/com/fanruan/api/log/LogKit.java b/src/main/java/com/fanruan/api/log/LogKit.java index bc5fc19..b599314 100644 --- a/src/main/java/com/fanruan/api/log/LogKit.java +++ b/src/main/java/com/fanruan/api/log/LogKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.log; +import com.fr.general.FRLogger; import com.fr.log.FineLoggerFactory; /** @@ -160,4 +161,12 @@ public class LogKit { public static void error(Throwable e, String format, Object... args) { FineLoggerFactory.getLogger().error(e, format, args); } + + /** + * 得到日志对象 + * @return 日志对象 + */ + public static FRLogger getLogger() { + return FRLogger.getLogger(); + } } diff --git a/src/main/java/com/fanruan/api/macro/ProductConstants.java b/src/main/java/com/fanruan/api/macro/ProductConstants.java new file mode 100644 index 0000000..1febf81 --- /dev/null +++ b/src/main/java/com/fanruan/api/macro/ProductConstants.java @@ -0,0 +1,14 @@ +package com.fanruan.api.macro; + + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/30 + */ +public class ProductConstants { + /** + * 详细的产品名字 + */ + public static final String PRODUCT_NAME = com.fr.stable.ProductConstants.PRODUCT_NAME; +} diff --git a/src/main/java/com/fanruan/api/structure/Expression.java b/src/main/java/com/fanruan/api/structure/Expression.java new file mode 100644 index 0000000..e543be8 --- /dev/null +++ b/src/main/java/com/fanruan/api/structure/Expression.java @@ -0,0 +1,7 @@ +package com.fanruan.api.structure; + +/** + * 表达式 + */ +public class Expression extends com.fr.stable.script.Expression { +} diff --git a/src/main/java/com/fanruan/api/structure/Formula.java b/src/main/java/com/fanruan/api/structure/Formula.java new file mode 100644 index 0000000..7c378d9 --- /dev/null +++ b/src/main/java/com/fanruan/api/structure/Formula.java @@ -0,0 +1,14 @@ +package com.fanruan.api.structure; + +/** + * 公式, 公式中可以运用已有的各种函数进行复杂的运算 + */ +public class Formula extends com.fr.base.Formula { + public Formula() { + super(); + } + + public Formula(String text) { + super(text); + } +} diff --git a/src/main/java/com/fanruan/api/structure/Parameter.java b/src/main/java/com/fanruan/api/structure/Parameter.java new file mode 100644 index 0000000..c4640fc --- /dev/null +++ b/src/main/java/com/fanruan/api/structure/Parameter.java @@ -0,0 +1,18 @@ +package com.fanruan.api.structure; + +/** + * 参数,参数是可以动态赋值的对象 + */ +public class Parameter extends com.fr.base.Parameter { + public Parameter() { + super(); + } + + public Parameter(String text) { + super(text); + } + + public Parameter(String name, Object value) { + super(name, value); + } +} diff --git a/src/main/java/com/fanruan/api/util/ContextKit.java b/src/main/java/com/fanruan/api/util/ContextKit.java new file mode 100644 index 0000000..12755df --- /dev/null +++ b/src/main/java/com/fanruan/api/util/ContextKit.java @@ -0,0 +1,16 @@ +package com.fanruan.api.util; + +import com.fr.base.FRContext; + +import java.util.Locale; + +public class ContextKit { + /** + * 返回国际化区属 + * @return 国际化后区域属性 + */ + @Deprecated + public static Locale getLocale() { + return FRContext.getLocale(); + } +} diff --git a/src/main/java/com/fanruan/api/util/InterKit.java b/src/main/java/com/fanruan/api/util/InterKit.java new file mode 100644 index 0000000..36ecac2 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/InterKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.util; + +import com.fr.general.Inter; + +public class InterKit { + + /** + * 获取国际化文本,已过时 + * @param text + * @return 国际化文本字符串 + */ + public static String getLocText(String text) { + return Inter.getLocText(text); + } +} diff --git a/src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java b/src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java new file mode 100644 index 0000000..3be5b3d --- /dev/null +++ b/src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java @@ -0,0 +1,21 @@ +package com.fanruan.api.base; + +import com.fr.stable.ParameterProvider; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class ParameterHelperKitTest { + + @Test + public void analyze4Parameters() { + ParameterProvider p[] = ParameterHelperKit.analyze4Parameters("var a1 = '${A1}';\n" + + "return \"A1的值\" + (a1 > 10 ? \"大于10\" : \"小于等于10\");",false); + assertEquals(p[0].getValue(),""); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/session/SessionKitTest.java b/src/test/java/com/fanruan/api/session/SessionKitTest.java index 275d52d..43eda1d 100644 --- a/src/test/java/com/fanruan/api/session/SessionKitTest.java +++ b/src/test/java/com/fanruan/api/session/SessionKitTest.java @@ -1,186 +1,186 @@ -package com.fanruan.api.session; - -import com.fanruan.api.Prepare; -import com.fr.general.web.ParameterConstants; -import com.fr.invoke.Reflect; -import com.fr.stable.StringUtils; -import com.fr.stable.web.SessionProvider; -import com.fr.stable.web.SessionSource; -import com.fr.stable.web.Weblet; -import com.fr.web.core.RemoteAddressManager; -import com.fr.web.core.SessionPoolManager; -import com.fr.web.session.SessionIDInfo; -import com.fr.web.utils.WebUtils; -import org.easymock.EasyMock; -import org.easymock.IAnswer; -import org.easymock.IMocksControl; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.easymock.PowerMock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; -import org.powermock.modules.junit4.PowerMockRunner; -import org.powermock.reflect.Whitebox; - -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2019-08-09 - */ -@RunWith(PowerMockRunner.class) -@PrepareForTest({SessionPoolManager.class, WebUtils.class}) -@SuppressStaticInitializationFor({"com.fr.web.core.SessionPoolManager"}) -public class SessionKitTest extends Prepare { - - private static final long MIN_ACCESS_INTERVAL = 900; - private int taskCount = 0; - private Map sessions = new HashMap(); - - @Test - public void testGenerateSession() throws Exception { - final SessionIDInfo sessionInfo = new MockSession("session"); - final Map params = new HashMap(); - PowerMock.mockStatic(SessionPoolManager.class); - PowerMock.mockStatic(WebUtils.class); - IMocksControl control = EasyMock.createControl(); - final HttpServletRequest request = control.createMock(HttpServletRequest.class); - EasyMock.expect(WebUtils.getIpAddr(request)).andReturn("127.0.0.1").anyTimes(); - EasyMock.expect(WebUtils.getHTTPRequestParameter(request, ParameterConstants.OP)).andReturn("view").anyTimes(); - EasyMock.expect(WebUtils.parameters4SessionIDInforContainMPCache(request)).andReturn(params).anyTimes(); - final Weblet weblet = control.createMock(Weblet.class); - EasyMock.expect(weblet.isSessionOccupy()).andReturn(false).anyTimes(); - EasyMock.expect(weblet.createSessionIDInfor(request, "127.0.0.1", params)).andReturn(sessionInfo).anyTimes(); - EasyMock.expect(addSessionIDInfo(sessionInfo)).andReturn(sessionInfo.getSessionID()).anyTimes(); - EasyMock.expect(SessionPoolManager.generateSessionID(request, null, weblet)).andAnswer(new IAnswer() { - @Override - public String answer() throws Throwable { - SessionProvider sessionIDInfor = weblet.createSessionIDInfor(request, "127.0.0.1", params); - String sessionID = addSessionIDInfo(sessionIDInfor); - if (weblet.isSessionOccupy()) { - assert sessionID != null; - RemoteAddressManager.add("127.0.0.1", sessionID); - } - return sessionID; - } - }).anyTimes(); - control.replay(); - PowerMock.replayAll(); - sessionInfo.setSource(SessionSource.SINGLE); - SessionPoolManager.generateSessionID(request, null, weblet); - Assert.assertSame(sessionInfo.getSource(), SessionSource.SINGLE); - sessionInfo.setSource(SessionSource.INTEGRATION); - SessionPoolManager.generateSessionID(request, null, weblet); - Assert.assertSame(sessionInfo.getSource(), SessionSource.INTEGRATION); - - } - - @Test - public void testAddDelayTask() { - String sessionID = "test"; - sessions.put("test", new MockSession("test")); - for (int i = 0; i < 100; i++) { - accessSession(sessionID); - } - Assert.assertEquals(1, this.taskCount); - for (int i = 0; i < 2; i++) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - //do nothing - } - accessSession(sessionID); - } - Assert.assertEquals(3, this.taskCount); - } - - private void accessSession(String sessionId) { - if (StringUtils.isBlank(sessionId)) { - return; - } - - SessionProvider sessionIDInfor = sessions.get(sessionId); - if (sessionIDInfor != null) { - long accessInterval = System.currentTimeMillis() - sessionIDInfor.getLastAccessTime(); - sessionIDInfor.updateTime(); - if (accessInterval > MIN_ACCESS_INTERVAL) { - taskCount++; - } - } - } - - @Test - public void testGetAllSession() { - Whitebox.setInternalState( - SessionPoolManager.class, - "sessionIDMap", - new ConcurrentHashMap() - ); - Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); - Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); - String sessionID1 = "Test1"; - sessionIDMap.put(sessionID1, new MockSession(sessionID1)); - sessionIDMap.put("Test2", new MockSession("Test2")); - closeSession(sessionID1); - List list = SessionPoolManager.getAllSession(SessionProvider.class); - assertEquals(1, list.size()); - assertEquals("Test2", list.get(0).getSessionID()); - assertNotNull(SessionKit.getSession("Test2")); - } - - @Test - public void testHasSessionID() { - Whitebox.setInternalState( - SessionPoolManager.class, - "sessionIDMap", - new ConcurrentHashMap() - ); - Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); - Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); - String sessionID1 = "Test1"; - sessionIDMap.put(sessionID1, new MockSession(sessionID1)); - sessionIDMap.put("Test2", new MockSession("Test2")); - closeSession(sessionID1); - assertFalse(SessionPoolManager.hasSessionID(sessionID1)); - assertTrue(SessionPoolManager.hasSessionID("Test2")); - } - - private void closeSession(final String sessionID) { - final Set sessionToDelete = Reflect.on(SessionPoolManager.class).get("sessionToDelete"); - sessionToDelete.add(sessionID); - ExecutorService closeSessionPool = Executors.newFixedThreadPool(1); - closeSessionPool.submit(new Runnable() { - @Override - public void run() { - try { - //模拟删除session对象的过程 - Thread.sleep(1000); - } catch (InterruptedException e) { - //do nothing - } - synchronized (SessionPoolManager.class) { - sessionToDelete.remove(sessionID); - } - } - }); - } - - private String addSessionIDInfo(SessionProvider sessionIDInfo) { - return Reflect.on(SessionPoolManager.class).call("addSessionIDInfor", sessionIDInfo).get(); - } -} \ No newline at end of file +//package com.fanruan.api.session; +// +//import com.fanruan.api.Prepare; +//import com.fr.general.web.ParameterConstants; +//import com.fr.invoke.Reflect; +//import com.fr.stable.StringUtils; +//import com.fr.stable.web.SessionProvider; +//import com.fr.stable.web.SessionSource; +//import com.fr.stable.web.Weblet; +//import com.fr.web.core.RemoteAddressManager; +//import com.fr.web.core.SessionPoolManager; +//import com.fr.web.session.SessionIDInfo; +//import com.fr.web.utils.WebUtils; +//import org.easymock.EasyMock; +//import org.easymock.IAnswer; +//import org.easymock.IMocksControl; +//import org.junit.Assert; +//import org.junit.Test; +//import org.junit.runner.RunWith; +//import org.powermock.api.easymock.PowerMock; +//import org.powermock.core.classloader.annotations.PrepareForTest; +//import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +//import org.powermock.modules.junit4.PowerMockRunner; +//import org.powermock.reflect.Whitebox; +// +//import javax.servlet.http.HttpServletRequest; +//import java.util.HashMap; +//import java.util.HashSet; +//import java.util.List; +//import java.util.Map; +//import java.util.Set; +//import java.util.concurrent.ConcurrentHashMap; +//import java.util.concurrent.ExecutorService; +//import java.util.concurrent.Executors; +// +//import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertFalse; +//import static org.junit.Assert.assertNotNull; +//import static org.junit.Assert.assertTrue; +// +///** +// * @author richie +// * @version 10.0 +// * Created by richie on 2019-08-09 +// */ +//@RunWith(PowerMockRunner.class) +//@PrepareForTest({SessionPoolManager.class, WebUtils.class}) +//@SuppressStaticInitializationFor({"com.fr.web.core.SessionPoolManager"}) +//public class SessionKitTest extends Prepare { +// +// private static final long MIN_ACCESS_INTERVAL = 900; +// private int taskCount = 0; +// private Map sessions = new HashMap(); +// +// @Test +// public void testGenerateSession() throws Exception { +// final SessionIDInfo sessionInfo = new MockSession("session"); +// final Map params = new HashMap(); +// PowerMock.mockStatic(SessionPoolManager.class); +// PowerMock.mockStatic(WebUtils.class); +// IMocksControl control = EasyMock.createControl(); +// final HttpServletRequest request = control.createMock(HttpServletRequest.class); +// EasyMock.expect(WebUtils.getIpAddr(request)).andReturn("127.0.0.1").anyTimes(); +// EasyMock.expect(WebUtils.getHTTPRequestParameter(request, ParameterConstants.OP)).andReturn("view").anyTimes(); +// EasyMock.expect(WebUtils.parameters4SessionIDInforContainMPCache(request)).andReturn(params).anyTimes(); +// final Weblet weblet = control.createMock(Weblet.class); +// EasyMock.expect(weblet.isSessionOccupy()).andReturn(false).anyTimes(); +// EasyMock.expect(weblet.createSessionIDInfor(request, "127.0.0.1", params)).andReturn(sessionInfo).anyTimes(); +// EasyMock.expect(addSessionIDInfo(sessionInfo)).andReturn(sessionInfo.getSessionID()).anyTimes(); +// EasyMock.expect(SessionPoolManager.generateSessionID(request, null, weblet)).andAnswer(new IAnswer() { +// @Override +// public String answer() throws Throwable { +// SessionProvider sessionIDInfor = weblet.createSessionIDInfor(request, "127.0.0.1", params); +// String sessionID = addSessionIDInfo(sessionIDInfor); +// if (weblet.isSessionOccupy()) { +// assert sessionID != null; +// RemoteAddressManager.add("127.0.0.1", sessionID); +// } +// return sessionID; +// } +// }).anyTimes(); +// control.replay(); +// PowerMock.replayAll(); +// sessionInfo.setSource(SessionSource.SINGLE); +// SessionPoolManager.generateSessionID(request, null, weblet); +// Assert.assertSame(sessionInfo.getSource(), SessionSource.SINGLE); +// sessionInfo.setSource(SessionSource.INTEGRATION); +// SessionPoolManager.generateSessionID(request, null, weblet); +// Assert.assertSame(sessionInfo.getSource(), SessionSource.INTEGRATION); +// +// } +// +// @Test +// public void testAddDelayTask() { +// String sessionID = "test"; +// sessions.put("test", new MockSession("test")); +// for (int i = 0; i < 100; i++) { +// accessSession(sessionID); +// } +// Assert.assertEquals(1, this.taskCount); +// for (int i = 0; i < 2; i++) { +// try { +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// //do nothing +// } +// accessSession(sessionID); +// } +// Assert.assertEquals(3, this.taskCount); +// } +// +// private void accessSession(String sessionId) { +// if (StringUtils.isBlank(sessionId)) { +// return; +// } +// +// SessionProvider sessionIDInfor = sessions.get(sessionId); +// if (sessionIDInfor != null) { +// long accessInterval = System.currentTimeMillis() - sessionIDInfor.getLastAccessTime(); +// sessionIDInfor.updateTime(); +// if (accessInterval > MIN_ACCESS_INTERVAL) { +// taskCount++; +// } +// } +// } +// +// @Test +// public void testGetAllSession() { +// Whitebox.setInternalState( +// SessionPoolManager.class, +// "sessionIDMap", +// new ConcurrentHashMap() +// ); +// Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); +// Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); +// String sessionID1 = "Test1"; +// sessionIDMap.put(sessionID1, new MockSession(sessionID1)); +// sessionIDMap.put("Test2", new MockSession("Test2")); +// closeSession(sessionID1); +// List list = SessionPoolManager.getAllSession(SessionProvider.class); +// assertEquals(1, list.size()); +// assertEquals("Test2", list.get(0).getSessionID()); +// assertNotNull(SessionKit.getSession("Test2")); +// } +// +// @Test +// public void testHasSessionID() { +// Whitebox.setInternalState( +// SessionPoolManager.class, +// "sessionIDMap", +// new ConcurrentHashMap() +// ); +// Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); +// Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); +// String sessionID1 = "Test1"; +// sessionIDMap.put(sessionID1, new MockSession(sessionID1)); +// sessionIDMap.put("Test2", new MockSession("Test2")); +// closeSession(sessionID1); +// assertFalse(SessionPoolManager.hasSessionID(sessionID1)); +// assertTrue(SessionPoolManager.hasSessionID("Test2")); +// } +// +// private void closeSession(final String sessionID) { +// final Set sessionToDelete = Reflect.on(SessionPoolManager.class).get("sessionToDelete"); +// sessionToDelete.add(sessionID); +// ExecutorService closeSessionPool = Executors.newFixedThreadPool(1); +// closeSessionPool.submit(new Runnable() { +// @Override +// public void run() { +// try { +// //模拟删除session对象的过程 +// Thread.sleep(1000); +// } catch (InterruptedException e) { +// //do nothing +// } +// synchronized (SessionPoolManager.class) { +// sessionToDelete.remove(sessionID); +// } +// } +// }); +// } +// +// private String addSessionIDInfo(SessionProvider sessionIDInfo) { +// return Reflect.on(SessionPoolManager.class).call("addSessionIDInfor", sessionIDInfo).get(); +// } +//} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/ContextKitTest.java b/src/test/java/com/fanruan/api/util/ContextKitTest.java new file mode 100644 index 0000000..c82a7cd --- /dev/null +++ b/src/test/java/com/fanruan/api/util/ContextKitTest.java @@ -0,0 +1,20 @@ +package com.fanruan.api.util; + +import org.junit.Test; + +import java.util.Locale; + +import static org.junit.Assert.*; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class ContextKitTest { + + @Test + public void getLocale() { + assertEquals(ContextKit.getLocale(), Locale.CHINA); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/InterKitTest.java b/src/test/java/com/fanruan/api/util/InterKitTest.java new file mode 100644 index 0000000..96f949e --- /dev/null +++ b/src/test/java/com/fanruan/api/util/InterKitTest.java @@ -0,0 +1,13 @@ +package com.fanruan.api.util; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class InterKitTest { + + @Test + public void getLocText() { + assertEquals(InterKit.getLocText("asdasd"),"asdasd"); + } +} \ No newline at end of file From 3d07eaf44f1faa1230aaecfc090a1023a679171d Mon Sep 17 00:00:00 2001 From: Kalven Date: Sat, 31 Aug 2019 03:50:00 +0800 Subject: [PATCH 02/13] =?UTF-8?q?KERNEL-1117=20=E6=A0=B9=E6=8D=AE=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=A2=9E=E5=8A=A0=E4=BA=86fineKit=E7=9A=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=96=87=E4=BB=B6=EF=BC=8C=E5=85=B6=E4=B8=AD=E5=8D=95?= =?UTF-8?q?=E4=BE=8B=E6=A8=A1=E5=BC=8F=E8=BF=94=E5=9B=9E=E5=8D=95=E4=BE=8B?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95=E6=B2=A1=E6=9C=89=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/session/SessionKitTest.java | 372 +++++++++--------- 1 file changed, 186 insertions(+), 186 deletions(-) diff --git a/src/test/java/com/fanruan/api/session/SessionKitTest.java b/src/test/java/com/fanruan/api/session/SessionKitTest.java index 43eda1d..275d52d 100644 --- a/src/test/java/com/fanruan/api/session/SessionKitTest.java +++ b/src/test/java/com/fanruan/api/session/SessionKitTest.java @@ -1,186 +1,186 @@ -//package com.fanruan.api.session; -// -//import com.fanruan.api.Prepare; -//import com.fr.general.web.ParameterConstants; -//import com.fr.invoke.Reflect; -//import com.fr.stable.StringUtils; -//import com.fr.stable.web.SessionProvider; -//import com.fr.stable.web.SessionSource; -//import com.fr.stable.web.Weblet; -//import com.fr.web.core.RemoteAddressManager; -//import com.fr.web.core.SessionPoolManager; -//import com.fr.web.session.SessionIDInfo; -//import com.fr.web.utils.WebUtils; -//import org.easymock.EasyMock; -//import org.easymock.IAnswer; -//import org.easymock.IMocksControl; -//import org.junit.Assert; -//import org.junit.Test; -//import org.junit.runner.RunWith; -//import org.powermock.api.easymock.PowerMock; -//import org.powermock.core.classloader.annotations.PrepareForTest; -//import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; -//import org.powermock.modules.junit4.PowerMockRunner; -//import org.powermock.reflect.Whitebox; -// -//import javax.servlet.http.HttpServletRequest; -//import java.util.HashMap; -//import java.util.HashSet; -//import java.util.List; -//import java.util.Map; -//import java.util.Set; -//import java.util.concurrent.ConcurrentHashMap; -//import java.util.concurrent.ExecutorService; -//import java.util.concurrent.Executors; -// -//import static org.junit.Assert.assertEquals; -//import static org.junit.Assert.assertFalse; -//import static org.junit.Assert.assertNotNull; -//import static org.junit.Assert.assertTrue; -// -///** -// * @author richie -// * @version 10.0 -// * Created by richie on 2019-08-09 -// */ -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({SessionPoolManager.class, WebUtils.class}) -//@SuppressStaticInitializationFor({"com.fr.web.core.SessionPoolManager"}) -//public class SessionKitTest extends Prepare { -// -// private static final long MIN_ACCESS_INTERVAL = 900; -// private int taskCount = 0; -// private Map sessions = new HashMap(); -// -// @Test -// public void testGenerateSession() throws Exception { -// final SessionIDInfo sessionInfo = new MockSession("session"); -// final Map params = new HashMap(); -// PowerMock.mockStatic(SessionPoolManager.class); -// PowerMock.mockStatic(WebUtils.class); -// IMocksControl control = EasyMock.createControl(); -// final HttpServletRequest request = control.createMock(HttpServletRequest.class); -// EasyMock.expect(WebUtils.getIpAddr(request)).andReturn("127.0.0.1").anyTimes(); -// EasyMock.expect(WebUtils.getHTTPRequestParameter(request, ParameterConstants.OP)).andReturn("view").anyTimes(); -// EasyMock.expect(WebUtils.parameters4SessionIDInforContainMPCache(request)).andReturn(params).anyTimes(); -// final Weblet weblet = control.createMock(Weblet.class); -// EasyMock.expect(weblet.isSessionOccupy()).andReturn(false).anyTimes(); -// EasyMock.expect(weblet.createSessionIDInfor(request, "127.0.0.1", params)).andReturn(sessionInfo).anyTimes(); -// EasyMock.expect(addSessionIDInfo(sessionInfo)).andReturn(sessionInfo.getSessionID()).anyTimes(); -// EasyMock.expect(SessionPoolManager.generateSessionID(request, null, weblet)).andAnswer(new IAnswer() { -// @Override -// public String answer() throws Throwable { -// SessionProvider sessionIDInfor = weblet.createSessionIDInfor(request, "127.0.0.1", params); -// String sessionID = addSessionIDInfo(sessionIDInfor); -// if (weblet.isSessionOccupy()) { -// assert sessionID != null; -// RemoteAddressManager.add("127.0.0.1", sessionID); -// } -// return sessionID; -// } -// }).anyTimes(); -// control.replay(); -// PowerMock.replayAll(); -// sessionInfo.setSource(SessionSource.SINGLE); -// SessionPoolManager.generateSessionID(request, null, weblet); -// Assert.assertSame(sessionInfo.getSource(), SessionSource.SINGLE); -// sessionInfo.setSource(SessionSource.INTEGRATION); -// SessionPoolManager.generateSessionID(request, null, weblet); -// Assert.assertSame(sessionInfo.getSource(), SessionSource.INTEGRATION); -// -// } -// -// @Test -// public void testAddDelayTask() { -// String sessionID = "test"; -// sessions.put("test", new MockSession("test")); -// for (int i = 0; i < 100; i++) { -// accessSession(sessionID); -// } -// Assert.assertEquals(1, this.taskCount); -// for (int i = 0; i < 2; i++) { -// try { -// Thread.sleep(1000); -// } catch (InterruptedException e) { -// //do nothing -// } -// accessSession(sessionID); -// } -// Assert.assertEquals(3, this.taskCount); -// } -// -// private void accessSession(String sessionId) { -// if (StringUtils.isBlank(sessionId)) { -// return; -// } -// -// SessionProvider sessionIDInfor = sessions.get(sessionId); -// if (sessionIDInfor != null) { -// long accessInterval = System.currentTimeMillis() - sessionIDInfor.getLastAccessTime(); -// sessionIDInfor.updateTime(); -// if (accessInterval > MIN_ACCESS_INTERVAL) { -// taskCount++; -// } -// } -// } -// -// @Test -// public void testGetAllSession() { -// Whitebox.setInternalState( -// SessionPoolManager.class, -// "sessionIDMap", -// new ConcurrentHashMap() -// ); -// Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); -// Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); -// String sessionID1 = "Test1"; -// sessionIDMap.put(sessionID1, new MockSession(sessionID1)); -// sessionIDMap.put("Test2", new MockSession("Test2")); -// closeSession(sessionID1); -// List list = SessionPoolManager.getAllSession(SessionProvider.class); -// assertEquals(1, list.size()); -// assertEquals("Test2", list.get(0).getSessionID()); -// assertNotNull(SessionKit.getSession("Test2")); -// } -// -// @Test -// public void testHasSessionID() { -// Whitebox.setInternalState( -// SessionPoolManager.class, -// "sessionIDMap", -// new ConcurrentHashMap() -// ); -// Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); -// Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); -// String sessionID1 = "Test1"; -// sessionIDMap.put(sessionID1, new MockSession(sessionID1)); -// sessionIDMap.put("Test2", new MockSession("Test2")); -// closeSession(sessionID1); -// assertFalse(SessionPoolManager.hasSessionID(sessionID1)); -// assertTrue(SessionPoolManager.hasSessionID("Test2")); -// } -// -// private void closeSession(final String sessionID) { -// final Set sessionToDelete = Reflect.on(SessionPoolManager.class).get("sessionToDelete"); -// sessionToDelete.add(sessionID); -// ExecutorService closeSessionPool = Executors.newFixedThreadPool(1); -// closeSessionPool.submit(new Runnable() { -// @Override -// public void run() { -// try { -// //模拟删除session对象的过程 -// Thread.sleep(1000); -// } catch (InterruptedException e) { -// //do nothing -// } -// synchronized (SessionPoolManager.class) { -// sessionToDelete.remove(sessionID); -// } -// } -// }); -// } -// -// private String addSessionIDInfo(SessionProvider sessionIDInfo) { -// return Reflect.on(SessionPoolManager.class).call("addSessionIDInfor", sessionIDInfo).get(); -// } -//} \ No newline at end of file +package com.fanruan.api.session; + +import com.fanruan.api.Prepare; +import com.fr.general.web.ParameterConstants; +import com.fr.invoke.Reflect; +import com.fr.stable.StringUtils; +import com.fr.stable.web.SessionProvider; +import com.fr.stable.web.SessionSource; +import com.fr.stable.web.Weblet; +import com.fr.web.core.RemoteAddressManager; +import com.fr.web.core.SessionPoolManager; +import com.fr.web.session.SessionIDInfo; +import com.fr.web.utils.WebUtils; +import org.easymock.EasyMock; +import org.easymock.IAnswer; +import org.easymock.IMocksControl; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.reflect.Whitebox; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-08-09 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({SessionPoolManager.class, WebUtils.class}) +@SuppressStaticInitializationFor({"com.fr.web.core.SessionPoolManager"}) +public class SessionKitTest extends Prepare { + + private static final long MIN_ACCESS_INTERVAL = 900; + private int taskCount = 0; + private Map sessions = new HashMap(); + + @Test + public void testGenerateSession() throws Exception { + final SessionIDInfo sessionInfo = new MockSession("session"); + final Map params = new HashMap(); + PowerMock.mockStatic(SessionPoolManager.class); + PowerMock.mockStatic(WebUtils.class); + IMocksControl control = EasyMock.createControl(); + final HttpServletRequest request = control.createMock(HttpServletRequest.class); + EasyMock.expect(WebUtils.getIpAddr(request)).andReturn("127.0.0.1").anyTimes(); + EasyMock.expect(WebUtils.getHTTPRequestParameter(request, ParameterConstants.OP)).andReturn("view").anyTimes(); + EasyMock.expect(WebUtils.parameters4SessionIDInforContainMPCache(request)).andReturn(params).anyTimes(); + final Weblet weblet = control.createMock(Weblet.class); + EasyMock.expect(weblet.isSessionOccupy()).andReturn(false).anyTimes(); + EasyMock.expect(weblet.createSessionIDInfor(request, "127.0.0.1", params)).andReturn(sessionInfo).anyTimes(); + EasyMock.expect(addSessionIDInfo(sessionInfo)).andReturn(sessionInfo.getSessionID()).anyTimes(); + EasyMock.expect(SessionPoolManager.generateSessionID(request, null, weblet)).andAnswer(new IAnswer() { + @Override + public String answer() throws Throwable { + SessionProvider sessionIDInfor = weblet.createSessionIDInfor(request, "127.0.0.1", params); + String sessionID = addSessionIDInfo(sessionIDInfor); + if (weblet.isSessionOccupy()) { + assert sessionID != null; + RemoteAddressManager.add("127.0.0.1", sessionID); + } + return sessionID; + } + }).anyTimes(); + control.replay(); + PowerMock.replayAll(); + sessionInfo.setSource(SessionSource.SINGLE); + SessionPoolManager.generateSessionID(request, null, weblet); + Assert.assertSame(sessionInfo.getSource(), SessionSource.SINGLE); + sessionInfo.setSource(SessionSource.INTEGRATION); + SessionPoolManager.generateSessionID(request, null, weblet); + Assert.assertSame(sessionInfo.getSource(), SessionSource.INTEGRATION); + + } + + @Test + public void testAddDelayTask() { + String sessionID = "test"; + sessions.put("test", new MockSession("test")); + for (int i = 0; i < 100; i++) { + accessSession(sessionID); + } + Assert.assertEquals(1, this.taskCount); + for (int i = 0; i < 2; i++) { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + //do nothing + } + accessSession(sessionID); + } + Assert.assertEquals(3, this.taskCount); + } + + private void accessSession(String sessionId) { + if (StringUtils.isBlank(sessionId)) { + return; + } + + SessionProvider sessionIDInfor = sessions.get(sessionId); + if (sessionIDInfor != null) { + long accessInterval = System.currentTimeMillis() - sessionIDInfor.getLastAccessTime(); + sessionIDInfor.updateTime(); + if (accessInterval > MIN_ACCESS_INTERVAL) { + taskCount++; + } + } + } + + @Test + public void testGetAllSession() { + Whitebox.setInternalState( + SessionPoolManager.class, + "sessionIDMap", + new ConcurrentHashMap() + ); + Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); + Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); + String sessionID1 = "Test1"; + sessionIDMap.put(sessionID1, new MockSession(sessionID1)); + sessionIDMap.put("Test2", new MockSession("Test2")); + closeSession(sessionID1); + List list = SessionPoolManager.getAllSession(SessionProvider.class); + assertEquals(1, list.size()); + assertEquals("Test2", list.get(0).getSessionID()); + assertNotNull(SessionKit.getSession("Test2")); + } + + @Test + public void testHasSessionID() { + Whitebox.setInternalState( + SessionPoolManager.class, + "sessionIDMap", + new ConcurrentHashMap() + ); + Whitebox.setInternalState(SessionPoolManager.class, "sessionToDelete", new HashSet()); + Map sessionIDMap = Reflect.on(SessionPoolManager.class).get("sessionIDMap"); + String sessionID1 = "Test1"; + sessionIDMap.put(sessionID1, new MockSession(sessionID1)); + sessionIDMap.put("Test2", new MockSession("Test2")); + closeSession(sessionID1); + assertFalse(SessionPoolManager.hasSessionID(sessionID1)); + assertTrue(SessionPoolManager.hasSessionID("Test2")); + } + + private void closeSession(final String sessionID) { + final Set sessionToDelete = Reflect.on(SessionPoolManager.class).get("sessionToDelete"); + sessionToDelete.add(sessionID); + ExecutorService closeSessionPool = Executors.newFixedThreadPool(1); + closeSessionPool.submit(new Runnable() { + @Override + public void run() { + try { + //模拟删除session对象的过程 + Thread.sleep(1000); + } catch (InterruptedException e) { + //do nothing + } + synchronized (SessionPoolManager.class) { + sessionToDelete.remove(sessionID); + } + } + }); + } + + private String addSessionIDInfo(SessionProvider sessionIDInfo) { + return Reflect.on(SessionPoolManager.class).call("addSessionIDInfor", sessionIDInfo).get(); + } +} \ No newline at end of file From 309a0c3357ec30096e1b2ee7faafab6660c490eb Mon Sep 17 00:00:00 2001 From: Kalven Date: Sat, 31 Aug 2019 11:56:14 +0800 Subject: [PATCH 03/13] =?UTF-8?q?KERNEL-1117=20=E6=A0=B9=E6=8D=AE=E8=A6=81?= =?UTF-8?q?=E6=B1=82=E8=BF=9B=E8=A1=8C=E4=BA=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/base/ParameterHelperKit.java | 21 ----------- .../com/fanruan/api/cal/ScriptFactoryKit.java | 20 ---------- .../cal/namespace/ParameterMapNameSpace.java | 14 ------- .../com/fanruan/api/design/DesignKit.java | 10 +++++ .../ui/{list => component}/QuickList.java | 2 +- .../component/textarea/RSyntaxTextArea.java | 7 ---- .../api/design/ui/dialog/BasicDialog.java | 37 ------------------- .../design/ui/layout/FRGUIPaneFactoryKit.java | 31 ---------------- .../ui/mainframe/DesignerContextKit.java | 14 ------- src/main/java/com/fanruan/api/log/LogKit.java | 7 ---- .../java/com/fanruan/api/util/ContextKit.java | 16 -------- .../java/com/fanruan/api/util/GeneralKit.java | 11 ++++++ .../java/com/fanruan/api/util/InterKit.java | 15 -------- .../com/fanruan/api/util/ContextKitTest.java | 20 ---------- .../com/fanruan/api/util/GeneralKitTest.java | 7 ++++ .../com/fanruan/api/util/InterKitTest.java | 13 ------- 16 files changed, 29 insertions(+), 216 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/base/ParameterHelperKit.java delete mode 100644 src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java delete mode 100644 src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java rename src/main/java/com/fanruan/api/design/ui/{list => component}/QuickList.java (83%) delete mode 100644 src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java delete mode 100644 src/main/java/com/fanruan/api/util/ContextKit.java delete mode 100644 src/main/java/com/fanruan/api/util/InterKit.java delete mode 100644 src/test/java/com/fanruan/api/util/ContextKitTest.java delete mode 100644 src/test/java/com/fanruan/api/util/InterKitTest.java diff --git a/src/main/java/com/fanruan/api/base/ParameterHelperKit.java b/src/main/java/com/fanruan/api/base/ParameterHelperKit.java deleted file mode 100644 index 3c7c05b..0000000 --- a/src/main/java/com/fanruan/api/base/ParameterHelperKit.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fanruan.api.base; - -import com.fr.base.Parameter; -import com.fr.base.ParameterHelper; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/30 - */ -public class ParameterHelperKit { - /** - * 从字符串中分析中有哪些需要的参数 - * @param text 待分析字符串 - * @param hasColumnRow 是否需要分析格子类型的参数 - * @return 字符串中包含的参数集合 - */ - public static Parameter[] analyze4Parameters(String text, boolean hasColumnRow) { - return ParameterHelper.analyze4Parameters(text, hasColumnRow); - } -} diff --git a/src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java b/src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java deleted file mode 100644 index cb1dc06..0000000 --- a/src/main/java/com/fanruan/api/cal/ScriptFactoryKit.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fanruan.api.cal; - -import com.fr.script.ScriptFactory; - -import javax.script.ScriptEngine; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/30 - */ -public class ScriptFactoryKit { - /** - * 单例模式,获取ScriptEngine对象 - * @return ScriptEngine对象 - */ - public static ScriptEngine newSingletonScriptEngine() { - return ScriptFactory.newSingletonScriptEngine(); - } -} diff --git a/src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java b/src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java deleted file mode 100644 index 8db7394..0000000 --- a/src/main/java/com/fanruan/api/cal/namespace/ParameterMapNameSpace.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fanruan.api.cal.namespace; - -import java.util.Map; - -public class ParameterMapNameSpace { - /** - * 根据参数映射创建一个参数命名空间 - * @param map 参数名和参数值的映射 - * @return 参数命名空间 - */ - public static com.fr.base.ParameterMapNameSpace create(Map map) { - return com.fr.base.ParameterMapNameSpace.create(map); - } -} diff --git a/src/main/java/com/fanruan/api/design/DesignKit.java b/src/main/java/com/fanruan/api/design/DesignKit.java index 267c9cb..ce6be5d 100644 --- a/src/main/java/com/fanruan/api/design/DesignKit.java +++ b/src/main/java/com/fanruan/api/design/DesignKit.java @@ -3,6 +3,8 @@ package com.fanruan.api.design; import com.fr.base.TableData; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; public class DesignKit { /** @@ -31,4 +33,12 @@ public class DesignKit { public static String i18nText(String key, Object... args) { return Toolkit.i18nText(key, args); } + + /** + * 单例模式,返回DesignerFrame对象 + * @return DesignerFrame对象 + */ + public static DesignerFrame getDesignerFrame() { + return DesignerContext.getDesignerFrame(); + } } diff --git a/src/main/java/com/fanruan/api/design/ui/list/QuickList.java b/src/main/java/com/fanruan/api/design/ui/component/QuickList.java similarity index 83% rename from src/main/java/com/fanruan/api/design/ui/list/QuickList.java rename to src/main/java/com/fanruan/api/design/ui/component/QuickList.java index aa4571e..9269a1c 100644 --- a/src/main/java/com/fanruan/api/design/ui/list/QuickList.java +++ b/src/main/java/com/fanruan/api/design/ui/component/QuickList.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.list; +package com.fanruan.api.design.ui.component; import javax.swing.*; diff --git a/src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java b/src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java deleted file mode 100644 index 0fb41d8..0000000 --- a/src/main/java/com/fanruan/api/design/ui/component/textarea/RSyntaxTextArea.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.design.ui.component.textarea; - -/** - * 公式输入的文本框 - */ -public class RSyntaxTextArea extends com.fr.design.gui.syntax.ui.rsyntaxtextarea.RSyntaxTextArea { -} diff --git a/src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java b/src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java deleted file mode 100644 index c95d0bc..0000000 --- a/src/main/java/com/fanruan/api/design/ui/dialog/BasicDialog.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.fanruan.api.design.ui.dialog; - -import com.fr.design.dialog.BasicPane; - -import java.awt.*; - -/** - * 对话框的抽象类 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/30 - */ -public abstract class BasicDialog extends com.fr.design.dialog.BasicDialog { - public BasicDialog(Frame frame) { - super(frame); - } - - public BasicDialog(Dialog dialog) { - super(dialog); - } - - public BasicDialog(Frame frame, BasicPane pane) { - super(frame, pane); - } - - public BasicDialog(Dialog dialog, BasicPane pane) { - super(dialog, pane); - } - - public BasicDialog(Frame frame, BasicPane pane, boolean isNeedButtonPane) { - super(frame, pane, isNeedButtonPane); - } - - public BasicDialog(Dialog dialog, BasicPane pane, boolean isNeedButtonPane) { - super(dialog, pane, isNeedButtonPane); - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java b/src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java deleted file mode 100644 index e04a1d5..0000000 --- a/src/main/java/com/fanruan/api/design/ui/layout/FRGUIPaneFactoryKit.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.fanruan.api.design.ui.layout; - -import javax.swing.*; -import java.awt.*; - - -public class FRGUIPaneFactoryKit { - /** - * 创建边框面板S - * @return JPanel对象 - */ - public static JPanel createBorderLayout_S_Pane() { - return com.fr.design.layout.FRGUIPaneFactory.createBorderLayout_S_Pane(); - } - - /** - * 创建一个靠左流式布局,正常流式内嵌 - * @return JPanel对象 - */ - public static JPanel createNormalFlowInnerContainer_S_Pane() { - return com.fr.design.layout.FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - } - - /** - * 创建一个边框布局 - * @return LayoutManager对象 - */ - public static LayoutManager createBorderLayout() { - return com.fr.design.layout.FRGUIPaneFactory.createBorderLayout(); - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java b/src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java deleted file mode 100644 index ee9c21b..0000000 --- a/src/main/java/com/fanruan/api/design/ui/mainframe/DesignerContextKit.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fanruan.api.design.ui.mainframe; - -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrame; - -public class DesignerContextKit { - /** - * 单例模式,返回DesignerFrame对象 - * @return DesignerFrame对象 - */ - public static DesignerFrame getDesignerFrame() { - return DesignerContext.getDesignerFrame(); - } -} diff --git a/src/main/java/com/fanruan/api/log/LogKit.java b/src/main/java/com/fanruan/api/log/LogKit.java index b599314..4eeb09f 100644 --- a/src/main/java/com/fanruan/api/log/LogKit.java +++ b/src/main/java/com/fanruan/api/log/LogKit.java @@ -162,11 +162,4 @@ public class LogKit { FineLoggerFactory.getLogger().error(e, format, args); } - /** - * 得到日志对象 - * @return 日志对象 - */ - public static FRLogger getLogger() { - return FRLogger.getLogger(); - } } diff --git a/src/main/java/com/fanruan/api/util/ContextKit.java b/src/main/java/com/fanruan/api/util/ContextKit.java deleted file mode 100644 index 12755df..0000000 --- a/src/main/java/com/fanruan/api/util/ContextKit.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.base.FRContext; - -import java.util.Locale; - -public class ContextKit { - /** - * 返回国际化区属 - * @return 国际化后区域属性 - */ - @Deprecated - public static Locale getLocale() { - return FRContext.getLocale(); - } -} diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 30a74bb..14b5fc7 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.util; +import com.fr.base.FRContext; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.third.guava.base.Objects; @@ -7,6 +8,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; +import java.util.Locale; import java.util.Map; /** @@ -69,4 +71,13 @@ public class GeneralKit { public static int compare(Object obj1, Object obj2) { return ComparatorUtils.compare(obj1, obj2); } + + /** + * 返回国际化区属 + * @return 国际化后区域属性 + */ + @Deprecated + public static Locale getLocale() { + return FRContext.getLocale(); + } } diff --git a/src/main/java/com/fanruan/api/util/InterKit.java b/src/main/java/com/fanruan/api/util/InterKit.java deleted file mode 100644 index 36ecac2..0000000 --- a/src/main/java/com/fanruan/api/util/InterKit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.general.Inter; - -public class InterKit { - - /** - * 获取国际化文本,已过时 - * @param text - * @return 国际化文本字符串 - */ - public static String getLocText(String text) { - return Inter.getLocText(text); - } -} diff --git a/src/test/java/com/fanruan/api/util/ContextKitTest.java b/src/test/java/com/fanruan/api/util/ContextKitTest.java deleted file mode 100644 index c82a7cd..0000000 --- a/src/test/java/com/fanruan/api/util/ContextKitTest.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fanruan.api.util; - -import org.junit.Test; - -import java.util.Locale; - -import static org.junit.Assert.*; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class ContextKitTest { - - @Test - public void getLocale() { - assertEquals(ContextKit.getLocale(), Locale.CHINA); - } -} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 7bbefa6..975ae8d 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -5,6 +5,8 @@ import com.fr.general.GeneralUtils; import org.junit.Assert; import org.junit.Test; +import java.util.Locale; + /** * @author richie * @version 10.0 @@ -39,4 +41,9 @@ public class GeneralKitTest extends Prepare { Assert.assertEquals(GeneralKit.compare(s,s3),0); Assert.assertEquals(GeneralKit.compare(s,s2),1); } + + @Test + public void getLocale() { + Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/InterKitTest.java b/src/test/java/com/fanruan/api/util/InterKitTest.java deleted file mode 100644 index 96f949e..0000000 --- a/src/test/java/com/fanruan/api/util/InterKitTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fanruan.api.util; - -import org.junit.Test; - -import static org.junit.Assert.*; - -public class InterKitTest { - - @Test - public void getLocText() { - assertEquals(InterKit.getLocText("asdasd"),"asdasd"); - } -} \ No newline at end of file From 7a6824f448b448773db0a2381d214ef6a7c653b0 Mon Sep 17 00:00:00 2001 From: Kalven Date: Sat, 31 Aug 2019 12:53:55 +0800 Subject: [PATCH 04/13] =?UTF-8?q?KERNEL-1117=20=E5=8F=91=E7=8E=B0=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E9=81=97=E6=BC=8F=E7=9A=84=E5=9C=B0=E6=96=B9=EF=BC=8C?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/design/util/FunctionDefNAD.java | 15 +++++++++++++ .../api/design/util/FunctionManagerKit.java | 18 ++++++++++++++++ .../api/design/util/NameAndFunctionList.java | 17 +++++++++++++++ .../util/NameAndTypeAndFunctionList.java | 15 +++++++++++++ .../com/fanruan/api/function/AVERAGE.java | 10 +++++++++ .../java/com/fanruan/api/function/CHAR.java | 10 +++++++++ .../java/com/fanruan/api/function/COUNT.java | 10 +++++++++ .../java/com/fanruan/api/function/DATE.java | 10 +++++++++ .../java/com/fanruan/api/function/MAX.java | 10 +++++++++ .../java/com/fanruan/api/function/MIN.java | 10 +++++++++ .../java/com/fanruan/api/function/RANGE.java | 10 +++++++++ .../java/com/fanruan/api/function/SUM.java | 10 +++++++++ .../java/com/fanruan/api/function/TIME.java | 10 +++++++++ .../fanruan/api/macro/OperatingSystemKit.java | 18 ++++++++++++++++ .../fanruan/api/macro/ProductConstants.java | 5 +++++ .../api/plugin/ExtraClassManagerKit.java | 18 ++++++++++++++++ .../api/base/ParameterHelperKitTest.java | 21 ------------------- 17 files changed, 196 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java create mode 100644 src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java create mode 100644 src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java create mode 100644 src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java create mode 100644 src/main/java/com/fanruan/api/function/AVERAGE.java create mode 100644 src/main/java/com/fanruan/api/function/CHAR.java create mode 100644 src/main/java/com/fanruan/api/function/COUNT.java create mode 100644 src/main/java/com/fanruan/api/function/DATE.java create mode 100644 src/main/java/com/fanruan/api/function/MAX.java create mode 100644 src/main/java/com/fanruan/api/function/MIN.java create mode 100644 src/main/java/com/fanruan/api/function/RANGE.java create mode 100644 src/main/java/com/fanruan/api/function/SUM.java create mode 100644 src/main/java/com/fanruan/api/function/TIME.java create mode 100644 src/main/java/com/fanruan/api/macro/OperatingSystemKit.java create mode 100644 src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java delete mode 100644 src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java diff --git a/src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java b/src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java new file mode 100644 index 0000000..fdf1608 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.util; + +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); + } +} diff --git a/src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java b/src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java new file mode 100644 index 0000000..72552d4 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java @@ -0,0 +1,18 @@ +package com.fanruan.api.design.util; + +/** + * 函数管理器 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class FunctionManagerKit { + /** + * 得到函数管理器实例 + * @return 函数管理器 + */ + public static com.fr.file.FunctionManager getInstance() { + return com.fr.file.FunctionManager.getInstance(); + } + +} diff --git a/src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java b/src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java new file mode 100644 index 0000000..99d9089 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java @@ -0,0 +1,17 @@ +package com.fanruan.api.design.util; + +import com.fr.stable.script.Function; + +import java.util.Arrays; + +/** + * 名称对应的函数列表 + * @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); + } +} diff --git a/src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java b/src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java new file mode 100644 index 0000000..300d800 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.util; + +import com.fr.stable.script.Function; + +/** + * 名字和类型对应的函数列表 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class NameAndTypeAndFunctionList extends com.fr.design.formula.NameAndTypeAndFunctionList { + public NameAndTypeAndFunctionList(String name, Function.Type type) { + super(name, type); + } +} diff --git a/src/main/java/com/fanruan/api/function/AVERAGE.java b/src/main/java/com/fanruan/api/function/AVERAGE.java new file mode 100644 index 0000000..837d4ee --- /dev/null +++ b/src/main/java/com/fanruan/api/function/AVERAGE.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,求平均值 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class AVERAGE extends com.fr.function.AVERAGE { +} diff --git a/src/main/java/com/fanruan/api/function/CHAR.java b/src/main/java/com/fanruan/api/function/CHAR.java new file mode 100644 index 0000000..796f550 --- /dev/null +++ b/src/main/java/com/fanruan/api/function/CHAR.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,求ASCII码对应的字符 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class CHAR extends com.fr.function.CHAR { +} diff --git a/src/main/java/com/fanruan/api/function/COUNT.java b/src/main/java/com/fanruan/api/function/COUNT.java new file mode 100644 index 0000000..2ad9646 --- /dev/null +++ b/src/main/java/com/fanruan/api/function/COUNT.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,计算区域内所含项的个数 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class COUNT extends com.fr.function.COUNT { +} diff --git a/src/main/java/com/fanruan/api/function/DATE.java b/src/main/java/com/fanruan/api/function/DATE.java new file mode 100644 index 0000000..a4b22c3 --- /dev/null +++ b/src/main/java/com/fanruan/api/function/DATE.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,获取一个表示某一特定日期的系列数。 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class DATE extends com.fr.function.DATE { +} diff --git a/src/main/java/com/fanruan/api/function/MAX.java b/src/main/java/com/fanruan/api/function/MAX.java new file mode 100644 index 0000000..536a1ed --- /dev/null +++ b/src/main/java/com/fanruan/api/function/MAX.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,求最大值 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class MAX extends com.fr.function.MAX { +} diff --git a/src/main/java/com/fanruan/api/function/MIN.java b/src/main/java/com/fanruan/api/function/MIN.java new file mode 100644 index 0000000..c3ee021 --- /dev/null +++ b/src/main/java/com/fanruan/api/function/MIN.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,求最小值 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class MIN extends com.fr.function.MIN { +} diff --git a/src/main/java/com/fanruan/api/function/RANGE.java b/src/main/java/com/fanruan/api/function/RANGE.java new file mode 100644 index 0000000..4d4733f --- /dev/null +++ b/src/main/java/com/fanruan/api/function/RANGE.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,取范围内满足条件的数据序列 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class RANGE extends com.fr.function.RANGE { +} diff --git a/src/main/java/com/fanruan/api/function/SUM.java b/src/main/java/com/fanruan/api/function/SUM.java new file mode 100644 index 0000000..13eb4f7 --- /dev/null +++ b/src/main/java/com/fanruan/api/function/SUM.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,求和 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class SUM extends com.fr.function.SUM { +} diff --git a/src/main/java/com/fanruan/api/function/TIME.java b/src/main/java/com/fanruan/api/function/TIME.java new file mode 100644 index 0000000..6c12000 --- /dev/null +++ b/src/main/java/com/fanruan/api/function/TIME.java @@ -0,0 +1,10 @@ +package com.fanruan.api.function; + +/** + * 基本函数,求代表指定时间的小数 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class TIME extends com.fr.function.TIME { +} diff --git a/src/main/java/com/fanruan/api/macro/OperatingSystemKit.java b/src/main/java/com/fanruan/api/macro/OperatingSystemKit.java new file mode 100644 index 0000000..134b69e --- /dev/null +++ b/src/main/java/com/fanruan/api/macro/OperatingSystemKit.java @@ -0,0 +1,18 @@ +package com.fanruan.api.macro; + +import com.fr.stable.OperatingSystem; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class OperatingSystemKit { + /** + * 判断是否为windows + * @return 判断结果 + */ + public static boolean isWindows() { + return OperatingSystem.isWindows(); + } +} diff --git a/src/main/java/com/fanruan/api/macro/ProductConstants.java b/src/main/java/com/fanruan/api/macro/ProductConstants.java index 1febf81..ed1637a 100644 --- a/src/main/java/com/fanruan/api/macro/ProductConstants.java +++ b/src/main/java/com/fanruan/api/macro/ProductConstants.java @@ -11,4 +11,9 @@ public class ProductConstants { * 详细的产品名字 */ public static final String PRODUCT_NAME = com.fr.stable.ProductConstants.PRODUCT_NAME; + + /** + * 大的版本号 + */ + public static final String MAIN_VERSION = com.fr.stable.ProductConstants.MAIN_VERSION; } diff --git a/src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java b/src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java new file mode 100644 index 0000000..90561da --- /dev/null +++ b/src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java @@ -0,0 +1,18 @@ +package com.fanruan.api.plugin; + +import com.fr.plugin.ExtraClassManager; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class ExtraClassManagerKit { + /** + * 获取ExtraClassManager实例 + * @return ExtraClassManager实例 + */ + public static ExtraClassManager getInstance() { + return ExtraClassManager.getInstance(); + } +} diff --git a/src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java b/src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java deleted file mode 100644 index 3be5b3d..0000000 --- a/src/test/java/com/fanruan/api/base/ParameterHelperKitTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fanruan.api.base; - -import com.fr.stable.ParameterProvider; -import org.junit.Test; - -import static org.junit.Assert.*; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class ParameterHelperKitTest { - - @Test - public void analyze4Parameters() { - ParameterProvider p[] = ParameterHelperKit.analyze4Parameters("var a1 = '${A1}';\n" + - "return \"A1的值\" + (a1 > 10 ? \"大于10\" : \"小于等于10\");",false); - assertEquals(p[0].getValue(),""); - } -} \ No newline at end of file From 3497c80e25c39632df0c49b21060aac14d44c29b Mon Sep 17 00:00:00 2001 From: Kalven Date: Sat, 31 Aug 2019 22:50:21 +0800 Subject: [PATCH 05/13] =?UTF-8?q?KERNEL-1117=20=E5=86=8D=E6=AC=A1=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/CalculatorKit.java | 10 ++++++++++ .../namespace/SimpleCellValueNameSpaceKit.java | 13 ------------- .../java/com/fanruan/api/function/AVERAGE.java | 10 ---------- .../java/com/fanruan/api/function/CHAR.java | 10 ---------- .../java/com/fanruan/api/function/COUNT.java | 10 ---------- .../java/com/fanruan/api/function/DATE.java | 10 ---------- .../java/com/fanruan/api/function/MAX.java | 10 ---------- .../java/com/fanruan/api/function/MIN.java | 10 ---------- .../java/com/fanruan/api/function/RANGE.java | 10 ---------- .../java/com/fanruan/api/function/SUM.java | 10 ---------- .../java/com/fanruan/api/function/TIME.java | 10 ---------- src/main/java/com/fanruan/api/log/LogKit.java | 1 - .../api/plugin/ExtraClassManagerKit.java | 18 ------------------ 13 files changed, 10 insertions(+), 122 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java delete mode 100644 src/main/java/com/fanruan/api/function/AVERAGE.java delete mode 100644 src/main/java/com/fanruan/api/function/CHAR.java delete mode 100644 src/main/java/com/fanruan/api/function/COUNT.java delete mode 100644 src/main/java/com/fanruan/api/function/DATE.java delete mode 100644 src/main/java/com/fanruan/api/function/MAX.java delete mode 100644 src/main/java/com/fanruan/api/function/MIN.java delete mode 100644 src/main/java/com/fanruan/api/function/RANGE.java delete mode 100644 src/main/java/com/fanruan/api/function/SUM.java delete mode 100644 src/main/java/com/fanruan/api/function/TIME.java delete mode 100644 src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java diff --git a/src/main/java/com/fanruan/api/cal/CalculatorKit.java b/src/main/java/com/fanruan/api/cal/CalculatorKit.java index 4a370e5..a4b3bac 100644 --- a/src/main/java/com/fanruan/api/cal/CalculatorKit.java +++ b/src/main/java/com/fanruan/api/cal/CalculatorKit.java @@ -5,6 +5,7 @@ import com.fanruan.api.session.SessionKit; import com.fr.base.ParameterMapNameSpace; import com.fr.base.TableDataNameSpace; import com.fr.data.TableDataSource; +import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.report.report.Report; import com.fr.script.Calculator; import com.fr.stable.StringUtils; @@ -77,6 +78,7 @@ public class CalculatorKit { return calculator; } + /** * 返回服务器数据集的算子空间(可以通过调用calculator.pushNameSpace()将算子空间塞进算子实例,从而支持服务器数据集相关的函数计算) * @return 算子空间对象 @@ -84,4 +86,12 @@ public class CalculatorKit { public static NameSpace getServerTableDataNameSpace(){ return TableDataNameSpace.getInstance(); } + + /** + * 单例模式,SimpleCellValueNameSpace + * @return SimpleCellValueNameSpace实例对象 + */ + public static NameSpace createSimpleCellValueNameSpace() { + return SimpleCellValueNameSpace.getInstance(); + } } \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java b/src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java deleted file mode 100644 index 83423cf..0000000 --- a/src/main/java/com/fanruan/api/cal/namespace/SimpleCellValueNameSpaceKit.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fanruan.api.cal.namespace; - -import com.fr.report.core.namespace.SimpleCellValueNameSpace; - -public class SimpleCellValueNameSpaceKit { - /** - * 单例模式,SimpleCellValueNameSpace - * @return SimpleCellValueNameSpace实例对象 - */ - public static SimpleCellValueNameSpace getInstance() { - return SimpleCellValueNameSpace.getInstance(); - } -} diff --git a/src/main/java/com/fanruan/api/function/AVERAGE.java b/src/main/java/com/fanruan/api/function/AVERAGE.java deleted file mode 100644 index 837d4ee..0000000 --- a/src/main/java/com/fanruan/api/function/AVERAGE.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,求平均值 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class AVERAGE extends com.fr.function.AVERAGE { -} diff --git a/src/main/java/com/fanruan/api/function/CHAR.java b/src/main/java/com/fanruan/api/function/CHAR.java deleted file mode 100644 index 796f550..0000000 --- a/src/main/java/com/fanruan/api/function/CHAR.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,求ASCII码对应的字符 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class CHAR extends com.fr.function.CHAR { -} diff --git a/src/main/java/com/fanruan/api/function/COUNT.java b/src/main/java/com/fanruan/api/function/COUNT.java deleted file mode 100644 index 2ad9646..0000000 --- a/src/main/java/com/fanruan/api/function/COUNT.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,计算区域内所含项的个数 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class COUNT extends com.fr.function.COUNT { -} diff --git a/src/main/java/com/fanruan/api/function/DATE.java b/src/main/java/com/fanruan/api/function/DATE.java deleted file mode 100644 index a4b22c3..0000000 --- a/src/main/java/com/fanruan/api/function/DATE.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,获取一个表示某一特定日期的系列数。 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class DATE extends com.fr.function.DATE { -} diff --git a/src/main/java/com/fanruan/api/function/MAX.java b/src/main/java/com/fanruan/api/function/MAX.java deleted file mode 100644 index 536a1ed..0000000 --- a/src/main/java/com/fanruan/api/function/MAX.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,求最大值 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class MAX extends com.fr.function.MAX { -} diff --git a/src/main/java/com/fanruan/api/function/MIN.java b/src/main/java/com/fanruan/api/function/MIN.java deleted file mode 100644 index c3ee021..0000000 --- a/src/main/java/com/fanruan/api/function/MIN.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,求最小值 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class MIN extends com.fr.function.MIN { -} diff --git a/src/main/java/com/fanruan/api/function/RANGE.java b/src/main/java/com/fanruan/api/function/RANGE.java deleted file mode 100644 index 4d4733f..0000000 --- a/src/main/java/com/fanruan/api/function/RANGE.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,取范围内满足条件的数据序列 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class RANGE extends com.fr.function.RANGE { -} diff --git a/src/main/java/com/fanruan/api/function/SUM.java b/src/main/java/com/fanruan/api/function/SUM.java deleted file mode 100644 index 13eb4f7..0000000 --- a/src/main/java/com/fanruan/api/function/SUM.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,求和 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class SUM extends com.fr.function.SUM { -} diff --git a/src/main/java/com/fanruan/api/function/TIME.java b/src/main/java/com/fanruan/api/function/TIME.java deleted file mode 100644 index 6c12000..0000000 --- a/src/main/java/com/fanruan/api/function/TIME.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.function; - -/** - * 基本函数,求代表指定时间的小数 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class TIME extends com.fr.function.TIME { -} diff --git a/src/main/java/com/fanruan/api/log/LogKit.java b/src/main/java/com/fanruan/api/log/LogKit.java index 4eeb09f..fb349de 100644 --- a/src/main/java/com/fanruan/api/log/LogKit.java +++ b/src/main/java/com/fanruan/api/log/LogKit.java @@ -1,6 +1,5 @@ package com.fanruan.api.log; -import com.fr.general.FRLogger; import com.fr.log.FineLoggerFactory; /** diff --git a/src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java b/src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java deleted file mode 100644 index 90561da..0000000 --- a/src/main/java/com/fanruan/api/plugin/ExtraClassManagerKit.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fanruan.api.plugin; - -import com.fr.plugin.ExtraClassManager; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class ExtraClassManagerKit { - /** - * 获取ExtraClassManager实例 - * @return ExtraClassManager实例 - */ - public static ExtraClassManager getInstance() { - return ExtraClassManager.getInstance(); - } -} From ccb9f387ea02be42c6d25cf8f8ae9c55200ad801 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 11:09:52 +0800 Subject: [PATCH 06/13] =?UTF-8?q?KERNEL-1117=20=E6=A0=B9=E6=8D=AE=E8=A6=81?= =?UTF-8?q?=E6=B1=82=E8=BF=9B=E8=A1=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{QuickList.java => UIQuickList.java} | 4 +-- .../ui/container/DialogActionAdapter.java | 11 ------- .../ui/container/FurtherBasicBeanPane.java | 8 ----- .../api/design/util/NameAndFunctionList.java | 17 ----------- .../util/NameAndTypeAndFunctionList.java | 15 ---------- .../ParameterInputPane.java | 2 +- src/main/java/com/fanruan/api/io/IOFile.java | 7 ----- .../fanruan/api/macro/OperatingSystem.java | 30 +++++++++++++++++++ .../fanruan/api/macro/OperatingSystemKit.java | 18 ----------- .../com/fanruan/api/structure/Expression.java | 7 ----- .../com/fanruan/api/structure/Parameter.java | 18 ----------- 11 files changed, 33 insertions(+), 104 deletions(-) rename src/main/java/com/fanruan/api/design/ui/component/{QuickList.java => UIQuickList.java} (57%) delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java delete mode 100644 src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java delete mode 100644 src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java rename src/main/java/com/fanruan/api/design/{ui/container => work}/ParameterInputPane.java (89%) delete mode 100644 src/main/java/com/fanruan/api/io/IOFile.java create mode 100644 src/main/java/com/fanruan/api/macro/OperatingSystem.java delete mode 100644 src/main/java/com/fanruan/api/macro/OperatingSystemKit.java delete mode 100644 src/main/java/com/fanruan/api/structure/Expression.java delete mode 100644 src/main/java/com/fanruan/api/structure/Parameter.java diff --git a/src/main/java/com/fanruan/api/design/ui/component/QuickList.java b/src/main/java/com/fanruan/api/design/ui/component/UIQuickList.java similarity index 57% rename from src/main/java/com/fanruan/api/design/ui/component/QuickList.java rename to src/main/java/com/fanruan/api/design/ui/component/UIQuickList.java index 9269a1c..b60283b 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/QuickList.java +++ b/src/main/java/com/fanruan/api/design/ui/component/UIQuickList.java @@ -5,8 +5,8 @@ import javax.swing.*; /** * 支持键盘输入快速查找项的JList */ -public class QuickList extends com.fr.design.gui.ilist.QuickList { - public QuickList(ListModel listModel) { +public class UIQuickList extends com.fr.design.gui.ilist.QuickList { + public UIQuickList(ListModel listModel) { super(listModel); } } diff --git a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java b/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java deleted file mode 100644 index a6ef245..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * 定义弹窗适配器,可以监听事件实现弹框功能 - */ -public class DialogActionAdapter extends com.fr.design.dialog.DialogActionAdapter { - - public DialogActionAdapter() { - - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java b/src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java deleted file mode 100644 index 34df3cb..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/FurtherBasicBeanPane.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * 对基本的容器做了进一步封装,提供了通用的方法 - * @param - */ -public abstract class FurtherBasicBeanPane extends com.fr.design.beans.FurtherBasicBeanPane { -} diff --git a/src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java b/src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java deleted file mode 100644 index 99d9089..0000000 --- a/src/main/java/com/fanruan/api/design/util/NameAndFunctionList.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fanruan.api.design.util; - -import com.fr.stable.script.Function; - -import java.util.Arrays; - -/** - * 名称对应的函数列表 - * @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); - } -} diff --git a/src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java b/src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java deleted file mode 100644 index 300d800..0000000 --- a/src/main/java/com/fanruan/api/design/util/NameAndTypeAndFunctionList.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.design.util; - -import com.fr.stable.script.Function; - -/** - * 名字和类型对应的函数列表 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class NameAndTypeAndFunctionList extends com.fr.design.formula.NameAndTypeAndFunctionList { - public NameAndTypeAndFunctionList(String name, Function.Type type) { - super(name, type); - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java b/src/main/java/com/fanruan/api/design/work/ParameterInputPane.java similarity index 89% rename from src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java rename to src/main/java/com/fanruan/api/design/work/ParameterInputPane.java index 6b505ad..c96b72b 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/ParameterInputPane.java +++ b/src/main/java/com/fanruan/api/design/work/ParameterInputPane.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.container; +package com.fanruan.api.design.work; import com.fr.stable.ParameterProvider; diff --git a/src/main/java/com/fanruan/api/io/IOFile.java b/src/main/java/com/fanruan/api/io/IOFile.java deleted file mode 100644 index b7e15b4..0000000 --- a/src/main/java/com/fanruan/api/io/IOFile.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.io; - -/** - * 需要进行XML读写的类,该类是数据源类的一个子类 - */ -public abstract class IOFile extends com.fr.base.io.IOFile { -} diff --git a/src/main/java/com/fanruan/api/macro/OperatingSystem.java b/src/main/java/com/fanruan/api/macro/OperatingSystem.java new file mode 100644 index 0000000..da783a3 --- /dev/null +++ b/src/main/java/com/fanruan/api/macro/OperatingSystem.java @@ -0,0 +1,30 @@ +package com.fanruan.api.macro; + +import com.fr.stable.os.AbstractOperatingSystem; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/8/31 + */ +public class OperatingSystem { + + private static final AbstractOperatingSystem myOS = com.fr.stable.os.OperatingSystem.getOperatingSystem(); + + private OperatingSystem() { + } + + + public static boolean isWindows() { + return myOS.getType() == com.fr.stable.os.OperatingSystem.WINDOWS; + } + + public static boolean isUnix() { + return myOS.isUnix(); + } + + public static boolean isMacOS() { + return myOS.getType() == com.fr.stable.os.OperatingSystem.MACOS; + } + +} diff --git a/src/main/java/com/fanruan/api/macro/OperatingSystemKit.java b/src/main/java/com/fanruan/api/macro/OperatingSystemKit.java deleted file mode 100644 index 134b69e..0000000 --- a/src/main/java/com/fanruan/api/macro/OperatingSystemKit.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fanruan.api.macro; - -import com.fr.stable.OperatingSystem; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class OperatingSystemKit { - /** - * 判断是否为windows - * @return 判断结果 - */ - public static boolean isWindows() { - return OperatingSystem.isWindows(); - } -} diff --git a/src/main/java/com/fanruan/api/structure/Expression.java b/src/main/java/com/fanruan/api/structure/Expression.java deleted file mode 100644 index e543be8..0000000 --- a/src/main/java/com/fanruan/api/structure/Expression.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.structure; - -/** - * 表达式 - */ -public class Expression extends com.fr.stable.script.Expression { -} diff --git a/src/main/java/com/fanruan/api/structure/Parameter.java b/src/main/java/com/fanruan/api/structure/Parameter.java deleted file mode 100644 index c4640fc..0000000 --- a/src/main/java/com/fanruan/api/structure/Parameter.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fanruan.api.structure; - -/** - * 参数,参数是可以动态赋值的对象 - */ -public class Parameter extends com.fr.base.Parameter { - public Parameter() { - super(); - } - - public Parameter(String text) { - super(text); - } - - public Parameter(String name, Object value) { - super(name, value); - } -} From b33fa93ae2469105a63292b8679c063baba8d335 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 14:10:40 +0800 Subject: [PATCH 07/13] =?UTF-8?q?KERNEL-1117=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/base/ScriptFormula.java | 17 ----------------- .../api/design/util/FunctionDefNAD.java | 15 --------------- .../api/design/util/FunctionManagerKit.java | 18 ------------------ .../com/fanruan/api/function/FunctionKit.java | 8 ++++++++ .../com/fanruan/api/macro/OperatingSystem.java | 1 + .../com/fanruan/api/structure/Formula.java | 14 -------------- 6 files changed, 9 insertions(+), 64 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/base/ScriptFormula.java delete mode 100644 src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java delete mode 100644 src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java delete mode 100644 src/main/java/com/fanruan/api/structure/Formula.java diff --git a/src/main/java/com/fanruan/api/base/ScriptFormula.java b/src/main/java/com/fanruan/api/base/ScriptFormula.java deleted file mode 100644 index 59a0124..0000000 --- a/src/main/java/com/fanruan/api/base/ScriptFormula.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fanruan.api.base; - -/** - * 使用script语言的脚本公式 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/30 - */ -public class ScriptFormula extends com.fr.base.ScriptFormula { - public ScriptFormula() { - super(); - } - - public ScriptFormula(String text) { - super(text); - } -} diff --git a/src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java b/src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java deleted file mode 100644 index fdf1608..0000000 --- a/src/main/java/com/fanruan/api/design/util/FunctionDefNAD.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.design.util; - -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); - } -} diff --git a/src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java b/src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java deleted file mode 100644 index 72552d4..0000000 --- a/src/main/java/com/fanruan/api/design/util/FunctionManagerKit.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fanruan.api.design.util; - -/** - * 函数管理器 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/8/31 - */ -public class FunctionManagerKit { - /** - * 得到函数管理器实例 - * @return 函数管理器 - */ - public static com.fr.file.FunctionManager getInstance() { - return com.fr.file.FunctionManager.getInstance(); - } - -} diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index 3784174..d43b9e5 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/src/main/java/com/fanruan/api/function/FunctionKit.java @@ -55,4 +55,12 @@ public class FunctionKit { FunctionManager.getInstance().addFunctionDef(fun); } } + + /** + * 得到函数管理器实例 + * @return 函数管理器 + */ + public static com.fr.file.FunctionManager getInstance() { + return com.fr.file.FunctionManager.getInstance(); + } } \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/macro/OperatingSystem.java b/src/main/java/com/fanruan/api/macro/OperatingSystem.java index da783a3..485266f 100644 --- a/src/main/java/com/fanruan/api/macro/OperatingSystem.java +++ b/src/main/java/com/fanruan/api/macro/OperatingSystem.java @@ -3,6 +3,7 @@ package com.fanruan.api.macro; import com.fr.stable.os.AbstractOperatingSystem; /** + * 操作系统判断类,判断操作系统种类 * @author Kalven * @version 10.0 * Created by Kalven on 2019/8/31 diff --git a/src/main/java/com/fanruan/api/structure/Formula.java b/src/main/java/com/fanruan/api/structure/Formula.java deleted file mode 100644 index 7c378d9..0000000 --- a/src/main/java/com/fanruan/api/structure/Formula.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.fanruan.api.structure; - -/** - * 公式, 公式中可以运用已有的各种函数进行复杂的运算 - */ -public class Formula extends com.fr.base.Formula { - public Formula() { - super(); - } - - public Formula(String text) { - super(text); - } -} From 93f40eb1011ee25c37a2991a4e83d80d4aa58f08 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 14:32:31 +0800 Subject: [PATCH 08/13] =?UTF-8?q?KERNEL-1117=20=E6=A0=B9=E6=8D=AE=E8=A6=81?= =?UTF-8?q?=E6=B1=82=E5=86=8D=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/function/FunctionKit.java | 18 ++++++++++++++++++ .../com/fanruan/api/macro/OperatingSystem.java | 15 +++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index d43b9e5..fddf03c 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/src/main/java/com/fanruan/api/function/FunctionKit.java @@ -1,8 +1,12 @@ package com.fanruan.api.function; import com.fanruan.api.function.shell.FineFunc; +import com.fr.design.formula.FunctionDefNAD; +import com.fr.design.formula.NameAndDescription; import com.fr.file.FunctionManager; +import com.fr.file.FunctionManagerProvider; import com.fr.script.Calculator; +//import com.fr.solution.plugin.design.formula.compat.FunctionDefNAD; import com.fr.stable.StringUtils; import com.fr.stable.script.FunctionDef; @@ -56,6 +60,20 @@ public class FunctionKit { } } + public static NameAndDescription[] getDescription() { + FunctionManagerProvider funtionManager = FunctionKit.getInstance(); + if (funtionManager != null) { + int functionDefCount = funtionManager.getFunctionDefCount(); + FunctionDefNAD[] nads = new FunctionDefNAD[functionDefCount]; + for (int i = 0; i < functionDefCount; i++) { + nads[i] = new FunctionDefNAD(funtionManager.getFunctionDef(i)); + } + + return nads; + } + + return new NameAndDescription[0]; + } /** * 得到函数管理器实例 * @return 函数管理器 diff --git a/src/main/java/com/fanruan/api/macro/OperatingSystem.java b/src/main/java/com/fanruan/api/macro/OperatingSystem.java index 485266f..dd2cce1 100644 --- a/src/main/java/com/fanruan/api/macro/OperatingSystem.java +++ b/src/main/java/com/fanruan/api/macro/OperatingSystem.java @@ -10,20 +10,35 @@ import com.fr.stable.os.AbstractOperatingSystem; */ public class OperatingSystem { + /** + * 得到当前操作系统信息 + */ private static final AbstractOperatingSystem myOS = com.fr.stable.os.OperatingSystem.getOperatingSystem(); private OperatingSystem() { } + /** + * 判断系统是否是Windows + * @return 判断结果 + */ public static boolean isWindows() { return myOS.getType() == com.fr.stable.os.OperatingSystem.WINDOWS; } + /** + * 判断系统是否是Unix + * @return 判断结果 + */ public static boolean isUnix() { return myOS.isUnix(); } + /** + * 判断系统是否是MacOS + * @return 判断结果 + */ public static boolean isMacOS() { return myOS.getType() == com.fr.stable.os.OperatingSystem.MACOS; } From 38740b4f3ae5f9eb330818c7e7a3c727cfafe7f2 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 14:41:52 +0800 Subject: [PATCH 09/13] =?UTF-8?q?KERNEL-1117=20=E5=8A=A0=E4=B8=8A=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/function/FunctionKit.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index fddf03c..5234d4e 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/src/main/java/com/fanruan/api/function/FunctionKit.java @@ -60,6 +60,10 @@ public class FunctionKit { } } + /** + * 得到描述函数管理器中所有的函数的名称描述 + * @return 函数的名称描述数组 + */ public static NameAndDescription[] getDescription() { FunctionManagerProvider funtionManager = FunctionKit.getInstance(); if (funtionManager != null) { From c7d07be2fd259cb14e05a9c6a4c00b0ebf4ca783 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 14:52:57 +0800 Subject: [PATCH 10/13] =?UTF-8?q?KERNEL-1117=20=E5=86=8D=E6=AC=A1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/cal/ParameterKit.java | 9 +++++++++ src/main/java/com/fanruan/api/function/FunctionKit.java | 1 - 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 963e152..7ba659a 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -89,4 +89,13 @@ public class ParameterKit { public static @NotNull ParameterMapNameSpace createParameterMapNameSpace(ParameterProvider[] ps) { return ParameterMapNameSpace.create(ps); } + + /** + * 创建新的参数对象 + * @param content 参数名 + * @return 参数对象 + */ + public static @NotNull Parameter createNewParameter(String content) { + return new Parameter(content); + } } diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index 5234d4e..68eaa19 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/src/main/java/com/fanruan/api/function/FunctionKit.java @@ -6,7 +6,6 @@ import com.fr.design.formula.NameAndDescription; import com.fr.file.FunctionManager; import com.fr.file.FunctionManagerProvider; import com.fr.script.Calculator; -//import com.fr.solution.plugin.design.formula.compat.FunctionDefNAD; import com.fr.stable.StringUtils; import com.fr.stable.script.FunctionDef; From cc9959e60dd5ca9d80690a8cee05f0f99610ae88 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 15:01:33 +0800 Subject: [PATCH 11/13] =?UTF-8?q?KERNEL-1117=20=E9=81=BF=E5=85=8DParameter?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9A=B4=E9=9C=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/cal/ParameterKit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 7ba659a..4807a7d 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -91,11 +91,11 @@ public class ParameterKit { } /** - * 创建新的参数对象 + * 根据参数名创建新的参数对象 * @param content 参数名 * @return 参数对象 */ - public static @NotNull Parameter createNewParameter(String content) { + public static @NotNull ParameterProvider createNewParameter(String content) { return new Parameter(content); } } From 0c6f26bc6a49dec3dbe04d43373744651ba08505 Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 17:02:02 +0800 Subject: [PATCH 12/13] =?UTF-8?q?KERNEL-1117=20=E5=8A=A0=E5=85=A5=E5=8D=95?= =?UTF-8?q?=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=9B=B4=E6=94=B9=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/ParameterKit.java | 18 ++++++++++-------- .../com/fanruan/api/cal/ParameterKitTest.java | 7 +++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 4807a7d..e3c3f92 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -37,6 +37,15 @@ public class ParameterKit { return new Parameter(name, value); } + /** + * 根据参数名创建新的参数对象 + * @param name 参数名 + * @return 参数对象 + */ + public static @NotNull ParameterProvider createNewParameter(String name) { + return new Parameter(name); + } + /** * 从字符串中分析中有哪些需要的参数 * @@ -90,12 +99,5 @@ public class ParameterKit { return ParameterMapNameSpace.create(ps); } - /** - * 根据参数名创建新的参数对象 - * @param content 参数名 - * @return 参数对象 - */ - public static @NotNull ParameterProvider createNewParameter(String content) { - return new Parameter(content); - } + } diff --git a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java index 9292107..1c66498 100644 --- a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java +++ b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java @@ -107,4 +107,11 @@ public class ParameterKitTest extends Prepare { Assert.assertEquals("p1", provider.getName()); Assert.assertEquals("124", provider.getValue()); } + + @Test + public void createNewParameter() { + ParameterProvider provider = ParameterKit.createNewParameter("p1"); + Assert.assertEquals(provider.getName(),"p1"); + Assert.assertEquals("", provider.getValue()); + } } \ No newline at end of file From 2e34e07f24bc86e4c5e6da85a7a703f62927f03b Mon Sep 17 00:00:00 2001 From: Kalven Date: Mon, 2 Sep 2019 17:13:26 +0800 Subject: [PATCH 13/13] =?UTF-8?q?KERNEL-1117=20=E4=BF=AE=E6=94=B9=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E5=90=8D=E5=92=8C=E5=8F=82=E6=95=B0=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/cal/ParameterKit.java | 2 +- src/main/java/com/fanruan/api/design/DesignKit.java | 10 ++++++++++ .../design/ui/container/HistoryTemplateListPane.java | 7 ------- .../java/com/fanruan/api/cal/ParameterKitTest.java | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index e3c3f92..a8db2f1 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -42,7 +42,7 @@ public class ParameterKit { * @param name 参数名 * @return 参数对象 */ - public static @NotNull ParameterProvider createNewParameter(String name) { + public static @NotNull ParameterProvider newParameter(String name) { return new Parameter(name); } diff --git a/src/main/java/com/fanruan/api/design/DesignKit.java b/src/main/java/com/fanruan/api/design/DesignKit.java index ce6be5d..194234a 100644 --- a/src/main/java/com/fanruan/api/design/DesignKit.java +++ b/src/main/java/com/fanruan/api/design/DesignKit.java @@ -2,9 +2,11 @@ package com.fanruan.api.design; import com.fr.base.TableData; import com.fr.design.data.datapane.preview.PreviewTablePane; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.JTemplate; public class DesignKit { /** @@ -41,4 +43,12 @@ public class DesignKit { public static DesignerFrame getDesignerFrame() { return DesignerContext.getDesignerFrame(); } + + /** + * 得到当前在修改的模板 + * @return 返回当前正在编辑的模板 + */ + public static JTemplate getCurrentEditingTemplate(){ + return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + } } diff --git a/src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java b/src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java deleted file mode 100644 index 50f6f81..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/HistoryTemplateListPane.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * 存放历史模板的列表容器 - */ -public class HistoryTemplateListPane extends com.fr.design.file.HistoryTemplateListPane { -} diff --git a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java index 1c66498..4093687 100644 --- a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java +++ b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java @@ -109,8 +109,8 @@ public class ParameterKitTest extends Prepare { } @Test - public void createNewParameter() { - ParameterProvider provider = ParameterKit.createNewParameter("p1"); + public void newParameter2() { + ParameterProvider provider = ParameterKit.newParameter("p1"); Assert.assertEquals(provider.getName(),"p1"); Assert.assertEquals("", provider.getValue()); }