Browse Source

提交demo代码

10.0
hugh 4 years ago
parent
commit
a48bfdf35a
  1. 6
      README.md
  2. 124
      build.gradle
  3. 13
      encrypt.xml
  4. 19
      plugin.xml
  5. 5
      src/main/java/com/tptj/demo/hg/stable/key/args/ActionDemo.java
  6. 26
      src/main/java/com/tptj/demo/hg/stable/key/args/ActionDemoImpl.java
  7. 26
      src/main/java/com/tptj/demo/hg/stable/key/args/Demo.java
  8. 11
      src/main/java/com/tptj/demo/hg/stable/key/args/HyperlinkImpl.java
  9. 30
      src/main/java/com/tptj/demo/hg/stable/key/args/HyperlinkTest.java
  10. 30
      src/main/java/com/tptj/demo/hg/stable/key/args/TestPane.java

6
README.md

@ -1,3 +1,7 @@
# demo-stable-key-args-provider
RPC服务接口
RPC服务接口\
demo生效后,会新增一个超链接类型【RPC测试】\
预先在服务器和本地的相同路径 D:\test\目录下 新建一个名为data的txt文件(D:\test\data.txt)\
服务器和本地的data.txt分别写上一行不同的内容(内容自己定)\
添加“RPC测试”超链时,配置界面会根据当前的工作目录显示对应的txt文件的内容。

124
build.gradle

@ -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'])
}

13
encrypt.xml

@ -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>

19
plugin.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.tptj.demo.hg.stable.key.args.v10</id>
<name><![CDATA[ RPC demo ]]></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.stable.key.args</main-package>
<function-recorder class="com.tptj.demo.hg.stable.key.args.Demo"/>
<extra-core>
<StableKeyArgsProvider class="com.tptj.demo.hg.stable.key.args.Demo"/>
</extra-core>
<extra-designer>
<HyperlinkProvider class="com.tptj.demo.hg.stable.key.args.HyperlinkTest"/>
</extra-designer>
</plugin>

5
src/main/java/com/tptj/demo/hg/stable/key/args/ActionDemo.java

@ -0,0 +1,5 @@
package com.tptj.demo.hg.stable.key.args;
public interface ActionDemo {
String get( String in );
}

26
src/main/java/com/tptj/demo/hg/stable/key/args/ActionDemoImpl.java

@ -0,0 +1,26 @@
package com.tptj.demo.hg.stable.key.args;
import com.fr.general.CommonIOUtils;
import com.fr.io.repository.base.fs.FileSystemRepository;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.io.InputStream;
public class ActionDemoImpl implements ActionDemo {
@Override
public String get(String in) {
try{
throw new Exception();
}catch (Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
try{
InputStream read = FileSystemRepository.getSingleton().read(in);
return CommonIOUtils.inputStream2String(read);
}catch(Exception e){
FineLoggerFactory.getLogger().error(e.getMessage(),e);
}
return StringUtils.EMPTY;
}
}

26
src/main/java/com/tptj/demo/hg/stable/key/args/Demo.java

@ -0,0 +1,26 @@
package com.tptj.demo.hg.stable.key.args;
import com.fr.intelli.record.Focus;
import com.fr.module.StableKey;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.impl.AbstractStableKeyArgsProvider;
import com.fr.workspace.base.WorkspaceKey;
import com.fr.workspace.pool.WorkRPCRegister;
import java.util.Arrays;
import java.util.List;
@EnableMetrics
public class Demo extends AbstractStableKeyArgsProvider<WorkRPCRegister<?>> {
@Override
@Focus(id="com.tptj.demo.hg.stable.key.args.v10",text = "RPC demo")
protected List<WorkRPCRegister<?>> createArgs() {
return Arrays.asList( WorkRPCRegister.wrap(ActionDemo.class, new ActionDemoImpl()) );
}
@Override
public StableKey<WorkRPCRegister<?>> getKey() {
return WorkspaceKey.RPC;
}
}

11
src/main/java/com/tptj/demo/hg/stable/key/args/HyperlinkImpl.java

@ -0,0 +1,11 @@
package com.tptj.demo.hg.stable.key.args;
import com.fr.js.Hyperlink;
import com.fr.stable.web.Repository;
public class HyperlinkImpl extends Hyperlink {
@Override
protected String actionJS(Repository repository) {
return "alert(123);";
}
}

30
src/main/java/com/tptj/demo/hg/stable/key/args/HyperlinkTest.java

@ -0,0 +1,30 @@
package com.tptj.demo.hg.stable.key.args;
import com.fr.design.fun.impl.AbstractHyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.general.ComparatorUtils;
public class HyperlinkTest extends AbstractHyperlinkProvider {
@Override
public int currentAPILevel() {
return CURRENT_LEVEL;
}
private NameableCreator nameableCreator = new NameObjectCreator("RPC测试", HyperlinkImpl.class, TestPane.class);
@Override
public int hashCode() {
return nameableCreator.menuName().hashCode();
}
@Override
public boolean equals(Object obj) {
return (obj != null && obj instanceof HyperlinkTest) && ComparatorUtils.equals(((HyperlinkTest) obj).nameableCreator, nameableCreator);
}
@Override
public NameableCreator createHyperlinkCreator() {
return nameableCreator;
}
}

30
src/main/java/com/tptj/demo/hg/stable/key/args/TestPane.java

@ -0,0 +1,30 @@
package com.tptj.demo.hg.stable.key.args;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.workspace.WorkContext;
import java.awt.*;
public class TestPane extends BasicBeanPane<HyperlinkImpl> {
public TestPane(){
String data = WorkContext.getCurrent().get(ActionDemo.class).get("D:/test/data.txt");
setLayout(FRGUIPaneFactory.createM_BorderLayout());
add(new UILabel(data), BorderLayout.CENTER);
}
@Override
public void populateBean(HyperlinkImpl hyperlink) {
}
@Override
public HyperlinkImpl updateBean() {
return new HyperlinkImpl();
}
@Override
protected String title4PopupWindow() {
return "RPC测试";
}
}
Loading…
Cancel
Save