From 6742d1e06cd93f8a17da1eed4443fe27f13ae6a6 Mon Sep 17 00:00:00 2001 From: Kalven Date: Wed, 4 Sep 2019 17:53:42 +0800 Subject: [PATCH] =?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