From ca1ecef2380f94e34294c5c87a7921bff63de076 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Fri, 6 Sep 2019 13:41:45 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=20feat:=20=E6=96=B0=E5=A2=9EcreateBorder?= =?UTF-8?q?Layout=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/design/util/GUICoreKit.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java index 1ff5155..9e4ded5 100644 --- a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -119,6 +119,14 @@ public class GUICoreKit { return FRGUIPaneFactory.createBorderLayout_S_Pane(); } + /** + * 创建一个边框布局 + * @return 返回BorderLayout对象 + * */ + public static LayoutManager createBorderLayout() { + return FRGUIPaneFactory.createBorderLayout(); + } + /** * 设置一个窗口居中 */ From 1e8dd0e3d9bc1eccfb70f0eb6702b47c76434da5 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Fri, 6 Sep 2019 15:35:37 +0800 Subject: [PATCH 02/25] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/conf/HolderKit.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/fanruan/api/conf/HolderKit.java b/src/main/java/com/fanruan/api/conf/HolderKit.java index 6268e47..6e9c709 100644 --- a/src/main/java/com/fanruan/api/conf/HolderKit.java +++ b/src/main/java/com/fanruan/api/conf/HolderKit.java @@ -5,6 +5,8 @@ import com.fanruan.api.conf.impl.ObjectColConf; import com.fanruan.api.conf.impl.ObjectMapConf; import com.fanruan.api.conf.impl.SimConf; import com.fr.config.holder.Conf; +import com.fr.config.holder.factory.Holders; +import com.fr.config.holder.impl.ColConf; import java.util.Collection; import java.util.Map; @@ -88,4 +90,14 @@ public class HolderKit { public static ObjectMapConf> objMap(Map map, Class keyType, Class valueType, boolean order) { return new ObjectMapConf<>(map, keyType, valueType, order); } + + /** + * 创建一个collection类型的holder + * @param collection 值Collection类型 + * @param valueType 值class类型 + * @return collection类型的holder + * */ + public static ColConf> collection(Collection collection, Class valueType) { + return Holders.collection(collection, valueType); + } } From fc7917be498ece8bd29410f8f34bbc5bbd82e63a Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Fri, 6 Sep 2019 15:44:05 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E5=88=A0=E5=8E=BB=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/design/util/GUICoreKit.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java index 9e4ded5..af8661c 100644 --- a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -118,15 +118,6 @@ public class GUICoreKit { public static JPanel createBorderLayoutPane() { return FRGUIPaneFactory.createBorderLayout_S_Pane(); } - - /** - * 创建一个边框布局 - * @return 返回BorderLayout对象 - * */ - public static LayoutManager createBorderLayout() { - return FRGUIPaneFactory.createBorderLayout(); - } - /** * 设置一个窗口居中 */ From ffe52018f2e3939f1cec85d3e2902281ec094e05 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 17 Sep 2019 19:25:49 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 51a76d4..f89ecf8 100644 --- a/readme.md +++ b/readme.md @@ -55,7 +55,13 @@ SessionKit#getSession(@NotNull String sessionID); ## 如何判断插件中调用的API需要增加到FineKit中 -最简单的原则:除了JDK自带的类、插件接口(包括抽象类)、枚举、以及使用了@Open注解标记的类之外,是否还使用了com.fanruan.api(com.fr.third除外)之外的类,如果有则需要修改。 +最简单的原则: + +1、插件只使用了JDK自带的类、插件接口(包括抽象类)、枚举、以及使用了@Open注解标记的类; +2、插件只使用了包名前缀为com.fr.third的类; +3、插件只使用了包名前缀为com.fanruan.api之外的类; + +如果违背了上述三个原则,则需要考虑将使用类加入FineKit中。 ## 如何提交新的API From 09a7df14d724c0e77a8b6c03f8a00a52d58582f2 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 17 Sep 2019 19:26:15 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index f89ecf8..2b6cbfa 100644 --- a/readme.md +++ b/readme.md @@ -58,7 +58,9 @@ SessionKit#getSession(@NotNull String sessionID); 最简单的原则: 1、插件只使用了JDK自带的类、插件接口(包括抽象类)、枚举、以及使用了@Open注解标记的类; + 2、插件只使用了包名前缀为com.fr.third的类; + 3、插件只使用了包名前缀为com.fanruan.api之外的类; 如果违背了上述三个原则,则需要考虑将使用类加入FineKit中。 From fd8d12543af687fb8ae8931f0a158e22a6b960fc Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 18 Sep 2019 16:07:15 +0800 Subject: [PATCH 06/25] =?UTF-8?q?update:=20finekit=E7=9A=84=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E8=A1=A5=E5=85=85=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/attachment/Attachment.java | 20 +++++++++++ .../com/fanruan/api/cal/namespace/FArray.java | 23 +++++++++++++ .../java/com/fanruan/api/i18n/I18nKit.java | 10 ++++++ .../java/com/fanruan/api/util/ArrayKit.java | 2 +- .../java/com/fanruan/api/util/CodeKit.java | 8 +++++ .../java/com/fanruan/api/util/GeneralKit.java | 9 ++++- src/main/java/com/fanruan/api/xml/XmlKit.java | 10 +++++- .../com/fanruan/api/xml/component/FRFile.java | 13 ++++++++ .../com/fanruan/api/util/ArrayKitTest.java | 33 ++++++++++++++++++- .../com/fanruan/api/util/CodeKitTest.java | 4 +-- .../com/fanruan/api/util/GeneralKitTest.java | 6 ++++ 11 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/fanruan/api/attachment/Attachment.java create mode 100644 src/main/java/com/fanruan/api/cal/namespace/FArray.java create mode 100644 src/main/java/com/fanruan/api/xml/component/FRFile.java diff --git a/src/main/java/com/fanruan/api/attachment/Attachment.java b/src/main/java/com/fanruan/api/attachment/Attachment.java new file mode 100644 index 0000000..e3e1e61 --- /dev/null +++ b/src/main/java/com/fanruan/api/attachment/Attachment.java @@ -0,0 +1,20 @@ +package com.fanruan.api.attachment; + +import com.fr.cache.AttachmentFileBase; +/** + * 附件信息类,用来存储FR中的各种附件 + * */ +public class Attachment extends com.fr.cache.Attachment{ + /** + * 根据给定的编号、类型、文件名和二进制数组创建一个附件对象 + * */ + public Attachment(String id, String type, String filename, AttachmentFileBase attachmentFileBase){ + super(id, type, filename, attachmentFileBase); + } + /** + * 根据给定的编号、类型、文件名、二进制数组、宽度和高度创建一个附件对象 + * */ + public Attachment(String id, String type, String filename, AttachmentFileBase attachmentFileBase, int width, int height){ + super(id, type, filename, attachmentFileBase, width, height); + } +} diff --git a/src/main/java/com/fanruan/api/cal/namespace/FArray.java b/src/main/java/com/fanruan/api/cal/namespace/FArray.java new file mode 100644 index 0000000..51c59b8 --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/namespace/FArray.java @@ -0,0 +1,23 @@ +package com.fanruan.api.cal.namespace; +import java.util.Collection; + +/** + * 生成一个链表类 + * */ +public class FArray extends com.fr.general.FArray{ + public FArray(){ + + } + /** + * 通过使用一个无需集合生成的链表类 + * */ + public FArray(Collection collection) { + super(collection); + } + /** + * 通过使用一个数组生成的链表类 + * */ + public FArray(T[] array) { + super(array); + } +} diff --git a/src/main/java/com/fanruan/api/i18n/I18nKit.java b/src/main/java/com/fanruan/api/i18n/I18nKit.java index a2f3cb1..e4e56d1 100644 --- a/src/main/java/com/fanruan/api/i18n/I18nKit.java +++ b/src/main/java/com/fanruan/api/i18n/I18nKit.java @@ -11,4 +11,14 @@ public class I18nKit { public static String getLocText(String string) { return InterProviderFactory.getProvider().getLocText(string); } + /** + * 获取国际化文本 + * + * @param string 需要国际化的值对应的键 + * @param args 变量 + * @return 返回国际化文本 + */ + public static String getLocText(String string,String... args) { + return InterProviderFactory.getProvider().getLocText(string,args); + } } diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 5df74b7..ed5b319 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -55,7 +55,7 @@ public class ArrayKit { * @param array 源数组 * @return 返回数组判断为空的结果 */ - public static boolean isEmpty(Object[] array) { + public static boolean isEmpty(T[] array) { return ArrayUtils.isEmpty(array); } /** diff --git a/src/main/java/com/fanruan/api/util/CodeKit.java b/src/main/java/com/fanruan/api/util/CodeKit.java index b819eb4..f59227f 100644 --- a/src/main/java/com/fanruan/api/util/CodeKit.java +++ b/src/main/java/com/fanruan/api/util/CodeKit.java @@ -12,4 +12,12 @@ public class CodeKit { public static String passwordDecode(String passwordText) { return CodeUtils.passwordDecode(passwordText); } + /** + * 将普通的java字符串编码成javascript代码 + * @param string4javascript 待编码的字符串 + * @return 编码后的代码 + * */ + public static String javascriptEncode(String string4javascript) { + return CommonCodeUtils.javascriptEncode(string4javascript); + } } diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 60d642b..9c6dc15 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -96,6 +96,13 @@ public class GeneralKit { public static Locale getLocale() { return FRContext.getLocale(); } - + /** + * 将路径节点数组用路径分隔符"/"连接起来 + * @param nodes 路径节点数组 + * @return 连接后的路径 + * */ + public static String pathJoin(String... nodes) { + return StableUtils.pathJoin(nodes); + } } diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index 89de42a..b497b7e 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -8,6 +8,7 @@ import com.fr.stable.xml.XMLReadable; import com.fr.stable.xml.XMLTools; import com.fr.stable.xml.XMLable; import com.fr.stable.xml.XMLableReader; +import com.fr.stable.xml.XMLWriter; import java.io.InputStream; @@ -75,5 +76,12 @@ public class XmlKit { public static void writeXMLConnection(XMLPrintWriter writer, Connection connection) { DataCoreXmlUtils.writeXMLConnection(writer, connection); } - + /** + * 把一个XMLable写成字符串 + * @param xmlable xml文件 + * @return 返回字符串 + * */ + public static String writeXMLableAsString(XMLWriter xmlable){ + return GeneralXMLTools.writeXMLableAsString(xmlable); + } } diff --git a/src/main/java/com/fanruan/api/xml/component/FRFile.java b/src/main/java/com/fanruan/api/xml/component/FRFile.java new file mode 100644 index 0000000..e62b732 --- /dev/null +++ b/src/main/java/com/fanruan/api/xml/component/FRFile.java @@ -0,0 +1,13 @@ +package com.fanruan.api.xml.component; + +/** +* FR文件类,用于表示具有指定名字、类型和内容的文件 +* */ +public class FRFile extends com.fr.stable.xml.FRFile{ + /** + * 根据指定的文件类型,文件名以及文件内容生成一个文件 + * */ + public FRFile(String type, String filename, byte[] bytes){ + super(type, filename, bytes); + } +} diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index 45c6096..4803a7c 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -11,9 +11,40 @@ public class ArrayKitTest extends Prepare { public void isEmpty() throws Exception{ Object[] emptyArray = new Object[0]; Object[] notEmptyArray = new Object[1]; + Boolean[] booleanEmptyArray = new Boolean[0]; + Boolean[] booleanNotEmptyArray = new Boolean[1]; + Byte[] byteEmptyArray = new Byte[0]; + Byte[] byteNotEmptyArray = new Byte[1]; + Character[] charEmptyArray = new Character[0]; + Character[] charNotEmptyArray = new Character[1]; + Double[] doubleEmptyArray = new Double[0]; + Double[] doubleNotEmptyArray = new Double[1]; + Float[] floatEmptyArray = new Float[0]; + Float[] floatNotEmptyArray = new Float[1]; + Integer[] intEmptyArray = new Integer[0]; + Integer[] intNotEmptyArray = new Integer[1]; + Long[] longEmptyArray = new Long[0]; + Long[] longNotEmptyArray = new Long[1]; + Short[] shortEmptyArray = new Short[0]; + Short[] shortNotEmptyArray = new Short[1]; Assert.assertTrue(ArrayKit.isEmpty(emptyArray)); Assert.assertFalse(ArrayKit.isEmpty(notEmptyArray)); - + Assert.assertTrue(ArrayKit.isEmpty(booleanEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(booleanNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(byteEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(byteNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(charEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(charNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(doubleEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(doubleNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(floatEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(floatNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(intEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(intNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(longEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(longNotEmptyArray)); + Assert.assertTrue(ArrayKit.isEmpty(shortEmptyArray)); + Assert.assertFalse(ArrayKit.isEmpty(shortNotEmptyArray)); } @Test diff --git a/src/test/java/com/fanruan/api/util/CodeKitTest.java b/src/test/java/com/fanruan/api/util/CodeKitTest.java index 10853e6..4b11e3b 100644 --- a/src/test/java/com/fanruan/api/util/CodeKitTest.java +++ b/src/test/java/com/fanruan/api/util/CodeKitTest.java @@ -6,7 +6,7 @@ import org.junit.Test; public class CodeKitTest { @Test - public void passwordDecode(String passwordText) { - Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123); + public void javascriptEncode() { + Assert.assertEquals(CodeKit.javascriptEncode("console.log(123)"), "console.log(123)"); } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 6ba3bf6..12882ee 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -55,4 +55,10 @@ public class GeneralKitTest extends Prepare { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } + @Test + public void pathJoin(){ + String strArray[] = {"abc", "def"}; + Assert.assertEquals(GeneralKit.pathJoin(strArray), "abc/def"); + } + } \ No newline at end of file From 5b96b8ce3a18156bb595954ed89d5b8530643172 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 18 Sep 2019 17:14:18 +0800 Subject: [PATCH 07/25] =?UTF-8?q?update:=20=E5=88=A0=E5=8E=BBFRFile?= =?UTF-8?q?=E5=92=8Cattachment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/attachment/Attachment.java | 20 ------------------- .../com/fanruan/api/xml/component/FRFile.java | 13 ------------ 2 files changed, 33 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/attachment/Attachment.java delete mode 100644 src/main/java/com/fanruan/api/xml/component/FRFile.java diff --git a/src/main/java/com/fanruan/api/attachment/Attachment.java b/src/main/java/com/fanruan/api/attachment/Attachment.java deleted file mode 100644 index e3e1e61..0000000 --- a/src/main/java/com/fanruan/api/attachment/Attachment.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fanruan.api.attachment; - -import com.fr.cache.AttachmentFileBase; -/** - * 附件信息类,用来存储FR中的各种附件 - * */ -public class Attachment extends com.fr.cache.Attachment{ - /** - * 根据给定的编号、类型、文件名和二进制数组创建一个附件对象 - * */ - public Attachment(String id, String type, String filename, AttachmentFileBase attachmentFileBase){ - super(id, type, filename, attachmentFileBase); - } - /** - * 根据给定的编号、类型、文件名、二进制数组、宽度和高度创建一个附件对象 - * */ - public Attachment(String id, String type, String filename, AttachmentFileBase attachmentFileBase, int width, int height){ - super(id, type, filename, attachmentFileBase, width, height); - } -} diff --git a/src/main/java/com/fanruan/api/xml/component/FRFile.java b/src/main/java/com/fanruan/api/xml/component/FRFile.java deleted file mode 100644 index e62b732..0000000 --- a/src/main/java/com/fanruan/api/xml/component/FRFile.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fanruan.api.xml.component; - -/** -* FR文件类,用于表示具有指定名字、类型和内容的文件 -* */ -public class FRFile extends com.fr.stable.xml.FRFile{ - /** - * 根据指定的文件类型,文件名以及文件内容生成一个文件 - * */ - public FRFile(String type, String filename, byte[] bytes){ - super(type, filename, bytes); - } -} From 2706950e44dd0afc7bab134abfeb7843707d0202 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 18 Sep 2019 17:29:59 +0800 Subject: [PATCH 08/25] =?UTF-8?q?update:=20=E4=BF=AE=E6=94=B9=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/conf/HolderKit.java | 1 - src/main/java/com/fanruan/api/i18n/I18nKit.java | 8 +++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/fanruan/api/conf/HolderKit.java b/src/main/java/com/fanruan/api/conf/HolderKit.java index 3f3e878..3e1f5b3 100644 --- a/src/main/java/com/fanruan/api/conf/HolderKit.java +++ b/src/main/java/com/fanruan/api/conf/HolderKit.java @@ -6,7 +6,6 @@ import com.fanruan.api.conf.impl.ObjectColConf; import com.fanruan.api.conf.impl.ObjectMapConf; import com.fanruan.api.conf.impl.SimConf; import com.fr.config.holder.Conf; -import com.fr.config.holder.factory.Holders; import java.util.Collection; diff --git a/src/main/java/com/fanruan/api/i18n/I18nKit.java b/src/main/java/com/fanruan/api/i18n/I18nKit.java index e4e56d1..74a95c9 100644 --- a/src/main/java/com/fanruan/api/i18n/I18nKit.java +++ b/src/main/java/com/fanruan/api/i18n/I18nKit.java @@ -1,4 +1,5 @@ package com.fanruan.api.i18n; + import com.fr.locale.InterProviderFactory; public class I18nKit { @@ -11,14 +12,15 @@ public class I18nKit { public static String getLocText(String string) { return InterProviderFactory.getProvider().getLocText(string); } + /** * 获取国际化文本 * * @param string 需要国际化的值对应的键 - * @param args 变量 + * @param args 变量 * @return 返回国际化文本 */ - public static String getLocText(String string,String... args) { - return InterProviderFactory.getProvider().getLocText(string,args); + public static String getLocText(String string, String... args) { + return InterProviderFactory.getProvider().getLocText(string, args); } } From df637a7ef8725123462a09fe7e53ddd55573e781 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 18 Sep 2019 18:09:09 +0800 Subject: [PATCH 09/25] =?UTF-8?q?update:=20=E5=88=A0=E5=8E=BBFarray?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/namespace/FArray.java | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/cal/namespace/FArray.java diff --git a/src/main/java/com/fanruan/api/cal/namespace/FArray.java b/src/main/java/com/fanruan/api/cal/namespace/FArray.java deleted file mode 100644 index 51c59b8..0000000 --- a/src/main/java/com/fanruan/api/cal/namespace/FArray.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.fanruan.api.cal.namespace; -import java.util.Collection; - -/** - * 生成一个链表类 - * */ -public class FArray extends com.fr.general.FArray{ - public FArray(){ - - } - /** - * 通过使用一个无需集合生成的链表类 - * */ - public FArray(Collection collection) { - super(collection); - } - /** - * 通过使用一个数组生成的链表类 - * */ - public FArray(T[] array) { - super(array); - } -} From 51e1c9817febe7e38413871af6f4bf59e7a0a9ce Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 19 Sep 2019 14:34:29 +0800 Subject: [PATCH 10/25] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 1 + .../com/fanruan/api/report/form/BaseWidget.java | 7 +++---- .../api/report/form/category/LoadingWidget.java | 14 ++++++++++++++ .../api/report/form/category/PlainWidget.java | 17 +++++++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java create mode 100644 src/main/java/com/fanruan/api/report/form/category/PlainWidget.java diff --git a/readme.md b/readme.md index 2b6cbfa..5bd856e 100644 --- a/readme.md +++ b/readme.md @@ -52,6 +52,7 @@ SessionKit#getSession(@NotNull String sessionID); |评分形态插件|https://git.fanruan.com/fanruan/demo-show-present| |急速下拉树插件|https://git.fanruan.com/fanruan/demo-widget-ztree| |网页框插件|https://git.fanruan.com/fanruan/demo-widget-iframe| +|时钟控件|https://git.fanruan.com/fanruan/demo-show-clock| ## 如何判断插件中调用的API需要增加到FineKit中 diff --git a/src/main/java/com/fanruan/api/report/form/BaseWidget.java b/src/main/java/com/fanruan/api/report/form/BaseWidget.java index 703fad3..3483a54 100644 --- a/src/main/java/com/fanruan/api/report/form/BaseWidget.java +++ b/src/main/java/com/fanruan/api/report/form/BaseWidget.java @@ -1,7 +1,6 @@ package com.fanruan.api.report.form; import com.fr.data.act.Describer; -import com.fr.data.act.Producer; import com.fr.form.ui.Widget; import com.fr.json.JSONException; import com.fr.json.JSONObject; @@ -13,9 +12,9 @@ import com.fr.stable.web.Repository; * @author richie * @version 10.0 * Created by richie on 2019-09-10 - * 控件的插件接口 + * 控件接口,如果控件支持"控件值"属性,则需要实现接口 {@link com.fr.form.ui.DataControl} */ -public abstract class BaseWidget extends Widget implements Describer, Producer { +public abstract class BaseWidget extends Widget implements Describer { @Override public boolean isEditor() { @@ -23,7 +22,7 @@ public abstract class BaseWidget extends Widget implements Describer, Producer { } @Override - public JSONObject createJSONConfig(Repository repository, Calculator calculator, NodeVisitor nodeVisitor) throws JSONException { + public final JSONObject createJSONConfig(Repository repository, Calculator calculator, NodeVisitor nodeVisitor) throws JSONException { JSONObject jo = super.createJSONConfig(repository, calculator, nodeVisitor); mixinJSON(repository, calculator, jo); return jo; diff --git a/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java b/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java new file mode 100644 index 0000000..bc5eaf6 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/form/category/LoadingWidget.java @@ -0,0 +1,14 @@ +package com.fanruan.api.report.form.category; + +import com.fanruan.api.report.form.BaseWidget; +import com.fr.data.act.Producer; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 初始化的时候除了配置,还会有加载数据的控件,典型的控件如下拉框、下拉树、复选框组等 + */ +public abstract class LoadingWidget extends BaseWidget implements Producer { + +} diff --git a/src/main/java/com/fanruan/api/report/form/category/PlainWidget.java b/src/main/java/com/fanruan/api/report/form/category/PlainWidget.java new file mode 100644 index 0000000..199f509 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/form/category/PlainWidget.java @@ -0,0 +1,17 @@ +package com.fanruan.api.report.form.category; + +import com.fanruan.api.report.form.BaseWidget; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 初始化时只有配置的控件,没有数据设置,典型的比如按钮、标签等 + */ +public abstract class PlainWidget extends BaseWidget { + + @Override + public boolean isEditor() { + return false; + } +} From 2ba49be1537041129774df06a1e9d60ba42887e8 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 19 Sep 2019 17:45:56 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E5=86=B3=E7=AD=96=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/decision/CommonKit.java | 54 +++++ .../com/fanruan/api/decision/UserKit.java | 39 ++++ .../api/decision/auth/BasePassport.java | 25 ++ .../decision/auth/bean/BasePassportBean.java | 40 ++++ .../api/{ => decision}/login/LoginKit.java | 16 +- .../api/decision/middle/ReadOnlyUser.java | 45 ++++ .../com/fanruan/api/runtime/ResourceKit.java | 219 ++++++++++++++++++ 7 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/fanruan/api/decision/CommonKit.java create mode 100644 src/main/java/com/fanruan/api/decision/UserKit.java create mode 100644 src/main/java/com/fanruan/api/decision/auth/BasePassport.java create mode 100644 src/main/java/com/fanruan/api/decision/auth/bean/BasePassportBean.java rename src/main/java/com/fanruan/api/{ => decision}/login/LoginKit.java (75%) create mode 100644 src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java create mode 100644 src/main/java/com/fanruan/api/runtime/ResourceKit.java diff --git a/src/main/java/com/fanruan/api/decision/CommonKit.java b/src/main/java/com/fanruan/api/decision/CommonKit.java new file mode 100644 index 0000000..a0c49a7 --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/CommonKit.java @@ -0,0 +1,54 @@ +package com.fanruan.api.decision; + +import com.fanruan.api.log.LogKit; +import com.fanruan.api.util.StringKit; +import com.fr.base.Base64; +import com.fr.base.ServerConfig; +import com.fr.decision.webservice.utils.DecisionServiceConstants; +import com.fr.stable.StringUtils; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 常规工具类 + */ +public class CommonKit { + + /** + * 这个方法用于判断从前端返回服务器端的密码是否有被修改过 + * + * @param password 从前端返回的密码文本 + * @return 如果密码没有被修改过就返回true,否则就返回false + */ + public static boolean isDefaultPasswordHolderString(String password) { + return DecisionServiceConstants.DEFAULT_PASSWORD.equals(password); + } + + /** + * 获取默认密码占位符 + * + * @return 默认密码占位符 + */ + public static String fetchDefaultPasswordHolderString() { + return DecisionServiceConstants.DEFAULT_PASSWORD; + } + + /** + * 将base64编码的字符串转为常规的字符串 + * + * @param encodeStr base64编码的字符串 + * @return 常规字符串 + */ + public static String getBase64DecodeStr(String encodeStr) { + try { + if (StringUtils.isNotEmpty(encodeStr)) { + return new String(Base64.decode(encodeStr), ServerConfig.getInstance().getServerCharset()); + } + } catch (Exception e) { + LogKit.error(e.getMessage(), e); + } + + return StringKit.EMPTY; + } +} diff --git a/src/main/java/com/fanruan/api/decision/UserKit.java b/src/main/java/com/fanruan/api/decision/UserKit.java new file mode 100644 index 0000000..323d6b4 --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/UserKit.java @@ -0,0 +1,39 @@ +package com.fanruan.api.decision; + +import com.fanruan.api.decision.middle.ReadOnlyUser; +import com.fr.decision.authority.data.User; +import com.fr.decision.webservice.utils.UserSourceFactory; +import com.fr.decision.webservice.utils.user.source.UserSource; +import com.fr.decision.webservice.v10.user.UserService; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + */ +public class UserKit { + + /** + * 根据用户名获取这个用户的来源 + * + * @param username 用户名 + * @return 用户来源 + * @throws Exception 如果在获取用户的过程中出错了,则抛出此异常 + */ + public static UserSource fetchUserSource(String username) throws Exception { + User user = UserService.getInstance().getUserByUserName(username); + return UserSourceFactory.getInstance().getUserSource(user); + } + + /** + * 根据用户名获取用户信息 + * + * @param username 用户名 + * @return 用户信息 + * @throws Exception 如果获取用户出错,则抛出此异常 + */ + public static ReadOnlyUser getReadOnlyUser(String username) throws Exception { + User user = UserService.getInstance().getUserByUserName(username); + return ReadOnlyUser.build(user.getUserName(), user.getPassword(), user.getRealName()); + } +} diff --git a/src/main/java/com/fanruan/api/decision/auth/BasePassport.java b/src/main/java/com/fanruan/api/decision/auth/BasePassport.java new file mode 100644 index 0000000..e0e8aea --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/auth/BasePassport.java @@ -0,0 +1,25 @@ +package com.fanruan.api.decision.auth; + +import com.fr.decision.authorize.impl.AbstractPassport; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 认证方式 + */ +public abstract class BasePassport extends AbstractPassport { + + /** + * 检查登录信息是否有效 + * + * @param username 用户名 + * @param inputPassword 输入的密码 + * @param savedPassword 配置文件中保存的密码 + * @param hashPassword 哈希后的密码 + * @return 登录凭证是有效的则返回true,否则返回false + */ + public boolean checkTicket(String username, String inputPassword, String savedPassword, String hashPassword) { + return false; + } +} diff --git a/src/main/java/com/fanruan/api/decision/auth/bean/BasePassportBean.java b/src/main/java/com/fanruan/api/decision/auth/bean/BasePassportBean.java new file mode 100644 index 0000000..e8b8b91 --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/auth/bean/BasePassportBean.java @@ -0,0 +1,40 @@ +package com.fanruan.api.decision.auth.bean; + +import com.fr.decision.authorize.Passport; +import com.fr.decision.webservice.bean.authentication.PassportBean; +import com.fr.third.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 用于表示不同认证方式的接口 + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class") +public abstract class BasePassportBean extends PassportBean { + + /** + * 用于标记认证类型的字符串 + * + * @return 字符串 + */ + @Override + public abstract String markType(); + + /** + * 根据配置对象生成认证配置数据层对象 + * + * @param t 配置对象 + * @return 配属数据层 + */ + @Override + public abstract BasePassportBean createPassportBean(T t); + + /** + * 生成配置对象 + * + * @return 配置 + */ + @Override + public abstract Passport createPassport(); +} diff --git a/src/main/java/com/fanruan/api/login/LoginKit.java b/src/main/java/com/fanruan/api/decision/login/LoginKit.java similarity index 75% rename from src/main/java/com/fanruan/api/login/LoginKit.java rename to src/main/java/com/fanruan/api/decision/login/LoginKit.java index be128c1..620c2a2 100644 --- a/src/main/java/com/fanruan/api/login/LoginKit.java +++ b/src/main/java/com/fanruan/api/decision/login/LoginKit.java @@ -1,4 +1,4 @@ -package com.fanruan.api.login; +package com.fanruan.api.decision.login; import com.fr.decision.authorize.Passport; import com.fr.decision.authorize.impl.HttpPassport; @@ -14,14 +14,27 @@ public class LoginKit { /** * 获取决策平台设置的认证类型 + * * @return 认证对象 */ public static Passport getCurrentPassport() { return FSConfig.getInstance().getPassport(); } + /** + * 获取指定类型的通行证,如果不存在,就返回null + * + * @param type 通行证类型 + * @param 类型 + * @return 通行证 + */ + public static T getPassport(Class type) { + return FSConfig.getInstance().getPassport(type); + } + /** * 获取http认证的地址 + * * @return http认证地址 */ public static @Nullable String getHttpPassportUrl() { @@ -34,6 +47,7 @@ public class LoginKit { /** * 获取http认证的秘钥 + * * @return http认证地址 */ public static @Nullable String getHttpPassportKey() { diff --git a/src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java b/src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java new file mode 100644 index 0000000..0c1321d --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java @@ -0,0 +1,45 @@ +package com.fanruan.api.decision.middle; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + */ +public class ReadOnlyUser { + + /** + * 非空项,无默认值 + */ + private String userName = null; + /** + * 非空项,无默认值 + */ + private String password = null; + + /** + * 姓名 + */ + private String realName = null; + + public static ReadOnlyUser build(String userName, String password, String realName) { + return new ReadOnlyUser(userName, password, realName); + } + + private ReadOnlyUser(String userName, String password, String realName) { + this.userName = userName; + this.password = password; + this.realName = realName; + } + + public String getUserName() { + return userName; + } + + public String getPassword() { + return password; + } + + public String getRealName() { + return realName; + } +} diff --git a/src/main/java/com/fanruan/api/runtime/ResourceKit.java b/src/main/java/com/fanruan/api/runtime/ResourceKit.java new file mode 100644 index 0000000..3bb638e --- /dev/null +++ b/src/main/java/com/fanruan/api/runtime/ResourceKit.java @@ -0,0 +1,219 @@ +package com.fanruan.api.runtime; + +import com.fr.io.utils.ResourceIOUtils; +import com.fr.stable.Filter; + +import java.io.IOException; +import java.io.InputStream; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 操作运行环境下文件的工具方法 + */ +public class ResourceKit { + + /** + * 路径是否存在 + * + * @param target 路径 + * @return 是否存在 + */ + public static boolean exist(String target) { + return ResourceIOUtils.exist(target); + } + + /** + * 创建文件 + * + * @param file 文件路径 + * @return 是否存在 + */ + public static boolean createFile(String file) { + return ResourceIOUtils.createFile(file); + } + + /** + * 创建文件夹 + * + * @param dir 文件夹路径 + * @return 是否成功 + */ + public static boolean createDirectory(String dir) { + return ResourceIOUtils.createDirectory(dir); + } + + /** + * 是否为文件夹 + * + * @param path 路径 + * @return 是否是文件夹 + */ + public static boolean isDirectory(String path) { + return ResourceIOUtils.isDirectory(path); + } + + /** + * 获取文件或者文件夹的名称 + * + * @param path 路径 + * @return 名称 + */ + public static String getName(String path) { + return ResourceIOUtils.getName(path); + } + + /** + * 列出路径下的所有内容的名称 + * + * @param dir 路径 + * @return 所有内容名称List + */ + public static String[] list(String dir) { + return ResourceIOUtils.list(dir); + } + + /** + * 列出路径下的所有符合要求的内容的名称 + * + * @param dir 路径 + * @param filter 过滤器 + * @return 所有内容名称List + */ + public static String[] list(String dir, Filter filter) { + return ResourceIOUtils.list(dir, filter); + } + + /** + * 文件夹是否存在 + * + * @param dir 文件夹 + * @return 是否存在 + */ + public static boolean isDirectoryExist(String dir) { + return ResourceIOUtils.isDirectoryExist(dir); + } + + + public static String getRealPath(String relativePath) { + return ResourceIOUtils.getRealPath(relativePath); + } + + /** + * 读取文件到流 + *

+ * 相对路径下如果是仓库资源从仓库读取,其它从本地读取 + *

+ * 据对路径按绝对路径读 + * + * @param path 路径 + * @return 流 + */ + public static InputStream read(String path) { + return ResourceIOUtils.read(path); + } + + /** + * 读取文件到bytes + * + * @param path 文件路径 + * @return bytes + */ + public static byte[] readBytes(String path) { + return ResourceIOUtils.readBytes(path); + } + + /** + * 写入数据流到文件 + * + * @param path 文件路径 + * @param data 数据 + */ + public static void write(String path, InputStream data) { + ResourceIOUtils.write(path, data); + } + + /** + * 写入字符串数据到文件 + * + * @param path 文件路径 + * @param data 数据 + */ + public static void write(String path, String data) { + ResourceIOUtils.write(path, data); + } + + /** + * 写入字节数组数据到文件 + * + * @param path 文件路径 + * @param data 数据 + */ + public static void write(String path, byte[] data) { + ResourceIOUtils.write(path, data); + } + + /** + * 获取父路径 + * + * @param path 路径 + * @return 父路径 + */ + public static String getParent(String path) { + return ResourceIOUtils.getParent(path); + } + + /** + * 从仓库删除 + * + * @param path 路径 + * @return 是否删除成功 + */ + public static boolean delete(String path) { + return ResourceIOUtils.delete(path); + } + + /** + * 文件的最后修改时间 + * + * @param path 文件路径 + * @return 修改的时间戳 + */ + public static long lastModified(String path) { + return ResourceIOUtils.lastModified(path); + } + + /** + * 文件大小 + * + * @param path 文件路径 + * @return 文件字节数 + */ + public static long getLength(String path) { + return ResourceIOUtils.getLength(path); + } + + /** + * 重命名 + *

+ * 文件位置根据oldFile来确定 + * + * @param oldFile 原文件path + * @param newFile 新文件path + * @return 是否成功 + */ + public static boolean renameTo(String oldFile, String newFile) { + return ResourceIOUtils.renameTo(oldFile, newFile); + } + + /** + * 拷贝文件到某目录下 + * + * @param src 源文件 + * @param dir 目标文件 + */ + public static void copy(String src, String dir) throws IOException { + ResourceIOUtils.copy(src, dir); + } +} From ea945c3b343341c3ed65ff0d7a0b6f2945443d35 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 19 Sep 2019 18:32:01 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E6=96=B0=E7=9A=84=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 5bd856e..d3c4811 100644 --- a/readme.md +++ b/readme.md @@ -53,6 +53,7 @@ SessionKit#getSession(@NotNull String sessionID); |急速下拉树插件|https://git.fanruan.com/fanruan/demo-widget-ztree| |网页框插件|https://git.fanruan.com/fanruan/demo-widget-iframe| |时钟控件|https://git.fanruan.com/fanruan/demo-show-clock| +|ldaps认证插件|https://git.fanruan.com/fanruan/demo-ldaps-passport| ## 如何判断插件中调用的API需要增加到FineKit中 From ac58649a40e0c9ca45ae458645572d3ccee30c73 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 19 Sep 2019 20:06:34 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 1 + .../fanruan/api/decision/AuthorityKit.java | 11 +++ .../api/decision/middle/ReadOnlyUser.java | 45 ------------ .../fanruan/api/decision/user/OpenUser.java | 73 +++++++++++++++++++ .../api/decision/{ => user}/UserKit.java | 35 ++++++++- .../java/com/fanruan/api/i18n/I18nKit.java | 13 ++++ .../java/com/fanruan/api/net/NetworkKit.java | 37 +++++++--- .../java/com/fanruan/api/web/FlushKit.java | 53 ++++++++++++++ .../java/com/fanruan/api/web/ResponseKit.java | 64 ++++++++++++++++ .../com/fanruan/api/web/TextGeneratorKit.java | 21 ++++++ 10 files changed, 294 insertions(+), 59 deletions(-) create mode 100644 src/main/java/com/fanruan/api/decision/AuthorityKit.java delete mode 100644 src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java create mode 100644 src/main/java/com/fanruan/api/decision/user/OpenUser.java rename src/main/java/com/fanruan/api/decision/{ => user}/UserKit.java (50%) create mode 100644 src/main/java/com/fanruan/api/web/FlushKit.java create mode 100644 src/main/java/com/fanruan/api/web/ResponseKit.java create mode 100644 src/main/java/com/fanruan/api/web/TextGeneratorKit.java diff --git a/readme.md b/readme.md index d3c4811..7d2ac95 100644 --- a/readme.md +++ b/readme.md @@ -54,6 +54,7 @@ SessionKit#getSession(@NotNull String sessionID); |网页框插件|https://git.fanruan.com/fanruan/demo-widget-iframe| |时钟控件|https://git.fanruan.com/fanruan/demo-show-clock| |ldaps认证插件|https://git.fanruan.com/fanruan/demo-ldaps-passport| +|个人国际化设置插件|https://git.fanruan.com/fanruan/decision-user-language| ## 如何判断插件中调用的API需要增加到FineKit中 diff --git a/src/main/java/com/fanruan/api/decision/AuthorityKit.java b/src/main/java/com/fanruan/api/decision/AuthorityKit.java new file mode 100644 index 0000000..54ba641 --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/AuthorityKit.java @@ -0,0 +1,11 @@ +package com.fanruan.api.decision; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 权限相关的工具类 + */ +public class AuthorityKit { + +} diff --git a/src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java b/src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java deleted file mode 100644 index 0c1321d..0000000 --- a/src/main/java/com/fanruan/api/decision/middle/ReadOnlyUser.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.fanruan.api.decision.middle; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2019-09-19 - */ -public class ReadOnlyUser { - - /** - * 非空项,无默认值 - */ - private String userName = null; - /** - * 非空项,无默认值 - */ - private String password = null; - - /** - * 姓名 - */ - private String realName = null; - - public static ReadOnlyUser build(String userName, String password, String realName) { - return new ReadOnlyUser(userName, password, realName); - } - - private ReadOnlyUser(String userName, String password, String realName) { - this.userName = userName; - this.password = password; - this.realName = realName; - } - - public String getUserName() { - return userName; - } - - public String getPassword() { - return password; - } - - public String getRealName() { - return realName; - } -} diff --git a/src/main/java/com/fanruan/api/decision/user/OpenUser.java b/src/main/java/com/fanruan/api/decision/user/OpenUser.java new file mode 100644 index 0000000..52ff51e --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/user/OpenUser.java @@ -0,0 +1,73 @@ +package com.fanruan.api.decision.user; + +import com.fr.decision.authority.data.User; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + */ +public class OpenUser { + + private User user; + + static OpenUser wrap(User user) { + return new OpenUser(user); + } + + public OpenUser create(String id) { + return new OpenUser(new User().id(id)); + } + + private OpenUser(User user) { + this.user = user; + } + + User select() { + return user; + } + + public String getUserName() { + return user.getUserName(); + } + + public String getPassword() { + return user.getPassword(); + } + + public void setPassword(String password) { + this.user.setPassword(password); + } + + public String getRealName() { + return user.getRealName(); + } + + public void setRealName(String realName) { + this.user.setRealName(realName); + } + + public String getLanguage() { + return user.getLanguage(); + } + + public void setLanguage(String language) { + this.user.setLanguage(language); + } + + public String getEmail() { + return user.getEmail(); + } + + public void setEmail(String email) { + this.user.setEmail(email); + } + + public String getMobile() { + return user.getMobile(); + } + + public void setMobile(String mobile) { + this.user.setMobile(mobile); + } +} diff --git a/src/main/java/com/fanruan/api/decision/UserKit.java b/src/main/java/com/fanruan/api/decision/user/UserKit.java similarity index 50% rename from src/main/java/com/fanruan/api/decision/UserKit.java rename to src/main/java/com/fanruan/api/decision/user/UserKit.java index 323d6b4..eeb1429 100644 --- a/src/main/java/com/fanruan/api/decision/UserKit.java +++ b/src/main/java/com/fanruan/api/decision/user/UserKit.java @@ -1,11 +1,13 @@ -package com.fanruan.api.decision; +package com.fanruan.api.decision.user; -import com.fanruan.api.decision.middle.ReadOnlyUser; +import com.fr.decision.authority.AuthorityContext; import com.fr.decision.authority.data.User; import com.fr.decision.webservice.utils.UserSourceFactory; import com.fr.decision.webservice.utils.user.source.UserSource; import com.fr.decision.webservice.v10.user.UserService; +import javax.servlet.http.HttpServletRequest; + /** * @author richie * @version 10.0 @@ -25,6 +27,11 @@ public class UserKit { return UserSourceFactory.getInstance().getUserSource(user); } + public static OpenUser getUserByRequest(HttpServletRequest req) throws Exception { + User user = UserService.getInstance().getUserByRequest(req); + return OpenUser.wrap(user); + } + /** * 根据用户名获取用户信息 * @@ -32,8 +39,28 @@ public class UserKit { * @return 用户信息 * @throws Exception 如果获取用户出错,则抛出此异常 */ - public static ReadOnlyUser getReadOnlyUser(String username) throws Exception { + public static OpenUser getUser(String username) throws Exception { User user = UserService.getInstance().getUserByUserName(username); - return ReadOnlyUser.build(user.getUserName(), user.getPassword(), user.getRealName()); + return OpenUser.wrap(user); + } + + /** + * 更新一个用户信息 + * + * @param user 用户 + * @throws Exception 更新用户信息失败则抛出此异常 + */ + public static void update(OpenUser user) throws Exception { + AuthorityContext.getInstance().getUserController().update(user.select()); + } + + /** + * 添加一个用户 + * + * @param user 用户 + * @throws Exception 添加用户失败则抛出此异常 + */ + public static void add(OpenUser user) throws Exception { + AuthorityContext.getInstance().getUserController().update(user.select()); } } diff --git a/src/main/java/com/fanruan/api/i18n/I18nKit.java b/src/main/java/com/fanruan/api/i18n/I18nKit.java index 74a95c9..a72f000 100644 --- a/src/main/java/com/fanruan/api/i18n/I18nKit.java +++ b/src/main/java/com/fanruan/api/i18n/I18nKit.java @@ -2,6 +2,9 @@ package com.fanruan.api.i18n; import com.fr.locale.InterProviderFactory; +import java.util.Locale; +import java.util.Map; + public class I18nKit { /** * 获取国际化文本 @@ -23,4 +26,14 @@ public class I18nKit { public static String getLocText(String string, String... args) { return InterProviderFactory.getProvider().getLocText(string, args); } + + /** + * 获取某种语言下所有的国际化键值对 + * + * @param locale 国际化 + * @return 国际化键值对集合 + */ + public static Map getEntireKV(Locale locale) { + return InterProviderFactory.getClientProvider().getEntireKV(locale); + } } diff --git a/src/main/java/com/fanruan/api/net/NetworkKit.java b/src/main/java/com/fanruan/api/net/NetworkKit.java index ebc52ef..e697b37 100644 --- a/src/main/java/com/fanruan/api/net/NetworkKit.java +++ b/src/main/java/com/fanruan/api/net/NetworkKit.java @@ -2,12 +2,14 @@ package com.fanruan.api.net; import com.fr.base.ServerConfig; import com.fr.data.NetworkHelper; +import com.fr.decision.webservice.utils.WebServiceUtils; import org.jetbrains.annotations.Nullable; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; +import java.util.Locale; import java.util.Map; /** @@ -21,7 +23,7 @@ public class NetworkKit { /** * 生成一个打印输出器 * - * @param res HTTP响应 + * @param res http响应 * @return 打印输出器 * @throws java.io.IOException 如果无法创建输出器则抛出此异常 */ @@ -32,7 +34,7 @@ public class NetworkKit { /** * 生成一个打印输出器 * - * @param res HTTP响应 + * @param res http响应 * @param charsetName 编码 * @return 打印输出器 * @throws java.io.IOException 如果无法创建输出器则抛出此异常 @@ -45,7 +47,7 @@ public class NetworkKit { * 写出指定的模板 * * @param resource 模板路径 - * @param response HTTP响应 + * @param response http响应 * @param map 用于替换模板中参数的的参数集 * @throws java.io.IOException 如果无法创建输出器则抛出此异常 */ @@ -56,7 +58,7 @@ public class NetworkKit { /** * 把HTTP请求中指定名字的参数值转化为整数,参数为空或不是整数则返回-1 * - * @param req HTTP请求 + * @param req http请求 * @param paraName 参数名 * @return 整型参数值 */ @@ -67,7 +69,7 @@ public class NetworkKit { /** * 把HTTP请求中指定名字的参数值转化为整数 * - * @param req HTTP请求 + * @param req http请求 * @param paraName 参数名 * @param defaultValue 默认值 * @return 返回req中参数的整数值。参数为空或不是整数则返回defaultValue @@ -79,7 +81,7 @@ public class NetworkKit { /** * 从http请求中获取sessionID * - * @param req HTTP请求 + * @param req http请求 * @return session编号 */ public static @Nullable String getHTTPRequestSessionIDParameter(HttpServletRequest req) { @@ -89,7 +91,7 @@ public class NetworkKit { /** * 把HTTP请求中指定名字的参数值转化为布尔值 * - * @param req HTTP请求 + * @param req http请求 * @param paraName 参数名 * @return 布尔类型的参数值 */ @@ -100,7 +102,7 @@ public class NetworkKit { /** * 获取HTTP请求中指定名字的参数值 * - * @param req HTTP请求 + * @param req http请求 * @param paraName 参数名 * @return 字符型参数值 */ @@ -111,7 +113,7 @@ public class NetworkKit { /** * 获取第一个不为空的参数 * - * @param req HTTP请求 + * @param req http请求 * @param paraNames 参数列表 * @return 字符型参数值 */ @@ -119,8 +121,23 @@ public class NetworkKit { return NetworkHelper.getHTTPRequestParameter(req, paraNames); } - + /** + * 生成服务器地址 + * + * @param req http请求 + * @return 服务器地址 + */ public static String createServletURL(HttpServletRequest req) { return NetworkHelper.createServletURL(req, ServerConfig.getInstance().getServletName()); } + + /** + * 从http请求中获取用户的国际化信息 + * + * @param req http请求 + * @return 国际化对象 + */ + public static Locale getLocale(HttpServletRequest req) { + return WebServiceUtils.getLocale(req); + } } diff --git a/src/main/java/com/fanruan/api/web/FlushKit.java b/src/main/java/com/fanruan/api/web/FlushKit.java new file mode 100644 index 0000000..70de44a --- /dev/null +++ b/src/main/java/com/fanruan/api/web/FlushKit.java @@ -0,0 +1,53 @@ +package com.fanruan.api.web; + +import com.fanruan.api.net.NetworkKit; +import com.fr.json.JSONArray; +import com.fr.json.JSONObject; + +import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 将内容输入到输出流中 + */ +public class FlushKit { + + /** + * 输出JSON类型的字符串 + * + * @param res HTTP响应 + * @param jo JSON对象 + * @throws Exception 输出出现错误则抛出此异常 + */ + public static void printAsJSON(HttpServletResponse res, JSONObject jo) throws Exception { + printAsString(res, jo.toString()); + } + + /** + * 输出JSON类型的字符串 + * + * @param res HTTP响应 + * @param ja JSON数组对象 + * @throws Exception 输出出现错误则抛出此异常 + */ + public static void printAsJSON(HttpServletResponse res, JSONArray ja) throws Exception { + printAsString(res, ja.toString()); + } + + /** + * 输出字符串,一般来说是JSON格式 + * + * @param res HTTP响应 + * @param jo JSON样式的字符串 + * @throws Exception 输出出现错误则抛出此异常 + */ + public static void printAsString(HttpServletResponse res, String jo) throws Exception { + PrintWriter pw = NetworkKit.createPrintWriter(res); + pw.print(jo); + pw.flush(); + pw.close(); + } +} diff --git a/src/main/java/com/fanruan/api/web/ResponseKit.java b/src/main/java/com/fanruan/api/web/ResponseKit.java new file mode 100644 index 0000000..28663c7 --- /dev/null +++ b/src/main/java/com/fanruan/api/web/ResponseKit.java @@ -0,0 +1,64 @@ +package com.fanruan.api.web; + +import com.fr.decision.webservice.Response; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + * 响应工具类 + */ +public class ResponseKit { + + /** + * 成功的响应,关注结果 + * + * @param obj 响应结果 + * @return 响应 + */ + public static Object ok(Object obj) { + return Response.ok(obj); + } + + /** + * 成功的响应,不关注结果 + * + * @return 响应 + */ + public static Object success() { + return Response.success(); + } + + /** + * 成功的响应,关注操作成功条目数 + * + * @param successNum 操作成功的条目数 + * @return 响应 + */ + public static Object success(int successNum) { + return Response.success(successNum); + } + + /** + * 失败的响应 + * + * @param errorCode 错误码 + * @param errorMsg 错误信息 + * @return 响应 + */ + public static Object error(String errorCode, String errorMsg) { + return Response.error(errorCode, errorMsg); + } + + /** + * 失败的响应 + * + * @param status 状态码 + * @param errorCode 错误码 + * @param errorMsg 错误信息 + * @return 响应 + */ + public static Object error(int status, String errorCode, String errorMsg) { + return Response.error(status, errorCode, errorMsg); + } +} diff --git a/src/main/java/com/fanruan/api/web/TextGeneratorKit.java b/src/main/java/com/fanruan/api/web/TextGeneratorKit.java new file mode 100644 index 0000000..b1a279c --- /dev/null +++ b/src/main/java/com/fanruan/api/web/TextGeneratorKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.web; + +import com.fr.decision.web.i18n.I18nTextGenerator; +import com.fr.gen.TextGenerator; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-19 + */ +public class TextGeneratorKit { + + /** + * 创建一个用于国际化的文本输出器 + * + * @return 文本输出器 + */ + public static TextGenerator newI18nTextGenerator() { + return new I18nTextGenerator(); + } +} From 81caf78dac87e25f4483ace40b58fdefd6a01b84 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 20 Sep 2019 09:00:04 +0800 Subject: [PATCH 14/25] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/readme.md b/readme.md index 7d2ac95..5d068d5 100644 --- a/readme.md +++ b/readme.md @@ -42,20 +42,6 @@ SessionKit#getSession(@NotNull String sessionID); 会在target目录下获得一个形如finekit-10.0-20190815.jar名字jar包,直接作为插件依赖jar包即可。 -## 已完全依赖FineKit的插件 - -|插件名|源码| -|-----|----| -|redis数据集插件|https://git.fanruan.com/fanruan/demo-tabledata-redis| -|增强公式编辑器插件|https://git.fanruan.com/fanruan/demo-formula-script| -|条件属性之文本对齐插件|https://git.fanruan.com/fanruan/demo-highlight-align| -|评分形态插件|https://git.fanruan.com/fanruan/demo-show-present| -|急速下拉树插件|https://git.fanruan.com/fanruan/demo-widget-ztree| -|网页框插件|https://git.fanruan.com/fanruan/demo-widget-iframe| -|时钟控件|https://git.fanruan.com/fanruan/demo-show-clock| -|ldaps认证插件|https://git.fanruan.com/fanruan/demo-ldaps-passport| -|个人国际化设置插件|https://git.fanruan.com/fanruan/decision-user-language| - ## 如何判断插件中调用的API需要增加到FineKit中 最简单的原则: @@ -76,4 +62,18 @@ SessionKit#getSession(@NotNull String sessionID); 3、克隆FineKit代码到本地,新增相关的API代码,并提交到自己的仓库; -4、提交Pull Request到FineKit主仓库,等待审核通过被合并即可。 \ No newline at end of file +4、提交Pull Request到FineKit主仓库,等待审核通过被合并即可。 + +## 已完全依赖FineKit的插件 + +|插件名|源码| +|-----|----| +|redis数据集插件|https://git.fanruan.com/fanruan/demo-tabledata-redis| +|增强公式编辑器插件|https://git.fanruan.com/fanruan/demo-formula-script| +|条件属性之文本对齐插件|https://git.fanruan.com/fanruan/demo-highlight-align| +|评分形态插件|https://git.fanruan.com/fanruan/demo-show-present| +|急速下拉树插件|https://git.fanruan.com/fanruan/demo-widget-ztree| +|网页框插件|https://git.fanruan.com/fanruan/demo-widget-iframe| +|时钟控件|https://git.fanruan.com/fanruan/demo-show-clock| +|ldaps认证插件|https://git.fanruan.com/fanruan/demo-ldaps-passport| +|个人国际化设置插件|https://git.fanruan.com/fanruan/decision-user-language| From 22e1853eb960ea24ff3e2d808d40e98edde74024 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 20 Sep 2019 14:03:51 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=94=AF=E6=8C=81FineK?= =?UTF-8?q?it=E7=9A=84=E6=8F=92=E4=BB=B6=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 5d068d5..62ff68f 100644 --- a/readme.md +++ b/readme.md @@ -77,3 +77,4 @@ SessionKit#getSession(@NotNull String sessionID); |时钟控件|https://git.fanruan.com/fanruan/demo-show-clock| |ldaps认证插件|https://git.fanruan.com/fanruan/demo-ldaps-passport| |个人国际化设置插件|https://git.fanruan.com/fanruan/decision-user-language| +|插件配置持久化|https://git.fanruan.com/fanruan/demo-db-access| From 5b28b2864d5e2dd8429010912665a78fe86939b7 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 20 Sep 2019 16:39:41 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.md b/readme.md index 62ff68f..c128af5 100644 --- a/readme.md +++ b/readme.md @@ -78,3 +78,4 @@ SessionKit#getSession(@NotNull String sessionID); |ldaps认证插件|https://git.fanruan.com/fanruan/demo-ldaps-passport| |个人国际化设置插件|https://git.fanruan.com/fanruan/decision-user-language| |插件配置持久化|https://git.fanruan.com/fanruan/demo-db-access| +|http认证简化插件|https://git.fanruan.com/fanruan/demo-auth-http| From ceb14fb45ec9e24926d29f8e6f36bb099e0ed72b Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 23 Sep 2019 09:27:59 +0800 Subject: [PATCH 17/25] js --- .../api/report/script/JavaScriptKit.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/com/fanruan/api/report/script/JavaScriptKit.java diff --git a/src/main/java/com/fanruan/api/report/script/JavaScriptKit.java b/src/main/java/com/fanruan/api/report/script/JavaScriptKit.java new file mode 100644 index 0000000..385f3d9 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/script/JavaScriptKit.java @@ -0,0 +1,23 @@ +package com.fanruan.api.report.script; + +import com.fr.js.JavaScript; +import com.fr.js.JavaScriptImpl; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/9/20 + * 从服务器端生成给web端使用的javascript代码的工具类 + */ +public class JavaScriptKit { + + /** + * 生成一个简单的JavaScript实例 + * + * @param content 脚本内容 + * @return JavaScript实例 + */ + public JavaScript newSimpleJavaScript(String content) { + return new JavaScriptImpl(content); + } +} From 403a0cf1449da892551697f90959ed60c2776ca7 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 24 Sep 2019 10:59:58 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E7=9A=84API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/conf/ConfigurationKit.java | 23 +++ .../com/fanruan/api/data/ConnectionKit.java | 11 ++ .../com/fanruan/api/design/DesignKit.java | 22 ++- .../api/design/macro/DatasourceConstants.java | 13 ++ .../design/work/ConnectionComboBoxPanel.java | 176 +++++++++++++++++- .../com/fanruan/api/locale.properties | 0 .../com/fanruan/api/locale_en_US.properties | 0 .../com/fanruan/api/locale_ja_JP.properties | 0 .../com/fanruan/api/locale_ko_KR.properties | 0 .../com/fanruan/api/locale_zh_CN.properties | 0 .../com/fanruan/api/locale_zh_TW.properties | 0 11 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java create mode 100644 src/main/resources/com/fanruan/api/locale.properties create mode 100644 src/main/resources/com/fanruan/api/locale_en_US.properties create mode 100644 src/main/resources/com/fanruan/api/locale_ja_JP.properties create mode 100644 src/main/resources/com/fanruan/api/locale_ko_KR.properties create mode 100644 src/main/resources/com/fanruan/api/locale_zh_CN.properties create mode 100644 src/main/resources/com/fanruan/api/locale_zh_TW.properties diff --git a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java index 86cebc0..6f7ccb1 100644 --- a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java +++ b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java @@ -6,6 +6,7 @@ import com.fr.config.Configuration; import com.fr.config.holder.ConfigChangeListener; import com.fr.transaction.Configurations; import com.fr.transaction.ValidateProxy; +import com.fr.transaction.WorkerCallBack; import com.fr.transaction.WorkerFacade; /** @@ -58,4 +59,26 @@ public class ConfigurationKit { } }); } + + /** + * 在一个事务中修改配置 + * + * @param configType 配置类 + * @param runner 执行器 + * @param callBack 事务回调 + */ + public static void modify(Class configType, Runner runner, WorkerCallBack callBack) { + WorkerFacade facade = new WorkerFacade(configType) { + @Override + public void run() { + if (runner != null) { + runner.run(); + } + } + }; + if (callBack != null) { + facade.addCallBack(callBack); + } + Configurations.modify(facade); + } } diff --git a/src/main/java/com/fanruan/api/data/ConnectionKit.java b/src/main/java/com/fanruan/api/data/ConnectionKit.java index 3931a38..1715ae8 100644 --- a/src/main/java/com/fanruan/api/data/ConnectionKit.java +++ b/src/main/java/com/fanruan/api/data/ConnectionKit.java @@ -7,6 +7,8 @@ import com.fr.file.ConnectionConfig; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Map; + /** * 数据连接相关工具类 */ @@ -46,4 +48,13 @@ public class ConnectionKit { public static Connection createNameConnection(String name) { return new NameDatabaseConnection(name); } + + /** + * 获取所有的数据连接 + * + * @return 所有的数据连接组成的集合 + */ + public static Map getConnections() { + return ConnectionConfig.getInstance().getConnections(); + } } diff --git a/src/main/java/com/fanruan/api/design/DesignKit.java b/src/main/java/com/fanruan/api/design/DesignKit.java index 194234a..b4b48d3 100644 --- a/src/main/java/com/fanruan/api/design/DesignKit.java +++ b/src/main/java/com/fanruan/api/design/DesignKit.java @@ -4,6 +4,7 @@ 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.DesignerBean; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.mainframe.JTemplate; @@ -11,14 +12,16 @@ import com.fr.design.mainframe.JTemplate; public class DesignKit { /** * 直接预览数据集,没有实际值及显示值 + * * @param tableData 数据集 */ - public static void previewTableData(TableData tableData){ + public static void previewTableData(TableData tableData) { PreviewTablePane.previewTableData(tableData, -1, -1); } /** * 文本国际化 + * * @param key 国际化键 * @return 国际化后的值 */ @@ -28,7 +31,8 @@ public class DesignKit { /** * 带参数的文本国际化 - * @param key 国际化键 + * + * @param key 国际化键 * @param args 参数 * @return 国际化后的值 */ @@ -38,6 +42,7 @@ public class DesignKit { /** * 单例模式,返回DesignerFrame对象 + * * @return DesignerFrame对象 */ public static DesignerFrame getDesignerFrame() { @@ -46,9 +51,20 @@ public class DesignKit { /** * 得到当前在修改的模板 + * * @return 返回当前正在编辑的模板 */ - public static JTemplate getCurrentEditingTemplate(){ + public static JTemplate getCurrentEditingTemplate() { return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); } + + /** + * 根据名字获取已经定义的bean对象 + * + * @param name bean的名字 + * @return bean对象 + */ + public static DesignerBean getDesignerBean(String name) { + return DesignerContext.getDesignerBean(name); + } } diff --git a/src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java b/src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java new file mode 100644 index 0000000..197531e --- /dev/null +++ b/src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java @@ -0,0 +1,13 @@ +package com.fanruan.api.design.macro; + +import com.fr.design.gui.NameInspector; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/9/24 + */ +public class DatasourceConstants { + + public static final String ILLEGAL_NAME_HOLDER = NameInspector.ILLEGAL_NAME_HOLDER; +} diff --git a/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java b/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java index 9e3228b..36284c6 100644 --- a/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java +++ b/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java @@ -1,9 +1,179 @@ package com.fanruan.api.design.work; +import com.fanruan.api.conf.ConfigurationKit; +import com.fanruan.api.data.ConnectionKit; +import com.fanruan.api.data.open.BaseConnection; +import com.fanruan.api.design.DesignKit; +import com.fanruan.api.design.macro.DatasourceConstants; +import com.fanruan.api.generic.Runner; +import com.fanruan.api.util.AssistKit; +import com.fanruan.api.util.StringKit; import com.fr.data.impl.Connection; +import com.fr.design.DesignerEnvManager; +import com.fr.design.data.datapane.connect.ConnectionListPane; +import com.fr.design.data.datapane.connect.ConnectionShowPane; +import com.fr.design.data.datapane.connect.ItemEditableComboBoxPanel; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.file.ConnectionConfig; +import com.fr.stable.NameReference; +import com.fr.transaction.WorkerCallBack; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.connection.DBConnectAuth; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * 选择数据连接的下拉框 + */ +public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { + + private static final long serialVersionUID = 1L; + private Class cls; + private List nameList = new ArrayList<>(); -public class ConnectionComboBoxPanel extends com.fr.design.data.datapane.connect.ConnectionComboBoxPanel{ public ConnectionComboBoxPanel(Class cls) { - super(cls); + super(); + this.cls = cls; + this.itemComboBox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + String selected = ConnectionComboBoxPanel.this.getSelectedItem(); + if (StringKit.isNotBlank(selected)) { + DesignerEnvManager.getEnvManager().setRecentSelectedConnection(selected); + } + } + }); + refreshItems(); + } + + protected Iterator items() { + nameList = new ArrayList<>(); + Iterator nameIt = ConnectionKit.getConnections().keySet().iterator(); + Collection noAuthConnections = WorkContext.getCurrent().get(DBConnectAuth.class).getNoAuthConnections(); + if (noAuthConnections == null) { + return nameList.iterator(); + } + while (nameIt.hasNext()) { + String conName = nameIt.next(); + if (noAuthConnections.contains(conName)) { + continue; + } + Connection connection = ConnectionKit.getConnection(conName); + filterConnection(connection, conName, nameList); + } + return nameList.iterator(); + } + + protected void filterConnection(@Nullable Connection connection, String conName, List nameList) { + if (connection != null) { + connection.addConnection(nameList, conName, new Class[]{BaseConnection.class}); + } + } + + public int getConnectionSize() { + return nameList.size(); + } + + private boolean isEmptyConnection() { + return nameList.isEmpty(); + } + + public String getConnection(int i) { + return nameList.get(i); + } + + + protected void editItems() { + final ConnectionListPane connectionListPane = new ConnectionListPane(); + final ConnectionConfig connectionConfig = ConnectionConfig.getInstance(); + ConnectionConfig cloned = connectionConfig.mirror(); + connectionListPane.populate(cloned); + final BasicDialog connectionListDialog = connectionListPane.showLargeWindow( + SwingUtilities.getWindowAncestor(ConnectionComboBoxPanel.this), null); + connectionListDialog.addDialogActionListener(new DialogActionAdapter() { + public void doOk() { + if (!connectionListPane.isNamePermitted()) { + connectionListDialog.setDoOKSucceed(false); + return; + } + ConfigurationKit.modify(ConnectionConfig.class, new Runner() { + @Override + public void run() { + connectionListPane.update(connectionConfig); + } + }, new WorkerCallBack() { + @Override + public boolean beforeCommit() { + //如果更新失败,则不关闭对话框,也不写xml文件,并且将对话框定位在请重命名的那个对象页面 + return doWithDatasourceManager(connectionConfig, connectionListPane, connectionListDialog); + } + + @Override + public void afterCommit() { + DesignKit.getDesignerBean("databasename").refreshBeanElement(); + } + + @Override + public void afterRollback() { + + } + }); + } + }); + connectionListDialog.setVisible(true); + refreshItems(); + } + + /** + * @param connection 数据库链接 + */ + public void populate(Connection connection) { + editButton.setEnabled(WorkContext.getCurrent().isRoot()); + if (connection instanceof NameReference) { + this.setSelectedItem(((NameReference) connection).getName()); + } else { + String s = DesignerEnvManager.getEnvManager().getRecentSelectedConnection(); + if (StringKit.isNotBlank(s)) { + for (int i = 0; i < this.getConnectionSize(); i++) { + String t = this.getConnection(i); + if (AssistKit.equals(s, t)) { + this.setSelectedItem(s); + break; + } + } + } + if (StringKit.isBlank(this.getSelectedItem()) && !isEmptyConnection()) { + this.setSelectedItem(this.getConnection(0)); + } + } + } + + private boolean doWithDatasourceManager(ConnectionConfig datasourceManager, ConnectionShowPane connectionShowPane, BasicDialog databaseListDialog) { + boolean isFailed = false; + //存在请重命名则不能更新 + int index = isConnectionMapContainsRename(datasourceManager); + if (index != -1) { + isFailed = true; + connectionShowPane.setSelectedIndex(index); + } + databaseListDialog.setDoOKSucceed(!isFailed); + + return !isFailed; + } + + private int isConnectionMapContainsRename(ConnectionConfig datasourceManager) { + Map tableDataMap = datasourceManager.getConnections(); + if (tableDataMap.containsKey(DatasourceConstants.ILLEGAL_NAME_HOLDER)) { + return datasourceManager.getConnectionIndex(DatasourceConstants.ILLEGAL_NAME_HOLDER); + } + return -1; } -} +} \ No newline at end of file diff --git a/src/main/resources/com/fanruan/api/locale.properties b/src/main/resources/com/fanruan/api/locale.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fanruan/api/locale_en_US.properties b/src/main/resources/com/fanruan/api/locale_en_US.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fanruan/api/locale_ja_JP.properties b/src/main/resources/com/fanruan/api/locale_ja_JP.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fanruan/api/locale_ko_KR.properties b/src/main/resources/com/fanruan/api/locale_ko_KR.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fanruan/api/locale_zh_CN.properties b/src/main/resources/com/fanruan/api/locale_zh_CN.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/com/fanruan/api/locale_zh_TW.properties b/src/main/resources/com/fanruan/api/locale_zh_TW.properties new file mode 100644 index 0000000..e69de29 From 3eb3d2a88d5f2700bb3502d40ba54b5cb1717a85 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 24 Sep 2019 11:17:39 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E6=94=B9=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...urceConstants.java => DataSourceConstants.java} | 2 +- .../api/design/work/AbstractTableDataPane.java | 4 +++- .../fanruan/api/design/work/BaseTableDataPane.java | 14 ++++++++++++++ .../api/design/work/ConnectionComboBoxPanel.java | 6 +++--- 4 files changed, 21 insertions(+), 5 deletions(-) rename src/main/java/com/fanruan/api/design/macro/{DatasourceConstants.java => DataSourceConstants.java} (87%) create mode 100644 src/main/java/com/fanruan/api/design/work/BaseTableDataPane.java diff --git a/src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java b/src/main/java/com/fanruan/api/design/macro/DataSourceConstants.java similarity index 87% rename from src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java rename to src/main/java/com/fanruan/api/design/macro/DataSourceConstants.java index 197531e..1d58b74 100644 --- a/src/main/java/com/fanruan/api/design/macro/DatasourceConstants.java +++ b/src/main/java/com/fanruan/api/design/macro/DataSourceConstants.java @@ -7,7 +7,7 @@ import com.fr.design.gui.NameInspector; * @version 10.0 * Created by richie on 2019/9/24 */ -public class DatasourceConstants { +public class DataSourceConstants { public static final String ILLEGAL_NAME_HOLDER = NameInspector.ILLEGAL_NAME_HOLDER; } diff --git a/src/main/java/com/fanruan/api/design/work/AbstractTableDataPane.java b/src/main/java/com/fanruan/api/design/work/AbstractTableDataPane.java index a0bd87a..ee81180 100644 --- a/src/main/java/com/fanruan/api/design/work/AbstractTableDataPane.java +++ b/src/main/java/com/fanruan/api/design/work/AbstractTableDataPane.java @@ -7,6 +7,8 @@ import com.fr.base.TableData; * @version 10.0 * Created by richie on 2019-08-30 * 数据插件继承此抽象类 + * @see com.fanruan.api.design.work.BaseTableDataPane */ -public abstract class AbstractTableDataPane extends com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane { +@Deprecated +public abstract class AbstractTableDataPane extends BaseTableDataPane { } diff --git a/src/main/java/com/fanruan/api/design/work/BaseTableDataPane.java b/src/main/java/com/fanruan/api/design/work/BaseTableDataPane.java new file mode 100644 index 0000000..8120550 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/BaseTableDataPane.java @@ -0,0 +1,14 @@ +package com.fanruan.api.design.work; + +import com.fr.base.TableData; +import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019/9/24 + * 数据插件界面实现类,都继承此抽象类 + */ +public abstract class BaseTableDataPane extends AbstractTableDataPane { + +} diff --git a/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java b/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java index 36284c6..047e38c 100644 --- a/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java +++ b/src/main/java/com/fanruan/api/design/work/ConnectionComboBoxPanel.java @@ -4,7 +4,7 @@ import com.fanruan.api.conf.ConfigurationKit; import com.fanruan.api.data.ConnectionKit; import com.fanruan.api.data.open.BaseConnection; import com.fanruan.api.design.DesignKit; -import com.fanruan.api.design.macro.DatasourceConstants; +import com.fanruan.api.design.macro.DataSourceConstants; import com.fanruan.api.generic.Runner; import com.fanruan.api.util.AssistKit; import com.fanruan.api.util.StringKit; @@ -171,8 +171,8 @@ public class ConnectionComboBoxPanel extends ItemEditableComboBoxPanel { private int isConnectionMapContainsRename(ConnectionConfig datasourceManager) { Map tableDataMap = datasourceManager.getConnections(); - if (tableDataMap.containsKey(DatasourceConstants.ILLEGAL_NAME_HOLDER)) { - return datasourceManager.getConnectionIndex(DatasourceConstants.ILLEGAL_NAME_HOLDER); + if (tableDataMap.containsKey(DataSourceConstants.ILLEGAL_NAME_HOLDER)) { + return datasourceManager.getConnectionIndex(DataSourceConstants.ILLEGAL_NAME_HOLDER); } return -1; } From 2cb33c307ff1fdc5002f27f23234f1a63698909f Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 24 Sep 2019 11:38:09 +0800 Subject: [PATCH 20/25] =?UTF-8?q?=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/name.md | 5 +++++ readme.md | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 docs/name.md diff --git a/docs/name.md b/docs/name.md new file mode 100644 index 0000000..60e1a3a --- /dev/null +++ b/docs/name.md @@ -0,0 +1,5 @@ +# 命名规范 + +* 在产品内部,接口会有一个抽象类实现,命名方式为Abstract+接口名,而在SDK中推荐使用Base+接口名来命名开放给插件使用的抽象类。 + +* 在产品内部,工具类工厂是以+Utils或者+Helper结尾的,而在SDK中推荐使用+Kit的方式作为类名的结尾。 diff --git a/readme.md b/readme.md index c128af5..1c1d596 100644 --- a/readme.md +++ b/readme.md @@ -32,6 +32,10 @@ SessionKit#getSession(@NotNull String sessionID); 开放类列表见:[非FineKit开放类](docs/claim.md) +## 约定俗成的规范 + +见:[命名规范](docs/name.md) + ## 使用方法 先使用maven打包,执行下面的命令(跳过单元测试) From 35ca5c3868d255782c83c222f83d58922502e129 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 24 Sep 2019 11:46:00 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E5=91=BD=E5=90=8D=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/name.md | 12 ++++++++++-- readme.md | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/name.md b/docs/name.md index 60e1a3a..24de771 100644 --- a/docs/name.md +++ b/docs/name.md @@ -1,5 +1,13 @@ -# 命名规范 +# 命名和设计规范 * 在产品内部,接口会有一个抽象类实现,命名方式为Abstract+接口名,而在SDK中推荐使用Base+接口名来命名开放给插件使用的抽象类。 -* 在产品内部,工具类工厂是以+Utils或者+Helper结尾的,而在SDK中推荐使用+Kit的方式作为类名的结尾。 +* 在产品内部,工具类工厂是以+Utils或者+Helper结尾的,而在SDK中推荐使用+Kit的方式作为工具类类名的结尾。 + +* 所有的包名字,都必须由一个个独立的小写的单词组成,务必不能混扎多单词组合、驼峰命名等。 + +* com.fanruan.api.design下均是提供给插件设计器部分使用的API。 + +* com.fanruan.api.report下均是提供给报表插件服务器部分使用的API。 + +* com.fanruan.api.decision下均是提供给插件调用的平台相关的API,包括但不限于:用户管理、登入登出、权限管理、模板管理等。 diff --git a/readme.md b/readme.md index 1c1d596..121545e 100644 --- a/readme.md +++ b/readme.md @@ -34,7 +34,7 @@ SessionKit#getSession(@NotNull String sessionID); ## 约定俗成的规范 -见:[命名规范](docs/name.md) +[命名和设计规范](docs/name.md) ## 使用方法 From 363eca56979ec2951f1952c927b3ae3ed8afd2b0 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 24 Sep 2019 12:02:46 +0800 Subject: [PATCH 22/25] =?UTF-8?q?=E5=A3=B0=E6=98=8E=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/claim.md | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/docs/claim.md b/docs/claim.md index 020e125..eb8fe20 100644 --- a/docs/claim.md +++ b/docs/claim.md @@ -1,5 +1,7 @@ # 非FineKit中的Open类 +## 公共类别 + com.fr.script.AbstractFunction com.fr.script.Calculator @@ -38,4 +40,28 @@ com.fr.web.struct.Registry com.fr.web.struct.category.ScriptPath -com.fr.web.struct.category.StylePath \ No newline at end of file +com.fr.web.struct.category.StylePath + +## 设计器类别 + +com.fr.design.beans.BasicBeanPane + +com.fr.design.beans.FurtherBasicBeanPane + +com.fr.design.dialog.BasicDialog + +com.fr.design.dialog.BasicPane + +com.fr.design.dialog.DialogActionAdapter + + + +## 图表类别 + +## 报表类别 + +com.fr.report.cell.cellattr.highlight.AbstractHighlight + +com.fr.report.cell.cellattr.highlight.AbstractStyleHighlightAction + +## BI类别 \ No newline at end of file From 90df089dc39c0e9ff2fe30984af3f5435b4cf930 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 24 Sep 2019 13:40:27 +0800 Subject: [PATCH 23/25] =?UTF-8?q?=E9=87=8D=E5=86=99=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E8=A7=86=E5=9B=BE=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/design/work/ReportletPane.java | 137 +++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/design/work/ReportletPane.java b/src/main/java/com/fanruan/api/design/work/ReportletPane.java index 4671429..0311bb6 100644 --- a/src/main/java/com/fanruan/api/design/work/ReportletPane.java +++ b/src/main/java/com/fanruan/api/design/work/ReportletPane.java @@ -1,4 +1,139 @@ package com.fanruan.api.design.work; -public class ReportletPane extends com.fr.design.gui.itree.filetree.ReportletPane { +import com.fanruan.api.design.DesignKit; +import com.fanruan.api.design.ui.component.UIButton; +import com.fanruan.api.design.ui.component.UITextArea; +import com.fanruan.api.design.ui.container.UIScrollPane; +import com.fanruan.api.design.util.GUICoreKit; +import com.fr.base.FRContext; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.itree.filetree.ClassFileTree; +import com.fr.design.gui.itree.filetree.TemplateFileTree; +import com.fr.file.filetree.IOFileNodeFilter; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +/** + * 模板选择视图面板 + */ +public class ReportletPane extends BasicPane { + + private TemplateFileTree templateReportletTree; + private UIScrollPane templateScrollPane; + private ClassFileTree classReportletTree; + private UIScrollPane classScrollPane; + + private UIButton switchButton; + private CardLayout card; + private JPanel cardPane; + + public ReportletPane() { + this.setLayout(new BorderLayout()); + UITextArea textPane = new UITextArea(); + this.add(textPane, BorderLayout.NORTH); + textPane.setEditable(false); + textPane.setLineWrap(true); + + textPane.setFont(FRContext.getDefaultValues().getFRFont().deriveFont(Font.BOLD, 12)); + textPane.setText(DesignKit.i18nText("Fine-Design_Basic_Schedule_The_Selected_File_Must_Be_End_With_Filter")); + + JPanel centerPane = GUICoreKit.createBorderLayoutPane(); + this.add(centerPane, BorderLayout.CENTER); + + switchButton = new UIButton("switch"); + centerPane.add(GUICoreKit.createBorderLayoutPane(switchButton, BorderLayout.WEST), BorderLayout.NORTH); + switchButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + switchCardPane(templateScrollPane.isVisible()); + } + }); + + cardPane = new JPanel(); + centerPane.add(cardPane, BorderLayout.CENTER); + cardPane.setLayout(card = new CardLayout()); + templateReportletTree = new TemplateFileTree(); + IOFileNodeFilter filter = new IOFileNodeFilter(new String[]{".cpt", ".class", ".frm", ".form"}); + templateReportletTree.setFileNodeFilter(filter); + cardPane.add(templateScrollPane = new UIScrollPane(templateReportletTree), "TEMPLATE"); + classReportletTree = new ClassFileTree(); + cardPane.add(classScrollPane = new UIScrollPane(classReportletTree), "CLASS"); + + this.refreshEnv(); + } + + /* + * 切换CardPane + */ + private void switchCardPane(boolean switch2Class) { + if (switch2Class) { + card.show(cardPane, "CLASS"); + switchButton.setText(DesignKit.i18nText("Fine-Design_Basic_Utils_Switch_To_Template_Reportlet")); + } else { + card.show(cardPane, "TEMPLATE"); + switchButton.setText(DesignKit.i18nText("Fine-Design_Basic_Utils_Switch_To_Class_Reportlet")); + } + } + + /** + * 检查是否符合规范 + * + * @throws Exception 抛错 + */ + public void checkValid() throws Exception { + String path = this.getSelectedReportletPath(); + if (path == null) { + throw new Exception(DesignKit.i18nText("Fine-Design_Basic_Function_The_Selected_File_Cannot_Be_Null")); + } + } + + + /** + * 刷新Env + */ + public void refreshEnv() { + this.templateReportletTree.refreshEnv(); + this.classReportletTree.refreshEnv(); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Reportlet"); + } + + /** + * 返回选中的模板的路径 + * + * @return 模板路径 + */ + public String getSelectedReportletPath() { + if (templateScrollPane.isVisible()) { + return templateReportletTree.getSelectedTemplatePath(); + } else if (classScrollPane.isVisible()) { + return classReportletTree.getSelectedClassPath(); + } + + return null; + } + + /** + * 根据路径设置视图中被选中的模板 + * + * @param templatePath 模板路径 + */ + public void setSelectedReportletPath(String templatePath) { + if (templatePath == null) { + return; + } + + if (templatePath.endsWith(".class")) { + switchCardPane(true); + classReportletTree.setSelectedClassPath(templatePath); + } else { + switchCardPane(false); + templateReportletTree.setSelectedTemplatePath(templatePath); + } + } } From cc61a9c157bb290e751e98ad642871c8504e88a5 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Tue, 24 Sep 2019 18:25:55 +0800 Subject: [PATCH 24/25] =?UTF-8?q?update:=20=E4=B8=80=E4=BA=9B=E8=A1=A5?= =?UTF-8?q?=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/container/NameObjectCreator.java | 19 +++++++++++++++++++ .../api/design/ui/editor/TextEditor.java | 14 ++++++++++++++ .../java/com/fanruan/api/net/NetworkKit.java | 11 +++++++++++ .../com/fanruan/api/session/SessionKit.java | 12 ++++++++++++ .../java/com/fanruan/api/util/RenderKit.java | 9 +++++++++ src/main/java/com/fanruan/api/web/WebKit.java | 17 +++++++++++++++++ src/main/java/com/fanruan/api/xml/XmlKit.java | 9 +++++++++ .../com/fanruan/api/net/NetworkKitTest.java | 4 ++++ 8 files changed, 95 insertions(+) create mode 100644 src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/TextEditor.java create mode 100644 src/main/java/com/fanruan/api/web/WebKit.java diff --git a/src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java b/src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java new file mode 100644 index 0000000..3145797 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java @@ -0,0 +1,19 @@ +package com.fanruan.api.design.ui.container; + +import com.fr.design.beans.BasicBeanPane; + +/** + * 创建一个名称空间对象 + * */ +public class NameObjectCreator extends com.fr.design.gui.controlpane.NameObjectCreator{ + public NameObjectCreator(String menuName, Class clazz, Class updatePane) { + super(menuName, clazz, updatePane); + } + public NameObjectCreator(String menuName, String iconPath, Class clazz) { + super(menuName, iconPath, clazz); + } + + public NameObjectCreator(String menuName, String iconPath, Class clazz, Class updatePane) { + super(menuName, iconPath, clazz, updatePane); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/TextEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/TextEditor.java new file mode 100644 index 0000000..4a08298 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/TextEditor.java @@ -0,0 +1,14 @@ +package com.fanruan.api.design.ui.editor; + +/** + * 文本编辑器 + * */ +public class TextEditor extends com.fr.design.editor.editor.TextEditor{ + public TextEditor(){ + + } + + public TextEditor(String value) { + super(value); + } +} diff --git a/src/main/java/com/fanruan/api/net/NetworkKit.java b/src/main/java/com/fanruan/api/net/NetworkKit.java index e697b37..e7d859c 100644 --- a/src/main/java/com/fanruan/api/net/NetworkKit.java +++ b/src/main/java/com/fanruan/api/net/NetworkKit.java @@ -140,4 +140,15 @@ public class NetworkKit { public static Locale getLocale(HttpServletRequest req) { return WebServiceUtils.getLocale(req); } + + /** + *获取HTTP请求中指定名字的参数值 + * @param req 请求 + * @param encode 是否编码 + * @param paraName 参数名 + * @return 参数值 + * */ + public static String getHTTPRequestEncodeParameter(HttpServletRequest req, String paraName, boolean encode) { + return NetworkHelper.getHTTPRequestEncodeParameter(req, paraName, encode); + } } diff --git a/src/main/java/com/fanruan/api/session/SessionKit.java b/src/main/java/com/fanruan/api/session/SessionKit.java index 55c00bc..83b8381 100644 --- a/src/main/java/com/fanruan/api/session/SessionKit.java +++ b/src/main/java/com/fanruan/api/session/SessionKit.java @@ -1,7 +1,10 @@ package com.fanruan.api.session; +import com.fr.stable.script.NameSpace; import com.fr.stable.web.SessionProvider; +import com.fr.web.core.ReportSessionIDInfor; import com.fr.web.core.SessionPoolManager; +import com.fr.web.session.SessionIDInfo; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -20,4 +23,13 @@ public class SessionKit { public static @Nullable SessionProvider getSession(@NotNull String sessionID) { return SessionPoolManager.getSessionIDInfor(sessionID, SessionProvider.class); } + + /** + * 生成一个关于回话的用于计算的名字空间 + * @param sessionId 会话ID + * @return 名字空间 + * */ + public static NameSpace asNameSpace(String sessionId) { + return SessionIDInfo.asNameSpace(sessionId); + } } diff --git a/src/main/java/com/fanruan/api/util/RenderKit.java b/src/main/java/com/fanruan/api/util/RenderKit.java index bd5d003..ad40f2e 100644 --- a/src/main/java/com/fanruan/api/util/RenderKit.java +++ b/src/main/java/com/fanruan/api/util/RenderKit.java @@ -33,5 +33,14 @@ public class RenderKit { public static String render(String s, Calculator c) throws Exception { return TemplateUtils.render(s, c); } + /** + * 根据参数, 来计算文档字符串 + * @param string 待渲染的文本模板 + * @return 返回渲染后的文本 + * @throws Exception 渲染过程中出现错误则抛出此异常 + */ + public static String render(String string) throws Exception { + return TemplateUtils.render(string); + } } diff --git a/src/main/java/com/fanruan/api/web/WebKit.java b/src/main/java/com/fanruan/api/web/WebKit.java new file mode 100644 index 0000000..8d2823a --- /dev/null +++ b/src/main/java/com/fanruan/api/web/WebKit.java @@ -0,0 +1,17 @@ +package com.fanruan.api.web; + +import com.fr.web.utils.WebUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +public class WebKit { + /** + * 将HTTPServletRequest中的所有参数都读取出来,存储在一个Map中,返回出去 + * @param req 请求 + * @return 参数的map + * */ + public static Map parameters4SessionIDInfor(HttpServletRequest req){ + return WebUtils.parameters4SessionIDInfor(req); + } +} diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index 6639bc2..e69c136 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -104,4 +104,13 @@ public class XmlKit { public static void writeParameters(XMLPrintWriter writer, ParameterProvider[] parameter) { StableXMLUtils.writeParameters(writer,parameter); } + + /** + * 以xml方式读string + * @param xmlString xml字符串 + * @return xml文件 + * */ + public static XMLReadable readStringAsXMLable(String xmlString) { + return GeneralXMLTools.readStringAsXMLable(xmlString); + } } diff --git a/src/test/java/com/fanruan/api/net/NetworkKitTest.java b/src/test/java/com/fanruan/api/net/NetworkKitTest.java index b8c5328..3205c6e 100644 --- a/src/test/java/com/fanruan/api/net/NetworkKitTest.java +++ b/src/test/java/com/fanruan/api/net/NetworkKitTest.java @@ -48,4 +48,8 @@ public class NetworkKitTest extends Prepare { @Test public void testGetHTTPRequestParameter() { } + + @Test + public void getHTTPRequestEncodeParameter() { + } } \ No newline at end of file From 560e1d63c835d6f9a6d363677389096fedd5cbae Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Tue, 24 Sep 2019 19:28:38 +0800 Subject: [PATCH 25/25] =?UTF-8?q?update:=20=E6=A0=B9=E6=8D=AEpr=E6=84=8F?= =?UTF-8?q?=E8=A7=81=E8=BF=9B=E8=A1=8C=E5=A4=84=E7=90=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/container/NameObjectCreator.java | 19 ------------------- .../com/fanruan/api/session/SessionKit.java | 13 +++++++++++++ .../java/com/fanruan/api/util/ArrayKit.java | 9 +++++++++ .../java/com/fanruan/api/util/RenderKit.java | 10 ---------- src/main/java/com/fanruan/api/web/WebKit.java | 17 ----------------- 5 files changed, 22 insertions(+), 46 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java delete mode 100644 src/main/java/com/fanruan/api/web/WebKit.java diff --git a/src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java b/src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java deleted file mode 100644 index 3145797..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/NameObjectCreator.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.api.design.ui.container; - -import com.fr.design.beans.BasicBeanPane; - -/** - * 创建一个名称空间对象 - * */ -public class NameObjectCreator extends com.fr.design.gui.controlpane.NameObjectCreator{ - public NameObjectCreator(String menuName, Class clazz, Class updatePane) { - super(menuName, clazz, updatePane); - } - public NameObjectCreator(String menuName, String iconPath, Class clazz) { - super(menuName, iconPath, clazz); - } - - public NameObjectCreator(String menuName, String iconPath, Class clazz, Class updatePane) { - super(menuName, iconPath, clazz, updatePane); - } -} diff --git a/src/main/java/com/fanruan/api/session/SessionKit.java b/src/main/java/com/fanruan/api/session/SessionKit.java index 83b8381..9f0091c 100644 --- a/src/main/java/com/fanruan/api/session/SessionKit.java +++ b/src/main/java/com/fanruan/api/session/SessionKit.java @@ -5,9 +5,13 @@ import com.fr.stable.web.SessionProvider; import com.fr.web.core.ReportSessionIDInfor; import com.fr.web.core.SessionPoolManager; import com.fr.web.session.SessionIDInfo; +import com.fr.web.utils.WebUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + /** * @author richie * @version 10.0 @@ -32,4 +36,13 @@ public class SessionKit { public static NameSpace asNameSpace(String sessionId) { return SessionIDInfo.asNameSpace(sessionId); } + + /** + * 将HTTPServletRequest中的所有参数都读取出来,存储在一个Map中,返回出去 + * @param req 请求 + * @return 参数的map + * */ + public static Map parameters4SessionIDInfor(HttpServletRequest req){ + return WebUtils.parameters4SessionIDInfor(req); + } } diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index ed5b319..ac62c64 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -58,6 +58,15 @@ public class ArrayKit { public static boolean isEmpty(T[] array) { return ArrayUtils.isEmpty(array); } + /** + * 判断数组是否为空 + * + * @param array 源数组 + * @return 返回数组判断为空的结果 + */ + public static boolean isEmpty(boolean[] array) { + return ArrayUtils.isEmpty(array); + } /** * 移除目标数组中对应下标的元素 * diff --git a/src/main/java/com/fanruan/api/util/RenderKit.java b/src/main/java/com/fanruan/api/util/RenderKit.java index ad40f2e..65d27f7 100644 --- a/src/main/java/com/fanruan/api/util/RenderKit.java +++ b/src/main/java/com/fanruan/api/util/RenderKit.java @@ -33,14 +33,4 @@ public class RenderKit { public static String render(String s, Calculator c) throws Exception { return TemplateUtils.render(s, c); } - /** - * 根据参数, 来计算文档字符串 - * @param string 待渲染的文本模板 - * @return 返回渲染后的文本 - * @throws Exception 渲染过程中出现错误则抛出此异常 - */ - public static String render(String string) throws Exception { - return TemplateUtils.render(string); - } - } diff --git a/src/main/java/com/fanruan/api/web/WebKit.java b/src/main/java/com/fanruan/api/web/WebKit.java deleted file mode 100644 index 8d2823a..0000000 --- a/src/main/java/com/fanruan/api/web/WebKit.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fanruan.api.web; - -import com.fr.web.utils.WebUtils; - -import javax.servlet.http.HttpServletRequest; -import java.util.Map; - -public class WebKit { - /** - * 将HTTPServletRequest中的所有参数都读取出来,存储在一个Map中,返回出去 - * @param req 请求 - * @return 参数的map - * */ - public static Map parameters4SessionIDInfor(HttpServletRequest req){ - return WebUtils.parameters4SessionIDInfor(req); - } -}