测试禁用、启用对插件运行的影响,先安装插件,新建模板,输入测试函数:FRTest("return value"),单元格显示内容为:用html显示内容。保存预览,显示aaa链接,单击链接,正常显示return value,如果禁用、启用一下插件,或者重启设计器,就不能显示正常内容了,提示报错。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

84 lines
2.8 KiB

package com.fr.plugin.cool.cartnoon;
import com.fr.intelli.record.Focus;
import com.fr.intelli.record.Original;
import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.PluginLicense;
import com.fr.plugin.PluginLicenseManager;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.cool.cartnoon.utils.AnimatedGifEncoder;
import com.fr.plugin.cool.cartnoon.web.ImageViewer;
import com.fr.plugin.manage.PluginManager;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.script.AbstractFunction;
import com.fr.stable.Primitive;
import com.fr.stable.fun.Authorize;
import java.awt.*;
import java.io.ByteArrayOutputStream;
@EnableMetrics
@Authorize(callSignKey = CartUtils.PLUGIN_ID)
public class FRPrintText extends AbstractFunction {
@Override
@Focus(id = CartUtils.PLUGIN_ID, text = "Plugin-Function_FRPrintText", source = Original.PLUGIN)
public Object run(Object[] args) {
PluginLicense pluginLicense = PluginLicenseManager.getInstance().getPluginLicenseByID(CartUtils.PLUGIN_ID);
if (!pluginLicense.isAvailable()) {
return InterProviderFactory.getProvider().getLocText("Plugin.Function.CartNoon_AUTHOR_ERROR");
}
PluginContext contexts = PluginManager.getContext(CartUtils.PLUGIN_ID);
if(!contexts.isActive()){
return "插件已被禁用!";
}
if(!CartUtils.CheckArgs(args,6)){
return Primitive.ERROR_VALUE;
}
final String text = args[0].toString();
int width= Integer.parseInt(args[1].toString());
int height= Integer.parseInt(args[2].toString());
int fontSize= Integer.parseInt(args[3].toString());
int rate= Integer.parseInt(args[4].toString());
final Color color = CartUtils.TextToColor(args[5].toString());
final String id= CartUtils.GetCellId(this);
final String url="/webroot/decision/url/img?id="+id;
CreatePrintAnimate(id,text,fontSize,rate,color,width);
return "<img src=\""+url+"\" width=\""+width+"\" height=\""+height+"\" />";
}
final void CreatePrintAnimate(String id, String text, int fontSize, int rate, Color color, int width) {
// 读数据
int len=text.length();
AnimatedGifEncoder e = new AnimatedGifEncoder();
ByteArrayOutputStream out=new ByteArrayOutputStream();
e.start(out);
//图片之间间隔时间
e.setDelay(rate); // 1 frame per sec
//重复次数 0表示无限重复 默认不重复
e.setRepeat(0);
//添加图片
String subStr;
for (int i = 0; i <= len; i++) {
subStr=text.substring(0,i);
e.addFrame(CartUtils.ImageFromText(subStr,fontSize,color,width));
}
e.finish();
byte[] data = out.toByteArray();
ImageViewer.gifData.put(id,data);
}
}