lucian
5 years ago
37 changed files with 1275 additions and 5 deletions
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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<T extends Collection> extends com.fr.config.holder.impl.xml.XmlColConf<Collection> { |
||||||
|
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); |
||||||
|
} |
||||||
|
} |
@ -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<T extends XMLable> extends com.fr.config.holder.impl.xml.XmlConf<XMLable> { |
||||||
|
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); |
||||||
|
} |
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
} |
@ -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 { |
||||||
|
|
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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<T extends BaseBook, S extends JTemplateProvider<T>> extends com.fr.design.DesignModelAdapter { |
||||||
|
public DesignModelAdapter(JTemplateProvider jTemplateProvider) { |
||||||
|
super(jTemplateProvider); |
||||||
|
} |
||||||
|
|
||||||
|
public static DesignModelAdapter<?, ?> getCurrentModelAdapter() { |
||||||
|
return DesignModelAdapter.getCurrentModelAdapter(); |
||||||
|
} |
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
} |
@ -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<AbstractPropertyTable> widgetPropertyTables; // 这个变量应该是保存控件拓展的属性tab
|
||||||
|
private List<MobileWidgetDefinePane> 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<AbstractPropertyTable>(); |
||||||
|
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<WidgetPropertyUIProvider> 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; |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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 { |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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(); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
@ -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<XMLable> 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); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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, "")); |
||||||
|
} |
||||||
|
} |
@ -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()); |
||||||
|
} |
||||||
|
} |
@ -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()); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue