From eb5b0d3b4c23c4ee4817a82f80909daadcc7f049 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 3 Sep 2019 11:25:48 +0800 Subject: [PATCH 01/38] =?UTF-8?q?token=E7=94=9F=E4=BA=A7=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/security/JwtKit.java | 213 ++++++++++++++++++ .../com/fanruan/api/security/JwtKitTest.java | 77 +++++++ 2 files changed, 290 insertions(+) create mode 100644 src/main/java/com/fanruan/api/security/JwtKit.java create mode 100644 src/test/java/com/fanruan/api/security/JwtKitTest.java diff --git a/src/main/java/com/fanruan/api/security/JwtKit.java b/src/main/java/com/fanruan/api/security/JwtKit.java new file mode 100644 index 0000000..d90cf8c --- /dev/null +++ b/src/main/java/com/fanruan/api/security/JwtKit.java @@ -0,0 +1,213 @@ +package com.fanruan.api.security; + +import com.fanruan.api.log.LogKit; +import com.fr.cert.token.JwtBuilder; +import com.fr.cert.token.Jwts; +import com.fr.cert.token.SignatureAlgorithm; +import com.fr.cert.token.SignatureException; +import com.fr.cert.token.impl.DefaultClaims; +import com.fr.security.KeySecretSeedConfig; +import com.fr.security.SecurityToolbox; + +import java.io.IOException; +import java.security.Key; +import java.util.Date; +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-03 + * 用于生成和解析基于JWT的token + */ +public class JwtKit { + + private static final String JWT_ID = "jwt"; + private static final String ISSUER = "fanruan"; + private static final SignatureAlgorithm DEFAULT_ALGORITHM = SignatureAlgorithm.HS256; + + /** + * 创建完整token + * + * @param issuer jwt签发者 + * @param subject jwt所面向的用户 + * @param audience 接收jwt的一方 + * @param expiration jwt的过期时间,这个过期时间必须要大于签发时间 + * @param notBeforeTime 定义在什么时间之前,该jwt都是不可用的. + * @param issuerAtTime jwt的签发时间 + * @param jwtId jwt的唯一身份标识,主要用来作为一次性token,从而回避重放攻击。 + * @param algorithm 加密算法 + * @param secretKey 秘钥 + * @return 签名后的token + */ + public static String createJWT(String issuer, String subject, String audience, Date expiration, Date notBeforeTime, + Date issuerAtTime, String jwtId, SignatureAlgorithm algorithm, Key secretKey) { + JwtBuilder builder = Jwts.builder() + .setIssuer(issuer) + .setSubject(subject) + .setAudience(audience) + .setExpiration(expiration) + .setNotBefore(notBeforeTime) + .setIssuedAt(issuerAtTime) + .setId(jwtId) + .signWith(algorithm, secretKey); + return builder.compact(); + } + + /** + * 创建默认的token,用不超时 + * + * @param subject 主题 + * @return token + */ + public static String createDefaultJWT(String subject) { + JwtBuilder builder = Jwts.builder() + .setIssuer(ISSUER) + .setIssuedAt(new Date()) + .setSubject(subject) + .setId(JWT_ID) + .signWith(DEFAULT_ALGORITHM, getKeyBytes()); + return builder.compact(); + } + + /** + * 创建默认的token + * + * @param subject 主题 + * @param description 描述 + * @return token + */ + public static String createDefaultJWT(String subject, String description) { + JwtBuilder builder = Jwts.builder() + .setIssuer(ISSUER) + .setIssuedAt(new Date()) + .setSubject(subject) + .setDescription(description) + .setId(JWT_ID) + .signWith(DEFAULT_ALGORITHM, getKeyBytes()); + return builder.compact(); + } + + /** + * 创建默认token + * + * @param subject 主题 + * @param description 描述 + * @param timeout 超时时长 + * @return token + */ + public static String createDefaultJWT(String subject, String description, long timeout) { + Date currentTime = new Date(); + Date timeoutTime = new Date(currentTime.getTime() + timeout); + JwtBuilder builder = Jwts.builder() + .setIssuer(ISSUER) + .setIssuedAt(currentTime) + .setExpiration(timeoutTime) + .setSubject(subject) + .setDescription(description) + .setId(JWT_ID) + .signWith(DEFAULT_ALGORITHM, getKeyBytes()); + return builder.compact(); + } + + /** + * 创建有超时时限的token + * + * @param subject 主题 + * @param timeout 超时时长 + * @return token + */ + public static String createDefaultJWT(String subject, long timeout) { + Date currentTime = new Date(); + Date timeoutTime = new Date(currentTime.getTime() + timeout); + JwtBuilder builder = Jwts.builder() + .setIssuer(ISSUER) + .setIssuedAt(currentTime) + .setExpiration(timeoutTime) + .setSubject(subject) + .setId(JWT_ID) + .signWith(DEFAULT_ALGORITHM, getKeyBytes()); + return builder.compact(); + } + + /** + * 解析token + * + * @param jwt token字符串 + * @return 签名通过之后的结果集 + * @throws SignatureException 签名错误异常 + */ + public static Map parseJWT(String jwt) { + try { + return Jwts.parser().setSigningKey(getKeyBytes()).parseClaimsJws(jwt).getBody(); + } catch (SignatureException e) { + LogKit.warn(e.getMessage()); + } + return new DefaultClaims(); + } + + + /** + * 根据自定义的key,创建token + * + * @param signatureKey 秘钥 + * @param claims token携带的信息 + * @return token + */ + public static String createVariedJWT(String signatureKey, Map claims) { + JwtBuilder builder = Jwts.builder() + .setIssuer(ISSUER) + .setIssuedAt(new Date()) + .setClaims(claims) + .setId(JWT_ID) + .signWith(DEFAULT_ALGORITHM, signatureKey); + return builder.compact(); + } + + /** + * 根据自定义的key,创建token + * + * @param signatureKey 秘钥 + * @param timeout 有效期 + * @param claims token携带的信息 + * @return token + */ + public static String createVariedJWT(String signatureKey, long timeout, Map claims) { + Date currentTime = new Date(); + Date timeoutTime = new Date(currentTime.getTime() + timeout); + JwtBuilder builder = Jwts.builder() + .setIssuer(ISSUER) + .setIssuedAt(new Date()) + .setExpiration(timeoutTime) + .setClaims(claims) + .setId(JWT_ID) + .signWith(DEFAULT_ALGORITHM, signatureKey); + return builder.compact(); + } + + /** + * 解析token, 先对key进行utf-8解码 + * + * @param jwt token字符串 + * @param signatureKey 秘钥 + * @return 签名通过之后的结果集 + * @throws SignatureException 签名错误异常 + */ + public static Map parseJWT(String jwt, String signatureKey) { + try { + return Jwts.parser().setSigningKey(signatureKey).parseClaimsJws(jwt).getBody(); + } catch (SignatureException e) { + LogKit.warn(e.getMessage()); + } + return new DefaultClaims(); + } + + private static byte[] getKeyBytes() { + try { + return SecurityToolbox.base642Byte(KeySecretSeedConfig.getInstance().getTrustSeed()); + } catch (IOException e) { + LogKit.error("key secret seed base64 decode error"); + } + return new byte[0]; + } +} diff --git a/src/test/java/com/fanruan/api/security/JwtKitTest.java b/src/test/java/com/fanruan/api/security/JwtKitTest.java new file mode 100644 index 0000000..abfd086 --- /dev/null +++ b/src/test/java/com/fanruan/api/security/JwtKitTest.java @@ -0,0 +1,77 @@ +package com.fanruan.api.security; + +import com.fanruan.api.Prepare; +import com.fr.cert.token.JwtBuilder; +import com.fr.cert.token.Jwts; +import com.fr.cert.token.SignatureAlgorithm; +import com.fr.security.SecurityToolbox; +import com.fr.stable.CodeUtils; +import org.junit.Assert; +import org.junit.Test; + +import java.io.UnsupportedEncodingException; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-03 + */ +public class JwtKitTest extends Prepare { + + @Test + public void testCreateDefaultJWT() throws Exception { + String tokenCN = JwtKit.createDefaultJWT("你好,我是中国人"); + Map claims = JwtKit.parseJWT(tokenCN); + Assert.assertEquals("你好,我是中国人", CodeUtils.cjkDecode(String.valueOf(claims.get("sub")))); + + String tokenEN = JwtKit.createDefaultJWT("Hello, world"); + Map claims2 = JwtKit.parseJWT(tokenEN); + Assert.assertEquals("Hello, world", CodeUtils.cjkDecode(String.valueOf(claims2.get("sub")))); + } + + @Test + public void testClaims() throws Exception { + String token = JwtKit.createDefaultJWT("千万", "我是千万的爹"); + Map claims2 = JwtKit.parseJWT(token); + String text = CodeUtils.cjkDecode(String.valueOf(claims2.get("description"))); + Assert.assertEquals("我是千万的爹", text); + } + + @Test + public void test1() throws UnsupportedEncodingException { + String token = createToken().compact(); + Assert.assertEquals(Jwts.parser().setSigningKey("abc=啊").parseClaimsJws(token).getBody().getSubject(), "hello.cpt"); + + token = createToken().signWithBase64SecretKey(SignatureAlgorithm.HS256, SecurityToolbox.byte2Base64("abc=啊".getBytes())).compact(); + Assert.assertEquals(Jwts.parser() + .setBase64SigningKey(SecurityToolbox.byte2Base64("abc=啊".getBytes())) + .parseClaimsJws(token).getBody().getSubject(), "hello.cpt"); + + token = createToken() + .signWith(SignatureAlgorithm.HS256, "abc=啊".getBytes("GBK")) + .compact(); + Assert.assertEquals("hello.cpt", Jwts.parser().setSigningKey("abc=啊".getBytes("GBK")).parseClaimsJws(token).getBody().getSubject()); + } + + private JwtBuilder createToken() { + SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; + + Calendar calendar = Calendar.getInstance(); + calendar.set(2019, Calendar.FEBRUARY, 20, 18, 0, 0); + Date currentTime = calendar.getTime(); + calendar.set(2029, Calendar.FEBRUARY, 20, 18, 0, 0); + Date expirationTime = calendar.getTime(); + return Jwts.builder() + .setHeaderParam("typ", "JWT") + .setIssuer("fanruan") + .setSubject("hello.cpt") + .setExpiration(expirationTime) + .setIssuedAt(currentTime) + .setId("01") + .signWith(signatureAlgorithm, "abc=啊"); + } + +} \ No newline at end of file From 93d50a26b9b806c32b92134626375d69ecd90e8f Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 3 Sep 2019 12:02:31 +0800 Subject: [PATCH 02/38] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index c947d61..0b54633 100644 --- a/readme.md +++ b/readme.md @@ -51,7 +51,7 @@ SessionKit#getSession(@NotNull String sessionID); ## 如何判断插件中调用的API需要增加到FineKit中 -最简单的原则:除了JDK自带的类、插件接口(包括抽象类)、以及使用了@Open注解标记的类之外,是否还使用了com.fanruan.api(com.fr.third除外)之外的类,如果有则需要修改。 +最简单的原则:除了JDK自带的类、插件接口(包括抽象类)、枚举、以及使用了@Open注解标记的类之外,是否还使用了com.fanruan.api(com.fr.third除外)之外的类,如果有则需要修改。 ## 如何提交新的API From b22d0bd6cdf27425ba4e9678eb82a9036eb245f0 Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 3 Sep 2019 12:02:50 +0800 Subject: [PATCH 03/38] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E6=9E=9A=E4=B8=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 0b54633..7f1db86 100644 --- a/readme.md +++ b/readme.md @@ -24,7 +24,7 @@ SessionKit#getSession(@NotNull String sessionID); ## 提交新API要求 -* 所有的API方法的返回值和参数,仅允许使用JDK自带的类、接口类型、插件抽象类、注解或者使用了@Open标记的对象类型。 +* 所有的API方法的返回值和参数,仅允许使用JDK自带的类、接口类型、枚举类型、插件抽象类、注解或者使用了@Open标记的对象类型。 * 所有的API方法均需要有单元测试覆盖。 From 0f73d49e9e279e9c0e4df124da62a4f8d8420d53 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 12:07:42 +0800 Subject: [PATCH 04/38] =?UTF-8?q?KERNEL-1197=20=E6=96=B0=E5=A2=9Eutils?= =?UTF-8?q?=EF=BC=8C=E4=BB=A5=E5=8F=8A=E4=B8=80=E4=BA=9B=E7=B1=BB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/base/AbstractPainter.java | 4 ++++ .../com/fanruan/api/base/BaseFormula.java | 4 ++++ .../design/work/formula/TinyFormulaPane.java | 7 ++++++ .../fanruan/api/util/BaseHTMLWriterKit.java | 21 ++++++++++++++++++ .../java/com/fanruan/api/util/CellKit.java | 22 +++++++++++++++++++ .../java/com/fanruan/api/util/StableKit.java | 15 +++++++++++++ 6 files changed, 73 insertions(+) create mode 100644 src/main/java/com/fanruan/api/base/AbstractPainter.java create mode 100644 src/main/java/com/fanruan/api/base/BaseFormula.java create mode 100644 src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java create mode 100644 src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java create mode 100644 src/main/java/com/fanruan/api/util/CellKit.java create mode 100644 src/main/java/com/fanruan/api/util/StableKit.java diff --git a/src/main/java/com/fanruan/api/base/AbstractPainter.java b/src/main/java/com/fanruan/api/base/AbstractPainter.java new file mode 100644 index 0000000..e236deb --- /dev/null +++ b/src/main/java/com/fanruan/api/base/AbstractPainter.java @@ -0,0 +1,4 @@ +package com.fanruan.api.base; + +public abstract class AbstractPainter extends com.fr.base.AbstractPainter { +} diff --git a/src/main/java/com/fanruan/api/base/BaseFormula.java b/src/main/java/com/fanruan/api/base/BaseFormula.java new file mode 100644 index 0000000..8529608 --- /dev/null +++ b/src/main/java/com/fanruan/api/base/BaseFormula.java @@ -0,0 +1,4 @@ +package com.fanruan.api.base; + +public abstract class BaseFormula extends com.fr.base.BaseFormula { +} diff --git a/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java b/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java new file mode 100644 index 0000000..23b7af5 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java @@ -0,0 +1,7 @@ +package com.fanruan.api.design.work.formula; + +public class TinyFormulaPane extends com.fr.design.formula.TinyFormulaPane { + public TinyFormulaPane() { + super(); + } +} diff --git a/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java b/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java new file mode 100644 index 0000000..ada9dde --- /dev/null +++ b/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.util; + +import com.fr.stable.html.Tag; +import com.fr.stable.web.Repository; +import com.fr.web.BaseHTMLWriterUtils; + +import java.awt.*; + +public class BaseHTMLWriterKit { + + /** + * 根据原始的图片和指定的尺寸以及报表上下文生成图片的HTML标签,该方法只生成一个简单的img标签 + * @param image 原始图片 + * @param dimension 指定尺寸 + * @param repo 报表上下文 + * @return img图片标签 + */ + public static Tag createImageTag4RepoWithCheckVml(Image image, Dimension dimension, Repository repo){ + return BaseHTMLWriterUtils.createImageTag4RepoWithCheckVml(image, dimension, repo); + } +} diff --git a/src/main/java/com/fanruan/api/util/CellKit.java b/src/main/java/com/fanruan/api/util/CellKit.java new file mode 100644 index 0000000..7a6759f --- /dev/null +++ b/src/main/java/com/fanruan/api/util/CellKit.java @@ -0,0 +1,22 @@ +package com.fanruan.api.util; + +import com.fr.base.Style; +import com.fr.report.cell.cellattr.core.CellUtils; + +import java.awt.*; + +public class CellKit { + + /** + * 如果value是ImageWithSuffix类的一个实例,则创建一个宽为width,高为height,类型为TYPE_4BYTE_ABGR的image,并将其按照比例和Style绘制。 + * @param value 传入的需要判断为是否是ImageWithSuffix实例的对象 + * @param resolution 缩放比例的分母,缩放比例为1/resolution + * @param style 绘制image的style + * @param width 绘制image的宽 + * @param height 绘制image的高 + * @return + */ + public static Image value2Image(Object value, int resolution, Style style, int width, int height){ + return CellUtils.value2Image(value, resolution, style, width, height); + } +} diff --git a/src/main/java/com/fanruan/api/util/StableKit.java b/src/main/java/com/fanruan/api/util/StableKit.java new file mode 100644 index 0000000..1a67501 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/StableKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.util; + +import com.fr.stable.StableUtils; + +public class StableKit { + + /** + * 判断一个对象是否可以转化为公式 + * @param object 要判断的字符串 + * @return 如果该字符串是以"="开头,说明可以转化成公式,否则不能转化成公式 + */ + public static boolean canBeFormula(Object object){ + return StableUtils.canBeFormula(object); + } +} From ff5eba5ead5eb4fca6feb7ca58d92b843efeb0ad Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 12:45:08 +0800 Subject: [PATCH 05/38] =?UTF-8?q?KERNEL-1197=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/base/AbstractPainter.java | 4 ---- .../fanruan/api/design/work/formula/TinyFormulaPane.java | 7 ------- .../fanruan/api/{util => report}/BaseHTMLWriterKit.java | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/base/AbstractPainter.java delete mode 100644 src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java rename src/main/java/com/fanruan/api/{util => report}/BaseHTMLWriterKit.java (95%) diff --git a/src/main/java/com/fanruan/api/base/AbstractPainter.java b/src/main/java/com/fanruan/api/base/AbstractPainter.java deleted file mode 100644 index e236deb..0000000 --- a/src/main/java/com/fanruan/api/base/AbstractPainter.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.base; - -public abstract class AbstractPainter extends com.fr.base.AbstractPainter { -} diff --git a/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java b/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java deleted file mode 100644 index 23b7af5..0000000 --- a/src/main/java/com/fanruan/api/design/work/formula/TinyFormulaPane.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.fanruan.api.design.work.formula; - -public class TinyFormulaPane extends com.fr.design.formula.TinyFormulaPane { - public TinyFormulaPane() { - super(); - } -} diff --git a/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java b/src/main/java/com/fanruan/api/report/BaseHTMLWriterKit.java similarity index 95% rename from src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java rename to src/main/java/com/fanruan/api/report/BaseHTMLWriterKit.java index ada9dde..fd9a07f 100644 --- a/src/main/java/com/fanruan/api/util/BaseHTMLWriterKit.java +++ b/src/main/java/com/fanruan/api/report/BaseHTMLWriterKit.java @@ -1,4 +1,4 @@ -package com.fanruan.api.util; +package com.fanruan.api.report; import com.fr.stable.html.Tag; import com.fr.stable.web.Repository; From 1429f63c69236c6850a05a61acd0b2bb545d8ee1 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 16:35:09 +0800 Subject: [PATCH 06/38] =?UTF-8?q?KERNEL-1197=20=E6=96=B0=E5=A2=9E=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AA=E8=BF=94=E5=9B=9E=E5=80=BC?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=EF=BC=8C=E5=88=A0=E9=99=A4=E6=8E=89=E4=BA=86?= =?UTF-8?q?=E8=A2=AB=E6=A0=87=E8=AE=B0=E4=B8=BAOpen=E7=9A=84BaseFormula?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/base/BaseFormula.java | 4 ---- .../java/com/fanruan/api/util/CellKit.java | 2 +- .../com/fanruan/api/util/CellKitTest.java | 22 +++++++++++++++++++ .../com/fanruan/api/util/StableKitTest.java | 19 ++++++++++++++++ 4 files changed, 42 insertions(+), 5 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/base/BaseFormula.java create mode 100644 src/test/java/com/fanruan/api/util/CellKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/src/main/java/com/fanruan/api/base/BaseFormula.java b/src/main/java/com/fanruan/api/base/BaseFormula.java deleted file mode 100644 index 8529608..0000000 --- a/src/main/java/com/fanruan/api/base/BaseFormula.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.base; - -public abstract class BaseFormula extends com.fr.base.BaseFormula { -} diff --git a/src/main/java/com/fanruan/api/util/CellKit.java b/src/main/java/com/fanruan/api/util/CellKit.java index 7a6759f..c007b5b 100644 --- a/src/main/java/com/fanruan/api/util/CellKit.java +++ b/src/main/java/com/fanruan/api/util/CellKit.java @@ -14,7 +14,7 @@ public class CellKit { * @param style 绘制image的style * @param width 绘制image的宽 * @param height 绘制image的高 - * @return + * @return 返回宽为width,高为height,类型为TYPE_4BYTE_ABGR的image */ public static Image value2Image(Object value, int resolution, Style style, int width, int height){ return CellUtils.value2Image(value, resolution, style, width, height); diff --git a/src/test/java/com/fanruan/api/util/CellKitTest.java b/src/test/java/com/fanruan/api/util/CellKitTest.java new file mode 100644 index 0000000..5d22589 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/CellKitTest.java @@ -0,0 +1,22 @@ +package com.fanruan.api.util; + +import com.fr.base.Style; +import com.fr.plugin.present.fun.StarPainter; +import org.junit.Assert; +import org.junit.Test; + +import java.awt.*; + +import static org.junit.Assert.*; + +public class CellKitTest { + + @Test + public void value2Image() { + StarPainter star = new StarPainter(1); + Style style = Style.getInstance(); + Image image = CellKit.value2Image(star, 1, style, 30, 50); + Assert.assertEquals(30, image.getWidth(null)); + Assert.assertEquals(50, image.getHeight(null)); + } +} \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/StableKitTest.java b/src/test/java/com/fanruan/api/util/StableKitTest.java new file mode 100644 index 0000000..753edd3 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/StableKitTest.java @@ -0,0 +1,19 @@ +package com.fanruan.api.util; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class StableKitTest { + + @Test + public void canBeFormula() { + String s1 = "=1"; + String s2 = "=a+b+"; + String s3 = "ppp"; + Assert.assertTrue(StableKit.canBeFormula(s1)); + Assert.assertTrue(StableKit.canBeFormula(s2)); + Assert.assertFalse(StableKit.canBeFormula(s3)); + } +} \ No newline at end of file From b741f9b9d5757ece06ccda958ed8c95b3bb14f66 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Tue, 3 Sep 2019 16:53:52 +0800 Subject: [PATCH 07/38] =?UTF-8?q?KERNEL-1197=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/FormulaKit.java | 11 +++++++++++ .../CellKit.java => report/PaintKit.java} | 4 ++-- .../java/com/fanruan/api/util/StableKit.java | 15 --------------- .../com/fanruan/api/cal/FormulaKitTest.java | 10 ++++++++++ .../{CellKitTest.java => PaintKitTest.java} | 7 +++---- .../com/fanruan/api/util/StableKitTest.java | 19 ------------------- 6 files changed, 26 insertions(+), 40 deletions(-) rename src/main/java/com/fanruan/api/{util/CellKit.java => report/PaintKit.java} (93%) delete mode 100644 src/main/java/com/fanruan/api/util/StableKit.java rename src/test/java/com/fanruan/api/util/{CellKitTest.java => PaintKitTest.java} (75%) delete mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/src/main/java/com/fanruan/api/cal/FormulaKit.java b/src/main/java/com/fanruan/api/cal/FormulaKit.java index 93cd52a..503a8ab 100644 --- a/src/main/java/com/fanruan/api/cal/FormulaKit.java +++ b/src/main/java/com/fanruan/api/cal/FormulaKit.java @@ -7,6 +7,7 @@ import com.fr.base.ScriptFormula; import com.fr.log.FineLoggerFactory; import com.fr.script.Calculator; import com.fr.stable.FormulaProvider; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.UtilEvalError; import com.fr.stable.script.CalculatorProvider; @@ -104,4 +105,14 @@ public class FormulaKit { } return checkFormulaContent(formula.getPureContent()); } + + /** + * 判断一个对象是否可以转化为公式 + * @param object 要判断的字符串 + * @return 如果该字符串是以"="开头,说明可以转化成公式,否则不能转化成公式 + */ + public static boolean canBeFormula(Object object){ + return StableUtils.canBeFormula(object); + } + } diff --git a/src/main/java/com/fanruan/api/util/CellKit.java b/src/main/java/com/fanruan/api/report/PaintKit.java similarity index 93% rename from src/main/java/com/fanruan/api/util/CellKit.java rename to src/main/java/com/fanruan/api/report/PaintKit.java index c007b5b..3b1787e 100644 --- a/src/main/java/com/fanruan/api/util/CellKit.java +++ b/src/main/java/com/fanruan/api/report/PaintKit.java @@ -1,11 +1,11 @@ -package com.fanruan.api.util; +package com.fanruan.api.report; import com.fr.base.Style; import com.fr.report.cell.cellattr.core.CellUtils; import java.awt.*; -public class CellKit { +public class PaintKit { /** * 如果value是ImageWithSuffix类的一个实例,则创建一个宽为width,高为height,类型为TYPE_4BYTE_ABGR的image,并将其按照比例和Style绘制。 diff --git a/src/main/java/com/fanruan/api/util/StableKit.java b/src/main/java/com/fanruan/api/util/StableKit.java deleted file mode 100644 index 1a67501..0000000 --- a/src/main/java/com/fanruan/api/util/StableKit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.stable.StableUtils; - -public class StableKit { - - /** - * 判断一个对象是否可以转化为公式 - * @param object 要判断的字符串 - * @return 如果该字符串是以"="开头,说明可以转化成公式,否则不能转化成公式 - */ - public static boolean canBeFormula(Object object){ - return StableUtils.canBeFormula(object); - } -} diff --git a/src/test/java/com/fanruan/api/cal/FormulaKitTest.java b/src/test/java/com/fanruan/api/cal/FormulaKitTest.java index abed6cb..f2faf24 100644 --- a/src/test/java/com/fanruan/api/cal/FormulaKitTest.java +++ b/src/test/java/com/fanruan/api/cal/FormulaKitTest.java @@ -72,4 +72,14 @@ public class FormulaKitTest extends Prepare { assertEquals(true, FormulaKit.checkFormulaContent(new Formula("="))); assertEquals(false, FormulaKit.checkFormulaContent("=")); } + + @Test + public void canBeFormula() { + String s1 = "=1"; + String s2 = "=a+b+"; + String s3 = "ppp"; + Assert.assertTrue(FormulaKit.canBeFormula(s1)); + Assert.assertTrue(FormulaKit.canBeFormula(s2)); + Assert.assertFalse(FormulaKit.canBeFormula(s3)); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/CellKitTest.java b/src/test/java/com/fanruan/api/util/PaintKitTest.java similarity index 75% rename from src/test/java/com/fanruan/api/util/CellKitTest.java rename to src/test/java/com/fanruan/api/util/PaintKitTest.java index 5d22589..33e2c17 100644 --- a/src/test/java/com/fanruan/api/util/CellKitTest.java +++ b/src/test/java/com/fanruan/api/util/PaintKitTest.java @@ -1,5 +1,6 @@ package com.fanruan.api.util; +import com.fanruan.api.report.PaintKit; import com.fr.base.Style; import com.fr.plugin.present.fun.StarPainter; import org.junit.Assert; @@ -7,15 +8,13 @@ import org.junit.Test; import java.awt.*; -import static org.junit.Assert.*; - -public class CellKitTest { +public class PaintKitTest { @Test public void value2Image() { StarPainter star = new StarPainter(1); Style style = Style.getInstance(); - Image image = CellKit.value2Image(star, 1, style, 30, 50); + Image image = PaintKit.value2Image(star, 1, style, 30, 50); Assert.assertEquals(30, image.getWidth(null)); Assert.assertEquals(50, image.getHeight(null)); } diff --git a/src/test/java/com/fanruan/api/util/StableKitTest.java b/src/test/java/com/fanruan/api/util/StableKitTest.java deleted file mode 100644 index 753edd3..0000000 --- a/src/test/java/com/fanruan/api/util/StableKitTest.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.api.util; - -import org.junit.Assert; -import org.junit.Test; - -import static org.junit.Assert.*; - -public class StableKitTest { - - @Test - public void canBeFormula() { - String s1 = "=1"; - String s2 = "=a+b+"; - String s3 = "ppp"; - Assert.assertTrue(StableKit.canBeFormula(s1)); - Assert.assertTrue(StableKit.canBeFormula(s2)); - Assert.assertFalse(StableKit.canBeFormula(s3)); - } -} \ No newline at end of file From 05c42fc0a37521f8c7deb461a5477b671645c853 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Tue, 3 Sep 2019 17:44:36 +0800 Subject: [PATCH 08/38] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E6=96=B9=E6=B3=95=E5=92=8C=E5=8F=82=E6=95=B0=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=B9=B6=E6=8F=90=E4=BE=9B=E5=8D=95=E6=B5=8B=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/ParameterKit.java | 9 +++++++++ .../api/design/ui/editor/ValueEditors.java | 17 +---------------- .../java/com/fanruan/api/util/ArrayKit.java | 11 +++++++++++ .../com/fanruan/api/cal/ParameterKitTest.java | 13 +++++++++++++ .../java/com/fanruan/api/util/ArrayKitTest.java | 14 ++++++++++++++ 5 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index bc1cb30..67e316e 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -108,4 +108,13 @@ public class ParameterKit { public static ParameterProvider[] analyzeAndUnionSameParameters(String[] paramTexts, Parameter[] ps){ return ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps); } + + /** + * 将ParameterProvider类型数组转换为Parameter类型数组 + * @param providers ParameterProvider类型数组 + * @return Parameter类型数组 + * */ + public static Parameter[] providers2Parameter(ParameterProvider[] providers) { + return Parameter.providers2Parameter(providers); + } } diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java index 4dda75f..760464c 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java +++ b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java @@ -4,22 +4,7 @@ import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.component.table.model.ParameterTableModel; import com.fanruan.api.util.StringKit; import com.fr.base.BaseFormula; -import com.fr.design.editor.editor.BooleanEditor; -import com.fr.design.editor.editor.ColumnRowEditor; -import com.fr.design.editor.editor.ColumnRowGroupEditor; -import com.fr.design.editor.editor.ColumnSelectedEditor; -import com.fr.design.editor.editor.ConstantsEditor; -import com.fr.design.editor.editor.CursorEditor; -import com.fr.design.editor.editor.DateEditor; -import com.fr.design.editor.editor.DoubleEditor; -import com.fr.design.editor.editor.Editor; -import com.fr.design.editor.editor.FormulaEditor; -import com.fr.design.editor.editor.IntegerEditor; -import com.fr.design.editor.editor.NoneEditor; -import com.fr.design.editor.editor.ParameterEditor; -import com.fr.design.editor.editor.SpinnerIntegerEditor; -import com.fr.design.editor.editor.TextEditor; -import com.fr.design.editor.editor.WidgetNameEditor; +import com.fr.design.editor.editor.*; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 56322f1..92510c4 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -2,6 +2,8 @@ package com.fanruan.api.util; import com.fr.stable.ArrayUtils; +import java.util.List; + /** * @author richie * @version 10.0 @@ -91,4 +93,13 @@ public class ArrayKit { public static boolean isNotEmpty(T[] array) { return ArrayUtils.isNotEmpty(array); } + + /** + * 返回一个ArrayList + * @param array 数组 + * @return 链表 + * */ + public static List toList(T[] array) { + return ArrayUtils.toList(array); + } } diff --git a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java index 4093687..2b05a31 100644 --- a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java +++ b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java @@ -114,4 +114,17 @@ public class ParameterKitTest extends Prepare { Assert.assertEquals(provider.getName(),"p1"); Assert.assertEquals("", provider.getValue()); } + + @Test + public void providers2Parameter() { + ParameterProvider[] parameters = new ParameterProvider[]{ + ParameterKit.newParameter("p1", 100), + ParameterKit.newParameter("p2", 200) + }; + Parameter [] result = new Parameter[]{ + new Parameter("p1", 100), + new Parameter("p2", 200) + }; + Assert.assertEquals(ParameterKit.providers2Parameter(parameters), result); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index cfedded..054ae22 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -1,6 +1,9 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; +import java.util.*; + +import com.fr.third.org.apache.poi.hssf.record.formula.functions.Int; import org.junit.Assert; import org.junit.Test; @@ -97,4 +100,15 @@ public class ArrayKitTest extends Prepare { Assert.assertEquals(ArrayKit.addAll(longTestArray, 5L,6L), longTestResult); Assert.assertEquals(ArrayKit.addAll(shortTestArray, new Short("5"),new Short("6")), shortTestResult); } + + @Test + public void toList() throws Exception{ + Integer array[] = {1,2,3}; + ArrayList result = new ArrayList(); + result.add(1); + result.add(2); + result.add(3); + Assert.assertEquals(ArrayKit.toList(array),result); + } + } From e0f727939e5304dd627e40f9b51e94556b0be570 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Tue, 3 Sep 2019 19:45:55 +0800 Subject: [PATCH 09/38] =?UTF-8?q?update:=20=E5=8E=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E6=96=B9=E6=B3=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/ParameterKit.java | 8 -------- .../api/design/ui/editor/ValueEditors.java | 17 ++++++++++++++++- .../com/fanruan/api/cal/ParameterKitTest.java | 13 ------------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 67e316e..afb080d 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -109,12 +109,4 @@ public class ParameterKit { return ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps); } - /** - * 将ParameterProvider类型数组转换为Parameter类型数组 - * @param providers ParameterProvider类型数组 - * @return Parameter类型数组 - * */ - public static Parameter[] providers2Parameter(ParameterProvider[] providers) { - return Parameter.providers2Parameter(providers); - } } diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java index 760464c..4dda75f 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java +++ b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java @@ -4,7 +4,22 @@ import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.component.table.model.ParameterTableModel; import com.fanruan.api.util.StringKit; import com.fr.base.BaseFormula; -import com.fr.design.editor.editor.*; +import com.fr.design.editor.editor.BooleanEditor; +import com.fr.design.editor.editor.ColumnRowEditor; +import com.fr.design.editor.editor.ColumnRowGroupEditor; +import com.fr.design.editor.editor.ColumnSelectedEditor; +import com.fr.design.editor.editor.ConstantsEditor; +import com.fr.design.editor.editor.CursorEditor; +import com.fr.design.editor.editor.DateEditor; +import com.fr.design.editor.editor.DoubleEditor; +import com.fr.design.editor.editor.Editor; +import com.fr.design.editor.editor.FormulaEditor; +import com.fr.design.editor.editor.IntegerEditor; +import com.fr.design.editor.editor.NoneEditor; +import com.fr.design.editor.editor.ParameterEditor; +import com.fr.design.editor.editor.SpinnerIntegerEditor; +import com.fr.design.editor.editor.TextEditor; +import com.fr.design.editor.editor.WidgetNameEditor; import java.util.ArrayList; import java.util.Iterator; diff --git a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java index 2b05a31..4093687 100644 --- a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java +++ b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java @@ -114,17 +114,4 @@ public class ParameterKitTest extends Prepare { Assert.assertEquals(provider.getName(),"p1"); Assert.assertEquals("", provider.getValue()); } - - @Test - public void providers2Parameter() { - ParameterProvider[] parameters = new ParameterProvider[]{ - ParameterKit.newParameter("p1", 100), - ParameterKit.newParameter("p2", 200) - }; - Parameter [] result = new Parameter[]{ - new Parameter("p1", 100), - new Parameter("p2", 200) - }; - Assert.assertEquals(ParameterKit.providers2Parameter(parameters), result); - } } \ No newline at end of file From 006d6465f8fbec9b1988c064cd3f0b707eded3db Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 4 Sep 2019 09:58:01 +0800 Subject: [PATCH 10/38] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E9=9B=86=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3+=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/data/open/BaseTableData.java | 63 ++++++++++++++ .../api/data/open/BaseTableDataTest.java | 86 +++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 src/main/java/com/fanruan/api/data/open/BaseTableData.java create mode 100644 src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java diff --git a/src/main/java/com/fanruan/api/data/open/BaseTableData.java b/src/main/java/com/fanruan/api/data/open/BaseTableData.java new file mode 100644 index 0000000..9a50356 --- /dev/null +++ b/src/main/java/com/fanruan/api/data/open/BaseTableData.java @@ -0,0 +1,63 @@ +package com.fanruan.api.data.open; + +import com.fr.data.AbstractParameterTableData; +import com.fr.general.data.DataModel; +import com.fr.script.Calculator; +import com.fr.stable.ParameterProvider; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-04 + * 插件的数据集接口 + */ +public abstract class BaseTableData extends AbstractParameterTableData { + + /** + * 实现这个方法来返回一个数据集 + * + * @param calculator 算子 + * @return 数据集二维表对象 + */ + @Override + public abstract DataModel createDataModel(Calculator calculator); + + /** + * 返回获取数据的执行对象 + * 系统取数时,调用此方法来返回一个获取数据的执行对象 + * 注意! 当数据集需要根据不同参数来多次取数时,此方法在一个计算过程中会被多次调用。 + * + * @param calculator 算子 + * @param rowCount 要获取数据的行数 + * @return 数据集二维表对象 + */ + @Override + public DataModel createDataModel(Calculator calculator, int rowCount) { + return createDataModel(calculator); + } + + /** + * 返回获取数据的执行对象 + * 系统取数时,调用此方法来返回一个获取数据的执行对象 + * 注意! 当数据集需要根据不同参数来多次取数时,此方法在一个计算过程中会被多次调用。 + * + * @param calculator 算子 + * @param name 数据集的名字 + * @return 数据集二维表对象 + */ + @Override + public DataModel createDataModel(Calculator calculator, String name) { + return createDataModel(calculator); + } + + /** + * 获取数据集中定义的参数 + * + * @param calculator 算子 + * @return 参数数组 + */ + @Override + public ParameterProvider[] getParameters(Calculator calculator) { + return super.getParameters(calculator); + } +} diff --git a/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java b/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java new file mode 100644 index 0000000..978179b --- /dev/null +++ b/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java @@ -0,0 +1,86 @@ +package com.fanruan.api.data.open; + +import com.fr.general.data.DataModel; +import com.fr.general.data.TableDataException; +import com.fr.measure.metric.DBMetric; +import com.fr.script.Calculator; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Iterator; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-04 + */ +public class BaseTableDataTest { + + @Test + public void testCreate() throws Exception { + Calculator calculator = Calculator.createCalculator(); + DemoTableData tableData = new DemoTableData(); + DataModel model = tableData.createDataModel(calculator); + Object r = model.getValueAt(0, 0); + Assert.assertEquals("abc", r); + } + + + private static class DemoTableData extends BaseTableData { + + @Override + public DataModel createDataModel(Calculator calculator) { + return new DataModel() { + @Override + public int getColumnCount() throws TableDataException { + return 1; + } + + @Override + public int getColumnIndex(String s) throws TableDataException { + return 1; + } + + @Override + public String getColumnName(int i) throws TableDataException { + return "test"; + } + + @Override + public boolean hasRow(int i) throws TableDataException { + return i < 1; + } + + @Override + public int getRowCount() throws TableDataException { + return 1; + } + + @Override + public Object getValueAt(int i, int i1) throws TableDataException { + return "abc"; + } + + @Override + public void release() throws Exception { + + } + + @Override + public Iterator getDataIterator() { + return null; + } + + @Override + public Object getIteratorDataByColumn(Object o, int i) { + return null; + } + + @Override + public DBMetric getMetric() { + return null; + } + }; + } + } +} \ No newline at end of file From b331e15152f54fceaed207433d6c1088f790fdbf Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 4 Sep 2019 09:58:46 +0800 Subject: [PATCH 11/38] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/data/open/BaseTableDataTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java b/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java index 978179b..9d2891a 100644 --- a/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java +++ b/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java @@ -1,7 +1,6 @@ package com.fanruan.api.data.open; import com.fr.general.data.DataModel; -import com.fr.general.data.TableDataException; import com.fr.measure.metric.DBMetric; import com.fr.script.Calculator; import org.junit.Assert; @@ -21,7 +20,7 @@ public class BaseTableDataTest { Calculator calculator = Calculator.createCalculator(); DemoTableData tableData = new DemoTableData(); DataModel model = tableData.createDataModel(calculator); - Object r = model.getValueAt(0, 0); + Object r = model.getValueAt(0, 0); Assert.assertEquals("abc", r); } @@ -32,37 +31,37 @@ public class BaseTableDataTest { public DataModel createDataModel(Calculator calculator) { return new DataModel() { @Override - public int getColumnCount() throws TableDataException { + public int getColumnCount() { return 1; } @Override - public int getColumnIndex(String s) throws TableDataException { + public int getColumnIndex(String s) { return 1; } @Override - public String getColumnName(int i) throws TableDataException { + public String getColumnName(int i) { return "test"; } @Override - public boolean hasRow(int i) throws TableDataException { + public boolean hasRow(int i) { return i < 1; } @Override - public int getRowCount() throws TableDataException { + public int getRowCount() { return 1; } @Override - public Object getValueAt(int i, int i1) throws TableDataException { + public Object getValueAt(int i, int i1) { return "abc"; } @Override - public void release() throws Exception { + public void release() { } From a8b0ca938f5eb2891d86c812c4b80102e1c5688e Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 4 Sep 2019 10:10:43 +0800 Subject: [PATCH 12/38] =?UTF-8?q?DataModel=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/data/open/BaseDataModel.java | 28 ++++++++++++++++ .../fanruan/api/err/TableDataException.java | 18 +++++++++++ .../api/data/open/BaseTableDataTest.java | 32 ++++--------------- 3 files changed, 53 insertions(+), 25 deletions(-) create mode 100644 src/main/java/com/fanruan/api/data/open/BaseDataModel.java create mode 100644 src/main/java/com/fanruan/api/err/TableDataException.java diff --git a/src/main/java/com/fanruan/api/data/open/BaseDataModel.java b/src/main/java/com/fanruan/api/data/open/BaseDataModel.java new file mode 100644 index 0000000..3a03e3f --- /dev/null +++ b/src/main/java/com/fanruan/api/data/open/BaseDataModel.java @@ -0,0 +1,28 @@ +package com.fanruan.api.data.open; + +import com.fanruan.api.err.TableDataException; +import com.fr.data.AbstractDataModel; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-04 + * 二维表模型 + */ +public abstract class BaseDataModel extends AbstractDataModel { + + @Override + public abstract int getColumnCount() throws TableDataException; + + @Override + public abstract String getColumnName(int rowIndex) throws TableDataException; + + @Override + public abstract int getRowCount() throws TableDataException; + + @Override + public abstract Object getValueAt(int rowIndex, int columnIndex) throws TableDataException; + + @Override + public abstract void release() throws Exception; +} diff --git a/src/main/java/com/fanruan/api/err/TableDataException.java b/src/main/java/com/fanruan/api/err/TableDataException.java new file mode 100644 index 0000000..690c1b2 --- /dev/null +++ b/src/main/java/com/fanruan/api/err/TableDataException.java @@ -0,0 +1,18 @@ +package com.fanruan.api.err; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-04 + * 数据集异常 + */ +public class TableDataException extends com.fr.general.data.TableDataException { + + public TableDataException(String s) { + super(s); + } + + public TableDataException(String s, Throwable throwable) { + super(s, throwable); + } +} diff --git a/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java b/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java index 9d2891a..a979832 100644 --- a/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java +++ b/src/test/java/com/fanruan/api/data/open/BaseTableDataTest.java @@ -1,13 +1,10 @@ package com.fanruan.api.data.open; import com.fr.general.data.DataModel; -import com.fr.measure.metric.DBMetric; import com.fr.script.Calculator; import org.junit.Assert; import org.junit.Test; -import java.util.Iterator; - /** * @author richie * @version 10.0 @@ -21,6 +18,10 @@ public class BaseTableDataTest { DemoTableData tableData = new DemoTableData(); DataModel model = tableData.createDataModel(calculator); Object r = model.getValueAt(0, 0); + Assert.assertTrue(model.hasRow(0)); + Assert.assertFalse(model.hasRow(1)); + Assert.assertEquals(1, model.getColumnCount()); + Assert.assertEquals(1, model.getRowCount()); Assert.assertEquals("abc", r); } @@ -29,14 +30,10 @@ public class BaseTableDataTest { @Override public DataModel createDataModel(Calculator calculator) { - return new DataModel() { - @Override - public int getColumnCount() { - return 1; - } + return new BaseDataModel() { @Override - public int getColumnIndex(String s) { + public int getColumnCount() { return 1; } @@ -61,23 +58,8 @@ public class BaseTableDataTest { } @Override - public void release() { - - } + public void release() throws Exception { - @Override - public Iterator getDataIterator() { - return null; - } - - @Override - public Object getIteratorDataByColumn(Object o, int i) { - return null; - } - - @Override - public DBMetric getMetric() { - return null; } }; } From 3cd1ab9d03dfa68e22aacb71a159e938910eda24 Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 4 Sep 2019 10:15:22 +0800 Subject: [PATCH 13/38] =?UTF-8?q?javadoc=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/data/open/BaseDataModel.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/main/java/com/fanruan/api/data/open/BaseDataModel.java b/src/main/java/com/fanruan/api/data/open/BaseDataModel.java index 3a03e3f..0b25818 100644 --- a/src/main/java/com/fanruan/api/data/open/BaseDataModel.java +++ b/src/main/java/com/fanruan/api/data/open/BaseDataModel.java @@ -11,18 +11,50 @@ import com.fr.data.AbstractDataModel; */ public abstract class BaseDataModel extends AbstractDataModel { + /** + * 获取数据集的列数 + * + * @return 列数 + * @throws TableDataException 如果获取数据集列数失败,则抛出此异常 + */ @Override public abstract int getColumnCount() throws TableDataException; + /** + * 获取数据集指定列的列名 + * + * @param rowIndex 列序号 + * @return 类名 + * @throws TableDataException 如果获取列名失败,则抛出此异常 + */ @Override public abstract String getColumnName(int rowIndex) throws TableDataException; + /** + * 湖区数据集的行数 + * + * @return 行数 + * @throws TableDataException 如果获取数据集行数失败,则抛出此异常 + */ @Override public abstract int getRowCount() throws TableDataException; + /** + * 获取数据集中指定位置的值 + * + * @param rowIndex 行 + * @param columnIndex 列 + * @return 值 + * @throws TableDataException 如果获取值失败,则抛出此异常 + */ @Override public abstract Object getValueAt(int rowIndex, int columnIndex) throws TableDataException; + /** + * 释放一些构建数据集过程中占用的资源 + * + * @throws Exception 释放资源时发生错误则抛出此异常 + */ @Override public abstract void release() throws Exception; } From b9b9c7042a06f8f4ff373ae26ffb3bad478de5e7 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 4 Sep 2019 10:56:13 +0800 Subject: [PATCH 14/38] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=BC=82=E5=B8=B8=E5=8F=8ApluginKit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/err/TableDataException.java | 14 ++++++++++ .../com/fanruan/api/plugin/PluginKit.java | 26 +++++++++++++++++++ .../com/fanruan/api/plugin/PluginKitTest.java | 13 ++++++++++ .../fanruan/api/plugin/TestExtraClass.java | 12 +++++++++ .../com/fanruan/api/util/ArrayKitTest.java | 1 - 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/fanruan/api/err/TableDataException.java create mode 100644 src/main/java/com/fanruan/api/plugin/PluginKit.java create mode 100644 src/test/java/com/fanruan/api/plugin/PluginKitTest.java create mode 100644 src/test/java/com/fanruan/api/plugin/TestExtraClass.java diff --git a/src/main/java/com/fanruan/api/err/TableDataException.java b/src/main/java/com/fanruan/api/err/TableDataException.java new file mode 100644 index 0000000..aa222be --- /dev/null +++ b/src/main/java/com/fanruan/api/err/TableDataException.java @@ -0,0 +1,14 @@ +package com.fanruan.api.err; + +/** + * 和数据集工具有关的异常 + * */ +public class TableDataException extends com.fr.general.data.TableDataException{ + public TableDataException(String msg){ + super(msg); + } + + public TableDataException (String msg, Throwable error){ + super(msg, error); + } +} diff --git a/src/main/java/com/fanruan/api/plugin/PluginKit.java b/src/main/java/com/fanruan/api/plugin/PluginKit.java new file mode 100644 index 0000000..d591197 --- /dev/null +++ b/src/main/java/com/fanruan/api/plugin/PluginKit.java @@ -0,0 +1,26 @@ +package com.fanruan.api.plugin; + +import com.fr.plugin.ExtraClassManager; +import com.fr.stable.fun.mark.Mutable; + +import java.util.Set; + +public class PluginKit { + /** + * 返回指定集合的不可变数组 + * @param string 字符串 + * @return 数组 + * */ + public Set getArray(String string) { + return ExtraClassManager.getInstance().getArray(string); + } + + /** + * 返回指定集合的不可变数组 + * @param string 字符串 + * @return 数组 + * */ + public Set getArray(String string, Mutable m) { + return ExtraClassManager.getInstance().getArray(string, m); + } +} diff --git a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java b/src/test/java/com/fanruan/api/plugin/PluginKitTest.java new file mode 100644 index 0000000..4c8a72f --- /dev/null +++ b/src/test/java/com/fanruan/api/plugin/PluginKitTest.java @@ -0,0 +1,13 @@ +package com.fanruan.api.plugin; + +import org.junit.Assert; +import org.junit.Test; + +public class PluginKitTest { + @Test + public void getArray(){ + PluginKit p1 = new PluginKit(); + TestExtraClass p2 = new TestExtraClass(); + Assert.assertEquals(p1.getArray("abcd"), p2.getArray("abcd")); + } +} diff --git a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java b/src/test/java/com/fanruan/api/plugin/TestExtraClass.java new file mode 100644 index 0000000..f81ed57 --- /dev/null +++ b/src/test/java/com/fanruan/api/plugin/TestExtraClass.java @@ -0,0 +1,12 @@ +package com.fanruan.api.plugin; +import com.fr.plugin.injectable.PluginSingleInjection; + +public class TestExtraClass extends com.fr.plugin.AbstractExtraClassManager{ + protected boolean mountSpecific(PluginSingleInjection injection){ + return true; + } + + protected boolean demountSpecific(PluginSingleInjection injection){ + return true; + } +} diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index 054ae22..715ecfd 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -3,7 +3,6 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; import java.util.*; -import com.fr.third.org.apache.poi.hssf.record.formula.functions.Int; import org.junit.Assert; import org.junit.Test; From dc8b62d5bc238895536c586cb33e5d52c40b419f Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Wed, 4 Sep 2019 10:59:23 +0800 Subject: [PATCH 15/38] =?UTF-8?q?KERNEL-1197=20=E4=BF=AE=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/com/fanruan/api/util/PaintKitTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/fanruan/api/util/PaintKitTest.java b/src/test/java/com/fanruan/api/util/PaintKitTest.java index 33e2c17..69acc07 100644 --- a/src/test/java/com/fanruan/api/util/PaintKitTest.java +++ b/src/test/java/com/fanruan/api/util/PaintKitTest.java @@ -2,19 +2,19 @@ package com.fanruan.api.util; import com.fanruan.api.report.PaintKit; import com.fr.base.Style; -import com.fr.plugin.present.fun.StarPainter; import org.junit.Assert; import org.junit.Test; import java.awt.*; +import java.awt.image.BufferedImage; public class PaintKitTest { @Test public void value2Image() { - StarPainter star = new StarPainter(1); + BufferedImage bi = new BufferedImage(40, 50, BufferedImage.TYPE_BYTE_GRAY); Style style = Style.getInstance(); - Image image = PaintKit.value2Image(star, 1, style, 30, 50); + Image image = PaintKit.value2Image(bi, 1, style, 30, 50); Assert.assertEquals(30, image.getWidth(null)); Assert.assertEquals(50, image.getHeight(null)); } From efbe7a04604548a94b2435e35b2c63914a51ba3b Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 4 Sep 2019 11:41:51 +0800 Subject: [PATCH 16/38] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9Eequals?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E5=8F=8A=E5=8D=95=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/util/GeneralKit.java | 13 +++++++++- .../com/fanruan/api/util/GeneralKitTest.java | 24 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 9e13593..8c3e3f6 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -4,6 +4,7 @@ import com.fr.base.FRContext; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import com.fr.stable.CommonUtils; +import com.fr.stable.StringUtils; import com.fr.third.guava.base.Objects; import com.fr.stable.StableUtils; import org.jetbrains.annotations.NotNull; @@ -83,7 +84,7 @@ public class GeneralKit { public static String join(Object[] array, String se) { return StableUtils.join(array, se); } - /* + /** * 返回国际化区属 * @return 国际化后区域属性 */ @@ -91,4 +92,14 @@ public class GeneralKit { public static Locale getLocale() { return FRContext.getLocale(); } + + /** + * 检测两个数组是否相等 + * @param array1 数组1 + * @param array2 数组2 + * @return 判断的结果 + * */ + public static boolean equals(T[] array1, T[] array2){ + return ComparatorUtils.equals(array1, array2); + } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index c8057ec..0d4e275 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -52,4 +52,28 @@ public class GeneralKitTest extends Prepare { public void getLocale() { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } + @Test + public void equals(){ + Object objArray[] = {1,2,3}; + Integer intArray[] = {1,2,3}; + Long[] longArray = {1L,2L,3L}; + Double doubleArray[] = {1.1,2.2,3.3}; + Byte[] byteArray = {1,2,3}; + Character[] charArray = {'a', 'b', 'c'}; + Boolean booleanArray[] = {true,true,false}; + Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3}), true); + Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3,4}), false); + Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3}), true); + Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3,4}), false); + Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L}), true); + Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L,4L}), false); + Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3}), true); + Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3,4.4}), false); + Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3}), true); + Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3,4}), false); + Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c'}), true); + Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c','d'}), false); + Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false}), true); + Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false,false}), false); + } } \ No newline at end of file From 3ba7c372b10934b81d5f61fb727bcad924ff01a1 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 4 Sep 2019 14:16:53 +0800 Subject: [PATCH 17/38] =?UTF-8?q?update:=20UI=E7=BB=84=E4=BB=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/design/ui/container/BasicBeanPane.java | 6 ++++++ .../api/design/ui/editor/ValueEditorPaneFactory.java | 10 ++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java diff --git a/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java b/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java index 2ffc211..9fdfdaa 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java +++ b/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java @@ -1,4 +1,10 @@ package com.fanruan.api.design.ui.container; +/** + * 基础的pane类 + * */ public abstract class BasicBeanPane extends com.fr.design.beans.BasicBeanPane { + public BasicBeanPane(){ + + } } diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java new file mode 100644 index 0000000..a55b66f --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.editor; + +/** + * 生成ValueEditorPane的工厂方法 + * */ +public class ValueEditorPaneFactory extends com.fr.design.editor.ValueEditorPaneFactory{ + public ValueEditorPaneFactory(){ + + } +} From e8973b8cf3e1f96ee0731b844957752d66967d07 Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 4 Sep 2019 14:42:00 +0800 Subject: [PATCH 18/38] =?UTF-8?q?update:=20ui=E7=BB=84=E4=BB=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/design/ui/container/DialogActionAdapter.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java diff --git a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java b/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java new file mode 100644 index 0000000..7b0a02a --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.container; + +/** + * 用来给dialog增加一些固定的方法 + * */ +public class DialogActionAdapter extends com.fr.design.dialog.DialogActionAdapter{ + public DialogActionAdapter(){ + + } +} From 0e6219e9e11b0b9583ae0f76f3ec0fa71f035b2e Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Wed, 4 Sep 2019 16:10:03 +0800 Subject: [PATCH 19/38] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=94=B9=E5=8A=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/ui/container/BasicBeanPane.java | 10 ------- .../ui/container/DialogActionAdapter.java | 10 ------- .../ui/editor/ValueEditorPaneFactory.java | 10 ------- .../design/work/DatabaseConnectionPane.java | 3 +-- .../com/fanruan/api/plugin/PluginKit.java | 26 ------------------- .../java/com/fanruan/api/util/GeneralKit.java | 9 ------- .../com/fanruan/api/util/GeneralKitTest.java | 25 +----------------- 7 files changed, 2 insertions(+), 91 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java delete mode 100644 src/main/java/com/fanruan/api/plugin/PluginKit.java diff --git a/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java b/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java deleted file mode 100644 index 9fdfdaa..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/BasicBeanPane.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * 基础的pane类 - * */ -public abstract class BasicBeanPane extends com.fr.design.beans.BasicBeanPane { - public BasicBeanPane(){ - - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java b/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java deleted file mode 100644 index 7b0a02a..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/DialogActionAdapter.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * 用来给dialog增加一些固定的方法 - * */ -public class DialogActionAdapter extends com.fr.design.dialog.DialogActionAdapter{ - public DialogActionAdapter(){ - - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java b/src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java deleted file mode 100644 index a55b66f..0000000 --- a/src/main/java/com/fanruan/api/design/ui/editor/ValueEditorPaneFactory.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.design.ui.editor; - -/** - * 生成ValueEditorPane的工厂方法 - * */ -public class ValueEditorPaneFactory extends com.fr.design.editor.ValueEditorPaneFactory{ - public ValueEditorPaneFactory(){ - - } -} diff --git a/src/main/java/com/fanruan/api/design/work/DatabaseConnectionPane.java b/src/main/java/com/fanruan/api/design/work/DatabaseConnectionPane.java index 4d6d086..9d2854a 100644 --- a/src/main/java/com/fanruan/api/design/work/DatabaseConnectionPane.java +++ b/src/main/java/com/fanruan/api/design/work/DatabaseConnectionPane.java @@ -4,7 +4,6 @@ package com.fanruan.api.design.work; import com.fanruan.api.design.ui.component.UIButton; import com.fanruan.api.design.ui.component.UIComboBox; import com.fanruan.api.design.ui.component.UILabel; -import com.fanruan.api.design.ui.container.BasicBeanPane; import com.fanruan.api.log.LogKit; import com.fanruan.api.macro.EncodeConstants; import com.fanruan.api.util.ArrayKit; @@ -31,7 +30,7 @@ import java.awt.event.WindowEvent; * * @param 数据连接类型 */ -public abstract class DatabaseConnectionPane extends BasicBeanPane { +public abstract class DatabaseConnectionPane extends com.fr.design.beans.BasicBeanPane { private UILabel message; private UIButton okButton; diff --git a/src/main/java/com/fanruan/api/plugin/PluginKit.java b/src/main/java/com/fanruan/api/plugin/PluginKit.java deleted file mode 100644 index d591197..0000000 --- a/src/main/java/com/fanruan/api/plugin/PluginKit.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.fanruan.api.plugin; - -import com.fr.plugin.ExtraClassManager; -import com.fr.stable.fun.mark.Mutable; - -import java.util.Set; - -public class PluginKit { - /** - * 返回指定集合的不可变数组 - * @param string 字符串 - * @return 数组 - * */ - public Set getArray(String string) { - return ExtraClassManager.getInstance().getArray(string); - } - - /** - * 返回指定集合的不可变数组 - * @param string 字符串 - * @return 数组 - * */ - public Set getArray(String string, Mutable m) { - return ExtraClassManager.getInstance().getArray(string, m); - } -} diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index 8c3e3f6..e5df970 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -93,13 +93,4 @@ public class GeneralKit { return FRContext.getLocale(); } - /** - * 检测两个数组是否相等 - * @param array1 数组1 - * @param array2 数组2 - * @return 判断的结果 - * */ - public static boolean equals(T[] array1, T[] array2){ - return ComparatorUtils.equals(array1, array2); - } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 0d4e275..23a11f9 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -2,6 +2,7 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; import com.fr.general.GeneralUtils; +import com.fr.stable.AssistUtils; import org.junit.Assert; import org.junit.Test; @@ -52,28 +53,4 @@ public class GeneralKitTest extends Prepare { public void getLocale() { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } - @Test - public void equals(){ - Object objArray[] = {1,2,3}; - Integer intArray[] = {1,2,3}; - Long[] longArray = {1L,2L,3L}; - Double doubleArray[] = {1.1,2.2,3.3}; - Byte[] byteArray = {1,2,3}; - Character[] charArray = {'a', 'b', 'c'}; - Boolean booleanArray[] = {true,true,false}; - Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3}), true); - Assert.assertEquals(GeneralKit.equals(objArray, new Object[]{1,2,3,4}), false); - Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3}), true); - Assert.assertEquals(GeneralKit.equals(intArray, new Integer[]{1,2,3,4}), false); - Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L}), true); - Assert.assertEquals(GeneralKit.equals(longArray, new Long[]{1L,2L,3L,4L}), false); - Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3}), true); - Assert.assertEquals(GeneralKit.equals(doubleArray, new Double[]{1.1,2.2,3.3,4.4}), false); - Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3}), true); - Assert.assertEquals(GeneralKit.equals(byteArray, new Byte[]{1,2,3,4}), false); - Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c'}), true); - Assert.assertEquals(GeneralKit.equals(charArray, new Character[]{'a','b','c','d'}), false); - Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false}), true); - Assert.assertEquals(GeneralKit.equals(booleanArray, new Boolean[]{true,true,false,false}), false); - } } \ No newline at end of file From 093d7480153eda8115e18c4b9cb0c6f18a826dce Mon Sep 17 00:00:00 2001 From: richie Date: Wed, 4 Sep 2019 16:52:02 +0800 Subject: [PATCH 20/38] =?UTF-8?q?=E5=BC=80=E6=94=BE=E7=B1=BB=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/claim.md | 41 +++++++++++++++++++ readme.md | 2 + .../fanruan/api/data/open/BaseDataModel.java | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/docs/claim.md b/docs/claim.md index e69de29..020e125 100644 --- a/docs/claim.md +++ b/docs/claim.md @@ -0,0 +1,41 @@ +# 非FineKit中的Open类 + +com.fr.script.AbstractFunction + +com.fr.script.Calculator + +com.fr.general.FRFont + +com.fr.base.BaseFormula + +com.fr.base.Style + +com.fr.plugin.ExtraClassManager + +com.fr.stable.Primitive + +com.fr.stable.os.AbstractOperatingSystem + +com.fr.stable.os.Arch + +com.fr.stable.os.OperatingSystem + +com.fr.plugin.context.PluginContexts + +com.fr.config.Status + +com.fr.config.holder.Conf + +com.fr.stable.ColumnRow + +com.fr.web.struct.AssembleComponent + +com.fr.web.struct.BaseFilter + +com.fr.web.struct.Component + +com.fr.web.struct.Registry + +com.fr.web.struct.category.ScriptPath + +com.fr.web.struct.category.StylePath \ No newline at end of file diff --git a/readme.md b/readme.md index 7f1db86..7931b23 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,8 @@ SessionKit#getSession(@NotNull String sessionID); * 所有的API方法均需要有javadoc文档说明。 +开放类列表见:[非FineKit开放类](docs/claim.md) + ## 使用方法 先使用maven打包,执行下面的命令(跳过单元测试) diff --git a/src/main/java/com/fanruan/api/data/open/BaseDataModel.java b/src/main/java/com/fanruan/api/data/open/BaseDataModel.java index 0b25818..c51dc27 100644 --- a/src/main/java/com/fanruan/api/data/open/BaseDataModel.java +++ b/src/main/java/com/fanruan/api/data/open/BaseDataModel.java @@ -53,7 +53,7 @@ public abstract class BaseDataModel extends AbstractDataModel { /** * 释放一些构建数据集过程中占用的资源 * - * @throws Exception 释放资源时发生错误则抛出此异常 + * @throws Exception 释放资源时发生错误,则抛出此异常 */ @Override public abstract void release() throws Exception; From 6742d1e06cd93f8a17da1eed4443fe27f13ae6a6 Mon Sep 17 00:00:00 2001 From: Kalven Date: Wed, 4 Sep 2019 17:53:42 +0800 Subject: [PATCH 21/38] =?UTF-8?q?KERNEL-1161=20=E6=9B=B4=E6=94=B9fineKit?= =?UTF-8?q?=EF=BC=8CGeneralKit=E4=B8=AD=E7=9A=84=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=B2=A1=E6=9C=89=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/cal/namespace/TreeLayerNameSpace.java | 16 ++++++++++++ .../api/design/ui/component/UIList.java | 26 +++++++++++++++++++ .../ui/container/AbstractDataModify.java | 10 +++++++ .../design/ui/container/DictionaryPane.java | 10 +++++++ .../design/ui/container/XLayoutContainer.java | 20 ++++++++++++++ .../ui/editor/AccessiblePropertyEditor.java | 15 +++++++++++ .../editor/CustomWriteAbleRepeatEditor.java | 10 +++++++ .../api/design/ui/editor/ItemCellEditor.java | 15 +++++++++++ .../ui/editor/UneditableAccessibleEditor.java | 15 +++++++++++ .../design/ui/editor/WidgetValueEditor.java | 18 +++++++++++++ .../api/design/ui/editor/XFieldEditor.java | 17 ++++++++++++ .../api/design/work/EncoderCellRenderer.java | 15 +++++++++++ .../com/fanruan/api/design/work/Item.java | 12 +++++++++ .../com/fanruan/api/function/FunctionKit.java | 10 +++++++ .../fanruan/api/macro/XCreatorConstants.java | 11 ++++++++ .../java/com/fanruan/api/util/ArrayKit.java | 9 +++++++ .../java/com/fanruan/api/util/GeneralKit.java | 24 +++++++++++++++++ .../fanruan/api/function/FunctionKitTest.java | 4 +++ .../com/fanruan/api/util/ArrayKitTest.java | 8 ++++++ .../com/fanruan/api/util/GeneralKitTest.java | 15 +++++++++++ 20 files changed, 280 insertions(+) create mode 100644 src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIList.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java create mode 100644 src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java create mode 100644 src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java create mode 100644 src/main/java/com/fanruan/api/design/work/Item.java create mode 100644 src/main/java/com/fanruan/api/macro/XCreatorConstants.java diff --git a/src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java b/src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java new file mode 100644 index 0000000..03dd058 --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java @@ -0,0 +1,16 @@ +package com.fanruan.api.cal.namespace; + +import java.util.Map; + +/** + * 树状控件命名空间,存放相关公式和键值对 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + */ +public class TreeLayerNameSpace extends com.fr.script.TreeLayerNameSpace { + + public TreeLayerNameSpace(Map layIndexMap) { + super(layIndexMap); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIList.java b/src/main/java/com/fanruan/api/design/ui/component/UIList.java new file mode 100644 index 0000000..a7e3a47 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIList.java @@ -0,0 +1,26 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.*; +import java.util.Vector; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 列表组件 + */ +public class UIList extends com.fr.design.gui.ilist.UIList { + + public UIList(ListModel dataModel) { + super(dataModel); + } + + public UIList(Object[] listData) { + super(listData); + } + + public UIList(Vector listData) { + super(listData); + } + +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java b/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java new file mode 100644 index 0000000..e437411 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.container; + +/** + * 抽象数据定义,实现数据可序列化 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/3 + */ +public abstract class AbstractDataModify extends com.fr.design.widget.ui.AbstractDataModify { +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java b/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java new file mode 100644 index 0000000..806d275 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.container; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 数据字典容器,获取数据字典 + */ +public class DictionaryPane extends com.fr.design.present.dict.DictionaryPane { +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java b/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java new file mode 100644 index 0000000..8a70c03 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java @@ -0,0 +1,20 @@ +package com.fanruan.api.design.ui.container; + +import com.fr.form.ui.container.WLayout; + +import java.awt.*; + +/** + * + * 属性设置部分布局容器 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/3 + */ +public abstract class XLayoutContainer extends com.fr.design.designer.creator.XLayoutContainer { + + public XLayoutContainer(WLayout widget, Dimension initSize) { + super(widget, initSize); + this.addContainerListener(this); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java new file mode 100644 index 0000000..edcafb0 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.ui.editor; + +import com.fr.design.mainframe.widget.accessibles.AccessibleEditor; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 可以通过按钮或其他方式进去编辑面板的编辑器 + */ +public class AccessiblePropertyEditor extends com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor { + public AccessiblePropertyEditor(AccessibleEditor editor) { + super(editor); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java new file mode 100644 index 0000000..2218085 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.editor; + +/** + * 允许自定义值的、允许直接编辑的、带重复的 --- 下拉框 下拉复选框 下拉树 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + */ +public abstract class CustomWriteAbleRepeatEditor extends com.fr.form.ui.CustomWriteAbleRepeatEditor { +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java new file mode 100644 index 0000000..53bf002 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.ui.editor; + +import com.fr.design.designer.properties.items.Item; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 用作左中右对齐设置的下拉框Editor + */ +public class ItemCellEditor extends com.fr.design.mainframe.widget.editors.ItemCellEditor { + public ItemCellEditor(Item[] items) { + super(items); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java new file mode 100644 index 0000000..d7fc5bf --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.ui.editor; + +import com.fr.design.designer.properties.Encoder; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 无法修改的编辑器 + */ +public abstract class UneditableAccessibleEditor extends com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor { + public UneditableAccessibleEditor(Encoder enc) { + super(enc); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java new file mode 100644 index 0000000..2bc46ab --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java @@ -0,0 +1,18 @@ +package com.fanruan.api.design.ui.editor; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 控件值的编辑器 + */ +public class WidgetValueEditor extends com.fr.design.mainframe.widget.editors.WidgetValueEditor { + + public WidgetValueEditor(Object o) { + super(o); + } + + public WidgetValueEditor(Object o, boolean onlyServer) { + super(o, onlyServer); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java b/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java new file mode 100644 index 0000000..ad42005 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java @@ -0,0 +1,17 @@ +package com.fanruan.api.design.ui.editor; + +import com.fr.form.ui.FieldEditor; + +import java.awt.*; + +/** + * 控件树 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/3 + */ +public abstract class XFieldEditor extends com.fr.design.designer.creator.XFieldEditor { + public XFieldEditor(FieldEditor widget, Dimension initSize) { + super(widget, initSize); + } +} diff --git a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java new file mode 100644 index 0000000..08ae95a --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.work; + +import com.fr.design.designer.properties.Encoder; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * + */ +public class EncoderCellRenderer extends com.fr.design.mainframe.widget.renderer.EncoderCellRenderer { + public EncoderCellRenderer(Encoder encoder) { + super(encoder); + } +} diff --git a/src/main/java/com/fanruan/api/design/work/Item.java b/src/main/java/com/fanruan/api/design/work/Item.java new file mode 100644 index 0000000..34e1707 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/Item.java @@ -0,0 +1,12 @@ +package com.fanruan.api.design.work; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + */ +public class Item extends com.fr.design.designer.properties.items.Item { + public Item(String name, Object value) { + super(name, value); + } +} diff --git a/src/main/java/com/fanruan/api/function/FunctionKit.java b/src/main/java/com/fanruan/api/function/FunctionKit.java index 68eaa19..7c5d03e 100644 --- a/src/main/java/com/fanruan/api/function/FunctionKit.java +++ b/src/main/java/com/fanruan/api/function/FunctionKit.java @@ -7,6 +7,7 @@ import com.fr.file.FunctionManager; import com.fr.file.FunctionManagerProvider; import com.fr.script.Calculator; import com.fr.stable.StringUtils; +import com.fr.stable.fun.FunctionHelper; import com.fr.stable.script.FunctionDef; import java.util.ArrayList; @@ -84,4 +85,13 @@ public class FunctionKit { public static com.fr.file.FunctionManager getInstance() { return com.fr.file.FunctionManager.getInstance(); } + + /** + * 根据插件ID生成整数类型的标识符 + * @param stringID + * @return + */ + public static int generateFunctionID(String stringID) { + return FunctionHelper.generateFunctionID(stringID); + } } \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/macro/XCreatorConstants.java b/src/main/java/com/fanruan/api/macro/XCreatorConstants.java new file mode 100644 index 0000000..2e99d7f --- /dev/null +++ b/src/main/java/com/fanruan/api/macro/XCreatorConstants.java @@ -0,0 +1,11 @@ +package com.fanruan.api.macro; + +/** + * 存放XCreator的常量 + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/3 + */ +public class XCreatorConstants { + public static final String PROPERTY_CATEGORY = com.fr.design.form.util.XCreatorConstants.PROPERTY_CATEGORY; +} diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 92510c4..5df74b7 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -102,4 +102,13 @@ public class ArrayKit { public static List toList(T[] array) { return ArrayUtils.toList(array); } + + /** + * 求数组长度 + * @param array 数组 + * @return 长度 + */ + public static int getLength(Object array) { + return ArrayUtils.getLength(array); + } } diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index e5df970..b7beed8 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -3,8 +3,12 @@ package com.fanruan.api.util; import com.fr.base.FRContext; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; +import com.fr.general.xml.GeneralXMLTools; import com.fr.stable.CommonUtils; import com.fr.stable.StringUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; import com.fr.third.guava.base.Objects; import com.fr.stable.StableUtils; import org.jetbrains.annotations.NotNull; @@ -93,4 +97,24 @@ public class GeneralKit { return FRContext.getLocale(); } + /** + * 从输入源中读取xml + * @param reader 输入源 + * @return xml文件 + */ + public static XMLable readXMLable(XMLableReader reader) { + return GeneralXMLTools.readXMLable(reader); + } + + /** + * 写XMLable + * @param writer 输出源 + * @param xml xml文件 + * @param tagName 标签名 + */ + public static void writeXMLable(XMLPrintWriter writer, XMLable xml, String tagName) { + GeneralXMLTools.writeXMLable(writer, xml, tagName); + } + + } diff --git a/src/test/java/com/fanruan/api/function/FunctionKitTest.java b/src/test/java/com/fanruan/api/function/FunctionKitTest.java index db3f0f9..b3dafbc 100644 --- a/src/test/java/com/fanruan/api/function/FunctionKitTest.java +++ b/src/test/java/com/fanruan/api/function/FunctionKitTest.java @@ -42,4 +42,8 @@ public class FunctionKitTest extends Prepare { assertNotEquals("OK", result); } + @Test + public void generateFunctionID() { + assertEquals(FunctionKit.generateFunctionID("com.fr.plugin.widget.ztree"),169608572); + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index 715ecfd..45c6096 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -110,4 +110,12 @@ public class ArrayKitTest extends Prepare { Assert.assertEquals(ArrayKit.toList(array),result); } + @Test + public void getLength() { + int[] a = new int[0]; + int[] b = new int[2]; + Assert.assertEquals(ArrayKit.getLength(a),0); + Assert.assertEquals(ArrayKit.getLength(null),0); + Assert.assertEquals(ArrayKit.getLength(b),2); + } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 23a11f9..3de04c5 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -3,6 +3,7 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; import com.fr.general.GeneralUtils; import com.fr.stable.AssistUtils; +import com.fr.stable.xml.XMLableReader; import org.junit.Assert; import org.junit.Test; @@ -53,4 +54,18 @@ public class GeneralKitTest extends Prepare { public void getLocale() { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } + + @Test + public void readXMLable() { + try { + XMLableReader xmLableReader = XMLableReader.createXMLableReader("asd"); + GeneralKit.readXMLable(xmLableReader); + } catch (Exception e) { + + } + } + + @Test + public void writeXMLable() { + } } \ No newline at end of file From 67db510afb14fad2c7648860115138650137f83c Mon Sep 17 00:00:00 2001 From: Kalven Date: Thu, 5 Sep 2019 10:06:40 +0800 Subject: [PATCH 22/38] =?UTF-8?q?KERNEL-1161=20=E6=A0=B9=E6=8D=AE=E8=A6=81?= =?UTF-8?q?=E6=B1=82=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/CalculatorKit.java | 10 ++++++++++ .../api/cal/namespace/TreeLayerNameSpace.java | 16 ---------------- .../{ => design}/macro/XCreatorConstants.java | 2 +- .../api/design/work/EncoderCellRenderer.java | 2 +- .../java/com/fanruan/api/util/GeneralKit.java | 19 ------------------- .../com/fanruan/api/util/GeneralKitTest.java | 13 ------------- 6 files changed, 12 insertions(+), 50 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java rename src/main/java/com/fanruan/api/{ => design}/macro/XCreatorConstants.java (86%) diff --git a/src/main/java/com/fanruan/api/cal/CalculatorKit.java b/src/main/java/com/fanruan/api/cal/CalculatorKit.java index 5cdfb6b..195141d 100644 --- a/src/main/java/com/fanruan/api/cal/CalculatorKit.java +++ b/src/main/java/com/fanruan/api/cal/CalculatorKit.java @@ -8,6 +8,7 @@ import com.fr.data.TableDataSource; import com.fr.report.core.namespace.SimpleCellValueNameSpace; import com.fr.report.report.Report; import com.fr.script.Calculator; +import com.fr.script.TreeLayerNameSpace; import com.fr.stable.StringUtils; import com.fr.stable.script.CalculatorProvider; import com.fr.stable.script.NameSpace; @@ -95,4 +96,13 @@ public class CalculatorKit { public static NameSpace createSimpleCellValueNameSpace() { return SimpleCellValueNameSpace.getInstance(); } + + /** + * 创建一个计算树状组件的命名空间 + * @param layIndexMap 树状组件中的值 + * @return 树状组件的命名空间 + */ + public static NameSpace createTreeLayerNameSpace(Map layIndexMap) { + return new TreeLayerNameSpace(layIndexMap); + } } \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java b/src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java deleted file mode 100644 index 03dd058..0000000 --- a/src/main/java/com/fanruan/api/cal/namespace/TreeLayerNameSpace.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fanruan.api.cal.namespace; - -import java.util.Map; - -/** - * 树状控件命名空间,存放相关公式和键值对 - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/9/4 - */ -public class TreeLayerNameSpace extends com.fr.script.TreeLayerNameSpace { - - public TreeLayerNameSpace(Map layIndexMap) { - super(layIndexMap); - } -} diff --git a/src/main/java/com/fanruan/api/macro/XCreatorConstants.java b/src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java similarity index 86% rename from src/main/java/com/fanruan/api/macro/XCreatorConstants.java rename to src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java index 2e99d7f..ea51fa8 100644 --- a/src/main/java/com/fanruan/api/macro/XCreatorConstants.java +++ b/src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java @@ -1,4 +1,4 @@ -package com.fanruan.api.macro; +package com.fanruan.api.design.macro; /** * 存放XCreator的常量 diff --git a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java index 08ae95a..d5f617c 100644 --- a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java +++ b/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java @@ -6,7 +6,7 @@ import com.fr.design.designer.properties.Encoder; * @author Kalven * @version 10.0 * Created by Kalven on 2019/9/4 - * + * 根据控件属性渲染单元格 */ public class EncoderCellRenderer extends com.fr.design.mainframe.widget.renderer.EncoderCellRenderer { public EncoderCellRenderer(Encoder encoder) { diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index b7beed8..60d642b 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -97,24 +97,5 @@ public class GeneralKit { return FRContext.getLocale(); } - /** - * 从输入源中读取xml - * @param reader 输入源 - * @return xml文件 - */ - public static XMLable readXMLable(XMLableReader reader) { - return GeneralXMLTools.readXMLable(reader); - } - - /** - * 写XMLable - * @param writer 输出源 - * @param xml xml文件 - * @param tagName 标签名 - */ - public static void writeXMLable(XMLPrintWriter writer, XMLable xml, String tagName) { - GeneralXMLTools.writeXMLable(writer, xml, tagName); - } - } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 3de04c5..6ba3bf6 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -55,17 +55,4 @@ public class GeneralKitTest extends Prepare { Assert.assertEquals(GeneralKit.getLocale(), Locale.CHINA); } - @Test - public void readXMLable() { - try { - XMLableReader xmLableReader = XMLableReader.createXMLableReader("asd"); - GeneralKit.readXMLable(xmLableReader); - } catch (Exception e) { - - } - } - - @Test - public void writeXMLable() { - } } \ No newline at end of file From 87546555fbe5179c7275a4269fb865c83ce9f888 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 5 Sep 2019 10:37:06 +0800 Subject: [PATCH 23/38] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/component/present/DictionaryPane.java | 87 +++++++++++++++++++ .../design/ui/container/DictionaryPane.java | 10 --- .../api/design/work/EncoderCellRenderer.java | 15 ---- .../api/design/work/{ => form}/Item.java | 2 +- .../form/basic}/AccessiblePropertyEditor.java | 2 +- .../work/form/basic/EncoderCellRenderer.java | 53 +++++++++++ .../form/basic}/ItemCellEditor.java | 2 +- .../basic}/UneditableAccessibleEditor.java | 2 +- .../form}/container/AbstractDataModify.java | 2 +- .../form}/container/XLayoutContainer.java | 2 +- .../creator}/CustomWriteAbleRepeatEditor.java | 2 +- .../form/creator}/XFieldEditor.java | 2 +- .../work/form/editors/StringEditor.java | 14 +++ .../form/editors}/WidgetValueEditor.java | 4 +- .../form}/macro/XCreatorConstants.java | 3 +- 15 files changed, 166 insertions(+), 36 deletions(-) create mode 100644 src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java delete mode 100644 src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java rename src/main/java/com/fanruan/api/design/work/{ => form}/Item.java (84%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/basic}/AccessiblePropertyEditor.java (89%) create mode 100644 src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/basic}/ItemCellEditor.java (87%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/basic}/UneditableAccessibleEditor.java (88%) rename src/main/java/com/fanruan/api/design/{ui => work/form}/container/AbstractDataModify.java (81%) rename src/main/java/com/fanruan/api/design/{ui => work/form}/container/XLayoutContainer.java (89%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/creator}/CustomWriteAbleRepeatEditor.java (85%) rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/creator}/XFieldEditor.java (87%) create mode 100644 src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java rename src/main/java/com/fanruan/api/design/{ui/editor => work/form/editors}/WidgetValueEditor.java (82%) rename src/main/java/com/fanruan/api/design/{ => work/form}/macro/XCreatorConstants.java (83%) diff --git a/src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java b/src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java new file mode 100644 index 0000000..c956bae --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/present/DictionaryPane.java @@ -0,0 +1,87 @@ +package com.fanruan.api.design.ui.component.present; + + +import com.fanruan.api.design.DesignKit; +import com.fr.data.Dictionary; +import com.fr.data.impl.DynamicSQLDict; +import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.constants.LayoutConstants; +import com.fr.design.data.DataCreatorUI; +import com.fr.design.gui.frpane.UIComboBoxPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.layout.TableLayout; +import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.present.dict.CustomDictPane; +import com.fr.design.present.dict.DatabaseDictPane; +import com.fr.design.present.dict.FormulaDictPane; +import com.fr.design.present.dict.TableDataDictPane; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 数据字典容器,获取数据字典 + */ +public class DictionaryPane extends UIComboBoxPane implements DataCreatorUI { + private TableDataDictPane tableDataDictPane; + + @Override + protected void initLayout() { + this.setLayout(new BorderLayout(0, 4)); + double p = TableLayout.PREFERRED; + double f = TableLayout.FILL; + double[] columnSize = {p, f}; + double[] rowSize = {p, p}; + int[][] rowCount = {{1, 1}, {1, 1}}; + + Component[][] components = new Component[][]{ + new Component[]{new UILabel(DesignKit.i18nText("Fine-Design_Basic_Type_Set"), UILabel.LEFT), jcb}, + new Component[]{null, null} + }; + JPanel northPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_HUGER, LayoutConstants.VGAP_MEDIUM); + this.add(northPane, BorderLayout.NORTH); + this.add(cardPane, BorderLayout.CENTER); + } + + @Override + protected String title4PopupWindow() { + return DesignKit.i18nText("Fine-Design_Form_DS_Dictionary"); + } + + @Override + public JComponent toSwingComponent() { + return this; + } + + @Override + public void populateBean(Dictionary ob) { + for (int i = 0; i < this.cards.size(); i++) { + FurtherBasicBeanPane pane = cards.get(i); + if (pane.accept(ob)) { + pane.populateBean(ob); + jcb.setSelectedIndex(i); + } else { + pane.reset(); + } + } + if (ob instanceof DynamicSQLDict) { + jcb.setSelectedIndex(1); + tableDataDictPane.populateBean((DynamicSQLDict) ob); + } + } + + @Override + protected List> initPaneList() { + List> paneList = new ArrayList>(); + paneList.add(new DatabaseDictPane()); + paneList.add(tableDataDictPane = new TableDataDictPane()); + paneList.add(new CustomDictPane()); + paneList.add(new FormulaDictPane()); + return paneList; + } +} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java b/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java deleted file mode 100644 index 806d275..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/DictionaryPane.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/9/4 - * 数据字典容器,获取数据字典 - */ -public class DictionaryPane extends com.fr.design.present.dict.DictionaryPane { -} diff --git a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java deleted file mode 100644 index d5f617c..0000000 --- a/src/main/java/com/fanruan/api/design/work/EncoderCellRenderer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.design.work; - -import com.fr.design.designer.properties.Encoder; - -/** - * @author Kalven - * @version 10.0 - * Created by Kalven on 2019/9/4 - * 根据控件属性渲染单元格 - */ -public class EncoderCellRenderer extends com.fr.design.mainframe.widget.renderer.EncoderCellRenderer { - public EncoderCellRenderer(Encoder encoder) { - super(encoder); - } -} diff --git a/src/main/java/com/fanruan/api/design/work/Item.java b/src/main/java/com/fanruan/api/design/work/form/Item.java similarity index 84% rename from src/main/java/com/fanruan/api/design/work/Item.java rename to src/main/java/com/fanruan/api/design/work/form/Item.java index 34e1707..3011f7e 100644 --- a/src/main/java/com/fanruan/api/design/work/Item.java +++ b/src/main/java/com/fanruan/api/design/work/form/Item.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.work; +package com.fanruan.api.design.work.form; /** * @author Kalven diff --git a/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java similarity index 89% rename from src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java rename to src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java index edcafb0..94f56c7 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/AccessiblePropertyEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/AccessiblePropertyEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.basic; import com.fr.design.mainframe.widget.accessibles.AccessibleEditor; diff --git a/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java b/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java new file mode 100644 index 0000000..7655a22 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/form/basic/EncoderCellRenderer.java @@ -0,0 +1,53 @@ +package com.fanruan.api.design.work.form.basic; + +import com.fr.design.designer.properties.Encoder; +import com.fr.design.mainframe.widget.renderer.GenericCellRenderer; + +import java.awt.*; + +/** + * @author Kalven + * @version 10.0 + * Created by Kalven on 2019/9/4 + * 根据控件属性渲染单元格 + */ +public class EncoderCellRenderer extends GenericCellRenderer { + + private static int LEFT = 1; + protected Encoder encoder; + protected Object value; + + public EncoderCellRenderer(Encoder encoder) { + this.encoder = encoder; + } + + @Override + public void paint(Graphics g) { + int width = getWidth(); + int height = getHeight(); + g.setColor(getBackground()); + g.fillRect(0, 0, width, height); + + int x = LEFT; + g.setColor(getForeground()); + + FontMetrics fm = g.getFontMetrics(); + int y = ((height - fm.getHeight()) / 2) + fm.getAscent(); + String txt = getValueText(); + if (txt != null) { + g.drawString(txt, x, y); + } + if (getBorder() != null) { + getBorder().paintBorder(this, g, 0, 0, width, height); + } + } + + @Override + public void setValue(Object value) { + this.value = value; + } + + private String getValueText() { + return encoder.encode(value); + } +} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/ItemCellEditor.java similarity index 87% rename from src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java rename to src/main/java/com/fanruan/api/design/work/form/basic/ItemCellEditor.java index 53bf002..ae11f90 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/ItemCellEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/ItemCellEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.basic; import com.fr.design.designer.properties.items.Item; diff --git a/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java b/src/main/java/com/fanruan/api/design/work/form/basic/UneditableAccessibleEditor.java similarity index 88% rename from src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java rename to src/main/java/com/fanruan/api/design/work/form/basic/UneditableAccessibleEditor.java index d7fc5bf..879e2ff 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/UneditableAccessibleEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/UneditableAccessibleEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.basic; import com.fr.design.designer.properties.Encoder; diff --git a/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java b/src/main/java/com/fanruan/api/design/work/form/container/AbstractDataModify.java similarity index 81% rename from src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java rename to src/main/java/com/fanruan/api/design/work/form/container/AbstractDataModify.java index e437411..2567a2b 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/AbstractDataModify.java +++ b/src/main/java/com/fanruan/api/design/work/form/container/AbstractDataModify.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.container; +package com.fanruan.api.design.work.form.container; /** * 抽象数据定义,实现数据可序列化 diff --git a/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java b/src/main/java/com/fanruan/api/design/work/form/container/XLayoutContainer.java similarity index 89% rename from src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java rename to src/main/java/com/fanruan/api/design/work/form/container/XLayoutContainer.java index 8a70c03..21cd772 100644 --- a/src/main/java/com/fanruan/api/design/ui/container/XLayoutContainer.java +++ b/src/main/java/com/fanruan/api/design/work/form/container/XLayoutContainer.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.container; +package com.fanruan.api.design.work.form.container; import com.fr.form.ui.container.WLayout; diff --git a/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java b/src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java similarity index 85% rename from src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java rename to src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java index 2218085..28aeaca 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/CustomWriteAbleRepeatEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.creator; /** * 允许自定义值的、允许直接编辑的、带重复的 --- 下拉框 下拉复选框 下拉树 diff --git a/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java b/src/main/java/com/fanruan/api/design/work/form/creator/XFieldEditor.java similarity index 87% rename from src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java rename to src/main/java/com/fanruan/api/design/work/form/creator/XFieldEditor.java index ad42005..53afb63 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/XFieldEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/creator/XFieldEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.creator; import com.fr.form.ui.FieldEditor; diff --git a/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java b/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java new file mode 100644 index 0000000..08551c4 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java @@ -0,0 +1,14 @@ +package com.fanruan.api.design.work.form.editors; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-05 + * 字符串编辑器 + */ +public class StringEditor extends com.fr.design.mainframe.widget.editors.StringEditor { + + public StringEditor() { + super(); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java b/src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java similarity index 82% rename from src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java rename to src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java index 2bc46ab..0c77e46 100644 --- a/src/main/java/com/fanruan/api/design/ui/editor/WidgetValueEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java @@ -1,10 +1,10 @@ -package com.fanruan.api.design.ui.editor; +package com.fanruan.api.design.work.form.editors; /** * @author Kalven * @version 10.0 * Created by Kalven on 2019/9/4 - * 控件值的编辑器 + * 控件值编辑器 */ public class WidgetValueEditor extends com.fr.design.mainframe.widget.editors.WidgetValueEditor { diff --git a/src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java b/src/main/java/com/fanruan/api/design/work/form/macro/XCreatorConstants.java similarity index 83% rename from src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java rename to src/main/java/com/fanruan/api/design/work/form/macro/XCreatorConstants.java index ea51fa8..8596304 100644 --- a/src/main/java/com/fanruan/api/design/macro/XCreatorConstants.java +++ b/src/main/java/com/fanruan/api/design/work/form/macro/XCreatorConstants.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.macro; +package com.fanruan.api.design.work.form.macro; /** * 存放XCreator的常量 @@ -7,5 +7,6 @@ package com.fanruan.api.design.macro; * Created by Kalven on 2019/9/3 */ public class XCreatorConstants { + public static final String PROPERTY_CATEGORY = com.fr.design.form.util.XCreatorConstants.PROPERTY_CATEGORY; } From d8c33d0c1958b377ab6aafd74abafd87912c32ee Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 5 Sep 2019 10:39:50 +0800 Subject: [PATCH 24/38] =?UTF-8?q?=E5=B0=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/design/work/form/{ => basic}/Item.java | 2 +- .../api/design/work/form/{editors => editor}/StringEditor.java | 2 +- .../design/work/form/{editors => editor}/WidgetValueEditor.java | 2 +- .../creator => report/form}/CustomWriteAbleRepeatEditor.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/com/fanruan/api/design/work/form/{ => basic}/Item.java (82%) rename src/main/java/com/fanruan/api/design/work/form/{editors => editor}/StringEditor.java (82%) rename src/main/java/com/fanruan/api/design/work/form/{editors => editor}/WidgetValueEditor.java (87%) rename src/main/java/com/fanruan/api/{design/work/form/creator => report/form}/CustomWriteAbleRepeatEditor.java (85%) diff --git a/src/main/java/com/fanruan/api/design/work/form/Item.java b/src/main/java/com/fanruan/api/design/work/form/basic/Item.java similarity index 82% rename from src/main/java/com/fanruan/api/design/work/form/Item.java rename to src/main/java/com/fanruan/api/design/work/form/basic/Item.java index 3011f7e..cf06bed 100644 --- a/src/main/java/com/fanruan/api/design/work/form/Item.java +++ b/src/main/java/com/fanruan/api/design/work/form/basic/Item.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.work.form; +package com.fanruan.api.design.work.form.basic; /** * @author Kalven diff --git a/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java b/src/main/java/com/fanruan/api/design/work/form/editor/StringEditor.java similarity index 82% rename from src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java rename to src/main/java/com/fanruan/api/design/work/form/editor/StringEditor.java index 08551c4..e301eb7 100644 --- a/src/main/java/com/fanruan/api/design/work/form/editors/StringEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/editor/StringEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.work.form.editors; +package com.fanruan.api.design.work.form.editor; /** * @author richie diff --git a/src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java b/src/main/java/com/fanruan/api/design/work/form/editor/WidgetValueEditor.java similarity index 87% rename from src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java rename to src/main/java/com/fanruan/api/design/work/form/editor/WidgetValueEditor.java index 0c77e46..9204356 100644 --- a/src/main/java/com/fanruan/api/design/work/form/editors/WidgetValueEditor.java +++ b/src/main/java/com/fanruan/api/design/work/form/editor/WidgetValueEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.work.form.editors; +package com.fanruan.api.design.work.form.editor; /** * @author Kalven diff --git a/src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java b/src/main/java/com/fanruan/api/report/form/CustomWriteAbleRepeatEditor.java similarity index 85% rename from src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java rename to src/main/java/com/fanruan/api/report/form/CustomWriteAbleRepeatEditor.java index 28aeaca..42de2d0 100644 --- a/src/main/java/com/fanruan/api/design/work/form/creator/CustomWriteAbleRepeatEditor.java +++ b/src/main/java/com/fanruan/api/report/form/CustomWriteAbleRepeatEditor.java @@ -1,4 +1,4 @@ -package com.fanruan.api.design.work.form.creator; +package com.fanruan.api.report.form; /** * 允许自定义值的、允许直接编辑的、带重复的 --- 下拉框 下拉复选框 下拉树 From 64ea8befd0b2651a72c2b7ff439bd887ee1d2434 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Thu, 5 Sep 2019 11:50:19 +0800 Subject: [PATCH 25/38] =?UTF-8?q?KERNEL-1198=20JSON=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=B3=A2FineKit=E6=8F=90=E4=BA=A4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/Parameter.java | 4 ++++ .../com/fanruan/api/data/TableDataKit.java | 9 +++++++++ .../api/data/impl/NameDatabaseConnection.java | 11 +++++++++++ .../ui/component/UITableEditorPane.java | 17 +++++++++++++++++ .../ui/container/AbstractTableDataPane.java | 10 ++++++++++ .../design/ui/container/UISQLEditPane.java | 11 +++++++++++ .../com/fanruan/api/util/TemplateKit.java | 19 +++++++++++++++++++ 7 files changed, 81 insertions(+) create mode 100644 src/main/java/com/fanruan/api/cal/Parameter.java create mode 100644 src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java create mode 100644 src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java create mode 100644 src/main/java/com/fanruan/api/util/TemplateKit.java diff --git a/src/main/java/com/fanruan/api/cal/Parameter.java b/src/main/java/com/fanruan/api/cal/Parameter.java new file mode 100644 index 0000000..6375a76 --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/Parameter.java @@ -0,0 +1,4 @@ +package com.fanruan.api.cal; + +public class Parameter extends com.fr.base.Parameter { +} diff --git a/src/main/java/com/fanruan/api/data/TableDataKit.java b/src/main/java/com/fanruan/api/data/TableDataKit.java index 333245f..90eacfb 100644 --- a/src/main/java/com/fanruan/api/data/TableDataKit.java +++ b/src/main/java/com/fanruan/api/data/TableDataKit.java @@ -3,6 +3,7 @@ package com.fanruan.api.data; import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.api.TableDataAssist; +import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.file.TableDataConfig; import com.fr.script.Calculator; import com.fr.stable.script.CalculatorProvider; @@ -74,4 +75,12 @@ public class TableDataKit { public static void renameTableData(@NotNull String oldName, @NotNull String newName) { TableDataConfig.getInstance().renameTableData(oldName, newName); } + + /** + * 直接预览数据集,没有实际值和显示值 + * @param tableData 数据集 + */ + public static void previewTableData(TableData tableData) { + PreviewTablePane.previewTableData(tableData); + } } diff --git a/src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java b/src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java new file mode 100644 index 0000000..8751618 --- /dev/null +++ b/src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java @@ -0,0 +1,11 @@ +package com.fanruan.api.data.impl; + +/** + * 列表数据连接组件 + */ +public class NameDatabaseConnection extends com.fr.data.impl.NameDatabaseConnection { + public NameDatabaseConnection() { super();} + public NameDatabaseConnection(String name) { + super(name); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java b/src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java new file mode 100644 index 0000000..2c6d5c3 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java @@ -0,0 +1,17 @@ +package com.fanruan.api.design.ui.component; + +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; + +/** + * 表格编辑面板 + * @param + */ +public class UITableEditorPane extends com.fr.design.gui.itableeditorpane.UITableEditorPane { + public UITableEditorPane(UITableModelAdapter model){ + super(model); + } + + public UITableEditorPane(UITableModelAdapter model, String string){ + super(model, string); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java b/src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java new file mode 100644 index 0000000..0ff1eab --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java @@ -0,0 +1,10 @@ +package com.fanruan.api.design.ui.container; + +import com.fr.base.TableData; + +/** + * 表格面板 + * @param + */ +public abstract class AbstractTableDataPane extends com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane { +} diff --git a/src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java b/src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java new file mode 100644 index 0000000..2113b93 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java @@ -0,0 +1,11 @@ +package com.fanruan.api.design.ui.container; + +/** + * SQL编辑面板 + */ +public class UISQLEditPane extends com.fr.design.data.datapane.sqlpane.SQLEditPane { + public UISQLEditPane(){ super();} + public UISQLEditPane(boolean bool) { + super(bool); + } +} diff --git a/src/main/java/com/fanruan/api/util/TemplateKit.java b/src/main/java/com/fanruan/api/util/TemplateKit.java new file mode 100644 index 0000000..1244c49 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/TemplateKit.java @@ -0,0 +1,19 @@ +package com.fanruan.api.util; + +import com.fr.base.TemplateUtils; + +import java.util.Map; + +public class TemplateKit { + + /** + * 根据参数, 来计算文档字符串 + * @param tpl 文档来源 + * @param context 参数map + * @return 计算后结果 + * @throws Exception + */ + public static String renderParameter4Tpl(String tpl, Map context) throws Exception { + return TemplateUtils.renderParameter4Tpl(tpl, context); + } +} From 3f0d694707f040d545dc780197fda62c12f40bef Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Thu, 5 Sep 2019 14:28:18 +0800 Subject: [PATCH 26/38] =?UTF-8?q?KERNEL-1198=20=E6=B6=88=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/data/impl/NameDatabaseConnection.java | 11 ----------- .../ui/component/UITableEditorPane.java | 17 ----------------- .../ui/container/AbstractTableDataPane.java | 10 ---------- .../design/ui/container/UISQLEditPane.java | 11 ----------- .../com/fanruan/api/util/TemplateKit.java | 19 ------------------- 5 files changed, 68 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java delete mode 100644 src/main/java/com/fanruan/api/util/TemplateKit.java diff --git a/src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java b/src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java deleted file mode 100644 index 8751618..0000000 --- a/src/main/java/com/fanruan/api/data/impl/NameDatabaseConnection.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.fanruan.api.data.impl; - -/** - * 列表数据连接组件 - */ -public class NameDatabaseConnection extends com.fr.data.impl.NameDatabaseConnection { - public NameDatabaseConnection() { super();} - public NameDatabaseConnection(String name) { - super(name); - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java b/src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java deleted file mode 100644 index 2c6d5c3..0000000 --- a/src/main/java/com/fanruan/api/design/ui/component/UITableEditorPane.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fanruan.api.design.ui.component; - -import com.fr.design.gui.itableeditorpane.UITableModelAdapter; - -/** - * 表格编辑面板 - * @param - */ -public class UITableEditorPane extends com.fr.design.gui.itableeditorpane.UITableEditorPane { - public UITableEditorPane(UITableModelAdapter model){ - super(model); - } - - public UITableEditorPane(UITableModelAdapter model, String string){ - super(model, string); - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java b/src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java deleted file mode 100644 index 0ff1eab..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/AbstractTableDataPane.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.fanruan.api.design.ui.container; - -import com.fr.base.TableData; - -/** - * 表格面板 - * @param - */ -public abstract class AbstractTableDataPane extends com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane { -} diff --git a/src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java b/src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java deleted file mode 100644 index 2113b93..0000000 --- a/src/main/java/com/fanruan/api/design/ui/container/UISQLEditPane.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.fanruan.api.design.ui.container; - -/** - * SQL编辑面板 - */ -public class UISQLEditPane extends com.fr.design.data.datapane.sqlpane.SQLEditPane { - public UISQLEditPane(){ super();} - public UISQLEditPane(boolean bool) { - super(bool); - } -} diff --git a/src/main/java/com/fanruan/api/util/TemplateKit.java b/src/main/java/com/fanruan/api/util/TemplateKit.java deleted file mode 100644 index 1244c49..0000000 --- a/src/main/java/com/fanruan/api/util/TemplateKit.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.base.TemplateUtils; - -import java.util.Map; - -public class TemplateKit { - - /** - * 根据参数, 来计算文档字符串 - * @param tpl 文档来源 - * @param context 参数map - * @return 计算后结果 - * @throws Exception - */ - public static String renderParameter4Tpl(String tpl, Map context) throws Exception { - return TemplateUtils.renderParameter4Tpl(tpl, context); - } -} From a64da28c498ccc446af75d3085793ca5973b5ff4 Mon Sep 17 00:00:00 2001 From: richie Date: Thu, 5 Sep 2019 14:34:56 +0800 Subject: [PATCH 27/38] =?UTF-8?q?=E5=8F=82=E6=95=B0=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/ParameterKit.java | 37 ++++++++++++++++--- .../com/fanruan/api/cal/ParameterKitTest.java | 17 ++++++++- .../com/fanruan/api/plugin/PluginKitTest.java | 8 ++-- .../fanruan/api/plugin/TestExtraClass.java | 12 ------ 4 files changed, 52 insertions(+), 22 deletions(-) delete mode 100644 src/test/java/com/fanruan/api/plugin/TestExtraClass.java diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index afb080d..471d9fe 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -1,8 +1,11 @@ package com.fanruan.api.cal; +import com.fanruan.api.util.ArrayKit; +import com.fanruan.api.util.AssistKit; import com.fr.base.Parameter; import com.fr.base.ParameterHelper; import com.fr.base.ParameterMapNameSpace; +import com.fr.stable.ArrayUtils; import com.fr.stable.ParameterProvider; import com.fr.stable.script.NameSpace; import org.jetbrains.annotations.NotNull; @@ -39,6 +42,7 @@ public class ParameterKit { /** * 根据参数名创建新的参数对象 + * * @param name 参数名 * @return 参数对象 */ @@ -98,15 +102,38 @@ public class ParameterKit { public static @NotNull NameSpace createParameterMapNameSpace(ParameterProvider[] ps) { return ParameterMapNameSpace.create(ps); } + /** - * 获得新的参数集合 + * 获得新的参数集数组,新的参数结合中参数的值是通过设定的同名参数传递进去的 * * @param paramTexts sql语句 - * @param ps 旧的参数集合 - * @return 新参数集合 + * @param ps 用于传值的参数数组 + * @return 新参数素组 */ - public static ParameterProvider[] analyzeAndUnionSameParameters(String[] paramTexts, Parameter[] ps){ - return ParameterHelper.analyzeAndUnionSameParameters(paramTexts, ps); + public static ParameterProvider[] analyzeAndUnionSameParameters(String[] paramTexts, ParameterProvider[] ps) { + + ParameterProvider[] parameters = ParameterKit.analyze4Parameters(paramTexts, false); + + if (ArrayUtils.isEmpty(parameters)) { + return parameters; + } + + if (ArrayKit.isNotEmpty(ps)) { + for (ParameterProvider newParameter : parameters) { + ParameterProvider existParameter = null; + for (ParameterProvider p : ps) { + if (AssistKit.equals(p.getName(), newParameter.getName())) { + existParameter = p; + break; + } + } + if (existParameter != null) { + newParameter.setValue(existParameter.getValue()); + } + } + } + + return parameters; } } diff --git a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java index 4093687..623650f 100644 --- a/src/test/java/com/fanruan/api/cal/ParameterKitTest.java +++ b/src/test/java/com/fanruan/api/cal/ParameterKitTest.java @@ -111,7 +111,22 @@ public class ParameterKitTest extends Prepare { @Test public void newParameter2() { ParameterProvider provider = ParameterKit.newParameter("p1"); - Assert.assertEquals(provider.getName(),"p1"); + Assert.assertEquals(provider.getName(), "p1"); Assert.assertEquals("", provider.getValue()); } + + @Test + public void analyzeAndUnionSameParameters() { + ParameterProvider p1 = ParameterKit.newParameter("p1", 100); + ParameterProvider p2 = ParameterKit.newParameter("p2", 200); + + ParameterProvider[] providers = ParameterKit.analyzeAndUnionSameParameters( + new String[]{"select * from td where name = ${p1} and age = ${p3}"}, + new ParameterProvider[]{p1, p2}); + for (ParameterProvider provider : providers) { + if ("p1".equals(provider.getName())) { + Assert.assertEquals(100, provider.getValue()); + } + } + } } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java b/src/test/java/com/fanruan/api/plugin/PluginKitTest.java index 4c8a72f..7d5f9a5 100644 --- a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java +++ b/src/test/java/com/fanruan/api/plugin/PluginKitTest.java @@ -1,13 +1,13 @@ package com.fanruan.api.plugin; +import com.fanruan.api.runtime.PluginKit; import org.junit.Assert; import org.junit.Test; public class PluginKitTest { @Test - public void getArray(){ - PluginKit p1 = new PluginKit(); - TestExtraClass p2 = new TestExtraClass(); - Assert.assertEquals(p1.getArray("abcd"), p2.getArray("abcd")); + public void getArray() { + Assert.assertFalse(PluginKit.isCurrentPluginAvailable()); + } } diff --git a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java b/src/test/java/com/fanruan/api/plugin/TestExtraClass.java deleted file mode 100644 index f81ed57..0000000 --- a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fanruan.api.plugin; -import com.fr.plugin.injectable.PluginSingleInjection; - -public class TestExtraClass extends com.fr.plugin.AbstractExtraClassManager{ - protected boolean mountSpecific(PluginSingleInjection injection){ - return true; - } - - protected boolean demountSpecific(PluginSingleInjection injection){ - return true; - } -} From 50204f18faa9194f9110bed1d62bab89e4fafb6d Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Thu, 5 Sep 2019 15:11:54 +0800 Subject: [PATCH 28/38] =?UTF-8?q?update:=20=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E7=BB=93=E6=9E=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../table/action/UITableEditAction.java | 4 ++-- .../table/model/UITableModelAdapter.java | 1 + .../com/fanruan/api/security/SecurityKit.java | 9 +++++++++ .../com/fanruan/api/plugin/PluginKitTest.java | 13 ------------- .../com/fanruan/api/plugin/TestExtraClass.java | 12 ------------ .../fanruan/api/security/SecurityKitTest.java | 18 ++++++++++++++++++ 6 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 src/test/java/com/fanruan/api/plugin/PluginKitTest.java delete mode 100644 src/test/java/com/fanruan/api/plugin/TestExtraClass.java create mode 100644 src/test/java/com/fanruan/api/security/SecurityKitTest.java diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java b/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java index 1c441cf..60da73c 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java +++ b/src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java @@ -5,8 +5,8 @@ import java.awt.event.ActionEvent; public class UITableEditAction extends com.fr.design.gui.itableeditorpane.UITableEditAction { @Override - public void checkEnabled() { - } + public void checkEnabled(){}; + @Override public void actionPerformed(ActionEvent e) { diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java index be69b7a..a26bd78 100644 --- a/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java +++ b/src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java @@ -20,6 +20,7 @@ public abstract class UITableModelAdapter extends com.fr.design.gui.itableedi super(strings); } + @Override public abstract UITableEditAction[] createAction(); diff --git a/src/main/java/com/fanruan/api/security/SecurityKit.java b/src/main/java/com/fanruan/api/security/SecurityKit.java index e6e903c..59c90d8 100644 --- a/src/main/java/com/fanruan/api/security/SecurityKit.java +++ b/src/main/java/com/fanruan/api/security/SecurityKit.java @@ -35,4 +35,13 @@ public class SecurityKit { public static String passwordDecode(String passwordText) { return CodeUtils.passwordDecode(passwordText); } + + /** + * 给字符串加密 + * @param passwordText 待加密的字符串 + * @return 解加密的字符串 + */ + public static String passwordEncode(String passwordText) { + return CodeUtils.passwordEncode(passwordText); + } } diff --git a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java b/src/test/java/com/fanruan/api/plugin/PluginKitTest.java deleted file mode 100644 index 4c8a72f..0000000 --- a/src/test/java/com/fanruan/api/plugin/PluginKitTest.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.fanruan.api.plugin; - -import org.junit.Assert; -import org.junit.Test; - -public class PluginKitTest { - @Test - public void getArray(){ - PluginKit p1 = new PluginKit(); - TestExtraClass p2 = new TestExtraClass(); - Assert.assertEquals(p1.getArray("abcd"), p2.getArray("abcd")); - } -} diff --git a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java b/src/test/java/com/fanruan/api/plugin/TestExtraClass.java deleted file mode 100644 index f81ed57..0000000 --- a/src/test/java/com/fanruan/api/plugin/TestExtraClass.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fanruan.api.plugin; -import com.fr.plugin.injectable.PluginSingleInjection; - -public class TestExtraClass extends com.fr.plugin.AbstractExtraClassManager{ - protected boolean mountSpecific(PluginSingleInjection injection){ - return true; - } - - protected boolean demountSpecific(PluginSingleInjection injection){ - return true; - } -} diff --git a/src/test/java/com/fanruan/api/security/SecurityKitTest.java b/src/test/java/com/fanruan/api/security/SecurityKitTest.java new file mode 100644 index 0000000..6760606 --- /dev/null +++ b/src/test/java/com/fanruan/api/security/SecurityKitTest.java @@ -0,0 +1,18 @@ +package com.fanruan.api.security; + +import java.util.*; + +import com.fr.stable.CommonCodeUtils; +import org.junit.Assert; +import org.junit.Test; + +public class SecurityKitTest { + @Test + public void passwordDecode(){ + Assert.assertEquals(SecurityKit.passwordDecode("1234"), CommonCodeUtils.passwordDecode("1234")); + } + @Test + public void passwordEncode(){ + Assert.assertEquals(SecurityKit.passwordEncode("1234"), CommonCodeUtils.passwordEncode("1234")); + } +} From c7340eb5d9164d6e6c567ee7d7713c165b6fed8d Mon Sep 17 00:00:00 2001 From: rinoux Date: Thu, 5 Sep 2019 18:01:50 +0800 Subject: [PATCH 29/38] =?UTF-8?q?=E8=B5=84=E6=BA=90=E4=BB=93=E5=BA=93kit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/io/ResourceModuleKit.java | 41 ++++++ .../fanruan/api/io/ResourceModuleKitTest.java | 124 ++++++++++++++++++ 2 files changed, 165 insertions(+) create mode 100644 src/main/java/com/fanruan/api/io/ResourceModuleKit.java create mode 100644 src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java diff --git a/src/main/java/com/fanruan/api/io/ResourceModuleKit.java b/src/main/java/com/fanruan/api/io/ResourceModuleKit.java new file mode 100644 index 0000000..295c8b5 --- /dev/null +++ b/src/main/java/com/fanruan/api/io/ResourceModuleKit.java @@ -0,0 +1,41 @@ +package com.fanruan.api.io; + +import com.fr.io.base.provider.RepositoryFactoryProvider; +import com.fr.io.context.ResourceModuleContext; +import org.jetbrains.annotations.NotNull; + +/** + * + * 资源仓库插件开发套件 + * + * @author rinoux + * @version 10.0 + * Created by rinoux on 2019/9/5 + */ +public class ResourceModuleKit { + + + /** + * 添加一个资源仓库工厂 + * + * @param factory 工厂 + * @param 工厂类型 + */ + public static void addFactory(@NotNull T factory) { + ResourceModuleContext.addFactory(factory); + } + + + /** + * 移除一个资源仓库工厂 + * + * @param factory 工厂 + * @param 工厂类型 + */ + public static void removeFactory(@NotNull T factory) { + ResourceModuleContext.removeFactory(factory.getIdentity()); + } + + + +} diff --git a/src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java b/src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java new file mode 100644 index 0000000..e5d3f50 --- /dev/null +++ b/src/test/java/com/fanruan/api/io/ResourceModuleKitTest.java @@ -0,0 +1,124 @@ +package com.fanruan.api.io; + +import com.fr.io.base.provider.FactoryLoaderProvider; +import com.fr.io.base.provider.RepositoryFactoryProvider; +import com.fr.io.base.provider.RepositoryInstallerProvider; +import com.fr.io.base.provider.RepositoryManagerProvider; +import com.fr.io.config.RepositoryConfig; +import com.fr.io.config.ResourceModuleConfigProvider; +import com.fr.io.context.RepositoryContextProvider; +import com.fr.io.context.ResourceModuleContext; +import com.fr.io.lock.LockFactory; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; + +/** + * ResourceModuleKit Tester. + * + * @author + * @version 1.0 + * @since
9月 5, 2019
+ */ +public class ResourceModuleKitTest { + + @Before + public void before() throws Exception { + final FactoryLoaderProvider loaderProvider = new FactoryLoaderProvider() { + final Map map = new HashMap<>(); + + @Override + public void add(RepositoryFactoryProvider factory) { + map.put(factory.getIdentity(), factory); + } + + @Override + public void remove(String identity) { + map.remove(identity); + } + + @Override + @SuppressWarnings("unchecked") + public RepositoryFactoryProvider get(String identity) { + return map.get(identity); + } + }; + + ResourceModuleContext.setRepositoryContext(new RepositoryContextProvider() { + @Override + public FactoryLoaderProvider getFactoryLoader() { + + return loaderProvider; + } + + @Override + public ResourceModuleConfigProvider getConfig() { + return null; + } + + @Override + public RepositoryManagerProvider getManager() { + return null; + } + + @Override + public RepositoryInstallerProvider getInstaller() { + return null; + } + + @Override + public LockFactory getLockFactory() { + return null; + } + }); + } + + @After + public void after() throws Exception { + ResourceModuleContext.setRepositoryContext(null); + } + + /** + * Method: addFactory(@NotNull T factory) + */ + @Test + public void testAddFactory() throws Exception { + RepositoryFactoryProvider factory = EasyMock.createMock(RepositoryFactoryProvider.class); + EasyMock.expect(factory.getIdentity()).andReturn("MockRF").anyTimes(); + + EasyMock.replay(factory); + + Assert.assertNull(ResourceModuleContext.getFactory("MockRF")); + + ResourceModuleKit.addFactory(factory); + + Assert.assertNotNull(ResourceModuleContext.getFactory("MockRF")); + } + + + /** + * Method: addFactory(@NotNull T factory) + */ + @Test + public void testRemoveFactory() throws Exception { + RepositoryFactoryProvider factory = EasyMock.createMock(RepositoryFactoryProvider.class); + EasyMock.expect(factory.getIdentity()).andReturn("MockRF").anyTimes(); + + EasyMock.replay(factory); + + Assert.assertNull(ResourceModuleContext.getFactory("MockRF")); + + ResourceModuleKit.addFactory(factory); + + Assert.assertNotNull(ResourceModuleContext.getFactory("MockRF")); + + ResourceModuleKit.removeFactory(factory); + + Assert.assertNull(ResourceModuleContext.getFactory("MockRF")); + } +} From 852b32943a8258830ff167d0758ef3b3f8f0b7eb Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Fri, 6 Sep 2019 11:38:04 +0800 Subject: [PATCH 30/38] =?UTF-8?q?KERNEL-1198=20JSON=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/cal/Parameter.java | 4 ---- .../com/fanruan/api/cal/ParameterKit.java | 8 +++++++ .../fanruan/api/conf/ConfigurationKit.java | 10 +++++++++ .../fanruan/api/data/AbstractDataModel.java | 4 ++++ .../api/data/AbstractDatabaseConnection.java | 4 ++++ .../api/data/AbstractParameterTableData.java | 4 ++++ .../com/fanruan/api/net/http/EntityKit.java | 21 +++++++++++++++++++ .../net/http/message/BasicNameValuePair.java | 9 ++++++++ .../java/com/fanruan/api/util/CodeKit.java | 10 +++++++++ .../com/fanruan/api/util/ComparatorKit.java | 15 +++++++++++++ src/main/java/com/fanruan/api/xml/XmlKit.java | 16 +++++++++----- 11 files changed, 96 insertions(+), 9 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/cal/Parameter.java create mode 100644 src/main/java/com/fanruan/api/data/AbstractDataModel.java create mode 100644 src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java create mode 100644 src/main/java/com/fanruan/api/data/AbstractParameterTableData.java create mode 100644 src/main/java/com/fanruan/api/net/http/EntityKit.java create mode 100644 src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java create mode 100644 src/main/java/com/fanruan/api/util/ComparatorKit.java diff --git a/src/main/java/com/fanruan/api/cal/Parameter.java b/src/main/java/com/fanruan/api/cal/Parameter.java deleted file mode 100644 index 6375a76..0000000 --- a/src/main/java/com/fanruan/api/cal/Parameter.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.cal; - -public class Parameter extends com.fr.base.Parameter { -} diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index 471d9fe..c1e1b68 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -136,4 +136,12 @@ public class ParameterKit { return parameters; } + /** + * 将ParameterProvider转化为Parameter + * @param providers 需要转换的ParameterProvider + * @return 转换后的Parameter + */ + public static Parameter[] providers2Parameter(ParameterProvider[] providers) { + return Parameter.providers2Parameter(providers); + } } diff --git a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java index b433465..43625ed 100644 --- a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java +++ b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.conf; +import com.fr.config.ConfigContext; import com.fr.config.Configuration; import com.fr.config.holder.ConfigChangeListener; import com.fr.transaction.Configurations; @@ -38,4 +39,13 @@ public class ConfigurationKit { }); } + /** + * 返回config实例,且config实例只存在一个 + * @param configuration Configuration类 + * @param + * @return config实例 + */ + public static T getConfigInstance(final Class configuration) { + return ConfigContext.getConfigInstance(configuration); + } } diff --git a/src/main/java/com/fanruan/api/data/AbstractDataModel.java b/src/main/java/com/fanruan/api/data/AbstractDataModel.java new file mode 100644 index 0000000..7ee273f --- /dev/null +++ b/src/main/java/com/fanruan/api/data/AbstractDataModel.java @@ -0,0 +1,4 @@ +package com.fanruan.api.data; + +public abstract class AbstractDataModel extends com.fr.data.AbstractDataModel { +} diff --git a/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java b/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java new file mode 100644 index 0000000..925da74 --- /dev/null +++ b/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java @@ -0,0 +1,4 @@ +package com.fanruan.api.data; + +public abstract class AbstractDatabaseConnection extends com.fr.data.impl.AbstractDatabaseConnection { +} diff --git a/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java b/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java new file mode 100644 index 0000000..23c1f05 --- /dev/null +++ b/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java @@ -0,0 +1,4 @@ +package com.fanruan.api.data; + +public abstract class AbstractParameterTableData extends com.fr.data.AbstractParameterTableData { +} diff --git a/src/main/java/com/fanruan/api/net/http/EntityKit.java b/src/main/java/com/fanruan/api/net/http/EntityKit.java new file mode 100644 index 0000000..d1d7b3f --- /dev/null +++ b/src/main/java/com/fanruan/api/net/http/EntityKit.java @@ -0,0 +1,21 @@ +package com.fanruan.api.net.http; + +import com.fr.third.org.apache.http.HttpEntity; +import com.fr.third.org.apache.http.ParseException; +import com.fr.third.org.apache.http.util.EntityUtils; + +import java.io.IOException; + +public class EntityKit { + /** + * 利用defaultCharset字符集将HttpEntity对象转化为String对象 + * @param entity 需要转化为String的HttpEntity对象 + * @param defaultCharset 传入的字符集 + * @return HttpEntity对象转化为的String对象 + * @throws IOException + * @throws ParseException + */ + public static String toString(HttpEntity entity, String defaultCharset) throws IOException, ParseException { + return EntityUtils.toString(entity, defaultCharset); + } +} diff --git a/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java b/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java new file mode 100644 index 0000000..82ffb80 --- /dev/null +++ b/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java @@ -0,0 +1,9 @@ +package com.fanruan.api.net.http.message; +/** + * 键值对类 + */ +public class BasicNameValuePair extends com.fr.third.org.apache.http.message.BasicNameValuePair { + public BasicNameValuePair(String name, String value) { + super(name, value); + } +} diff --git a/src/main/java/com/fanruan/api/util/CodeKit.java b/src/main/java/com/fanruan/api/util/CodeKit.java index b819eb4..5c89421 100644 --- a/src/main/java/com/fanruan/api/util/CodeKit.java +++ b/src/main/java/com/fanruan/api/util/CodeKit.java @@ -12,4 +12,14 @@ public class CodeKit { public static String passwordDecode(String passwordText) { return CodeUtils.passwordDecode(passwordText); } + + /** + * 将经过处理的中日韩文字符串解码成原先的中日韩文 + * @param text 经过处理的中日韩文字 + * @return 中日韩文字 + * @throws Exception + */ + public static String cjkDecode(String text) throws Exception { + return CodeUtils.cjkDecode(text); + } } diff --git a/src/main/java/com/fanruan/api/util/ComparatorKit.java b/src/main/java/com/fanruan/api/util/ComparatorKit.java new file mode 100644 index 0000000..39fddff --- /dev/null +++ b/src/main/java/com/fanruan/api/util/ComparatorKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.util; + +import com.fr.general.ComparatorUtils; + +public class ComparatorKit { + /** + * 比较两个Object对象是否相等 + * @param object1 第一个Object对象 + * @param object2 第二个Object对象 + * @return 相等返回True 不相等返回False + */ + public static boolean equals(Object object1, Object object2){ + return ComparatorUtils.equals(object1, object2); + } +} diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index 89de42a..bcc1ae0 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -3,11 +3,8 @@ package com.fanruan.api.xml; import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.impl.Connection; import com.fr.general.xml.GeneralXMLTools; -import com.fr.stable.xml.XMLPrintWriter; -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.ParameterProvider; +import com.fr.stable.xml.*; import java.io.InputStream; @@ -76,4 +73,13 @@ public class XmlKit { DataCoreXmlUtils.writeXMLConnection(writer, connection); } + /** + *读出xml参数 + * @param reader xml读出对象 + * @return 返回保存参数数组 + */ + public static ParameterProvider readParameter(XMLableReader reader) { + return StableXMLUtils.readParameter(reader); + } + } From 0fc41e9f70a368544dbe828c15324d1e7e14984b Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 6 Sep 2019 11:51:04 +0800 Subject: [PATCH 31/38] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/data/open/BaseConnection.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/com/fanruan/api/data/open/BaseConnection.java diff --git a/src/main/java/com/fanruan/api/data/open/BaseConnection.java b/src/main/java/com/fanruan/api/data/open/BaseConnection.java new file mode 100644 index 0000000..95d8c0c --- /dev/null +++ b/src/main/java/com/fanruan/api/data/open/BaseConnection.java @@ -0,0 +1,51 @@ +package com.fanruan.api.data.open; + +import com.fanruan.api.util.ArrayKit; +import com.fr.data.impl.AbstractDatabaseConnection; +import com.fr.data.impl.Connection; + +/** + * @author richie + * @version 10.0 + * Created by richie on 2019-09-06 + * 用于数据连接插件的抽象类 + */ +public abstract class BaseConnection extends AbstractDatabaseConnection { + + /** + * 测试连接 + * + * @throws Exception 异常 + */ + @Override + public abstract void testConnection() throws Exception; + + /** + * 创建连接 + * + * @return 返回连接 + * @throws Exception 异常 + */ + @Override + public java.sql.Connection createConnection() throws Exception { + return Connection.IGNORE; + } + + /** + * 连接成功或失败时给出的信息 + * + * @return 信息 + */ + @Override + public abstract String connectMessage(boolean status); + + + /** + * 获取数据连接的摘要信息 + * + * @return 摘要 + */ + public String[] summary(String... args) { + return ArrayKit.EMPTY_STRING_ARRAY; + } +} From 056141604d2ff53eff0dc26e4509c582c8476a00 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Fri, 6 Sep 2019 11:55:52 +0800 Subject: [PATCH 32/38] =?UTF-8?q?KERNEL-1198=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/ParameterKit.java | 9 ---- .../fanruan/api/conf/ConfigurationKit.java | 51 ------------------- 2 files changed, 60 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/conf/ConfigurationKit.java diff --git a/src/main/java/com/fanruan/api/cal/ParameterKit.java b/src/main/java/com/fanruan/api/cal/ParameterKit.java index c1e1b68..388726f 100644 --- a/src/main/java/com/fanruan/api/cal/ParameterKit.java +++ b/src/main/java/com/fanruan/api/cal/ParameterKit.java @@ -135,13 +135,4 @@ public class ParameterKit { return parameters; } - - /** - * 将ParameterProvider转化为Parameter - * @param providers 需要转换的ParameterProvider - * @return 转换后的Parameter - */ - public static Parameter[] providers2Parameter(ParameterProvider[] providers) { - return Parameter.providers2Parameter(providers); - } } diff --git a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java b/src/main/java/com/fanruan/api/conf/ConfigurationKit.java deleted file mode 100644 index 43625ed..0000000 --- a/src/main/java/com/fanruan/api/conf/ConfigurationKit.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.fanruan.api.conf; - -import com.fr.config.ConfigContext; -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.WorkerFacade; - -/** - * @author richie - * @version 10.0 - * Created by richie on 2019-08-30 - * 配置监听管理器 - */ -public class ConfigurationKit { - - /** - * 注册监听配置变化的监听器 - * - * @param listener 监听器 - */ - public static void registerListener(ConfigChangeListener listener) { - ValidateProxy.getInstance().getValidateManager().registerListener(listener); - } - - /** - * 保存配置 - * - * @param type 配置的类型 - * @param action 保存动作 - */ - public static void modify(Class type, Runner action) { - Configurations.modify(new WorkerFacade(type) { - @Override - public void run() { - action.run(); - } - }); - } - - /** - * 返回config实例,且config实例只存在一个 - * @param configuration Configuration类 - * @param - * @return config实例 - */ - public static T getConfigInstance(final Class configuration) { - return ConfigContext.getConfigInstance(configuration); - } -} From 7d85ca16eec72f081d4b406a6587cbf45928183f Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 6 Sep 2019 15:40:20 +0800 Subject: [PATCH 33/38] collection --- .../java/com/fanruan/api/conf/HolderKit.java | 54 +++++++++++++------ 1 file changed, 37 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/fanruan/api/conf/HolderKit.java b/src/main/java/com/fanruan/api/conf/HolderKit.java index 6268e47..16b3ee4 100644 --- a/src/main/java/com/fanruan/api/conf/HolderKit.java +++ b/src/main/java/com/fanruan/api/conf/HolderKit.java @@ -5,6 +5,7 @@ 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.impl.ColConf; import java.util.Collection; import java.util.Map; @@ -16,11 +17,13 @@ import java.util.Map; * 配置对象操作类 * TODO:补充单元测试 */ +@SuppressWarnings("unchecked") public class HolderKit { /** * 初始化一个基本对象类型的配置 - * @param t 初始值 + * + * @param t 初始值 * @param 类型 * @return 配置对象 */ @@ -30,9 +33,10 @@ public class HolderKit { /** * 初始化一个对象类型的配置 - * @param t 初始值 + * + * @param t 初始值 * @param type 对象class类 - * @param 类型 + * @param 类型 * @return 配置对象 */ public static Conf obj(T t, Class type) { @@ -41,9 +45,10 @@ public class HolderKit { /** * 初始化一个集合类型的配置 + * * @param collection 初始值 - * @param type 对象class类型 - * @param 类型 + * @param type 对象class类型 + * @param 类型 * @return 配置对象 */ public static ObjectColConf> objCollection(Collection collection, Class type) { @@ -52,10 +57,11 @@ public class HolderKit { /** * 初始化一个集合类型的配置 + * * @param collection 初始值 - * @param type 对象class类型 - * @param order 是否是有序的配置 - * @param 类型 + * @param type 对象class类型 + * @param order 是否是有序的配置 + * @param 类型 * @return 配置对象 */ public static ObjectColConf> objCollection(Collection collection, Class type, boolean order) { @@ -64,11 +70,12 @@ public class HolderKit { /** * 初始化一个字典类型的配置 - * @param map 初始值 - * @param keyType 键class类型 + * + * @param map 初始值 + * @param keyType 键class类型 * @param valueType 值class类型 - * @param 键类型 - * @param 值类型 + * @param 键类型 + * @param 值类型 * @return 配置对象 */ public static ObjectMapConf> objMap(Map map, Class keyType, Class valueType) { @@ -77,15 +84,28 @@ public class HolderKit { /** * 初始化一个字典类型的配置 - * @param map 初始值 - * @param keyType 键class类型 + * + * @param map 初始值 + * @param keyType 键class类型 * @param valueType 值class类型 - * @param order 是否是有序配置 - * @param 键类型 - * @param 值类型 + * @param order 是否是有序配置 + * @param 键类型 + * @param 值类型 * @return 配置对象 */ public static ObjectMapConf> objMap(Map map, Class keyType, Class valueType, boolean order) { return new ObjectMapConf<>(map, keyType, valueType, order); } + + /** + * 初始化一个集合类型的配置 + * + * @param collection 集合 + * @param valueType 值类型 + * @param 类型 + * @return 配置对象 + */ + public static ColConf> collection(Collection collection, Class valueType) { + return new ColConf(collection, valueType); + } } From d77dbffebf653c6df3db8cef89136bec7190ac92 Mon Sep 17 00:00:00 2001 From: richie Date: Fri, 6 Sep 2019 16:00:56 +0800 Subject: [PATCH 34/38] =?UTF-8?q?ignore=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bce210c..71cf645 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ .idea/ target/ .DS_Store -.class_path +.classpath *.jar \ No newline at end of file From 3bc58139f8f40d92adbcd73348420df1b27fc977 Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Sat, 7 Sep 2019 08:36:18 +0800 Subject: [PATCH 35/38] =?UTF-8?q?KERNEL-1198=20=E5=8E=BB=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E4=BF=AE=E6=94=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/data/AbstractDataModel.java | 4 ---- .../api/data/AbstractDatabaseConnection.java | 4 ---- .../api/data/AbstractParameterTableData.java | 4 ---- .../com/fanruan/api/data/TableDataKit.java | 7 ------- .../com/fanruan/api/net/http/EntityKit.java | 21 ------------------- .../net/http/message/BasicNameValuePair.java | 9 -------- .../com/fanruan/api/util/ComparatorKit.java | 15 ------------- src/main/java/com/fanruan/api/xml/XmlKit.java | 7 ++++++- 8 files changed, 6 insertions(+), 65 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/data/AbstractDataModel.java delete mode 100644 src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java delete mode 100644 src/main/java/com/fanruan/api/data/AbstractParameterTableData.java delete mode 100644 src/main/java/com/fanruan/api/net/http/EntityKit.java delete mode 100644 src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java delete mode 100644 src/main/java/com/fanruan/api/util/ComparatorKit.java diff --git a/src/main/java/com/fanruan/api/data/AbstractDataModel.java b/src/main/java/com/fanruan/api/data/AbstractDataModel.java deleted file mode 100644 index 7ee273f..0000000 --- a/src/main/java/com/fanruan/api/data/AbstractDataModel.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.data; - -public abstract class AbstractDataModel extends com.fr.data.AbstractDataModel { -} diff --git a/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java b/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java deleted file mode 100644 index 925da74..0000000 --- a/src/main/java/com/fanruan/api/data/AbstractDatabaseConnection.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.data; - -public abstract class AbstractDatabaseConnection extends com.fr.data.impl.AbstractDatabaseConnection { -} diff --git a/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java b/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java deleted file mode 100644 index 23c1f05..0000000 --- a/src/main/java/com/fanruan/api/data/AbstractParameterTableData.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.fanruan.api.data; - -public abstract class AbstractParameterTableData extends com.fr.data.AbstractParameterTableData { -} diff --git a/src/main/java/com/fanruan/api/data/TableDataKit.java b/src/main/java/com/fanruan/api/data/TableDataKit.java index 90eacfb..955bc32 100644 --- a/src/main/java/com/fanruan/api/data/TableDataKit.java +++ b/src/main/java/com/fanruan/api/data/TableDataKit.java @@ -76,11 +76,4 @@ public class TableDataKit { TableDataConfig.getInstance().renameTableData(oldName, newName); } - /** - * 直接预览数据集,没有实际值和显示值 - * @param tableData 数据集 - */ - public static void previewTableData(TableData tableData) { - PreviewTablePane.previewTableData(tableData); - } } diff --git a/src/main/java/com/fanruan/api/net/http/EntityKit.java b/src/main/java/com/fanruan/api/net/http/EntityKit.java deleted file mode 100644 index d1d7b3f..0000000 --- a/src/main/java/com/fanruan/api/net/http/EntityKit.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.fanruan.api.net.http; - -import com.fr.third.org.apache.http.HttpEntity; -import com.fr.third.org.apache.http.ParseException; -import com.fr.third.org.apache.http.util.EntityUtils; - -import java.io.IOException; - -public class EntityKit { - /** - * 利用defaultCharset字符集将HttpEntity对象转化为String对象 - * @param entity 需要转化为String的HttpEntity对象 - * @param defaultCharset 传入的字符集 - * @return HttpEntity对象转化为的String对象 - * @throws IOException - * @throws ParseException - */ - public static String toString(HttpEntity entity, String defaultCharset) throws IOException, ParseException { - return EntityUtils.toString(entity, defaultCharset); - } -} diff --git a/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java b/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java deleted file mode 100644 index 82ffb80..0000000 --- a/src/main/java/com/fanruan/api/net/http/message/BasicNameValuePair.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.fanruan.api.net.http.message; -/** - * 键值对类 - */ -public class BasicNameValuePair extends com.fr.third.org.apache.http.message.BasicNameValuePair { - public BasicNameValuePair(String name, String value) { - super(name, value); - } -} diff --git a/src/main/java/com/fanruan/api/util/ComparatorKit.java b/src/main/java/com/fanruan/api/util/ComparatorKit.java deleted file mode 100644 index 39fddff..0000000 --- a/src/main/java/com/fanruan/api/util/ComparatorKit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.util; - -import com.fr.general.ComparatorUtils; - -public class ComparatorKit { - /** - * 比较两个Object对象是否相等 - * @param object1 第一个Object对象 - * @param object2 第二个Object对象 - * @return 相等返回True 不相等返回False - */ - public static boolean equals(Object object1, Object object2){ - return ComparatorUtils.equals(object1, object2); - } -} diff --git a/src/main/java/com/fanruan/api/xml/XmlKit.java b/src/main/java/com/fanruan/api/xml/XmlKit.java index bcc1ae0..dc2cfc1 100644 --- a/src/main/java/com/fanruan/api/xml/XmlKit.java +++ b/src/main/java/com/fanruan/api/xml/XmlKit.java @@ -4,7 +4,12 @@ import com.fr.data.core.DataCoreXmlUtils; import com.fr.data.impl.Connection; import com.fr.general.xml.GeneralXMLTools; import com.fr.stable.ParameterProvider; -import com.fr.stable.xml.*; +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.XMLPrintWriter; +import com.fr.stable.xml.StableXMLUtils; import java.io.InputStream; From c4076bda6c48e61712cf8f31e072f92b9d3164fb Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Sat, 7 Sep 2019 13:05:55 +0800 Subject: [PATCH 36/38] =?UTF-8?q?KERNEL-1198=20=E6=8C=89=E8=A6=81=E6=B1=82?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/data/TableDataKit.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/data/TableDataKit.java b/src/main/java/com/fanruan/api/data/TableDataKit.java index 955bc32..63a7d91 100644 --- a/src/main/java/com/fanruan/api/data/TableDataKit.java +++ b/src/main/java/com/fanruan/api/data/TableDataKit.java @@ -3,7 +3,6 @@ package com.fanruan.api.data; import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.api.TableDataAssist; -import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.file.TableDataConfig; import com.fr.script.Calculator; import com.fr.stable.script.CalculatorProvider; From fc36f997c76474ba8ae2d6ba81cce4d50f24b81f Mon Sep 17 00:00:00 2001 From: "Mars.Ma" Date: Mon, 9 Sep 2019 14:22:03 +0800 Subject: [PATCH 37/38] =?UTF-8?q?KERNEL-1198=20=E6=96=B0=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E7=9A=84=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/util/CodeKitTest.java | 14 +++++++ .../java/com/fanruan/api/xml/XmlKitTest.java | 38 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/test/java/com/fanruan/api/xml/XmlKitTest.java diff --git a/src/test/java/com/fanruan/api/util/CodeKitTest.java b/src/test/java/com/fanruan/api/util/CodeKitTest.java index 10853e6..5224324 100644 --- a/src/test/java/com/fanruan/api/util/CodeKitTest.java +++ b/src/test/java/com/fanruan/api/util/CodeKitTest.java @@ -1,5 +1,6 @@ package com.fanruan.api.util; +import com.fr.stable.CodeUtils; import com.fr.stable.CommonCodeUtils; import org.junit.Assert; import org.junit.Test; @@ -9,4 +10,17 @@ public class CodeKitTest { public void passwordDecode(String passwordText) { Assert.assertEquals(CodeKit.passwordDecode(passwordText), 123); } + + @Test + public void cjkDecode() { + String s = "中文 한글 日本語"; + String encode = CodeUtils.cjkEncode(s); + + try { + String decode = CodeKit.cjkDecode(encode); + Assert.assertTrue(s.equals(decode)); + } catch (Exception e) { + + } + } } diff --git a/src/test/java/com/fanruan/api/xml/XmlKitTest.java b/src/test/java/com/fanruan/api/xml/XmlKitTest.java new file mode 100644 index 0000000..2c33d4d --- /dev/null +++ b/src/test/java/com/fanruan/api/xml/XmlKitTest.java @@ -0,0 +1,38 @@ +package com.fanruan.api.xml; + +import com.fr.base.Parameter; +import com.fr.base.TableData; +import com.fr.plugin.db.json.core.JSONTableData; +import com.fr.stable.ParameterProvider; +import com.fr.stable.bridge.StableFactory; +import com.fr.stable.xml.StableXMLUtils; +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLUtils; +import com.fr.stable.xml.XMLableReader; +import com.fr.third.javax.xml.stream.XMLStreamException; +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class XmlKitTest { + + @Test + public void readParameter() { + try { + XMLableReader xml = XMLableReader.createXMLableReader("\n" + + "\n" + + "Tove\n" + + "Jani\n" + + "Reminder\n" + + "Don't forget me this weekend!\n" + + ""); + Parameter parameter = new Parameter("test", 1); + StableFactory.registerXMLDescription("Parameter",parameter); + Parameter p = (Parameter)XmlKit.readParameter(xml); + Assert.assertTrue(p.getName().equals("test")); + } catch (XMLStreamException e) { + e.printStackTrace(); + } + } +} \ No newline at end of file From 161ff0ba486182a12fe77cd3e031582d3eb33105 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 9 Sep 2019 17:10:00 +0800 Subject: [PATCH 38/38] =?UTF-8?q?=E9=94=99=E8=AF=AF=E7=9A=84import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/conf/HolderKit.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/fanruan/api/conf/HolderKit.java b/src/main/java/com/fanruan/api/conf/HolderKit.java index 16b3ee4..323ceb3 100644 --- a/src/main/java/com/fanruan/api/conf/HolderKit.java +++ b/src/main/java/com/fanruan/api/conf/HolderKit.java @@ -1,11 +1,11 @@ package com.fanruan.api.conf; +import com.fanruan.api.conf.impl.ColConf; import com.fanruan.api.conf.impl.ObjConf; 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.impl.ColConf; import java.util.Collection; import java.util.Map;