From 34ba599b1c9a329a1f08412915b6504f70dea53f Mon Sep 17 00:00:00 2001 From: lucian Date: Thu, 26 Mar 2020 09:21:25 +0800 Subject: [PATCH 1/5] =?UTF-8?q?KERNEL-3521=20=E6=B7=BB=E5=8A=A0FineKit?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/formula/Formula.java | 16 + .../fanruan/api/cluster/ClusterBridgeKit.java | 22 + .../fanruan/api/cluster/state/MachineKit.java | 19 + .../api/concurrent/NamedThreadFactory.java | 20 + .../com/fanruan/api/conf/xml/XmlColConf.java | 30 ++ .../com/fanruan/api/conf/xml/XmlConf.java | 22 + .../fanruan/api/conf/xml/XmlHolderKit.java | 17 +- .../com/fanruan/api/decision/CommonKit.java | 12 + .../decision/monitor/RuntimeMemScoreKit.java | 26 ++ .../api/decision/store/StateHubManager.java | 10 + .../mainframe/HyperlinkGroupPaneAction.java | 17 + .../api/design/ui/component/UIHeadGroup.java | 22 + .../design/ui/component/UIRadioButton.java | 44 ++ .../table/model/DesignModelAdapter.java | 19 + .../ui/table/AbstractPropertyTable.java | 12 + .../fanruan/api/design/util/GUICoreKit.java | 18 + .../design/work/FormHyperlinkGroupPane.java | 14 + .../api/design/work/SelectImagePane.java | 18 + .../api/design/work/WidgetPropertyPane.java | 419 ++++++++++++++++++ .../api/image/general/ImageWithSuffix.java | 18 + .../fanruan/api/report/cell/CellImage.java | 9 + .../fanruan/api/report/cell/FloatElement.java | 22 + .../java/com/fanruan/api/util/ArrayKit.java | 4 + .../java/com/fanruan/api/util/AssistKit.java | 18 + .../fanruan/api/util/FineCollectionKit.java | 19 + .../java/com/fanruan/api/util/GeneralKit.java | 10 + .../java/com/fanruan/api/util/HyperKit.java | 39 ++ .../api/cluster/ClusterBridgeKitTest.java | 50 +++ .../api/cluster/state/MachineKitTest.java | 44 ++ .../api/conf/xml/XmlHolderKitTest.java | 62 +++ .../fanruan/api/decision/CommonKitTest.java | 59 +++ .../monitor/RuntimeMemScoreKitTest.java | 28 ++ .../com/fanruan/api/util/ArrayKitTest.java | 12 + .../com/fanruan/api/util/AssistKitTest.java | 17 + .../api/util/FineCollectionKitTest.java | 23 + .../com/fanruan/api/util/GeneralKitTest.java | 7 + .../com/fanruan/api/util/HyperKitTest.java | 62 +++ 37 files changed, 1275 insertions(+), 5 deletions(-) create mode 100644 src/main/java/com/fanruan/api/cal/formula/Formula.java create mode 100644 src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java create mode 100644 src/main/java/com/fanruan/api/cluster/state/MachineKit.java create mode 100644 src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java create mode 100644 src/main/java/com/fanruan/api/conf/xml/XmlColConf.java create mode 100644 src/main/java/com/fanruan/api/conf/xml/XmlConf.java create mode 100644 src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java create mode 100644 src/main/java/com/fanruan/api/decision/store/StateHubManager.java create mode 100644 src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIHeadGroup.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/UIRadioButton.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java create mode 100644 src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java create mode 100644 src/main/java/com/fanruan/api/design/work/FormHyperlinkGroupPane.java create mode 100644 src/main/java/com/fanruan/api/design/work/SelectImagePane.java create mode 100644 src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java create mode 100644 src/main/java/com/fanruan/api/image/general/ImageWithSuffix.java create mode 100644 src/main/java/com/fanruan/api/report/cell/CellImage.java create mode 100644 src/main/java/com/fanruan/api/report/cell/FloatElement.java create mode 100644 src/main/java/com/fanruan/api/util/FineCollectionKit.java create mode 100644 src/main/java/com/fanruan/api/util/HyperKit.java create mode 100644 src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java create mode 100644 src/test/java/com/fanruan/api/cluster/state/MachineKitTest.java create mode 100644 src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java create mode 100644 src/test/java/com/fanruan/api/decision/CommonKitTest.java create mode 100644 src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/FineCollectionKitTest.java create mode 100644 src/test/java/com/fanruan/api/util/HyperKitTest.java diff --git a/src/main/java/com/fanruan/api/cal/formula/Formula.java b/src/main/java/com/fanruan/api/cal/formula/Formula.java new file mode 100644 index 0000000..461ed8e --- /dev/null +++ b/src/main/java/com/fanruan/api/cal/formula/Formula.java @@ -0,0 +1,16 @@ +package com.fanruan.api.cal.formula; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class Formula extends com.fr.base.Formula { + public Formula() { + super(); + } + + public Formula(String content) { + super(content); + } +} diff --git a/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java b/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java new file mode 100644 index 0000000..218b226 --- /dev/null +++ b/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java @@ -0,0 +1,22 @@ +package com.fanruan.api.cluster; + +import com.fr.cluster.ClusterBridge; +import com.fr.cluster.core.ClusterView; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class ClusterBridgeKit { + + public static ClusterView getView() { + return ClusterBridge.getView(); + } + + public static boolean isClusterMode() { + return ClusterBridge.isClusterMode(); + } + + +} diff --git a/src/main/java/com/fanruan/api/cluster/state/MachineKit.java b/src/main/java/com/fanruan/api/cluster/state/MachineKit.java new file mode 100644 index 0000000..ddcee03 --- /dev/null +++ b/src/main/java/com/fanruan/api/cluster/state/MachineKit.java @@ -0,0 +1,19 @@ +package com.fanruan.api.cluster.state; + +import com.fr.cluster.engine.core.jchannel.MachineMarker; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class MachineKit { + + public static String currentID() { + return MachineMarker.currentID(); + } + + public static String currentName() { + return MachineMarker.currentName(); + } +} diff --git a/src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java b/src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java new file mode 100644 index 0000000..915b430 --- /dev/null +++ b/src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java @@ -0,0 +1,20 @@ +package com.fanruan.api.concurrent; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class NamedThreadFactory extends com.fr.concurrent.NamedThreadFactory { + public NamedThreadFactory(Class aClass) { + super(aClass); + } + + public NamedThreadFactory(String s) { + super(s); + } + + public NamedThreadFactory(String s, boolean b) { + super(s, b); + } +} diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java b/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java new file mode 100644 index 0000000..caf9405 --- /dev/null +++ b/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java @@ -0,0 +1,30 @@ +package com.fanruan.api.conf.xml; + +import java.util.Collection; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class XmlColConf extends com.fr.config.holder.impl.xml.XmlColConf { + public XmlColConf(String s, Collection collection, Class aClass) { + super(s, collection, aClass); + } + + public XmlColConf(Collection collection, Class aClass) { + super(collection, aClass); + } + + public XmlColConf(Collection collection, Class aClass, boolean b) { + super(collection, aClass, b); + } + + public XmlColConf(Collection collection, Class aClass, String s) { + super(collection, aClass, s); + } + + public XmlColConf(Collection collection, Class aClass, String s, boolean b) { + super(collection, aClass, s, b); + } +} diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlConf.java b/src/main/java/com/fanruan/api/conf/xml/XmlConf.java new file mode 100644 index 0000000..27d83e0 --- /dev/null +++ b/src/main/java/com/fanruan/api/conf/xml/XmlConf.java @@ -0,0 +1,22 @@ +package com.fanruan.api.conf.xml; + +import com.fr.stable.xml.XMLable; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class XmlConf extends com.fr.config.holder.impl.xml.XmlConf { + public XmlConf(String s, XMLable xmLable, Class aClass) { + super(s, xmLable, aClass); + } + + public XmlConf(XMLable xmLable, Class aClass) { + super(xmLable, aClass); + } + + public XmlConf(XMLable xmLable, Class aClass, String s) { + super(xmLable, aClass, s); + } +} diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java index 85c156d..d0059b3 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java +++ b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java @@ -1,9 +1,8 @@ package com.fanruan.api.conf.xml; -import com.fr.config.holder.Conf; -import com.fr.config.holder.impl.xml.XmlConf; import com.fr.stable.xml.XMLable; +import java.util.Collection; /** * @author richie * @version 10.0 @@ -14,13 +13,21 @@ public class XmlHolderKit { /** * 创建一个要写入配置的xml多项 + * @param 类型 * @param t 配置对象 * @param clazz 类型 * @param xmlTag xml标签 - * @param 类型 * @return 配置对象 */ - public static Conf obj(T t, Class clazz, String xmlTag) { - return new XmlConf(t, clazz, xmlTag); + public static XmlConf obj(T t, Class clazz, String xmlTag) { + return new XmlConf(t, clazz, xmlTag); + } + + public static XmlColConf> collection(Collection t, Class clazz) { + return collection(t,clazz,true); + } + + public static XmlColConf> collection(Collection t, Class clazz, boolean order) { + return new XmlColConf>(t, clazz, order); } } diff --git a/src/main/java/com/fanruan/api/decision/CommonKit.java b/src/main/java/com/fanruan/api/decision/CommonKit.java index a0c49a7..61ef66f 100644 --- a/src/main/java/com/fanruan/api/decision/CommonKit.java +++ b/src/main/java/com/fanruan/api/decision/CommonKit.java @@ -7,6 +7,7 @@ import com.fr.base.ServerConfig; import com.fr.decision.webservice.utils.DecisionServiceConstants; import com.fr.stable.StringUtils; +import java.awt.Image; /** * @author richie * @version 10.0 @@ -51,4 +52,15 @@ public class CommonKit { return StringKit.EMPTY; } + + /** + * 将图片对象用指定的格式输出成base64编码表示的字符串 + * + * @param im 图片对象 + * @param format 要输出的格式 + * @return 表示图片的base64编码的字符串 + */ + public static String encode(Image im, String format) { + return Base64.encode(im, format); + } } diff --git a/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java b/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java new file mode 100644 index 0000000..3e1d929 --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java @@ -0,0 +1,26 @@ +package com.fanruan.api.decision.monitor; + +import com.fr.decision.system.monitor.gc.load.RuntimeMemScoreProvider; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class RuntimeMemScoreKit { + + //计算中止分值 + public static int getBalancePromoterScore() { + return RuntimeMemScoreProvider.getBalancePromoterScore(); + } + + //释放会话分值 + public static int getReleasePromoterScore() { + return RuntimeMemScoreProvider.getReleasePromoterScore(); + } + + //分发得分 + public static int getLoadScore() { + return RuntimeMemScoreProvider.getLoadScore(); + } +} diff --git a/src/main/java/com/fanruan/api/decision/store/StateHubManager.java b/src/main/java/com/fanruan/api/decision/store/StateHubManager.java new file mode 100644 index 0000000..b6da07d --- /dev/null +++ b/src/main/java/com/fanruan/api/decision/store/StateHubManager.java @@ -0,0 +1,10 @@ +package com.fanruan.api.decision.store; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class StateHubManager extends com.fr.store.StateHubManager { + +} diff --git a/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java b/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java new file mode 100644 index 0000000..83f82e6 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java @@ -0,0 +1,17 @@ +package com.fanruan.api.design.mainframe; + +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class HyperlinkGroupPaneAction { + public static HyperlinkGroupPaneActionProvider getInstance() { + + return HyperlinkGroupPaneActionImpl.getInstance(); + } + +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIHeadGroup.java b/src/main/java/com/fanruan/api/design/ui/component/UIHeadGroup.java new file mode 100644 index 0000000..6e677dd --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIHeadGroup.java @@ -0,0 +1,22 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.Icon; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class UIHeadGroup extends com.fr.design.gui.ibutton.UIHeadGroup { + public UIHeadGroup(String[] strings) { + super(strings); + } + + public UIHeadGroup(Icon[] icons) { + super(icons); + } + + public UIHeadGroup(Icon[] icons, String[] strings) { + super(icons, strings); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/UIRadioButton.java b/src/main/java/com/fanruan/api/design/ui/component/UIRadioButton.java new file mode 100644 index 0000000..c7d04e7 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/UIRadioButton.java @@ -0,0 +1,44 @@ +package com.fanruan.api.design.ui.component; + +import javax.swing.Action; +import javax.swing.Icon; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/20 + */ +public class UIRadioButton extends com.fr.design.gui.ibutton.UIRadioButton { + + public UIRadioButton() { + super(); + } + + public UIRadioButton(Icon icon) { + super(icon); + } + + public UIRadioButton(Action action) { + super(action); + } + + public UIRadioButton(Icon icon, boolean selected) { + super(icon, selected); + } + + public UIRadioButton(String text) { + super(text); + } + + public UIRadioButton(String text, boolean selected) { + super(text, selected); + } + + public UIRadioButton(String text, Icon icon) { + super(text, icon); + } + + public UIRadioButton(String text, Icon icon, boolean selected) { + super(text, icon, selected); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java new file mode 100644 index 0000000..e4c30c6 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java @@ -0,0 +1,19 @@ +package com.fanruan.api.design.ui.component.table.model; + +import com.fr.base.io.BaseBook; +import com.fr.design.mainframe.JTemplateProvider; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public abstract class DesignModelAdapter> extends com.fr.design.DesignModelAdapter { + public DesignModelAdapter(JTemplateProvider jTemplateProvider) { + super(jTemplateProvider); + } + + public static DesignModelAdapter getCurrentModelAdapter() { + return DesignModelAdapter.getCurrentModelAdapter(); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java b/src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java new file mode 100644 index 0000000..83d79e4 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java @@ -0,0 +1,12 @@ +package com.fanruan.api.design.ui.table; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public abstract class AbstractPropertyTable extends com.fr.design.gui.itable.AbstractPropertyTable { + public AbstractPropertyTable() { + super(); + } +} diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java index e9ea44a..5d34633 100644 --- a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -121,6 +121,24 @@ public class GUICoreKit { return FRGUIPaneFactory.createBorderLayout_S_Pane(); } + /** + * 创建纵向内置boxlayout的面板 + * + * @return JPanel对象 + */ + public static JPanel createYAXISBoxInnerContainerPane() { + return FRGUIPaneFactory.createY_AXISBoxInnerContainer_S_Pane(); + } + + /** + * 创建一个边框布局 + * + * @return BorderLayout对象 + */ + public static LayoutManager createBorderLayout() { + return FRGUIPaneFactory.createBorderLayout(); + } + /** * 设置一个窗口居中 */ diff --git a/src/main/java/com/fanruan/api/design/work/FormHyperlinkGroupPane.java b/src/main/java/com/fanruan/api/design/work/FormHyperlinkGroupPane.java new file mode 100644 index 0000000..2b51844 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/FormHyperlinkGroupPane.java @@ -0,0 +1,14 @@ +package com.fanruan.api.design.work; + +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class FormHyperlinkGroupPane extends com.fr.design.gui.xpane.FormHyperlinkGroupPane { + protected FormHyperlinkGroupPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) { + super(hyperlinkGroupPaneActionProvider); + } +} diff --git a/src/main/java/com/fanruan/api/design/work/SelectImagePane.java b/src/main/java/com/fanruan/api/design/work/SelectImagePane.java new file mode 100644 index 0000000..07f1e10 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/SelectImagePane.java @@ -0,0 +1,18 @@ +package com.fanruan.api.design.work; + +import com.fanruan.api.report.cell.CellImage; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class SelectImagePane extends com.fr.design.report.SelectImagePane { + public SelectImagePane() { + super(); + } + + public CellImage update() { + return (CellImage) super.update(); + } +} diff --git a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java b/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java new file mode 100644 index 0000000..5c5d39a --- /dev/null +++ b/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java @@ -0,0 +1,419 @@ +package com.fanruan.api.design.work; + +import com.fanruan.api.design.ui.component.UIHeadGroup; +import com.fanruan.api.design.ui.component.UILabel; +import com.fanruan.api.design.ui.container.UIScrollPane; +import com.fanruan.api.design.ui.table.AbstractPropertyTable; +import com.fanruan.api.design.util.GUICoreKit; +import com.fanruan.api.util.ArrayKit; +import com.fanruan.api.util.IOKit; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.constants.UIConstants; +import com.fr.design.designer.beans.events.DesignerEditListener; +import com.fr.design.designer.beans.events.DesignerEvent; +import com.fr.design.designer.creator.XComponent; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XCreatorUtils; +import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.XWFitLayout; +import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.properties.EventPropertyTable; +import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; +import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; +import com.fr.design.fun.WidgetPropertyUIProvider; +import com.fr.design.mainframe.BaseFormDesigner; +import com.fr.design.mainframe.BaseWidgetPropertyPane; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.FormDockView; +import com.fr.design.mainframe.FormSelection; +import com.fr.design.mainframe.widget.ui.FormWidgetCardPane; +import com.fr.design.widget.ui.designer.mobile.MobileWidgetDefinePane; + +import javax.swing.*; +import java.awt.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +/** + * 控件属性表绘制 + * Modified by fanglei + */ +public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane { + + private static final int PADDING = 10; + private static final int PADDING_M = 12; + private FormWidgetCardPane formWidgetCardPane; // 控件的属性表 + private EventPropertyTable eventTable; // 控件的事件表 + private List widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab + private List mobileExtraPropertyPanes; // 保存9.0设计器下移动端拓展的属性tab,舍弃JTable + private FormDesigner designer; // 当前designer + private UIScrollPane psp; // 用来装载属性表table的容器 + private JPanel wsp; // 装载移动端tab的容器,包括移动端属性表和控件拓展的移动端属性表 + private UIHeadGroup tabsHeaderIconPane; + private XComponent lastAffectedCreator; + + + public static WidgetPropertyPane getInstance() { + if (HOLDER.singleton == null) { + HOLDER.singleton = new WidgetPropertyPane(); + } + return HOLDER.singleton; + } + + public static WidgetPropertyPane getInstance(FormDesigner formEditor) { + HOLDER.singleton.setEditingFormDesigner(formEditor); + HOLDER.singleton.refreshDockingView(); + return HOLDER.singleton; + } + + private static class HOLDER { + private static WidgetPropertyPane singleton = new WidgetPropertyPane(); + } + + private WidgetPropertyPane() { + setLayout(GUICoreKit.createBorderLayout()); + } + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Control_Setting"); + } + + + @Override + public String getViewTitle() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Property_Table"); + } + + @Override + public Icon getViewIcon() { + return IOKit.readIcon("/com/fr/design/images/m_report/attributes.png"); + } + + @Override + /** + * 绘制属性表tab + */ + public void refreshDockingView() { + designer = this.getEditingFormDesigner(); + removeAll(); + if (designer == null) { + clearDockingView(); + return; + } + widgetPropertyTables = new ArrayList(); + mobileExtraPropertyPanes = new ArrayList<>(); + + //依次创建属性表、事件表、移动端表,再将它们整合到TabPane中去 + this.createPropertyTable(); + this.createEventTable(); + this.createMobileWidgetTable(); + this.createTabPane(); + + this.initTables(); + } + + /** + * 初始化属性表,事件表,移动端拓展的属性表 + */ + private void initTables() { + formWidgetCardPane.populate(); + eventTable.refresh(); + + if (mobileExtraPropertyPanes != null) { + for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { + extraPane.initPropertyGroups(designer); + } + } + if (widgetPropertyTables != null) { + for (AbstractPropertyTable propertyTable : widgetPropertyTables) { + propertyTable.initPropertyGroups(designer); + } + } + } + + /** + * 创建属性表table + */ + private void createPropertyTable() { + formWidgetCardPane = new FormWidgetCardPane(designer); + designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); + psp = new UIScrollPane(formWidgetCardPane); // 用来装载属性表table + psp.setBorder(null); + } + + /** + * 创建事件表(事件选项卡不是JTable) + */ + private void createEventTable() { + eventTable = new EventPropertyTable(designer); + designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); + } + + /** + * 创建移动端控件列表 + */ + private void createMobileWidgetTable() { + //加上表头后,这里不再使用borderLayout布局,而采用BoxLayout布局 + wsp = GUICoreKit.createYAXISBoxInnerContainerPane(); + wsp.setBorder(null); + designer.addDesignerEditListener(new MobileWidgetDesignerAdapter()); + + //获取拓展移动端属性tab + WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); + addWidgetAttr(widgetAttrProviders); + } + + /** + * 将属性表,事件表,移动端控件列表整合到TabPane里面去 + */ + private void createTabPane() { + initTabPane(); + } + + /** + * 获取当前控件扩展的属性tab + * 来源有两个: + * 1, 各个控件从各自的Xcreator里扩展(例如手机重布局的tab就是从Xcreator中扩展的); + * 2, 所有的控件从插件里扩展. + * + * @return 扩展的tab + */ + private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() { + FormSelection selection = designer.getSelectionModel().getSelection(); + WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null; + XCreator xCreator = selection.getSelectedCreator(); + if (selection != null && xCreator != null) { + embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); + if(!designer.getDesignerMode().isFormParameterEditor()) { + if (!xCreator.acceptType(XWAbsoluteLayout.class, XWFitLayout.class)) { + embeddedPropertyUIProviders = ArrayKit.insert(0, embeddedPropertyUIProviders, new MobileBookMarkPropertyUI(xCreator)); + } + if (xCreator.supportMobileStyle()) { + embeddedPropertyUIProviders = ArrayKit.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator)); + } + } + } + Set set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); + return ArrayKit.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()])); + } + + /** + * 判断是将拓展的tab放入属性表还是将原来的tab放入属性表 + * + * @param widgetAttrProviders 拓展的tab + */ + private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) { + if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,提示"无可用配置项" + wsp.add(getUnavailablePane()); + } else { + for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { + MobileWidgetDefinePane extraPane = (MobileWidgetDefinePane) widgetAttrProvider.createWidgetAttrPane(); + if (extraPane != null) { + extraPane.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING_M)); + mobileExtraPropertyPanes.add(extraPane); + wsp.add(extraPane); + } + AbstractPropertyTable propertyTable = (AbstractPropertyTable) widgetAttrProvider.createWidgetAttrTable(); + if (propertyTable != null) { + widgetPropertyTables.add(propertyTable); + designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); + + UIScrollPane uiScrollPane = new UIScrollPane(propertyTable); + wsp.add(uiScrollPane); + } + } + } + } + + // "无可用配置项"面板 + private JPanel getUnavailablePane() { + JPanel panel = GUICoreKit.createBorderLayoutPane(); + UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No_Settings_Available")); + label.setHorizontalAlignment(SwingConstants.CENTER); + panel.add(label); + return panel; + } + + private void initTabPane() { + final String[] tabTitles = new String[]{ + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"), + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal") + }; + final CardLayout tabbedPane = new CardLayout(); + final JPanel center = new JPanel(tabbedPane); + center.add(formWidgetCardPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties")); + center.add(eventTable, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event")); + center.add(wsp, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal")); + this.add(center, BorderLayout.CENTER); + + tabsHeaderIconPane = new UIHeadGroup(tabTitles) { + @Override + public void tabChanged(int index) { + //切换的时候再populate + if (index == 1) { + eventTable.populateNameObjects(); + } else if (index == 2) { + if (mobileExtraPropertyPanes != null) { + for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { + extraPane.populate(designer); + } + } + } + tabbedPane.show(center, tabTitles[index]); + } + }; + tabsHeaderIconPane.setNeedLeftRightOutLine(true); + tabsHeaderIconPane.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.SHADOW_GREY)); + this.add(tabsHeaderIconPane, BorderLayout.NORTH); + } + + + /** + * 选中的组件是否在参数面板里 + * + * @param designer 设计器 + * @return 是则返回true + */ + public boolean hasSelectParaPane(FormDesigner designer) { + XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); + if (xCreator == null) { + xCreator = designer.getRootComponent(); + } + XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); + + boolean xCreatorAccept = xCreator.acceptType(XWParameterLayout.class); + boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); + + return xCreatorAccept || containerAccept; + } + + @Override + public void setEditingFormDesigner(BaseFormDesigner editor) { + FormDesigner fd = (FormDesigner) editor; + super.setEditingFormDesigner(fd); + } + + private void clearDockingView() { + formWidgetCardPane = null; + eventTable = null; + if (widgetPropertyTables != null) { + widgetPropertyTables.clear(); + } + JScrollPane psp = new JScrollPane(); + psp.setBorder(null); + this.add(psp, BorderLayout.CENTER); + } + + /** + * 属性表监听界面事件(编辑,删除,选中,改变大小) + */ + private class WidgetPropertyDesignerAdapter implements DesignerEditListener { + FormWidgetCardPane formWidgetCardPane; + + + WidgetPropertyDesignerAdapter(FormWidgetCardPane formWidgetCardPane) { + this.formWidgetCardPane = formWidgetCardPane; + } + + @Override + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED + || evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { + formWidgetCardPane.populate(); + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + // 防止多次触发 + if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { + return; + } + lastAffectedCreator = evt.getAffectedCreator(); + refreshDockingView(); + formWidgetCardPane.populate(); + } + } + + @Override + public boolean equals(Object o) { + return o instanceof WidgetPropertyDesignerAdapter; + } + } + + /** + * 事件表监听界面事件(编辑,选中) + */ + private class EventPropertyDesignerAdapter implements DesignerEditListener { + EventPropertyTable propertyTable; + + EventPropertyDesignerAdapter(EventPropertyTable eventTable) { + this.propertyTable = eventTable; + } + + @Override + public void fireCreatorModified(DesignerEvent evt) { + if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) { + propertyTable.refresh(); + } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + // 防止多次触发 + if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { + return; + } + lastAffectedCreator = evt.getAffectedCreator(); + propertyTable.refresh(); + } + } + + @Override + public boolean equals(Object o) { + return o instanceof EventPropertyDesignerAdapter; + } + } + + /** + * 移动端属性表监听界面事件(改变大小,编辑,选中,增加控件) + */ + private class MobileWidgetDesignerAdapter implements DesignerEditListener { + + MobileWidgetDesignerAdapter() { + } + + /** + * 响应界面改变事件 + * + * @param evt 事件 + */ + public void fireCreatorModified(DesignerEvent evt) { + int[] validEventIds = {DesignerEvent.CREATOR_RESIZED, DesignerEvent.CREATOR_EDITED, + DesignerEvent.CREATOR_SELECTED, DesignerEvent.CREATOR_ADDED, DesignerEvent.CREATOR_ORDER_CHANGED}; + boolean isValid = false; + for (int validEventId : validEventIds) { + if (evt.getCreatorEventID() == validEventId) { + isValid = true; + break; + } + } + if (!isValid) { + return; + } + + if (mobileExtraPropertyPanes != null) { + for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { + extraPane.populate(designer); + } + } + + } + + @Override + public boolean equals(Object o) { + return o instanceof MobileWidgetDesignerAdapter; + } + } + + @Override + public Location preferredLocation() { + return Location.WEST_BELOW; + } +} diff --git a/src/main/java/com/fanruan/api/image/general/ImageWithSuffix.java b/src/main/java/com/fanruan/api/image/general/ImageWithSuffix.java new file mode 100644 index 0000000..4b479bd --- /dev/null +++ b/src/main/java/com/fanruan/api/image/general/ImageWithSuffix.java @@ -0,0 +1,18 @@ +package com.fanruan.api.image.general; + +import java.awt.Image; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class ImageWithSuffix extends com.fr.general.ImageWithSuffix { + public ImageWithSuffix(Image image, String format) { + super(image, format); + } + + public ImageWithSuffix(Image image) { + super(image); + } +} diff --git a/src/main/java/com/fanruan/api/report/cell/CellImage.java b/src/main/java/com/fanruan/api/report/cell/CellImage.java new file mode 100644 index 0000000..91dff68 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/cell/CellImage.java @@ -0,0 +1,9 @@ +package com.fanruan.api.report.cell; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class CellImage extends com.fr.report.cell.cellattr.CellImage { +} diff --git a/src/main/java/com/fanruan/api/report/cell/FloatElement.java b/src/main/java/com/fanruan/api/report/cell/FloatElement.java new file mode 100644 index 0000000..e81ca96 --- /dev/null +++ b/src/main/java/com/fanruan/api/report/cell/FloatElement.java @@ -0,0 +1,22 @@ +package com.fanruan.api.report.cell; + +import com.fr.stable.unit.UNIT; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class FloatElement extends com.fr.report.cell.FloatElement { + public FloatElement() { + super(); + } + + public FloatElement(Object value) { + super(value); + } + + public FloatElement(UNIT leftDistance, UNIT topDistance, UNIT width, UNIT height, Object value) { + super(leftDistance, topDistance, width, height, value); + } +} diff --git a/src/main/java/com/fanruan/api/util/ArrayKit.java b/src/main/java/com/fanruan/api/util/ArrayKit.java index ac62c64..e5d71f2 100644 --- a/src/main/java/com/fanruan/api/util/ArrayKit.java +++ b/src/main/java/com/fanruan/api/util/ArrayKit.java @@ -120,4 +120,8 @@ public class ArrayKit { public static int getLength(Object array) { return ArrayUtils.getLength(array); } + + public static T[] insert(final int index, final T[] array, final T... values) { + return ArrayUtils.insert(index, array, values); + } } diff --git a/src/main/java/com/fanruan/api/util/AssistKit.java b/src/main/java/com/fanruan/api/util/AssistKit.java index 4f52ac3..55fc0bf 100644 --- a/src/main/java/com/fanruan/api/util/AssistKit.java +++ b/src/main/java/com/fanruan/api/util/AssistKit.java @@ -23,6 +23,24 @@ public class AssistKit { return AssistUtils.equals(parm1, parm2); } + /** + * 判断 float 类型是否相等。 + *

+ * 浮点数采用“尾数+阶码”的编码方式,类似于科学计数法的“有效数字+指数”的表示方式。 + * 二进制无法精确表示大部分的十进制小数。 + *

+ * 这里首先比较该数二进制是否相等,若不相等则采用近视精度比较,精度可自定义。 + * + * @param f1 单精度浮点 + * @param f2 单精度浮点 + * @param delta 判断精度 + * @return 是否相等 + * @see #equals(float, float) + */ + public static boolean equalsFloat(float f1, float f2, float delta) { + return AssistUtils.equalsFloat(f1, f2 ,delta); + } + /** * 判断两个Object类型数据是否相等 * @param parm1 第一个Object数据 diff --git a/src/main/java/com/fanruan/api/util/FineCollectionKit.java b/src/main/java/com/fanruan/api/util/FineCollectionKit.java new file mode 100644 index 0000000..2f12779 --- /dev/null +++ b/src/main/java/com/fanruan/api/util/FineCollectionKit.java @@ -0,0 +1,19 @@ +package com.fanruan.api.util; + +import com.fr.collections.FineCollections; +import com.fr.collections.api.FineCollectionClient; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class FineCollectionKit { + public static FineCollections getFineCollections() { + return FineCollections.getInstance(); + } + + public static FineCollectionClient getClient() { + return FineCollections.getInstance().getClient(); + } +} diff --git a/src/main/java/com/fanruan/api/util/GeneralKit.java b/src/main/java/com/fanruan/api/util/GeneralKit.java index e645726..132d04d 100644 --- a/src/main/java/com/fanruan/api/util/GeneralKit.java +++ b/src/main/java/com/fanruan/api/util/GeneralKit.java @@ -148,4 +148,14 @@ public class GeneralKit { return (rgb & 0xff000000) | (gray << 16) | (gray << 8) | (gray); } + /** + * 寻找指定名字的class文件 + * + * @param className 指定的类名 + * @return class类 + */ + public static Class classForName(String className) throws ClassNotFoundException, NoClassDefFoundError { + return StableUtils.classForName(className); + } + } diff --git a/src/main/java/com/fanruan/api/util/HyperKit.java b/src/main/java/com/fanruan/api/util/HyperKit.java new file mode 100644 index 0000000..14df20b --- /dev/null +++ b/src/main/java/com/fanruan/api/util/HyperKit.java @@ -0,0 +1,39 @@ +package com.fanruan.api.util; + +import com.fr.js.HyperlinkUtils; +import com.fr.js.NameJavaScriptGroup; +import com.fr.json.JSONArray; +import com.fr.json.JSONException; +import com.fr.stable.web.Repository; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/23 + */ +public class HyperKit { + + /** + * 写超链的内容 + * + * @param g 超级链接的集合 + * @param repo 库 + * @return JSONArray转化的字符串 + * @throws JSONException JSON异常 J + */ + public static String writeJSLinkContent(NameJavaScriptGroup g, Repository repo) throws JSONException { + return HyperlinkUtils.writeJSLinkContent(g, repo); + } + + /** + * 把超链转化成json + * + * @param g 超链 + * @param repo 库 + * @return json对象 + * @throws JSONException JSON异常 + */ + public static JSONArray createJSLink(NameJavaScriptGroup g, Repository repo) throws JSONException { + return HyperlinkUtils.createJSLink(g, repo); + } +} diff --git a/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java b/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java new file mode 100644 index 0000000..55e79f9 --- /dev/null +++ b/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java @@ -0,0 +1,50 @@ +package com.fanruan.api.cluster; + +import com.fr.cluster.ClusterBridge; +import com.fr.cluster.core.ClusterView; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(ClusterBridge.class) +public class ClusterBridgeKitTest { + + @Test + public void testGetView() { + ClusterView view = EasyMock.mock(ClusterView.class); + PowerMock.mockStatic(ClusterBridge.class); + EasyMock.expect(ClusterBridge.getView()).andReturn(view).once(); + EasyMock.expect(ClusterBridge.getView()).andReturn(null).once(); + + EasyMock.replay(view); + PowerMock.replay(ClusterBridge.class); + Assert.assertEquals(ClusterBridgeKit.getView(), view); + Assert.assertNull(ClusterBridgeKit.getView()); + + EasyMock.verify(view); + PowerMock.verify(ClusterBridge.class); + } + + @Test + public void testIsClusterMode() { + PowerMock.mockStatic(ClusterBridge.class); + EasyMock.expect(ClusterBridge.isClusterMode()).andReturn(true).once(); + EasyMock.expect(ClusterBridge.isClusterMode()).andReturn(false).once(); + + PowerMock.replay(ClusterBridge.class); + Assert.assertTrue(ClusterBridgeKit.isClusterMode()); + Assert.assertFalse(ClusterBridgeKit.isClusterMode()); + + PowerMock.verify(ClusterBridge.class); + } +} diff --git a/src/test/java/com/fanruan/api/cluster/state/MachineKitTest.java b/src/test/java/com/fanruan/api/cluster/state/MachineKitTest.java new file mode 100644 index 0000000..0df6699 --- /dev/null +++ b/src/test/java/com/fanruan/api/cluster/state/MachineKitTest.java @@ -0,0 +1,44 @@ +package com.fanruan.api.cluster.state; + +import com.fr.cluster.engine.core.jchannel.MachineMarker; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(MachineMarker.class) +@SuppressStaticInitializationFor("com.fr.cluster.engine.core.jchannel.MachineMarker") +public class MachineKitTest { + + @Test + public void testCurrentID() { + + PowerMock.mockStatic(MachineMarker.class); + EasyMock.expect(MachineMarker.currentID()).andReturn("1").anyTimes(); + + PowerMock.replay(MachineMarker.class); + Assert.assertEquals(MachineKit.currentID(), "1"); + PowerMock.verify(MachineMarker.class); + } + + @Test + public void testCurrentName() { + PowerMock.mockStatic(MachineMarker.class); + EasyMock.expect(MachineMarker.currentName()).andReturn("1").anyTimes(); + + PowerMock.replay(MachineMarker.class); + Assert.assertEquals(MachineKit.currentName(), "1"); + PowerMock.verify(MachineMarker.class); + } +} diff --git a/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java b/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java new file mode 100644 index 0000000..cf5511d --- /dev/null +++ b/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java @@ -0,0 +1,62 @@ +package com.fanruan.api.conf.xml; +import java.util.ArrayList; +import java.util.List; + +import com.fr.stable.xml.XMLable; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({XmlHolderKit.class}) +public class XmlHolderKitTest { + + @Test + public void testOjb() throws Exception { + + XMLable xmlable = EasyMock.createMock(XMLable.class); + XmlConf xmlConf = EasyMock.createMock(XmlConf.class); + + PowerMock.expectNew(XmlConf.class, xmlable, XMLable.class, "A").andReturn(xmlConf); + + EasyMock.replay(xmlable, xmlConf); + PowerMock.replay(XmlConf.class); + + Assert.assertEquals(XmlHolderKit.obj(xmlable, XMLable.class, "A"), xmlConf); + + EasyMock.verify(xmlable, xmlConf); + PowerMock.verify(XmlConf.class); + } + + @Test + public void testCollection() throws Exception { + + XmlColConf xmlColConf1 = EasyMock.createMock(XmlColConf.class); + XmlColConf xmlColConf2 = EasyMock.createMock(XmlColConf.class); + List list = new ArrayList<>(); + + PowerMock.expectNew(XmlColConf.class, list, XMLable.class, true).andReturn(xmlColConf1).times(2); + PowerMock.expectNew(XmlColConf.class, list, XMLable.class, false).andReturn(xmlColConf2).once(); + + EasyMock.replay(xmlColConf1, xmlColConf2); + PowerMock.replay(XmlColConf.class); + + Assert.assertEquals(XmlHolderKit.collection(list, XMLable.class), xmlColConf1); + Assert.assertEquals(XmlHolderKit.collection(list, XMLable.class, true), xmlColConf1); + Assert.assertEquals(XmlHolderKit.collection(list, XMLable.class, false), xmlColConf2); + + EasyMock.verify(xmlColConf1, xmlColConf2); + PowerMock.verify(XmlColConf.class); + } + + +} diff --git a/src/test/java/com/fanruan/api/decision/CommonKitTest.java b/src/test/java/com/fanruan/api/decision/CommonKitTest.java new file mode 100644 index 0000000..52a7996 --- /dev/null +++ b/src/test/java/com/fanruan/api/decision/CommonKitTest.java @@ -0,0 +1,59 @@ +package com.fanruan.api.decision; + +import com.fr.base.Base64; +import com.fr.base.ServerConfig; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.io.UnsupportedEncodingException; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest(ServerConfig.class) +public class CommonKitTest { + + @Test + public void testIsDefaultPassword() { + Assert.assertTrue(CommonKit.isDefaultPasswordHolderString("********")); + } + + @Test + public void testFetchDefaultPassword() { + Assert.assertEquals(CommonKit.fetchDefaultPasswordHolderString(), "********"); + } + + @Test + public void testGetBase64DecodeStr() throws UnsupportedEncodingException { + ServerConfig serverConfig = EasyMock.createMock(ServerConfig.class); + PowerMock.mockStatic(ServerConfig.class); + EasyMock.expect(ServerConfig.getInstance()).andReturn(serverConfig).anyTimes(); + EasyMock.expect(serverConfig.getServerCharset()).andReturn("utf-8").anyTimes(); + + EasyMock.replay(serverConfig); + PowerMock.replay(ServerConfig.class); + String result = new String(Base64.decode("a"), "utf-8"); + Assert.assertEquals(CommonKit.getBase64DecodeStr("a"), result); + Assert.assertEquals(CommonKit.getBase64DecodeStr(""), ""); + + EasyMock.verify(serverConfig); + PowerMock.verify(ServerConfig.class); + } + + @Test + public void testEncode() { + Image im = new BufferedImage(1, 1, 1); + String result = Base64.encode(im, ""); + Assert.assertEquals(result, CommonKit.encode(im, "")); + } +} diff --git a/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java b/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java new file mode 100644 index 0000000..9c7981d --- /dev/null +++ b/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java @@ -0,0 +1,28 @@ +package com.fanruan.api.decision.monitor; + +import com.fr.decision.system.monitor.gc.load.RuntimeMemScoreProvider; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +public class RuntimeMemScoreKitTest { + + @Test + public void testGetLoadScore() { + Assert.assertEquals(RuntimeMemScoreProvider.getLoadScore(), RuntimeMemScoreKit.getLoadScore()); + } + + @Test + public void testGetReleasePromoterScore() { + Assert.assertEquals(RuntimeMemScoreProvider.getReleasePromoterScore(), RuntimeMemScoreKit.getReleasePromoterScore()); + } + + @Test + public void testGetBalancePromoterScore() { + Assert.assertEquals(RuntimeMemScoreProvider.getBalancePromoterScore(), RuntimeMemScoreKit.getBalancePromoterScore()); + } +} diff --git a/src/test/java/com/fanruan/api/util/ArrayKitTest.java b/src/test/java/com/fanruan/api/util/ArrayKitTest.java index 4803a7c..e66c1cd 100644 --- a/src/test/java/com/fanruan/api/util/ArrayKitTest.java +++ b/src/test/java/com/fanruan/api/util/ArrayKitTest.java @@ -149,4 +149,16 @@ public class ArrayKitTest extends Prepare { Assert.assertEquals(ArrayKit.getLength(null),0); Assert.assertEquals(ArrayKit.getLength(b),2); } + + @Test + public void testInsert() { + Integer[] array1 = new Integer[] {0, 1, 2}; + Integer[] result1 = new Integer[] {0, 7, 8, 1, 2}; + + String[] array2 = new String[] {"1", "2"}; + String[] result2 = new String[] {"3", "1", "2"}; + + Assert.assertEquals(ArrayKit.insert(1, array1, 7, 8), result1); + Assert.assertEquals(ArrayKit.insert(0, array2, "3"), result2); + } } diff --git a/src/test/java/com/fanruan/api/util/AssistKitTest.java b/src/test/java/com/fanruan/api/util/AssistKitTest.java index def10b4..15039a1 100644 --- a/src/test/java/com/fanruan/api/util/AssistKitTest.java +++ b/src/test/java/com/fanruan/api/util/AssistKitTest.java @@ -1,6 +1,7 @@ package com.fanruan.api.util; import com.fr.event.Null; +import com.fr.stable.AssistUtils; import org.junit.Assert; import org.junit.Test; @@ -65,4 +66,20 @@ public class AssistKitTest { Assert.assertEquals(Arrays.hashCode(a), AssistKit.hashCode(s)); Assert.assertEquals(0, AssistKit.hashCode(null)); } + + @Test + public void testEqualsFloat() { + float f1 = 0.6f; + float f2 = 0.6f; + float f3 = 0.6001f; + float f4 = 0.601f; + float f5 = 0.602f; + float delta = 0.001f; + + Assert.assertTrue(AssistKit.equalsFloat(f1, f2, delta)); + Assert.assertTrue(AssistKit.equalsFloat(f1, f3, delta)); + Assert.assertTrue(AssistKit.equalsFloat(f1, f4, delta)); + Assert.assertFalse(AssistKit.equalsFloat(f1, f5, delta)); + } + } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java b/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java new file mode 100644 index 0000000..d50482e --- /dev/null +++ b/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java @@ -0,0 +1,23 @@ +package com.fanruan.api.util; + +import com.fr.collections.FineCollections; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +public class FineCollectionKitTest { + + @Test + public void testGetClient() { + Assert.assertEquals(FineCollections.getInstance().getClient(), FineCollectionKit.getClient()); + } + + @Test + public void testGetInstance() { + Assert.assertEquals(FineCollections.getInstance(), FineCollectionKit.getFineCollections()); + } +} diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 5481651..0851ee7 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.StableUtils; import org.junit.Assert; import org.junit.Test; @@ -73,4 +74,10 @@ public class GeneralKitTest extends Prepare { Assert.assertEquals(GeneralKit.pathJoin(strArray), "abc/def"); } + @Test + public void testClassForName() throws ClassNotFoundException { + String className = "com.fanruan.api.util.GeneralKitTest"; + Assert.assertEquals(GeneralKit.classForName(className), StableUtils.classForName(className)); + } + } \ No newline at end of file diff --git a/src/test/java/com/fanruan/api/util/HyperKitTest.java b/src/test/java/com/fanruan/api/util/HyperKitTest.java new file mode 100644 index 0000000..71e04ab --- /dev/null +++ b/src/test/java/com/fanruan/api/util/HyperKitTest.java @@ -0,0 +1,62 @@ +package com.fanruan.api.util; + +import com.fanruan.api.json.JSONKit; +import com.fr.js.HyperlinkUtils; +import com.fr.js.NameJavaScriptGroup; +import com.fr.json.JSONArray; +import com.fr.stable.web.Repository; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.api.easymock.PowerMock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/24 + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({HyperlinkUtils.class}) +public class HyperKitTest { + + @Test + public void testWriteJS() { + NameJavaScriptGroup g = EasyMock.createMock(NameJavaScriptGroup.class); + Repository repo = EasyMock.createMock(Repository.class); + PowerMock.mockStatic(HyperlinkUtils.class); + EasyMock.expect(HyperlinkUtils.writeJSLinkContent(g, repo)).andReturn("A").once(); + EasyMock.expect(HyperlinkUtils.writeJSLinkContent(g, repo)).andReturn("B").once(); + + EasyMock.replay(g, repo); + PowerMock.replay(HyperlinkUtils.class); + + Assert.assertEquals(HyperKit.writeJSLinkContent(g, repo), "A"); + Assert.assertEquals(HyperKit.writeJSLinkContent(g, repo), "B"); + + EasyMock.verify(g, repo); + PowerMock.verify(HyperlinkUtils.class); + } + + @Test + public void testCreateJSLink() { + JSONArray array1 = JSONKit.createJSONArray("[]"); + JSONArray array2 = JSONKit.createJSONArray("[{\"1\":\"a\"}, {\"1\":\"b\"}]"); + NameJavaScriptGroup g = EasyMock.createMock(NameJavaScriptGroup.class); + Repository repo = EasyMock.createMock(Repository.class); + PowerMock.mockStatic(HyperlinkUtils.class); + EasyMock.expect(HyperlinkUtils.createJSLink(g, repo)).andReturn(array1).once(); + EasyMock.expect(HyperlinkUtils.createJSLink(g, repo)).andReturn(array2).once(); + + EasyMock.replay(g, repo); + PowerMock.replay(HyperlinkUtils.class); + + Assert.assertEquals(HyperKit.createJSLink(g, repo), array1); + Assert.assertEquals(HyperKit.createJSLink(g, repo), array2); + + EasyMock.verify(g, repo); + PowerMock.verify(HyperlinkUtils.class); + } +} From 1592d614d2c0cbd21e69c540d4a0069b38bfc30f Mon Sep 17 00:00:00 2001 From: lucian Date: Thu, 26 Mar 2020 12:45:37 +0800 Subject: [PATCH 2/5] =?UTF-8?q?KERNEL-3521=20=E6=B7=BB=E5=8A=A0FineKit?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java index d0059b3..cb79741 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java +++ b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java @@ -1,5 +1,6 @@ package com.fanruan.api.conf.xml; +import com.fr.config.holder.Conf; import com.fr.stable.xml.XMLable; import java.util.Collection; @@ -13,14 +14,15 @@ public class XmlHolderKit { /** * 创建一个要写入配置的xml多项 + * * @param 类型 * @param 类型 * @param t 配置对象 * @param clazz 类型 * @param xmlTag xml标签 * @return 配置对象 */ - public static XmlConf obj(T t, Class clazz, String xmlTag) { - return new XmlConf(t, clazz, xmlTag); + public static Conf obj(T t, Class clazz, String xmlTag) { + return new XmlConf(t, clazz, xmlTag); } public static XmlColConf> collection(Collection t, Class clazz) { From f3f6fe516af91c5a93b169575ed29b99ce1c2393 Mon Sep 17 00:00:00 2001 From: lucian Date: Fri, 27 Mar 2020 17:44:07 +0800 Subject: [PATCH 3/5] =?UTF-8?q?KERNEL-3521=20=E6=B7=BB=E5=8A=A0FineKit?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fanruan/api/cal/formula/Formula.java | 16 - .../fanruan/api/cluster/ClusterBridgeKit.java | 20 +- .../fanruan/api/concurrent/ConcurrentKit.java | 15 + .../api/concurrent/NamedThreadFactory.java | 20 - .../fanruan/api/conf/xml/XmlHolderKit.java | 21 +- .../decision/monitor/RuntimeMemScoreKit.java | 10 - .../table/model/DesignModelAdapter.java | 19 - .../table/model/DesignModelAdapterKit.java | 15 + ...pertyTable.java => BasePropertyTable.java} | 4 +- .../api/design/work/WidgetPropertyPane.java | 417 +----------------- .../work/component/ParameterComboBox.java | 3 +- .../fanruan/api/util/FineCollectionKit.java | 3 - .../api/cluster/ClusterBridgeKitTest.java | 34 +- .../monitor/RuntimeMemScoreKitTest.java | 9 - .../api/util/FineCollectionKitTest.java | 4 - .../com/fanruan/api/util/GeneralKitTest.java | 1 + .../java/com/fanruan/api/util/IOKitTest.java | 2 +- 17 files changed, 106 insertions(+), 507 deletions(-) delete mode 100644 src/main/java/com/fanruan/api/cal/formula/Formula.java create mode 100644 src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java delete mode 100644 src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java create mode 100644 src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java rename src/main/java/com/fanruan/api/design/ui/table/{AbstractPropertyTable.java => BasePropertyTable.java} (52%) diff --git a/src/main/java/com/fanruan/api/cal/formula/Formula.java b/src/main/java/com/fanruan/api/cal/formula/Formula.java deleted file mode 100644 index 461ed8e..0000000 --- a/src/main/java/com/fanruan/api/cal/formula/Formula.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.fanruan.api.cal.formula; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 - */ -public class Formula extends com.fr.base.Formula { - public Formula() { - super(); - } - - public Formula(String content) { - super(content); - } -} diff --git a/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java b/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java index 218b226..41156be 100644 --- a/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java +++ b/src/main/java/com/fanruan/api/cluster/ClusterBridgeKit.java @@ -1,7 +1,11 @@ package com.fanruan.api.cluster; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.core.ClusterNode; import com.fr.cluster.core.ClusterView; +import com.fr.stable.Filter; + +import java.util.List; /** * @author Lucian.Chen @@ -10,8 +14,20 @@ import com.fr.cluster.core.ClusterView; */ public class ClusterBridgeKit { - public static ClusterView getView() { - return ClusterBridge.getView(); + public static ClusterNode getCurrentNode() { + return ClusterBridge.getView().getCurrent(); + } + + public static ClusterNode getNodeById(String var1) { + return ClusterBridge.getView().getNodeById(var1); + } + + public static List listNodes() { + return ClusterBridge.getView().listNodes(); + } + + public static List listNodes(Filter var1) { + return ClusterBridge.getView().listNodes(var1); } public static boolean isClusterMode() { diff --git a/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java b/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java new file mode 100644 index 0000000..bb0acd6 --- /dev/null +++ b/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.concurrent; + +import com.fr.concurrent.NamedThreadFactory; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/27 + */ +public class ConcurrentKit { + + public static NamedThreadFactory newNamedThreadFactory(String s) { + return new NamedThreadFactory(s); + } +} diff --git a/src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java b/src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java deleted file mode 100644 index 915b430..0000000 --- a/src/main/java/com/fanruan/api/concurrent/NamedThreadFactory.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.fanruan.api.concurrent; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 - */ -public class NamedThreadFactory extends com.fr.concurrent.NamedThreadFactory { - public NamedThreadFactory(Class aClass) { - super(aClass); - } - - public NamedThreadFactory(String s) { - super(s); - } - - public NamedThreadFactory(String s, boolean b) { - super(s, b); - } -} diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java index cb79741..f88a363 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java +++ b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java @@ -14,21 +14,38 @@ public class XmlHolderKit { /** * 创建一个要写入配置的xml多项 - * * @param 类型 - * @param 类型 * @param t 配置对象 * @param clazz 类型 * @param xmlTag xml标签 + * @param 类型 * @return 配置对象 */ public static Conf obj(T t, Class clazz, String xmlTag) { return new XmlConf(t, clazz, xmlTag); } + /** + * 创建一个集合类型的xml配置 + * + * @param t 初始值 + * @param clazz 对象class类型 + * @param 类型 + * @return 配置对象 + */ public static XmlColConf> collection(Collection t, Class clazz) { return collection(t,clazz,true); } + + /** + * 创建一个集合类型的xml配置 + * + * @param t 初始值 + * @param clazz 对象class类型 + * @param order 是否是有序的配置 + * @param 类型 + * @return 配置对象 + */ public static XmlColConf> collection(Collection t, Class clazz, boolean order) { return new XmlColConf>(t, clazz, order); } diff --git a/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java b/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java index 3e1d929..1f2e8ce 100644 --- a/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java +++ b/src/main/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKit.java @@ -9,16 +9,6 @@ import com.fr.decision.system.monitor.gc.load.RuntimeMemScoreProvider; */ public class RuntimeMemScoreKit { - //计算中止分值 - public static int getBalancePromoterScore() { - return RuntimeMemScoreProvider.getBalancePromoterScore(); - } - - //释放会话分值 - public static int getReleasePromoterScore() { - return RuntimeMemScoreProvider.getReleasePromoterScore(); - } - //分发得分 public static int getLoadScore() { return RuntimeMemScoreProvider.getLoadScore(); diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java deleted file mode 100644 index e4c30c6..0000000 --- a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapter.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.fanruan.api.design.ui.component.table.model; - -import com.fr.base.io.BaseBook; -import com.fr.design.mainframe.JTemplateProvider; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 - */ -public abstract class DesignModelAdapter> extends com.fr.design.DesignModelAdapter { - public DesignModelAdapter(JTemplateProvider jTemplateProvider) { - super(jTemplateProvider); - } - - public static DesignModelAdapter getCurrentModelAdapter() { - return DesignModelAdapter.getCurrentModelAdapter(); - } -} diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java new file mode 100644 index 0000000..525c9df --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java @@ -0,0 +1,15 @@ +package com.fanruan.api.design.ui.component.table.model; + +import com.fr.design.DesignModelAdapter; + +/** + * @author Lucian.Chen + * @version 10.0 + * Created by Lucian.Chen on 2020/3/27 + */ +public class DesignModelAdapterKit { + + public static DesignModelAdapter getCurrentModelAdapter() { + return DesignModelAdapter.getCurrentModelAdapter(); + } +} diff --git a/src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java b/src/main/java/com/fanruan/api/design/ui/table/BasePropertyTable.java similarity index 52% rename from src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java rename to src/main/java/com/fanruan/api/design/ui/table/BasePropertyTable.java index 83d79e4..749b664 100644 --- a/src/main/java/com/fanruan/api/design/ui/table/AbstractPropertyTable.java +++ b/src/main/java/com/fanruan/api/design/ui/table/BasePropertyTable.java @@ -5,8 +5,8 @@ package com.fanruan.api.design.ui.table; * @version 10.0 * Created by Lucian.Chen on 2020/3/23 */ -public abstract class AbstractPropertyTable extends com.fr.design.gui.itable.AbstractPropertyTable { - public AbstractPropertyTable() { +public abstract class BasePropertyTable extends com.fr.design.gui.itable.AbstractPropertyTable { + public BasePropertyTable() { super(); } } diff --git a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java b/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java index 5c5d39a..8621d73 100644 --- a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java +++ b/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java @@ -1,419 +1,12 @@ package com.fanruan.api.design.work; -import com.fanruan.api.design.ui.component.UIHeadGroup; -import com.fanruan.api.design.ui.component.UILabel; -import com.fanruan.api.design.ui.container.UIScrollPane; -import com.fanruan.api.design.ui.table.AbstractPropertyTable; -import com.fanruan.api.design.util.GUICoreKit; -import com.fanruan.api.util.ArrayKit; -import com.fanruan.api.util.IOKit; -import com.fr.design.ExtraDesignClassManager; -import com.fr.design.constants.UIConstants; -import com.fr.design.designer.beans.events.DesignerEditListener; -import com.fr.design.designer.beans.events.DesignerEvent; -import com.fr.design.designer.creator.XComponent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteLayout; -import com.fr.design.designer.creator.XWFitLayout; -import com.fr.design.designer.creator.XWParameterLayout; -import com.fr.design.designer.properties.EventPropertyTable; -import com.fr.design.designer.properties.mobile.MobileBookMarkPropertyUI; -import com.fr.design.designer.properties.mobile.MobileStylePropertyUI; -import com.fr.design.fun.WidgetPropertyUIProvider; -import com.fr.design.mainframe.BaseFormDesigner; -import com.fr.design.mainframe.BaseWidgetPropertyPane; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.FormDockView; -import com.fr.design.mainframe.FormSelection; -import com.fr.design.mainframe.widget.ui.FormWidgetCardPane; -import com.fr.design.widget.ui.designer.mobile.MobileWidgetDefinePane; - -import javax.swing.*; -import java.awt.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - /** * 控件属性表绘制 - * Modified by fanglei + * */ -public class WidgetPropertyPane extends FormDockView implements BaseWidgetPropertyPane { - - private static final int PADDING = 10; - private static final int PADDING_M = 12; - private FormWidgetCardPane formWidgetCardPane; // 控件的属性表 - private EventPropertyTable eventTable; // 控件的事件表 - private List widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab - private List mobileExtraPropertyPanes; // 保存9.0设计器下移动端拓展的属性tab,舍弃JTable - private FormDesigner designer; // 当前designer - private UIScrollPane psp; // 用来装载属性表table的容器 - private JPanel wsp; // 装载移动端tab的容器,包括移动端属性表和控件拓展的移动端属性表 - private UIHeadGroup tabsHeaderIconPane; - private XComponent lastAffectedCreator; - - - public static WidgetPropertyPane getInstance() { - if (HOLDER.singleton == null) { - HOLDER.singleton = new WidgetPropertyPane(); - } - return HOLDER.singleton; - } - - public static WidgetPropertyPane getInstance(FormDesigner formEditor) { - HOLDER.singleton.setEditingFormDesigner(formEditor); - HOLDER.singleton.refreshDockingView(); - return HOLDER.singleton; - } - - private static class HOLDER { - private static WidgetPropertyPane singleton = new WidgetPropertyPane(); - } - - private WidgetPropertyPane() { - setLayout(GUICoreKit.createBorderLayout()); - } - - @Override - protected String title4PopupWindow() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Control_Setting"); - } - - - @Override - public String getViewTitle() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Property_Table"); - } - - @Override - public Icon getViewIcon() { - return IOKit.readIcon("/com/fr/design/images/m_report/attributes.png"); - } - - @Override - /** - * 绘制属性表tab - */ - public void refreshDockingView() { - designer = this.getEditingFormDesigner(); - removeAll(); - if (designer == null) { - clearDockingView(); - return; - } - widgetPropertyTables = new ArrayList(); - mobileExtraPropertyPanes = new ArrayList<>(); - - //依次创建属性表、事件表、移动端表,再将它们整合到TabPane中去 - this.createPropertyTable(); - this.createEventTable(); - this.createMobileWidgetTable(); - this.createTabPane(); - - this.initTables(); - } - - /** - * 初始化属性表,事件表,移动端拓展的属性表 - */ - private void initTables() { - formWidgetCardPane.populate(); - eventTable.refresh(); - - if (mobileExtraPropertyPanes != null) { - for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { - extraPane.initPropertyGroups(designer); - } - } - if (widgetPropertyTables != null) { - for (AbstractPropertyTable propertyTable : widgetPropertyTables) { - propertyTable.initPropertyGroups(designer); - } - } - } - - /** - * 创建属性表table - */ - private void createPropertyTable() { - formWidgetCardPane = new FormWidgetCardPane(designer); - designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); - psp = new UIScrollPane(formWidgetCardPane); // 用来装载属性表table - psp.setBorder(null); - } - - /** - * 创建事件表(事件选项卡不是JTable) - */ - private void createEventTable() { - eventTable = new EventPropertyTable(designer); - designer.addDesignerEditListener(new EventPropertyDesignerAdapter(eventTable)); - } - - /** - * 创建移动端控件列表 - */ - private void createMobileWidgetTable() { - //加上表头后,这里不再使用borderLayout布局,而采用BoxLayout布局 - wsp = GUICoreKit.createYAXISBoxInnerContainerPane(); - wsp.setBorder(null); - designer.addDesignerEditListener(new MobileWidgetDesignerAdapter()); - - //获取拓展移动端属性tab - WidgetPropertyUIProvider[] widgetAttrProviders = getExtraPropertyUIProviders(); - addWidgetAttr(widgetAttrProviders); - } - - /** - * 将属性表,事件表,移动端控件列表整合到TabPane里面去 - */ - private void createTabPane() { - initTabPane(); - } - - /** - * 获取当前控件扩展的属性tab - * 来源有两个: - * 1, 各个控件从各自的Xcreator里扩展(例如手机重布局的tab就是从Xcreator中扩展的); - * 2, 所有的控件从插件里扩展. - * - * @return 扩展的tab - */ - private WidgetPropertyUIProvider[] getExtraPropertyUIProviders() { - FormSelection selection = designer.getSelectionModel().getSelection(); - WidgetPropertyUIProvider[] embeddedPropertyUIProviders = null; - XCreator xCreator = selection.getSelectedCreator(); - if (selection != null && xCreator != null) { - embeddedPropertyUIProviders = selection.getSelectedCreator().getWidgetPropertyUIProviders(); - if(!designer.getDesignerMode().isFormParameterEditor()) { - if (!xCreator.acceptType(XWAbsoluteLayout.class, XWFitLayout.class)) { - embeddedPropertyUIProviders = ArrayKit.insert(0, embeddedPropertyUIProviders, new MobileBookMarkPropertyUI(xCreator)); - } - if (xCreator.supportMobileStyle()) { - embeddedPropertyUIProviders = ArrayKit.insert(0, embeddedPropertyUIProviders, new MobileStylePropertyUI(xCreator)); - } - } - } - Set set = ExtraDesignClassManager.getInstance().getArray(WidgetPropertyUIProvider.XML_TAG); - return ArrayKit.addAll(embeddedPropertyUIProviders, set.toArray(new WidgetPropertyUIProvider[set.size()])); - } - - /** - * 判断是将拓展的tab放入属性表还是将原来的tab放入属性表 - * - * @param widgetAttrProviders 拓展的tab - */ - private void addWidgetAttr(WidgetPropertyUIProvider[] widgetAttrProviders) { - if (widgetAttrProviders.length == 0) { // 判断有没有拓展的tab,提示"无可用配置项" - wsp.add(getUnavailablePane()); - } else { - for (WidgetPropertyUIProvider widgetAttrProvider : widgetAttrProviders) { - MobileWidgetDefinePane extraPane = (MobileWidgetDefinePane) widgetAttrProvider.createWidgetAttrPane(); - if (extraPane != null) { - extraPane.setBorder(BorderFactory.createEmptyBorder(PADDING, PADDING, PADDING, PADDING_M)); - mobileExtraPropertyPanes.add(extraPane); - wsp.add(extraPane); - } - AbstractPropertyTable propertyTable = (AbstractPropertyTable) widgetAttrProvider.createWidgetAttrTable(); - if (propertyTable != null) { - widgetPropertyTables.add(propertyTable); - designer.addDesignerEditListener(new WidgetPropertyDesignerAdapter(formWidgetCardPane)); - - UIScrollPane uiScrollPane = new UIScrollPane(propertyTable); - wsp.add(uiScrollPane); - } - } - } - } - - // "无可用配置项"面板 - private JPanel getUnavailablePane() { - JPanel panel = GUICoreKit.createBorderLayoutPane(); - UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_No_Settings_Available")); - label.setHorizontalAlignment(SwingConstants.CENTER); - panel.add(label); - return panel; - } - - private void initTabPane() { - final String[] tabTitles = new String[]{ - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal") - }; - final CardLayout tabbedPane = new CardLayout(); - final JPanel center = new JPanel(tabbedPane); - center.add(formWidgetCardPane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Properties")); - center.add(eventTable, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Event")); - center.add(wsp, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Widget_Mobile_Terminal")); - this.add(center, BorderLayout.CENTER); - - tabsHeaderIconPane = new UIHeadGroup(tabTitles) { - @Override - public void tabChanged(int index) { - //切换的时候再populate - if (index == 1) { - eventTable.populateNameObjects(); - } else if (index == 2) { - if (mobileExtraPropertyPanes != null) { - for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { - extraPane.populate(designer); - } - } - } - tabbedPane.show(center, tabTitles[index]); - } - }; - tabsHeaderIconPane.setNeedLeftRightOutLine(true); - tabsHeaderIconPane.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.SHADOW_GREY)); - this.add(tabsHeaderIconPane, BorderLayout.NORTH); - } - - - /** - * 选中的组件是否在参数面板里 - * - * @param designer 设计器 - * @return 是则返回true - */ - public boolean hasSelectParaPane(FormDesigner designer) { - XCreator xCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); - if (xCreator == null) { - xCreator = designer.getRootComponent(); - } - XLayoutContainer container = XCreatorUtils.getHotspotContainer(xCreator); - - boolean xCreatorAccept = xCreator.acceptType(XWParameterLayout.class); - boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class); - - return xCreatorAccept || containerAccept; - } - - @Override - public void setEditingFormDesigner(BaseFormDesigner editor) { - FormDesigner fd = (FormDesigner) editor; - super.setEditingFormDesigner(fd); - } - - private void clearDockingView() { - formWidgetCardPane = null; - eventTable = null; - if (widgetPropertyTables != null) { - widgetPropertyTables.clear(); - } - JScrollPane psp = new JScrollPane(); - psp.setBorder(null); - this.add(psp, BorderLayout.CENTER); - } - - /** - * 属性表监听界面事件(编辑,删除,选中,改变大小) - */ - private class WidgetPropertyDesignerAdapter implements DesignerEditListener { - FormWidgetCardPane formWidgetCardPane; - - - WidgetPropertyDesignerAdapter(FormWidgetCardPane formWidgetCardPane) { - this.formWidgetCardPane = formWidgetCardPane; - } - - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_DELETED - || evt.getCreatorEventID() == DesignerEvent.CREATOR_RESIZED) { - formWidgetCardPane.populate(); - } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - // 防止多次触发 - if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { - return; - } - lastAffectedCreator = evt.getAffectedCreator(); - refreshDockingView(); - formWidgetCardPane.populate(); - } - } - - @Override - public boolean equals(Object o) { - return o instanceof WidgetPropertyDesignerAdapter; - } - } - - /** - * 事件表监听界面事件(编辑,选中) - */ - private class EventPropertyDesignerAdapter implements DesignerEditListener { - EventPropertyTable propertyTable; - - EventPropertyDesignerAdapter(EventPropertyTable eventTable) { - this.propertyTable = eventTable; - } - - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == DesignerEvent.CREATOR_EDITED) { - propertyTable.refresh(); - } else if (evt.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { - // 防止多次触发 - if (lastAffectedCreator != null && lastAffectedCreator == evt.getAffectedCreator()) { - return; - } - lastAffectedCreator = evt.getAffectedCreator(); - propertyTable.refresh(); - } - } - - @Override - public boolean equals(Object o) { - return o instanceof EventPropertyDesignerAdapter; - } - } - - /** - * 移动端属性表监听界面事件(改变大小,编辑,选中,增加控件) - */ - private class MobileWidgetDesignerAdapter implements DesignerEditListener { - - MobileWidgetDesignerAdapter() { - } - - /** - * 响应界面改变事件 - * - * @param evt 事件 - */ - public void fireCreatorModified(DesignerEvent evt) { - int[] validEventIds = {DesignerEvent.CREATOR_RESIZED, DesignerEvent.CREATOR_EDITED, - DesignerEvent.CREATOR_SELECTED, DesignerEvent.CREATOR_ADDED, DesignerEvent.CREATOR_ORDER_CHANGED}; - boolean isValid = false; - for (int validEventId : validEventIds) { - if (evt.getCreatorEventID() == validEventId) { - isValid = true; - break; - } - } - if (!isValid) { - return; - } - - if (mobileExtraPropertyPanes != null) { - for (MobileWidgetDefinePane extraPane : mobileExtraPropertyPanes) { - extraPane.populate(designer); - } - } - - } - - @Override - public boolean equals(Object o) { - return o instanceof MobileWidgetDesignerAdapter; - } - } +public class WidgetPropertyPane { - @Override - public Location preferredLocation() { - return Location.WEST_BELOW; + public static com.fr.design.mainframe.WidgetPropertyPane getInstance() { + return com.fr.design.mainframe.WidgetPropertyPane.getInstance(); } -} +} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java b/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java index addf257..0d66cc1 100644 --- a/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java +++ b/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java @@ -2,6 +2,7 @@ package com.fanruan.api.design.work.component; import com.fanruan.api.cal.ParameterKit; import com.fanruan.api.design.ui.component.UIComboBox; +import com.fanruan.api.design.ui.component.table.model.DesignModelAdapterKit; import com.fanruan.api.util.AssistKit; import com.fr.design.DesignModelAdapter; import com.fr.stable.ParameterProvider; @@ -41,7 +42,7 @@ public class ParameterComboBox extends UIComboBox { public void updateParaItems() { - DesignModelAdapter designModel = DesignModelAdapter.getCurrentModelAdapter(); + DesignModelAdapter designModel = DesignModelAdapterKit.getCurrentModelAdapter(); this.removeAllItems(); if (designModel != null) { diff --git a/src/main/java/com/fanruan/api/util/FineCollectionKit.java b/src/main/java/com/fanruan/api/util/FineCollectionKit.java index 2f12779..7f86542 100644 --- a/src/main/java/com/fanruan/api/util/FineCollectionKit.java +++ b/src/main/java/com/fanruan/api/util/FineCollectionKit.java @@ -9,9 +9,6 @@ import com.fr.collections.api.FineCollectionClient; * Created by Lucian.Chen on 2020/3/23 */ public class FineCollectionKit { - public static FineCollections getFineCollections() { - return FineCollections.getInstance(); - } public static FineCollectionClient getClient() { return FineCollections.getInstance().getClient(); diff --git a/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java b/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java index 55e79f9..f3af3be 100644 --- a/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java +++ b/src/test/java/com/fanruan/api/cluster/ClusterBridgeKitTest.java @@ -1,7 +1,9 @@ package com.fanruan.api.cluster; import com.fr.cluster.ClusterBridge; +import com.fr.cluster.core.ClusterNode; import com.fr.cluster.core.ClusterView; +import com.fr.stable.Filter; import org.easymock.EasyMock; import org.junit.Assert; import org.junit.Test; @@ -10,6 +12,9 @@ import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; +import java.util.ArrayList; +import java.util.List; + /** * @author Lucian.Chen * @version 10.0 @@ -23,15 +28,32 @@ public class ClusterBridgeKitTest { public void testGetView() { ClusterView view = EasyMock.mock(ClusterView.class); PowerMock.mockStatic(ClusterBridge.class); - EasyMock.expect(ClusterBridge.getView()).andReturn(view).once(); - EasyMock.expect(ClusterBridge.getView()).andReturn(null).once(); + EasyMock.expect(ClusterBridge.getView()).andReturn(view).anyTimes(); + Filter filter = EasyMock.createMock(Filter.class); + + ClusterNode node1 = EasyMock.mock(ClusterNode.class); + ClusterNode node2 = EasyMock.mock(ClusterNode.class); + ClusterNode node3 = EasyMock.mock(ClusterNode.class); + List list1 = new ArrayList<>(); + List list2 = new ArrayList<>(); + list1.add(node1); + list1.add(node2); + list2.add(node3); + + EasyMock.expect(view.getCurrent()).andReturn(node1).once(); + EasyMock.expect(view.getNodeById("1")).andReturn(node2).once(); + EasyMock.expect(view.listNodes()).andReturn(list1).once(); + EasyMock.expect(view.listNodes(filter)).andReturn(list2).once(); + - EasyMock.replay(view); + EasyMock.replay(view, filter, node1, node2, node3); PowerMock.replay(ClusterBridge.class); - Assert.assertEquals(ClusterBridgeKit.getView(), view); - Assert.assertNull(ClusterBridgeKit.getView()); + Assert.assertEquals(ClusterBridgeKit.getCurrentNode(), node1); + Assert.assertEquals(ClusterBridgeKit.getNodeById("1"), node2); + Assert.assertEquals(ClusterBridgeKit.listNodes(), list1); + Assert.assertEquals(ClusterBridgeKit.listNodes(filter), list2); - EasyMock.verify(view); + EasyMock.verify(view, filter, node1, node2, node3); PowerMock.verify(ClusterBridge.class); } diff --git a/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java b/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java index 9c7981d..154d925 100644 --- a/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java +++ b/src/test/java/com/fanruan/api/decision/monitor/RuntimeMemScoreKitTest.java @@ -16,13 +16,4 @@ public class RuntimeMemScoreKitTest { Assert.assertEquals(RuntimeMemScoreProvider.getLoadScore(), RuntimeMemScoreKit.getLoadScore()); } - @Test - public void testGetReleasePromoterScore() { - Assert.assertEquals(RuntimeMemScoreProvider.getReleasePromoterScore(), RuntimeMemScoreKit.getReleasePromoterScore()); - } - - @Test - public void testGetBalancePromoterScore() { - Assert.assertEquals(RuntimeMemScoreProvider.getBalancePromoterScore(), RuntimeMemScoreKit.getBalancePromoterScore()); - } } diff --git a/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java b/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java index d50482e..01ab4cc 100644 --- a/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java +++ b/src/test/java/com/fanruan/api/util/FineCollectionKitTest.java @@ -16,8 +16,4 @@ public class FineCollectionKitTest { Assert.assertEquals(FineCollections.getInstance().getClient(), FineCollectionKit.getClient()); } - @Test - public void testGetInstance() { - Assert.assertEquals(FineCollections.getInstance(), FineCollectionKit.getFineCollections()); - } } diff --git a/src/test/java/com/fanruan/api/util/GeneralKitTest.java b/src/test/java/com/fanruan/api/util/GeneralKitTest.java index 0851ee7..5a28afc 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.license.utils.JsonUtil; import com.fr.stable.StableUtils; import org.junit.Assert; import org.junit.Test; diff --git a/src/test/java/com/fanruan/api/util/IOKitTest.java b/src/test/java/com/fanruan/api/util/IOKitTest.java index 7b6ddbc..5a84674 100644 --- a/src/test/java/com/fanruan/api/util/IOKitTest.java +++ b/src/test/java/com/fanruan/api/util/IOKitTest.java @@ -30,7 +30,7 @@ public class IOKitTest extends Prepare { @Test public void readIcon() { - Assert.assertEquals((IOKit.readIcon("/com/fanruan/api/util/close.png")).getIconHeight(),(new ImageIcon(IOUtils.readImageWithCache("/com/fanruan/api/util/close.png")).getIconHeight())); + Assert.assertEquals((IOKit.readIcon("/com/fanruan/api/util/close.png")).getIconHeight(), IOUtils.readIcon("/com/fanruan/api/util/close.png").getIconHeight()); } @Test From 6eabb72ab529ac25af8eaa71297349470ff3d475 Mon Sep 17 00:00:00 2001 From: lucian Date: Mon, 30 Mar 2020 18:28:37 +0800 Subject: [PATCH 4/5] =?UTF-8?q?KERNEL-3521=20=E6=B7=BB=E5=8A=A0FineKit?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fanruan/api/concurrent/ConcurrentKit.java | 9 +- .../api/conf/{ => impl}/xml/XmlColConf.java | 2 +- .../api/conf/{ => impl}/xml/XmlConf.java | 2 +- .../fanruan/api/conf/xml/XmlHolderKit.java | 2 + .../com/fanruan/api/design/DesignKit.java | 30 +++ .../mainframe/HyperlinkGroupPaneAction.java | 17 -- .../table/model/DesignModelAdapterKit.java | 15 -- .../fanruan/api/design/util/GUICoreKit.java | 9 + .../api/design/work/SelectImagePane.java | 192 +++++++++++++++++- .../api/design/work/WidgetPropertyPane.java | 12 -- .../work/component/ParameterComboBox.java | 4 +- .../api/conf/xml/XmlHolderKitTest.java | 3 + 12 files changed, 241 insertions(+), 56 deletions(-) rename src/main/java/com/fanruan/api/conf/{ => impl}/xml/XmlColConf.java (95%) rename src/main/java/com/fanruan/api/conf/{ => impl}/xml/XmlConf.java (93%) delete mode 100644 src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java delete mode 100644 src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java delete mode 100644 src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java diff --git a/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java b/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java index bb0acd6..7dcc423 100644 --- a/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java +++ b/src/main/java/com/fanruan/api/concurrent/ConcurrentKit.java @@ -9,7 +9,12 @@ import com.fr.concurrent.NamedThreadFactory; */ public class ConcurrentKit { - public static NamedThreadFactory newNamedThreadFactory(String s) { - return new NamedThreadFactory(s); + /** + * 创建命名的线程工厂 + * @param prefix 线程池名称前缀 + * @return 线程工厂 + */ + public static NamedThreadFactory newNamedThreadFactory(String prefix) { + return new NamedThreadFactory(prefix); } } diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java b/src/main/java/com/fanruan/api/conf/impl/xml/XmlColConf.java similarity index 95% rename from src/main/java/com/fanruan/api/conf/xml/XmlColConf.java rename to src/main/java/com/fanruan/api/conf/impl/xml/XmlColConf.java index caf9405..efcdf89 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlColConf.java +++ b/src/main/java/com/fanruan/api/conf/impl/xml/XmlColConf.java @@ -1,4 +1,4 @@ -package com.fanruan.api.conf.xml; +package com.fanruan.api.conf.impl.xml; import java.util.Collection; diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlConf.java b/src/main/java/com/fanruan/api/conf/impl/xml/XmlConf.java similarity index 93% rename from src/main/java/com/fanruan/api/conf/xml/XmlConf.java rename to src/main/java/com/fanruan/api/conf/impl/xml/XmlConf.java index 27d83e0..425ea8c 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlConf.java +++ b/src/main/java/com/fanruan/api/conf/impl/xml/XmlConf.java @@ -1,4 +1,4 @@ -package com.fanruan.api.conf.xml; +package com.fanruan.api.conf.impl.xml; import com.fr.stable.xml.XMLable; diff --git a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java index f88a363..942864b 100644 --- a/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java +++ b/src/main/java/com/fanruan/api/conf/xml/XmlHolderKit.java @@ -1,5 +1,7 @@ package com.fanruan.api.conf.xml; +import com.fanruan.api.conf.impl.xml.XmlColConf; +import com.fanruan.api.conf.impl.xml.XmlConf; import com.fr.config.holder.Conf; import com.fr.stable.xml.XMLable; diff --git a/src/main/java/com/fanruan/api/design/DesignKit.java b/src/main/java/com/fanruan/api/design/DesignKit.java index b4b48d3..60d73d4 100644 --- a/src/main/java/com/fanruan/api/design/DesignKit.java +++ b/src/main/java/com/fanruan/api/design/DesignKit.java @@ -1,14 +1,20 @@ package com.fanruan.api.design; +import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.base.TableData; +import com.fr.design.DesignModelAdapter; import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerBean; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; +import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; import com.fr.design.mainframe.JTemplate; +import javax.swing.JComponent; + public class DesignKit { /** * 直接预览数据集,没有实际值及显示值 @@ -67,4 +73,28 @@ public class DesignKit { public static DesignerBean getDesignerBean(String name) { return DesignerContext.getDesignerBean(name); } + + /** + * 超链接面板操作 + * @return 操作对象 + */ + public static HyperlinkGroupPaneActionProvider getHyperlinkGroupPaneAction() { + + return HyperlinkGroupPaneActionImpl.getInstance(); + } + + /** + * 当前的设计模式 FormModel or WorkBookModel + * @return 设计器模式 + */ + public static DesignModelAdapter getCurrentModelAdapter() { + return DesignModelAdapter.getCurrentModelAdapter(); + } + + /** + * 控件属性容器 + */ + public static JComponent getWidgetComponent() { + return (JComponent) (WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator()).getComponent(0); + } } diff --git a/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java b/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java deleted file mode 100644 index 83f82e6..0000000 --- a/src/main/java/com/fanruan/api/design/mainframe/HyperlinkGroupPaneAction.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.fanruan.api.design.mainframe; - -import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; -import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 - */ -public class HyperlinkGroupPaneAction { - public static HyperlinkGroupPaneActionProvider getInstance() { - - return HyperlinkGroupPaneActionImpl.getInstance(); - } - -} diff --git a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java b/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java deleted file mode 100644 index 525c9df..0000000 --- a/src/main/java/com/fanruan/api/design/ui/component/table/model/DesignModelAdapterKit.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.fanruan.api.design.ui.component.table.model; - -import com.fr.design.DesignModelAdapter; - -/** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/27 - */ -public class DesignModelAdapterKit { - - public static DesignModelAdapter getCurrentModelAdapter() { - return DesignModelAdapter.getCurrentModelAdapter(); - } -} diff --git a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java index 5d34633..455914c 100644 --- a/src/main/java/com/fanruan/api/design/util/GUICoreKit.java +++ b/src/main/java/com/fanruan/api/design/util/GUICoreKit.java @@ -139,6 +139,15 @@ public class GUICoreKit { return FRGUIPaneFactory.createBorderLayout(); } + /** + * 创建一个靠左空边框面板,间隔中等 + * + * @return JPanel对象 + */ + public static JPanel createMediumHGapHighTopFlowInnerContainerPane() { + return FRGUIPaneFactory.createMediumHGapHighTopFlowInnerContainer_M_Pane(); + } + /** * 设置一个窗口居中 */ diff --git a/src/main/java/com/fanruan/api/design/work/SelectImagePane.java b/src/main/java/com/fanruan/api/design/work/SelectImagePane.java index 07f1e10..78c1651 100644 --- a/src/main/java/com/fanruan/api/design/work/SelectImagePane.java +++ b/src/main/java/com/fanruan/api/design/work/SelectImagePane.java @@ -1,18 +1,198 @@ package com.fanruan.api.design.work; +import com.fanruan.api.design.ui.component.UIButton; +import com.fanruan.api.design.ui.component.UIRadioButton; +import com.fanruan.api.design.util.GUICoreKit; import com.fanruan.api.report.cell.CellImage; +import com.fr.base.Style; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.frpane.ImgChooseWrapper; +import com.fr.design.style.background.image.ImageFileChooser; +import com.fr.design.style.background.image.ImagePreviewPane; +import com.fr.report.cell.Elem; +import com.fr.report.cell.painter.CellImagePainter; +import com.fr.stable.Constants; + +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.BorderLayout; +import java.awt.GridLayout; +import java.awt.Image; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; /** - * @author Lucian.Chen - * @version 10.0 - * Created by Lucian.Chen on 2020/3/23 + * 这个类主要用于插入图片时的设置 */ -public class SelectImagePane extends com.fr.design.report.SelectImagePane { +public class SelectImagePane extends BasicPane { + private ImagePreviewPane previewPane = null; + + private ImageFileChooser imageFileChooser = null; + private UIRadioButton defaultRadioButton = null; + private UIRadioButton tiledRadioButton = null; + private UIRadioButton extendRadioButton = null; + private UIRadioButton adjustRadioButton = null; + + private Style imageStyle = null; + + private File imageFile; + public SelectImagePane() { - super(); + this.setLayout(GUICoreKit.createBorderLayout()); + + // preview pane + JPanel previewContainerPane = GUICoreKit.createBorderLayoutPane(); + this.add(previewContainerPane, BorderLayout.CENTER); + + JPanel previewOwnerPane = GUICoreKit.createBorderLayoutPane(); + previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER); + + previewOwnerPane.setBorder(GUICoreKit.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"), null)); + + previewPane = new ImagePreviewPane(); + previewOwnerPane.add(new JScrollPane(previewPane)); + + JPanel selectFilePane = GUICoreKit.createBorderLayoutPane(); + previewContainerPane.add(selectFilePane, BorderLayout.EAST); + selectFilePane.setBorder(BorderFactory + .createEmptyBorder(8, 2, 4, 0)); + + UIButton selectPictureButton = new UIButton( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Select_Picture")); + selectFilePane.add(selectPictureButton, BorderLayout.NORTH); + selectPictureButton.setMnemonic('S'); + selectPictureButton.addActionListener(selectPictureActionListener); + + JPanel layoutPane = GUICoreKit.createMediumHGapHighTopFlowInnerContainerPane(); + selectFilePane.add(layoutPane, BorderLayout.CENTER); + + //布局 + defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); + tiledRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Titled")); + extendRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image_Extend")); + adjustRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Image_Adjust")); + + defaultRadioButton.addActionListener(layoutActionListener); + tiledRadioButton.addActionListener(layoutActionListener); + extendRadioButton.addActionListener(layoutActionListener); + adjustRadioButton.addActionListener(layoutActionListener); + + JPanel jp = new JPanel(new GridLayout(4, 1, 15, 15)); + jp.add(defaultRadioButton); + jp.add(tiledRadioButton); + jp.add(extendRadioButton); + jp.add(adjustRadioButton); + layoutPane.add(jp); + + ButtonGroup layoutBG = new ButtonGroup(); + layoutBG.add(defaultRadioButton); + layoutBG.add(tiledRadioButton); + layoutBG.add(extendRadioButton); + layoutBG.add(adjustRadioButton); + + defaultRadioButton.setSelected(true); + + // init image file chooser. + imageFileChooser = new ImageFileChooser(); + imageFileChooser.setMultiSelectionEnabled(false); + } + + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser + .showOpenDialog(SelectImagePane.this); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + imageFile = selectedFile; + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal); + } + } + }; + + // 调整图片样式,只有水平和垂直对齐以及拉伸。相对于背景,平铺不予考虑。 + private void changeImageStyle() { + previewPane.setImageStyle(this.imageStyle); + previewPane.repaint(); + } + + private void setImageStyle() { + if (tiledRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_TILED); + } else if (adjustRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST); + } else if (extendRadioButton.isSelected()) { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_EXTEND); + } else { + imageStyle = Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER); + } + } + + ActionListener layoutActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + }; + + @Override + protected String title4PopupWindow() { + return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image"); + } + + public void populate(Elem cell) { + Style style = null; + if (cell != null) { + Object value = cell.getValue(); + if (value instanceof Image) { + setImage((Image) value); + } else if (value instanceof CellImagePainter) { + setImage(((CellImagePainter) value).getImage()); + } + + style = cell.getStyle(); + } + if (style == null) { + return; + } + + if (style.getImageLayout() == Constants.IMAGE_TILED) { + tiledRadioButton.setSelected(true); + } else if (style.getImageLayout() == Constants.IMAGE_EXTEND) { + extendRadioButton.setSelected(true); + } else if (style.getImageLayout() == Constants.IMAGE_ADJUST) { + adjustRadioButton.setSelected(true); + } else { + style.deriveImageLayout(Constants.IMAGE_CENTER); + defaultRadioButton.setSelected(true); + } + this.imageStyle = style; + changeImageStyle(); + } + + public void setImage(Image image) { + previewPane.setImage(image); } public CellImage update() { - return (CellImage) super.update(); + CellImage cellImage = new CellImage(); + cellImage.setImage(previewPane.getImageWithSuffix()); + cellImage.setStyle(this.imageStyle); + return cellImage; + } + + public File getSelectedImage() { + return imageFile; } } + diff --git a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java b/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java deleted file mode 100644 index 8621d73..0000000 --- a/src/main/java/com/fanruan/api/design/work/WidgetPropertyPane.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.fanruan.api.design.work; - -/** - * 控件属性表绘制 - * - */ -public class WidgetPropertyPane { - - public static com.fr.design.mainframe.WidgetPropertyPane getInstance() { - return com.fr.design.mainframe.WidgetPropertyPane.getInstance(); - } -} \ No newline at end of file diff --git a/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java b/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java index 0d66cc1..2b43ebe 100644 --- a/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java +++ b/src/main/java/com/fanruan/api/design/work/component/ParameterComboBox.java @@ -1,8 +1,8 @@ package com.fanruan.api.design.work.component; import com.fanruan.api.cal.ParameterKit; +import com.fanruan.api.design.DesignKit; import com.fanruan.api.design.ui.component.UIComboBox; -import com.fanruan.api.design.ui.component.table.model.DesignModelAdapterKit; import com.fanruan.api.util.AssistKit; import com.fr.design.DesignModelAdapter; import com.fr.stable.ParameterProvider; @@ -42,7 +42,7 @@ public class ParameterComboBox extends UIComboBox { public void updateParaItems() { - DesignModelAdapter designModel = DesignModelAdapterKit.getCurrentModelAdapter(); + DesignModelAdapter designModel = DesignKit.getCurrentModelAdapter(); this.removeAllItems(); if (designModel != null) { diff --git a/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java b/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java index cf5511d..317c037 100644 --- a/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java +++ b/src/test/java/com/fanruan/api/conf/xml/XmlHolderKitTest.java @@ -1,7 +1,10 @@ package com.fanruan.api.conf.xml; + import java.util.ArrayList; import java.util.List; +import com.fanruan.api.conf.impl.xml.XmlColConf; +import com.fanruan.api.conf.impl.xml.XmlConf; import com.fr.stable.xml.XMLable; import org.easymock.EasyMock; import org.junit.Assert; From d1e64878b005a848485dfe3432a08c2801d7dba3 Mon Sep 17 00:00:00 2001 From: lucian Date: Tue, 31 Mar 2020 10:38:15 +0800 Subject: [PATCH 5/5] =?UTF-8?q?KERNEL-3521=20=E6=B7=BB=E5=8A=A0FineKit?= =?UTF-8?q?=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/component/target/TargetComponent.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/fanruan/api/design/ui/component/target/TargetComponent.java diff --git a/src/main/java/com/fanruan/api/design/ui/component/target/TargetComponent.java b/src/main/java/com/fanruan/api/design/ui/component/target/TargetComponent.java new file mode 100644 index 0000000..f4a60e5 --- /dev/null +++ b/src/main/java/com/fanruan/api/design/ui/component/target/TargetComponent.java @@ -0,0 +1,16 @@ +package com.fanruan.api.design.ui.component.target; + +/** + * 模板设计界面 + */ +public abstract class TargetComponent extends com.fr.design.designer.TargetComponent { + + public TargetComponent(T t) { + super(t); + } + + public TargetComponent() { + super(); + } + +}