From 0d7f2c59e57d6ae6d26eb4ab1a2b33e8916ef4e5 Mon Sep 17 00:00:00 2001 From: Kalven Date: Tue, 27 Aug 2019 09:55:43 +0800 Subject: [PATCH] =?UTF-8?q?KERNEL-1117=20=E6=94=B9=E5=8F=98=E4=BA=86baseki?= =?UTF-8?q?t=E5=92=8CGUICoreKit=E7=9A=84=E4=BD=8D=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E4=BA=86=E4=B9=8B=E5=89=8D=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/design/util/GUICoreKit.java | 24 +++++++++++++++++++ .../java/com/fanruan/api/util/ArrayKit.java | 10 ++++++++ .../java/com/fanruan/api/util/GeneralKit.java | 15 ++++++++++++ .../java/com/fanruan/api/util/StableKit.java | 16 +++++++++++++ .../com/fanruan/api/util/TemplateKit.java | 19 +++++++++++++++ .../com/fanruan/api/util/GeneralKitTest.java | 15 +++++++++++- .../com/fanruan/api/util/StableKitTest.java | 14 +++++++++++ 7 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/fanruan/api/design/util/GUICoreKit.java create mode 100644 src/main/java/com/fanruan/api/util/StableKit.java create mode 100644 src/main/java/com/fanruan/api/util/TemplateKit.java create mode 100644 src/test/java/com/fanruan/api/util/StableKitTest.java diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java new file mode 100644 index 0000000..8a99ddf --- /dev/null +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -0,0 +1,24 @@ +package com.fanruan.api.design.util; + +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; + +public class GUICoreKit { + + public static JPanel createFlowPane(Object... var0) { + return GUICoreUtils.createFlowPane(var0); + } + + /** + * 弹出菜单,在坐标为x,y处弹出内容为component的菜单 + * @param menu + * @param component + * @param x + * @param y + */ + public static void showPopupMenu(JPopupMenu menu, Component component, int x, int y) { + GUICoreUtils.showPopupMenu(menu, component, x, y); + } +} diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index 2a3d1b2..3eb9b75 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -82,4 +82,14 @@ public class ArrayKit { * @return 返回增加元素后的数组 */ public static T[] addAll(T[] array, T... element){return ArrayUtils.addAll(array, element);}; + + /** + * 判断数组是否为不空 + * @param array + * @param + * @return 若数组array不空返回true,否则返回false + */ + public static boolean isNotEmpty(T[] array) { + return ArrayUtils.isNotEmpty(array); + } } diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index f5e328e..2b470b7 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.util; +import com.fr.general.ComparatorUtils; import com.fr.general.GeneralUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -50,7 +51,21 @@ public class GeneralKit { return GeneralUtils.objectToNumber(obj, returnNull); } + /** + * 读取jar的版本号 + * @return 返回jar版本号 + */ public static @Nullable String readBuildNO() { return GeneralUtils.readBuildNO(); } + + /** + * 返回两个对象比较的大小 + * @param obj1 + * @param obj2 + * @return 若相等返回0,obj1小于obj2返回负数,否则返回正数 + */ + public static int compare(Object obj1, Object obj2) { + return ComparatorUtils.compare(obj1, obj2); + } } 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..112339e --- /dev/null +++ b/src/main/java/com/fanruan/api/util/StableKit.java @@ -0,0 +1,16 @@ +package com.fanruan.api.util; + +import com.fr.stable.StableUtils; + +public class StableKit { + + /** + * 判断class1是否是class2的子类实例化 + * @param class1 + * @param class2 + * @return 返回判断结果 + */ + public static boolean classInstanceOf(Class class1, Class class2) { + return StableUtils.classInstanceOf(class1, class2); + } +} 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..e8704fe --- /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 map + * @return 返回计算后的值 + * @throws Exception + */ + public static String renderParameter4Tpl(String tpl, Map map) throws Exception { + return TemplateUtils.renderParameter4Tpl(tpl, map); + } +} diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 84b8e23..1383740 100644 --- a/src/test/java/com/fanruan/api/util/GeneralKitTest.java +++ b/src/test/java/com/fanruan/api/util/GeneralKitTest.java @@ -1,6 +1,8 @@ package com.fanruan.api.util; import com.fanruan.api.Prepare; +import com.fr.general.GeneralUtils; +import com.fr.third.javax.persistence.criteria.CriteriaBuilder; import org.junit.Assert; import org.junit.Test; @@ -24,7 +26,18 @@ public class GeneralKitTest extends Prepare { @Test public void readBuildNO() { - Assert.assertEquals(GeneralKit.readBuildNO(), com.fr.general.GeneralUtils.readBuildNO()); + Assert.assertEquals(GeneralKit.readBuildNO(), GeneralUtils.readBuildNO()); } + + @Test + public void compare() { + Integer s = new Integer(1); + Integer s3 = new Integer(1); + Integer s1 = new Integer(2); + Integer s2 = new Integer(0); + Assert.assertEquals(GeneralKit.compare(s,s1),-1); + Assert.assertEquals(GeneralKit.compare(s,s3),0); + Assert.assertEquals(GeneralKit.compare(s,s2),1); + } } \ 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..cb470b7 --- /dev/null +++ b/src/test/java/com/fanruan/api/util/StableKitTest.java @@ -0,0 +1,14 @@ +package com.fanruan.api.util; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class StableKitTest { + + @Test + public void classInstanceOf() { + assertEquals(StableKit.classInstanceOf(Integer.class,Object.class),true); + assertEquals(StableKit.classInstanceOf(Object.class,Integer.class),false); + } +} \ No newline at end of file