10 changed files with 574 additions and 1 deletions
@ -1,3 +1,7 @@
|
||||
# demo-java-script-action-provider |
||||
|
||||
报表事件处理方式扩展 |
||||
报表事件处理方式扩展\ |
||||
demo生效后,填报预览附件demo.cpt\ |
||||
点击按钮“123”,会弹出alert(xxxxx)\ |
||||
在按钮的点击事件中,可以选择 Demo Script这个时间处理方式。可修改对应的文本值,该值就是alert出来的具体值\ |
||||
注:因为仅仅是demo,所以未做特殊和冲突字符的转义和检测! |
@ -0,0 +1,124 @@
|
||||
|
||||
apply plugin: 'java' |
||||
|
||||
[compileJava,compileTestJava]*.options*.encoding = 'UTF-8' |
||||
|
||||
ext { |
||||
/** |
||||
* 项目中依赖的jar的路径 |
||||
* 1.如果依赖的jar需要打包到zip中,放置在lib根目录下 |
||||
* 2.如果依赖的jar仅仅是编译时需要,防止在lib下子目录下即可 |
||||
*/ |
||||
libPath = "$projectDir/../webroot/WEB-INF/lib" |
||||
|
||||
/** |
||||
* 是否对插件的class进行加密保护,防止反编译 |
||||
*/ |
||||
guard = false |
||||
|
||||
def pluginInfo = getPluginInfo() |
||||
pluginPre = "fine-plugin" |
||||
pluginName = pluginInfo.id |
||||
pluginVersion = pluginInfo.version |
||||
|
||||
outputPath = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/classes" |
||||
} |
||||
|
||||
group = 'com.fr.plugin' |
||||
version = '10.0' |
||||
sourceCompatibility = '8' |
||||
|
||||
sourceSets { |
||||
main { |
||||
java.outputDir = file(outputPath) |
||||
output.resourcesDir = file(outputPath) |
||||
} |
||||
} |
||||
|
||||
ant.importBuild("encrypt.xml") |
||||
//定义ant变量 |
||||
ant.projectDir = projectDir |
||||
ant.references["compile.classpath"] = ant.path { |
||||
fileset(dir: libPath, includes: '**/*.jar') |
||||
fileset(dir: ".",includes:"**/*.jar" ) |
||||
} |
||||
|
||||
classes.dependsOn('clean') |
||||
|
||||
task copyFiles(type: Copy,dependsOn: 'classes'){ |
||||
from outputPath |
||||
into "$projectDir/classes" |
||||
} |
||||
|
||||
task preJar(type:Copy,dependsOn: guard ? 'compile_encrypt_javas' : 'compile_plain_javas'){ |
||||
from "$projectDir/classes" |
||||
into "$projectDir/transform-classes" |
||||
include "**/*.*" |
||||
} |
||||
jar.dependsOn("preJar") |
||||
|
||||
task makeJar(type: Jar,dependsOn: preJar){ |
||||
from fileTree(dir: "$projectDir/transform-classes") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
destinationDir = file("$buildDir/libs") |
||||
|
||||
doLast(){ |
||||
delete file("$projectDir/classes") |
||||
delete file("$projectDir/transform-classes") |
||||
} |
||||
} |
||||
|
||||
task copyFile(type: Copy,dependsOn: ["makeJar"]){ |
||||
from "$buildDir/libs" |
||||
from("$projectDir/lib") { |
||||
include "*.jar" |
||||
} |
||||
from "$projectDir/plugin.xml" |
||||
into file("$buildDir/temp/plugin") |
||||
} |
||||
|
||||
task zip(type:Zip,dependsOn:["copyFile"]){ |
||||
from "$buildDir/temp/plugin" |
||||
destinationDir file("$buildDir/install") |
||||
baseName pluginPre |
||||
appendix pluginName |
||||
version pluginVersion |
||||
} |
||||
|
||||
//控制build时包含哪些文件,排除哪些文件 |
||||
processResources { |
||||
// exclude everything |
||||
// 用*.css没效果 |
||||
// exclude '**/*.css' |
||||
// except this file |
||||
// include 'xx.xml' |
||||
} |
||||
|
||||
/*读取plugin.xml中的version*/ |
||||
def getPluginInfo(){ |
||||
def xmlFile = file("plugin.xml") |
||||
if (!xmlFile.exists()) { |
||||
return ["id":"none", "version":"1.0.0"] |
||||
} |
||||
def plugin = new XmlParser().parse(xmlFile) |
||||
def version = plugin.version[0].text() |
||||
def id = plugin.id[0].text() |
||||
return ["id":id,"version":version] |
||||
} |
||||
|
||||
repositories { |
||||
mavenLocal() |
||||
maven { |
||||
url = uri('http://mvn.finedevelop.com/repository/maven-public/') |
||||
} |
||||
} |
||||
|
||||
dependencies { |
||||
//使用本地jar |
||||
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||
implementation fileTree(dir: libPath, include: ['**/*.jar']) |
||||
} |
||||
|
||||
|
@ -0,0 +1,278 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<WorkBook xmlVersion="20170720" releaseVersion="10.0.0"> |
||||
<Report class="com.fr.report.worksheet.WorkSheet" name="sheet1"> |
||||
<ReportPageAttr> |
||||
<HR/> |
||||
<FR/> |
||||
<HC/> |
||||
<FC/> |
||||
</ReportPageAttr> |
||||
<ColumnPrivilegeControl/> |
||||
<RowPrivilegeControl/> |
||||
<RowHeight defaultValue="723900"> |
||||
<![CDATA[723900,723900,723900,723900,723900,723900,723900,723900,723900,723900,723900]]></RowHeight> |
||||
<ColumnWidth defaultValue="2743200"> |
||||
<![CDATA[2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200,2743200]]></ColumnWidth> |
||||
<CellElementList> |
||||
<C c="0" r="0" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="0" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="0" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="0" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="0" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="0" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="1" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="1" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="1" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="1" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="1" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="1" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="2" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="2" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="2" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="2" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="2" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="2" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="3" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="3" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="3" s="0"> |
||||
<PrivilegeControl/> |
||||
<Widget class="com.fr.form.ui.FreeButton"> |
||||
<Listener event="click"> |
||||
<JavaScript class="com.tptj.demo.hg.java.script.action.provider.DemoScript" pluginID="com.tptj.demo.hg.java.script.action.provider.v10"> |
||||
<Parameters/> |
||||
<DemoScript data="234哇而突然·"/> |
||||
</JavaScript> |
||||
</Listener> |
||||
<WidgetAttr description=""> |
||||
<MobileBookMark useBookMark="false" bookMarkName="" frozen="false"/> |
||||
<PrivilegeControl/> |
||||
</WidgetAttr> |
||||
<Text> |
||||
<![CDATA[123]]></Text> |
||||
</Widget> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="3" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="3" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="3" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="4" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="4" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="4" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="4" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="4" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="4" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="5" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="5" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="5" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="5" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="5" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="5" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="6" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="6" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="6" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="6" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="6" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="6" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="7" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="7" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="7" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="7" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="7" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="7" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="0" r="8" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="8" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="2" r="8" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="3" r="8" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="4" r="8" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="5" r="8" s="0"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
</CellElementList> |
||||
<ReportAttrSet> |
||||
<ReportSettings headerHeight="0" footerHeight="0"> |
||||
<PaperSetting/> |
||||
<Background name="ColorBackground" color="-1"/> |
||||
</ReportSettings> |
||||
</ReportAttrSet> |
||||
<PrivilegeControl/> |
||||
</Report> |
||||
<ReportParameterAttr> |
||||
<Attributes showWindow="true" delayPlaying="true" windowPosition="1" align="0" useParamsTemplate="true" currentIndex="0"/> |
||||
<PWTitle> |
||||
<![CDATA[参数]]></PWTitle> |
||||
</ReportParameterAttr> |
||||
<StyleList> |
||||
<Style imageLayout="1"> |
||||
<FRFont name="SimSun" style="0" size="72"/> |
||||
<Background name="NullBackground"/> |
||||
<Border> |
||||
<Top style="1"/> |
||||
<Bottom style="1"/> |
||||
<Left style="1"/> |
||||
<Right style="1"/> |
||||
</Border> |
||||
</Style> |
||||
</StyleList> |
||||
<DesignerVersion DesignerVersion="KAA"/> |
||||
<PreviewType PreviewType="1"/> |
||||
<TemplateIdAttMark class="com.fr.base.iofile.attr.TemplateIdAttrMark"> |
||||
<TemplateIdAttMark TemplateId="95dc497b-0768-40b9-9579-637156f5cb90"/> |
||||
</TemplateIdAttMark> |
||||
</WorkBook> |
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project> |
||||
<target name="compile_encrypt_javas" depends="copyFiles"> |
||||
<echo message="加密文件"/> |
||||
<echo message="${projectDir}"/> |
||||
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||
<classpath refid="compile.classpath"/> |
||||
</taskdef> |
||||
<pretreatment baseDir="${projectDir}"/> |
||||
</target> |
||||
<target name="compile_plain_javas" depends="copyFiles"> |
||||
</target> |
||||
</project> |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.tptj.demo.hg.java.script.action.provider.v10</id> |
||||
<name><![CDATA[ JavaScriptActionProvider ]]></name> |
||||
<active>yes</active> |
||||
<version>1.0</version> |
||||
<env-version>10.0</env-version> |
||||
<vendor>tptj</vendor> |
||||
<jartime>2019-07-18</jartime> |
||||
<description><![CDATA[ ]]></description> |
||||
<change-notes><![CDATA[]]></change-notes> |
||||
<main-package>com.tptj.demo.hg.java.script.action.provider</main-package> |
||||
<function-recorder class="com.tptj.demo.hg.java.script.action.provider.DemoScript"/> |
||||
<extra-designer> |
||||
<JavaScriptActionProvider class="com.tptj.demo.hg.java.script.action.provider.Demo"/> |
||||
</extra-designer> |
||||
</plugin> |
@ -0,0 +1,24 @@
|
||||
package com.tptj.demo.hg.java.script.action.provider; |
||||
|
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.fun.impl.AbstractJavaScriptActionProvider; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.js.JavaScript; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021-04-28 |
||||
**/ |
||||
public class Demo extends AbstractJavaScriptActionProvider { |
||||
|
||||
@Override |
||||
public FurtherBasicBeanPane<? extends JavaScript> getJavaScriptActionPane() { |
||||
return new DemoPane(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean accept(JTemplate template){ |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,51 @@
|
||||
package com.tptj.demo.hg.java.script.action.provider; |
||||
|
||||
|
||||
import com.fr.design.beans.FurtherBasicBeanPane; |
||||
import com.fr.design.gui.itextarea.UITextArea; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.awt.*; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021-04-28 |
||||
**/ |
||||
public class DemoPane extends FurtherBasicBeanPane<DemoScript> { |
||||
|
||||
private UITextArea w_data; |
||||
|
||||
public DemoPane(){ |
||||
w_data = new UITextArea(); |
||||
this.setLayout(new BorderLayout()); |
||||
this.add(w_data, BorderLayout.CENTER); |
||||
} |
||||
|
||||
@Override |
||||
public boolean accept(Object o) { |
||||
return o instanceof DemoScript; |
||||
} |
||||
|
||||
@Override |
||||
public void reset() { |
||||
populateBean(new DemoScript()); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(DemoScript obj) { |
||||
w_data.setText( obj.getData() ); |
||||
} |
||||
|
||||
@Override |
||||
public DemoScript updateBean() { |
||||
DemoScript obj = new DemoScript(); |
||||
obj.setData( w_data.getText() ); |
||||
return obj; |
||||
} |
||||
|
||||
@Override |
||||
public String title4PopupWindow() { |
||||
return "Demo Script"; |
||||
} |
||||
} |
@ -0,0 +1,63 @@
|
||||
package com.tptj.demo.hg.java.script.action.provider; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.js.AbstractJavaScript; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021-04-28 |
||||
**/ |
||||
@EnableMetrics |
||||
public class DemoScript extends AbstractJavaScript { |
||||
|
||||
private String data; |
||||
|
||||
@Override |
||||
@Focus(id="com.tptj.demo.hg.java.script.action.provider.v10",text = "JavaScriptActionProvider") |
||||
protected String actionJS(Repository repository) { |
||||
return "alert(\""+data+"\");"; |
||||
} |
||||
|
||||
public String getData() { |
||||
return data; |
||||
} |
||||
|
||||
public void setData(String data) { |
||||
this.data = data; |
||||
} |
||||
|
||||
private final static String XML_TAG = "DemoScript"; |
||||
|
||||
@Override |
||||
public void readXML(XMLableReader reader) { |
||||
super.readXML(reader); |
||||
String name = reader.getTagName(); |
||||
if ( XML_TAG.equals(name) ) { |
||||
data = reader.getAttrAsString("data", StringUtils.EMPTY); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
super.writeXML(writer); |
||||
writer.startTAG(XML_TAG).attr("data",data).end(); |
||||
} |
||||
|
||||
@Override |
||||
public Object clone() throws CloneNotSupportedException { |
||||
DemoScript obj = (DemoScript)super.clone(); |
||||
obj.data = data; |
||||
return obj; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return actionJS(null); |
||||
} |
||||
} |
Loading…
Reference in new issue