forked from fanruan/finekit
Browse Source
* 'master' of https://cloud.finedevelop.com/scm/tc/finekit: (30 commits) 说明 说明 配置监听+错误的插件类 更新更多的使用FineKit的插件列表 自定义控件插件 错误的import 修改 修改 改动 改动 按要求增添修改 一点小修改 控件设计界面接口 控件设计界面接口 新增控件接口 更新jar重载方法 修改 修改 再次修改 按要求修改 ... # Conflicts: # src/main/java/com/fanruan/api/conf/HolderKit.java # src/main/java/com/fanruan/api/util/CodeKit.java # src/main/java/com/fanruan/api/xml/XmlKit.javamaster
zjz1993
5 years ago
32 changed files with 867 additions and 84 deletions
@ -0,0 +1,4 @@
|
||||
package com.fanruan.api.design.work; |
||||
|
||||
public class ReportletPane extends com.fr.design.gui.itree.filetree.ReportletPane { |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fanruan.api.design.work.form.creator; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
|
||||
import java.beans.IntrospectionException; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public class Attribute { |
||||
|
||||
private CRPropertyDescriptor descriptor; |
||||
|
||||
public static Attribute newAttribute(String name, Class<?> beanClass) { |
||||
return new Attribute(name, beanClass); |
||||
} |
||||
|
||||
public static Attribute newAttribute(String name, Class<?> beanClass, String readMethod, String writeMethod) { |
||||
return new Attribute(name, beanClass, readMethod, writeMethod); |
||||
} |
||||
|
||||
private Attribute(String name, Class<?> beanClass) { |
||||
try { |
||||
descriptor = new CRPropertyDescriptor(name, beanClass); |
||||
} catch (IntrospectionException e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
private Attribute(String name, Class<?> beanClass, String readMethod, String writeMethod) { |
||||
try { |
||||
descriptor = new CRPropertyDescriptor(name, beanClass, readMethod, writeMethod); |
||||
} catch (IntrospectionException e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} |
||||
|
||||
public Attribute keyValue(String name, Object value) { |
||||
if (descriptor != null) { |
||||
descriptor.putKeyValue(name, value); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Attribute i18n(String i18nName) { |
||||
if (descriptor != null) { |
||||
descriptor.setI18NName(i18nName); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Attribute editorClass(Class<?> clazz) { |
||||
if (descriptor != null) { |
||||
descriptor.setEditorClass(clazz); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
public Attribute rendererClass(Class<?> clazz) { |
||||
if (descriptor != null) { |
||||
descriptor.setRendererClass(clazz); |
||||
} |
||||
return this; |
||||
} |
||||
|
||||
/** |
||||
* 这个属于内部调用的方法,外部不应该调用 |
||||
*/ |
||||
protected CRPropertyDescriptor toPropertyDescriptor() { |
||||
return descriptor; |
||||
} |
||||
} |
@ -0,0 +1,80 @@
|
||||
package com.fanruan.api.design.work.form.creator; |
||||
|
||||
import com.fanruan.api.util.IOKit; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public class OpacityButton extends JButton { |
||||
|
||||
private static final float FULL_OPACITY = 1.0F; |
||||
private static final float HALF_OPACITY = 0.4F; |
||||
|
||||
private String name; |
||||
private String imagePath; |
||||
private float opacity; |
||||
|
||||
public OpacityButton(String name, String imagePath, float opacity) { |
||||
this.name = name; |
||||
this.imagePath = imagePath; |
||||
this.opacity = opacity; |
||||
this.draw(); |
||||
} |
||||
|
||||
private void draw() { |
||||
ImageIcon imageIcon = (ImageIcon) IOKit.readIcon(imagePath); |
||||
Image img = imageIcon.getImage(); |
||||
MediaTracker mt = new MediaTracker(this); |
||||
int w = 21; |
||||
int h = 21; |
||||
mt.addImage(img, 0); |
||||
try { |
||||
mt.waitForAll(); |
||||
} catch (InterruptedException ignore) { |
||||
return; |
||||
} |
||||
|
||||
GraphicsConfiguration gc = new JFrame().getGraphicsConfiguration(); // 本地图形设备
|
||||
Image image = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT);//建立透明画布
|
||||
Graphics2D g = (Graphics2D) image.getGraphics(); //在画布上创建画笔
|
||||
|
||||
Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f); //指定透明度为半透明90%
|
||||
g.setComposite(alpha); |
||||
g.drawImage(img, 0, 0, this); //注意是,将image画到g画笔所在的画布上
|
||||
g.setColor(Color.black);//设置颜色为黑色
|
||||
g.drawString(name, 25, 20);//写字
|
||||
g.dispose(); //释放内存
|
||||
|
||||
Composite alpha2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity); |
||||
Image image1 = gc.createCompatibleImage(w, h, Transparency.TRANSLUCENT); |
||||
g = (Graphics2D) image1.getGraphics(); |
||||
g.setComposite(alpha2); |
||||
g.drawImage(img, 2, 2, this); //改变图像起始位置,产生动态效果
|
||||
g.setColor(Color.black); |
||||
g.drawString(name, 25, 20); |
||||
g.dispose(); |
||||
|
||||
this.setIgnoreRepaint(true); |
||||
this.setFocusable(false);//设置没有焦点
|
||||
this.setBorder(null);//设置不画按钮边框
|
||||
this.setContentAreaFilled(false);//设置不画按钮背景
|
||||
this.setIcon(new ImageIcon(image1)); //把刚才生成的半透明image变成ImageIcon,贴到按钮上去
|
||||
this.setRolloverIcon(new ImageIcon(image1)); |
||||
this.setPressedIcon(new ImageIcon(image));//按下去的图标
|
||||
} |
||||
|
||||
/** |
||||
* 更改组件的可见性 |
||||
* |
||||
* @param visible 设置为true表示可见,设置为false表示不可见 |
||||
*/ |
||||
public void makeVisible(boolean visible) { |
||||
this.opacity = visible ? FULL_OPACITY : HALF_OPACITY; |
||||
this.draw(); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fanruan.api.design.work.form.creator; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.mainframe.widget.editors.InChangeBooleanEditor; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.form.ui.concept.Blankable; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
* 控件的UI展示和设计类 |
||||
*/ |
||||
public abstract class XFieldCreator extends XOpenCreator { |
||||
|
||||
public XFieldCreator(Widget fieldEditor, Dimension dimension) { |
||||
super(fieldEditor, dimension); |
||||
} |
||||
|
||||
@Override |
||||
public Attribute[] attributes() { |
||||
|
||||
Attribute allowBlank = Attribute.newAttribute("allowBlank", this.data.getClass()).i18n( |
||||
DesignKit.i18nText("Fine-Design_Form_Allow_Blank")) |
||||
.editorClass(InChangeBooleanEditor.class).keyValue( |
||||
XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate"); |
||||
Attribute blankErrorMsg = Attribute.newAttribute("errorMessage", this.data.getClass()).i18n( |
||||
DesignKit.i18nText("Fine-Design_Report_Engine_Verify_Message")) |
||||
.keyValue(XCreatorConstants.PROPERTY_VALIDATE, "Fine-Design_Basic_Validate"); |
||||
Attribute fontSize = Attribute.newAttribute("fontSize", this.data.getClass(), "getFontSize", "setFontSize") |
||||
.i18n(DesignKit.i18nText("Fine-Design_Form_Font_Size")) |
||||
.keyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Report_Advanced"); |
||||
|
||||
Widget widget = toData(); |
||||
// 控件类型允许值为空,但是设置了不允许为空,就要设置为空时的提示信息
|
||||
if (widget instanceof Blankable && !((Blankable) widget).isAllowBlank()) { |
||||
return new Attribute[]{ |
||||
allowBlank, blankErrorMsg, fontSize |
||||
}; |
||||
} |
||||
return new Attribute[]{ |
||||
allowBlank, fontSize |
||||
}; |
||||
|
||||
} |
||||
|
||||
} |
@ -1,17 +0,0 @@
|
||||
package com.fanruan.api.design.work.form.creator; |
||||
|
||||
import com.fr.form.ui.FieldEditor; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* 控件树 |
||||
* @author Kalven |
||||
* @version 10.0 |
||||
* Created by Kalven on 2019/9/3 |
||||
*/ |
||||
public abstract class XFieldEditor extends com.fr.design.designer.creator.XFieldEditor { |
||||
public XFieldEditor(FieldEditor widget, Dimension initSize) { |
||||
super(widget, initSize); |
||||
} |
||||
} |
@ -0,0 +1,114 @@
|
||||
package com.fanruan.api.design.work.form.creator; |
||||
|
||||
import com.fanruan.api.design.DesignKit; |
||||
import com.fanruan.api.design.work.form.macro.XCreatorConstants; |
||||
import com.fanruan.api.util.ArrayKit; |
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XWidgetCreator; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.stable.core.PropertyChangeAdapter; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.beans.IntrospectionException; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public abstract class XOpenCreator extends XWidgetCreator { |
||||
|
||||
public XOpenCreator(Widget widget, Dimension size) { |
||||
super(widget, size); |
||||
} |
||||
|
||||
final public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||
CRPropertyDescriptor[] basic = new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(DesignKit.i18nText("Fine-Design_Form_Form_Widget_Name")), |
||||
new CRPropertyDescriptor("enabled", this.data.getClass()).setI18NName(DesignKit.i18nText("Fine-Design_Report_Enabled")) |
||||
.setPropertyChangeListener(new PropertyChangeAdapter() { |
||||
|
||||
@Override |
||||
public void propertyChange() { |
||||
setEnabled(toData().isEnabled()); |
||||
} |
||||
}), |
||||
new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( |
||||
DesignKit.i18nText("Fine-Design_Form_Widget_Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { |
||||
|
||||
@Override |
||||
public void propertyChange() { |
||||
makeVisible(toData().isVisible()); |
||||
} |
||||
}), |
||||
new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName") |
||||
.setI18NName(DesignKit.i18nText("Fine-Design_Form_Label_Name")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") |
||||
}; |
||||
Attribute[] attributes = attributes(); |
||||
CRPropertyDescriptor[] current = new CRPropertyDescriptor[attributes.length]; |
||||
for (int i = 0, len = attributes.length; i < len; i++) { |
||||
current[i] = attributes[i].toPropertyDescriptor(); |
||||
} |
||||
return ArrayKit.addAll(basic, current); |
||||
} |
||||
|
||||
/** |
||||
* 控件支持的属性以及操作设置这些属性的方法,使用反射调用属性的设置方法。 |
||||
* 示例:如果不显示的传入读取和写入方法,则默认调用"get+属性名"或者"set+属性名"的方法。 |
||||
* |
||||
* @return 控件支持的属性以及操作设置这些属性的方法集合 |
||||
*/ |
||||
public abstract Attribute[] attributes(); |
||||
|
||||
/** |
||||
* 待说明 |
||||
* |
||||
* @return 待说明 |
||||
*/ |
||||
public Widget toData() { |
||||
return this.data; |
||||
} |
||||
|
||||
/** |
||||
* 根据Widget的属性值初始化XCreator的属性值 |
||||
*/ |
||||
@Override |
||||
protected void initXCreatorProperties() { |
||||
this.setEnabled(toData().isEnabled()); |
||||
} |
||||
|
||||
/** |
||||
* 待说明 |
||||
*/ |
||||
public void recalculateChildrenSize() { |
||||
} |
||||
|
||||
|
||||
protected void makeVisible(boolean visible) { |
||||
|
||||
} |
||||
|
||||
public void paint(Graphics g) { |
||||
AlphaComposite composite = this.data.isVisible() ? (AlphaComposite) ((Graphics2D) g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER, HALF_OPACITY); |
||||
((Graphics2D) g).setComposite(composite); |
||||
super.paint(g); |
||||
} |
||||
|
||||
/** |
||||
* 重命名 |
||||
* |
||||
* @param designer 表单设计器 |
||||
* @param creator 当前组件 |
||||
*/ |
||||
public void ChangeCreatorName(FormDesigner designer, XCreator creator) { |
||||
String oldName = creator.toData().getWidgetName(); |
||||
String value = JOptionPane.showInputDialog(designer, DesignKit.i18nText("Fine-Design_Form_Change_Widget_Name_Discription"), oldName); |
||||
if (value != null) { |
||||
designer.renameCreator(creator, value); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,7 @@
|
||||
package com.fanruan.api.err; |
||||
|
||||
/** |
||||
* 验证异常 |
||||
*/ |
||||
public class ValidationException extends com.fr.design.Exception.ValidationException { |
||||
} |
@ -0,0 +1,11 @@
|
||||
package com.fanruan.api.generic; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-17 |
||||
*/ |
||||
public interface Matcher<T> { |
||||
|
||||
boolean match(T t); |
||||
} |
@ -1,4 +1,4 @@
|
||||
package com.fanruan.api.conf; |
||||
package com.fanruan.api.generic; |
||||
|
||||
/** |
||||
* @author richie |
@ -0,0 +1,4 @@
|
||||
package com.fanruan.api.report.analy.data; |
||||
|
||||
public abstract class NodeVisitor extends com.fr.stable.core.NodeVisitor { |
||||
} |
@ -0,0 +1,31 @@
|
||||
package com.fanruan.api.report.form; |
||||
|
||||
import com.fr.data.act.Describer; |
||||
import com.fr.data.act.Producer; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.core.NodeVisitor; |
||||
import com.fr.stable.web.Repository; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
* 控件的插件接口 |
||||
*/ |
||||
public abstract class BaseWidget extends Widget implements Describer, Producer { |
||||
|
||||
@Override |
||||
public boolean isEditor() { |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
public JSONObject createJSONConfig(Repository repository, Calculator calculator, NodeVisitor nodeVisitor) throws JSONException { |
||||
JSONObject jo = super.createJSONConfig(repository, calculator, nodeVisitor); |
||||
mixinJSON(repository, calculator, jo); |
||||
return jo; |
||||
} |
||||
} |
@ -1,10 +0,0 @@
|
||||
package com.fanruan.api.report.form; |
||||
|
||||
/** |
||||
* 允许自定义值的、允许直接编辑的、带重复的 --- 下拉框 下拉复选框 下拉树 |
||||
* @author Kalven |
||||
* @version 10.0 |
||||
* Created by Kalven on 2019/9/4 |
||||
*/ |
||||
public abstract class CustomWriteAbleRepeatEditor extends com.fr.form.ui.CustomWriteAbleRepeatEditor { |
||||
} |
@ -0,0 +1,64 @@
|
||||
package com.fanruan.api.report.form.category; |
||||
|
||||
import com.fanruan.api.report.form.BaseWidget; |
||||
import com.fanruan.api.report.form.describer.TextDescriber; |
||||
import com.fanruan.api.util.ArrayKit; |
||||
import com.fanruan.api.xml.XmlKit; |
||||
import com.fr.stable.script.CalculatorProvider; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public abstract class TextWidget extends BaseWidget { |
||||
|
||||
private TextDescriber textDescriber; |
||||
|
||||
/** |
||||
* 获取联动参数 |
||||
* |
||||
* @param c 当前算子 |
||||
* @return 放回当前控件依赖的参数 |
||||
*/ |
||||
public String[] dependence(CalculatorProvider c) { |
||||
return ArrayKit.EMPTY_STRING_ARRAY; |
||||
} |
||||
|
||||
/** |
||||
* 获取支持的事件 |
||||
* |
||||
* @return 当前控件支持的事件 |
||||
*/ |
||||
public String[] supportedEvents() { |
||||
return new String[]{AFTERINIT, BEFOREEDIT, AFTEREDIT, STOPEDIT}; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if (TextDescriber.XML_TAG.equals(tagName)) { |
||||
textDescriber = (TextDescriber) XmlKit.readXMLable(reader); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
if (textDescriber != null) { |
||||
XmlKit.writeXMLable(writer, textDescriber, TextDescriber.XML_TAG); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
TextWidget cloned = (TextWidget) super.clone(); |
||||
if (textDescriber != null) { |
||||
cloned.textDescriber = (TextDescriber) textDescriber.clone(); |
||||
} |
||||
return cloned; |
||||
} |
||||
} |
@ -0,0 +1,78 @@
|
||||
package com.fanruan.api.report.form.describer; |
||||
|
||||
import com.fanruan.api.cal.FormulaKit; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fanruan.api.util.GeneralKit; |
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.data.act.Describer; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.script.CalculatorProvider; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public class EditTextDescriber implements Describer, XMLable { |
||||
|
||||
public static final String XML_TAG = "EditTextDescriber"; |
||||
|
||||
private boolean directEdit = true; |
||||
|
||||
private String waterMark; |
||||
|
||||
public EditTextDescriber() { |
||||
|
||||
} |
||||
|
||||
public boolean isDirectEdit() { |
||||
return this.directEdit; |
||||
} |
||||
|
||||
public void setDirectEdit(boolean directEdit) { |
||||
this.directEdit = directEdit; |
||||
} |
||||
|
||||
public void setWaterMark(String waterMark) { |
||||
this.waterMark = waterMark; |
||||
} |
||||
|
||||
public String getWaterMark() { |
||||
return waterMark; |
||||
} |
||||
|
||||
@Override |
||||
public void mixinJSON(Repository repo, CalculatorProvider c, JSONObject jo) { |
||||
jo.put("directEdit", directEdit); |
||||
if (StringKit.isNotBlank(waterMark)) { |
||||
if (FormulaKit.canBeFormula(waterMark)) { |
||||
try { |
||||
jo.put("watermark", GeneralKit.objectToString(FormulaKit.newFormula(waterMark).eval(c))); |
||||
} catch (Exception e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} else { |
||||
jo.put("watermark", waterMark); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader xmLableReader) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter xmlPrintWriter) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
return super.clone(); |
||||
} |
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.fanruan.api.report.form.describer; |
||||
|
||||
import com.fr.data.act.Describer; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.script.CalculatorProvider; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public class RepeatDescriber implements Describer, XMLable { |
||||
|
||||
public static final String XML_TAG = "RepeatDescriber"; |
||||
|
||||
private boolean removeRepeat = true; |
||||
|
||||
public boolean isRemoveRepeat() { |
||||
return this.removeRepeat; |
||||
} |
||||
|
||||
public void setRemoveRepeat(boolean removeRepeat) { |
||||
this.removeRepeat = removeRepeat; |
||||
} |
||||
|
||||
@Override |
||||
public void mixinJSON(Repository repo, CalculatorProvider c, JSONObject jo) { |
||||
if (removeRepeat) { |
||||
jo.put("norepeat", true); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader xmLableReader) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter xmlPrintWriter) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
return super.clone(); |
||||
} |
||||
} |
@ -0,0 +1,83 @@
|
||||
package com.fanruan.api.report.form.describer; |
||||
|
||||
import com.fanruan.api.util.StringKit; |
||||
import com.fr.data.act.Describer; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.script.CalculatorProvider; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLable; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-09-10 |
||||
*/ |
||||
public class TextDescriber implements Describer, XMLable { |
||||
|
||||
public static final String XML_TAG = "TextDescriber"; |
||||
|
||||
private boolean allowBlank = true; |
||||
private String errorMessage; |
||||
private int fontSize = 12; |
||||
|
||||
public TextDescriber() { |
||||
|
||||
} |
||||
|
||||
public TextDescriber(boolean allowBlank) { |
||||
this.allowBlank = allowBlank; |
||||
} |
||||
|
||||
public boolean isAllowBlank() { |
||||
return this.allowBlank; |
||||
} |
||||
|
||||
public void setAllowBlank(boolean allowBlank) { |
||||
this.allowBlank = allowBlank; |
||||
} |
||||
|
||||
public int getFontSize() { |
||||
return this.fontSize; |
||||
} |
||||
|
||||
public void setFontSize(int size) { |
||||
this.fontSize = size; |
||||
} |
||||
|
||||
public String getErrorMessage() { |
||||
return errorMessage == null ? StringUtils.EMPTY : errorMessage; |
||||
} |
||||
|
||||
public void setErrorMessage(String errorMessage) { |
||||
this.errorMessage = errorMessage; |
||||
} |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader xmLableReader) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter xmlPrintWriter) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
return super.clone(); |
||||
} |
||||
|
||||
@Override |
||||
public void mixinJSON(Repository repo, CalculatorProvider c, JSONObject jo) { |
||||
if (!allowBlank) { |
||||
jo.put("allowBlank", true); |
||||
} |
||||
if (StringKit.isNotEmpty(errorMessage)) { |
||||
jo.put("errorMessage", errorMessage); |
||||
} |
||||
jo.put("fontSize", this.fontSize); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fanruan.api.report.form.value; |
||||
|
||||
import com.fr.form.ui.WidgetValue; |
||||
import com.fr.form.ui.concept.data.ValueInitializer; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019/9/17 |
||||
* 初始化工具类 |
||||
*/ |
||||
public class InitializerKit { |
||||
|
||||
/** |
||||
* 初始化化一个控件值对象 |
||||
* |
||||
* @return 控件值 |
||||
*/ |
||||
public static ValueInitializer newValue() { |
||||
return new WidgetValue(); |
||||
} |
||||
|
||||
/** |
||||
* 初始化一个控件值对象 |
||||
* |
||||
* @param value 控件值的值 |
||||
* @return 控件值 |
||||
*/ |
||||
public static ValueInitializer newValue(Object value) { |
||||
return new WidgetValue(value); |
||||
} |
||||
} |
@ -1,20 +0,0 @@
|
||||
package com.fanruan.api.runtime; |
||||
|
||||
import com.fr.plugin.context.PluginContexts; |
||||
|
||||
/** |
||||
* @author richie |
||||
* @version 10.0 |
||||
* Created by richie on 2019-08-30 |
||||
* 插件相关的工具类 |
||||
*/ |
||||
public class PluginKit { |
||||
|
||||
/** |
||||
* 当前插件是否可用(例如:插件授权文件过期时,该犯法会返回false) |
||||
* @return 插件可用则返回true,不可用则返回false |
||||
*/ |
||||
public static boolean isCurrentPluginAvailable() { |
||||
return PluginContexts.currentContext().isAvailable(); |
||||
} |
||||
} |
@ -1,13 +0,0 @@
|
||||
package com.fanruan.api.plugin; |
||||
|
||||
import com.fanruan.api.runtime.PluginKit; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class PluginKitTest { |
||||
@Test |
||||
public void getArray() { |
||||
Assert.assertFalse(PluginKit.isCurrentPluginAvailable()); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,30 @@
|
||||
package com.fanruan.api.xml; |
||||
|
||||
import com.fr.base.Parameter; |
||||
import com.fr.stable.bridge.StableFactory; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
import com.fr.third.javax.xml.stream.XMLStreamException; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class XmlKitTest { |
||||
|
||||
@Test |
||||
public void readParameter() { |
||||
try { |
||||
XMLableReader xml = XMLableReader.createXMLableReader("<!-- Edited by XMLSpy® -->\n" + |
||||
"<note>\n" + |
||||
"<Parameter>Tove</Parameter>\n" + |
||||
"<from>Jani</from>\n" + |
||||
"<heading>Reminder</heading>\n" + |
||||
"<body>Don't forget me this weekend!</body>\n" + |
||||
"</note>"); |
||||
Parameter parameter = new Parameter("test", 1); |
||||
StableFactory.registerXMLDescription("Parameter",parameter); |
||||
Parameter p = (Parameter)XmlKit.readParameter(xml); |
||||
Assert.assertTrue(p.getName().equals("test")); |
||||
} catch (XMLStreamException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue