forked from fanruan/demo-tabledata-transfer
lidongy
4 years ago
commit
abae404468
20 changed files with 699 additions and 0 deletions
@ -0,0 +1,10 @@ |
|||||||
|
*.iml |
||||||
|
.idea/ |
||||||
|
lib/report/*.jar |
||||||
|
target/ |
||||||
|
.DS_Store |
||||||
|
.gradle |
||||||
|
build |
||||||
|
local.properties |
||||||
|
classes/ |
||||||
|
transform-classes/ |
@ -0,0 +1,128 @@ |
|||||||
|
|
||||||
|
apply plugin: 'java' |
||||||
|
|
||||||
|
|
||||||
|
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 |
||||||
|
|
||||||
|
privateLib = "$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0" |
||||||
|
outputPath = privateLib + "/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/') |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
task prepare(type: Copy) { |
||||||
|
into privateLib |
||||||
|
from configurations.runtimeClasspath |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
//使用本地jar |
||||||
|
implementation fileTree(dir: 'lib', include: ['**/*.jar']) |
||||||
|
implementation fileTree(dir: libPath, include: ['**/*.jar']) |
||||||
|
} |
||||||
|
|
@ -0,0 +1,130 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<project basedir="." default="jar" name="plugin"> |
||||||
|
<!-- JDK路径,根据自己机器上实际位置修改--> |
||||||
|
<property name="jdk.home" value="C:\Program Files\Java\jdk1.8.0_251"/> |
||||||
|
|
||||||
|
<property name="libs" value="${basedir}/lib"/> |
||||||
|
<property name="publicLibs" value=""/> |
||||||
|
<property name="reportLibs" value="${basedir}/../webroot/WEB-INF/lib"/> |
||||||
|
<property name="destLoc" value="."/> |
||||||
|
<property name="classes" value="classes"/> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<property name="current-version" value="${plugin.version}"/> |
||||||
|
|
||||||
|
<!-- 插件版本--> |
||||||
|
<property name="plugin-version" value="${current-version}"/> |
||||||
|
<!-- 插件名字--> |
||||||
|
<property name="plugin-name" value="tabledata-transfer"/> |
||||||
|
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/> |
||||||
|
|
||||||
|
<target name="prepare"> |
||||||
|
<delete dir="${classes}"/> |
||||||
|
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<delete dir="${destLoc}/${plugin.name}"/> |
||||||
|
</target> |
||||||
|
<path id="compile.classpath"> |
||||||
|
<fileset dir="${libs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
<fileset dir="${publicLibs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
<fileset dir="${reportLibs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
</path> |
||||||
|
<patternset id="resources4Jar"> |
||||||
|
<exclude name="**/.settings/**"/> |
||||||
|
<exclude name=".classpath"/> |
||||||
|
<exclude name=".project"/> |
||||||
|
|
||||||
|
<exclude name="**/*.java"/> |
||||||
|
<exclude name="**/*.db"/> |
||||||
|
<exclude name="**/*.g"/> |
||||||
|
<exclude name="**/package.html"/> |
||||||
|
</patternset> |
||||||
|
<target name="copy_resources"> |
||||||
|
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/> |
||||||
|
<delete dir="tmp"/> |
||||||
|
<copy todir="tmp"> |
||||||
|
<fileset dir="${resources_from}/src/main/resources"> |
||||||
|
<patternset refid="resources4Jar"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<copy todir="${classes}"> |
||||||
|
<fileset dir="tmp"/> |
||||||
|
</copy> |
||||||
|
<delete dir="tmp"/> |
||||||
|
</target> |
||||||
|
<target name="compile_javas"> |
||||||
|
<echo message="编译${compile_files}下的Java文件"/> |
||||||
|
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}" |
||||||
|
target="${target_jdk_version}" |
||||||
|
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}" |
||||||
|
executable="${compile_jdk_version}/bin/javac"> |
||||||
|
<src path="${basedir}/src/main/java"/> |
||||||
|
<exclude name="**/.svn/**"/> |
||||||
|
<compilerarg line="-encoding UTF8 "/> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</javac> |
||||||
|
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask"> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</taskdef> |
||||||
|
<pretreatment baseDir="${basedir}"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="jar_classes"> |
||||||
|
<echo message="打Jar包:${jar_name}"/> |
||||||
|
<delete file="${basedir}/${jar_name}"/> |
||||||
|
<jar jarfile="${basedir}/${jar_name}"> |
||||||
|
<fileset dir="${classes}"> |
||||||
|
</fileset> |
||||||
|
</jar> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="super_jar" depends="prepare"> |
||||||
|
<antcall target="copy_resources"> |
||||||
|
<param name="resources_from" value="${basedir}"/> |
||||||
|
</antcall> |
||||||
|
<antcall target="compile_javas"> |
||||||
|
<param name="source_jdk_version" value="1.7"/> |
||||||
|
<param name="target_jdk_version" value="1.7"/> |
||||||
|
<param name="compile_jdk_version" value="${jdk.home}"/> |
||||||
|
<param name="compile_files" value="${basedir}/src"/> |
||||||
|
</antcall> |
||||||
|
<echo message="compile plugin success!"/> |
||||||
|
|
||||||
|
<antcall target="jar_classes"> |
||||||
|
<param name="jar_name" value="${plugin-jar}"/> |
||||||
|
</antcall> |
||||||
|
<delete dir="${classes}"/> |
||||||
|
|
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="jar" depends="super_jar"> |
||||||
|
<antcall target="zip"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="zip"> |
||||||
|
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||||
|
<echo message="----------zip files----------"/> |
||||||
|
<mkdir dir="${plugin-folder}"/> |
||||||
|
<copy todir="${plugin-folder}"> |
||||||
|
<fileset dir="."> |
||||||
|
<include name="${plugin-jar}"/> |
||||||
|
<include name="plugin.xml"/> |
||||||
|
</fileset> |
||||||
|
<fileset dir="${libs}"> |
||||||
|
<include name="*.jar"/> |
||||||
|
<include name="*.dll"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<zip destfile="${basedir}/${plugin-folder}.zip" basedir="."> |
||||||
|
<include name="${plugin-folder}/*.jar"/> |
||||||
|
<include name="${plugin-folder}/*.dll"/> |
||||||
|
<include name="${plugin-folder}/plugin.xml"/> |
||||||
|
</zip> |
||||||
|
<move file="${plugin-folder}.zip" todir="${destLoc}/install"/> |
||||||
|
</target> |
||||||
|
</project> |
Binary file not shown.
@ -0,0 +1,24 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<plugin> |
||||||
|
<id>com.fr.plugin.demo.dataset.transfer</id> |
||||||
|
<name><![CDATA[demo数据集迁移]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>1.0.0</version> |
||||||
|
<env-version>10.0</env-version> |
||||||
|
<jartime>2020-01-20</jartime> |
||||||
|
<vendor>dec.lidongy</vendor> |
||||||
|
<description><![CDATA[demo数据连接、数据集迁移]]></description> |
||||||
|
<change-notes><![CDATA[ |
||||||
|
[2021-3-4]demo数据连接、数据集迁移<br/> |
||||||
|
]]></change-notes> |
||||||
|
<extra-designer> |
||||||
|
<ConnectionProvider class="com.fr.plugin.demo.dataset.transfer.DemoConnectionImpl"/> |
||||||
|
<TableDataDefineProvider class="com.fr.plugin.demo.dataset.transfer.DemoTableDataDefine"/> |
||||||
|
<ServerTableDataDefineProvider class="com.fr.plugin.demo.dataset.transfer.DemoTableDataDefine"/> |
||||||
|
</extra-designer> |
||||||
|
<extra-decision> |
||||||
|
<TransferConnectionManagerProvider class="com.fr.plugin.demo.dataset.transfer.DemoConnectionTransferManager"/> |
||||||
|
<TransferDataSetManagerProvider class="com.fr.plugin.demo.dataset.transfer.DemoTableDataTransferManager"/> |
||||||
|
</extra-decision> |
||||||
|
<function-recorder class="com.fr.plugin.demo.dataset.transfer.DemoConnectionImpl"/> |
||||||
|
</plugin> |
@ -0,0 +1,61 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
|
||||||
|
<parent> |
||||||
|
<groupId>com.fr.plugin</groupId> |
||||||
|
<artifactId>starter</artifactId> |
||||||
|
<version>10.0</version> |
||||||
|
</parent> |
||||||
|
<packaging>jar</packaging> |
||||||
|
<artifactId>demo-dataset-transfer</artifactId> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>com.fanruan.api</groupId> |
||||||
|
<artifactId>finekit</artifactId> |
||||||
|
<version>10.0</version> |
||||||
|
<scope>system</scope> |
||||||
|
<systemPath>${project.basedir}/lib/finekit-10.0.jar</systemPath> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
<build> |
||||||
|
<!---如果要更改调试插件,改这里的配置就可以了--> |
||||||
|
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.demo.dataset.transfer-1.0/classes</outputDirectory> |
||||||
|
<plugins> |
||||||
|
<plugin> |
||||||
|
<groupId>org.apache.maven.plugins</groupId> |
||||||
|
<artifactId>maven-compiler-plugin</artifactId> |
||||||
|
<configuration> |
||||||
|
<source>6</source> |
||||||
|
<target>6</target> |
||||||
|
</configuration> |
||||||
|
</plugin> |
||||||
|
</plugins> |
||||||
|
</build> |
||||||
|
<repositories> |
||||||
|
<repository> |
||||||
|
<id>fanruan</id> |
||||||
|
<name>fanruan</name> |
||||||
|
<url>http://mvn.finedevelop.com/repository/maven-public/</url> |
||||||
|
<snapshots> |
||||||
|
<enabled>true</enabled> |
||||||
|
<updatePolicy>always</updatePolicy> |
||||||
|
<checksumPolicy>warn</checksumPolicy> |
||||||
|
</snapshots> |
||||||
|
</repository> |
||||||
|
</repositories> |
||||||
|
<pluginRepositories> |
||||||
|
<pluginRepository> |
||||||
|
<id>fanruan</id> |
||||||
|
<name>fanruan</name> |
||||||
|
<url>http://mvn.finedevelop.com/repository/maven-public/</url> |
||||||
|
<snapshots> |
||||||
|
<enabled>true</enabled> |
||||||
|
<updatePolicy>always</updatePolicy> |
||||||
|
<checksumPolicy>warn</checksumPolicy> |
||||||
|
</snapshots> |
||||||
|
</pluginRepository> |
||||||
|
</pluginRepositories> |
||||||
|
</project> |
@ -0,0 +1,8 @@ |
|||||||
|
#帆软报表数据连接、数据源迁移demo插件 |
||||||
|
#使用举例: |
||||||
|
##1,创建插件中定义的数据连接 |
||||||
|
![connection](/screenshots/connection.png) |
||||||
|
##2,创建插件中定义的数据集 |
||||||
|
![dataset](/screenshots/dataset.png) |
||||||
|
##3,在决策平台中即可进行资源迁移 |
||||||
|
![transfer](/screenshots/transfer.png) |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 34 KiB |
@ -0,0 +1,51 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fanruan.api.conf.HolderKit; |
||||||
|
import com.fanruan.api.data.open.BaseConnection; |
||||||
|
import com.fr.config.holder.Conf; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 2017/5/15. |
||||||
|
*/ |
||||||
|
public class DemoConnection extends BaseConnection { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1450808242114897557L; |
||||||
|
private Conf<String> host = HolderKit.simple(""); |
||||||
|
private Conf<String> username = HolderKit.simple(""); |
||||||
|
|
||||||
|
public String getHost() { |
||||||
|
return host.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setHost(String host) { |
||||||
|
this.host.set(host); |
||||||
|
} |
||||||
|
|
||||||
|
public String getUsername() { |
||||||
|
return username.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setUsername(String username) { |
||||||
|
this.username.set(username); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getDriver() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void testConnection() throws Exception { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String connectMessage(boolean status) { |
||||||
|
if (status) { |
||||||
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Datasource_Connection_Successfully") + "!"; |
||||||
|
} else { |
||||||
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Database_Connection_Failed") + "!"; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fr.data.impl.Connection; |
||||||
|
import com.fr.design.beans.BasicBeanPane; |
||||||
|
import com.fr.design.fun.impl.AbstractConnectionProvider; |
||||||
|
import com.fr.intelli.record.Focus; |
||||||
|
import com.fr.intelli.record.Original; |
||||||
|
import com.fr.record.analyzer.EnableMetrics; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author lidongy |
||||||
|
* @version 10.0 |
||||||
|
* Created by lidongy on 2021/3/4 |
||||||
|
*/ |
||||||
|
@EnableMetrics |
||||||
|
public class DemoConnectionImpl extends AbstractConnectionProvider { |
||||||
|
@Override |
||||||
|
@Focus(id = "com.fr.plugin.demo.dataset.transfer", text = "", source = Original.PLUGIN) |
||||||
|
public String nameForConnection() { |
||||||
|
return "TransferableConnection"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String iconPathForConnection() { |
||||||
|
return "/com/fr/plugin/demo/dataset/transfer/images/demo.png"; |
||||||
|
} |
||||||
|
|
||||||
|
public Class<? extends Connection> classForConnection() { |
||||||
|
return DemoConnection.class; |
||||||
|
} |
||||||
|
|
||||||
|
public Class<? extends BasicBeanPane<? extends Connection>> appearanceForConnection() { |
||||||
|
return DemoConnectionPane.class; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,62 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fanruan.api.design.ui.component.UILabel; |
||||||
|
import com.fanruan.api.design.ui.layout.TableLayoutKit; |
||||||
|
import com.fr.design.data.datapane.connect.DatabaseConnectionPane; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 2017/5/15. |
||||||
|
*/ |
||||||
|
public class DemoConnectionPane extends DatabaseConnectionPane<DemoConnection> { |
||||||
|
|
||||||
|
private JTextField hostTextPane; |
||||||
|
private JTextField userNameTextPane; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
protected JPanel mainPanel() { |
||||||
|
JPanel panel = new JPanel(new BorderLayout()); |
||||||
|
|
||||||
|
double p = TableLayoutKit.PREFERRED; |
||||||
|
double f = TableLayoutKit.FILL; |
||||||
|
double[] rowSize = new double[]{p, p, p, p, p, p, p, p, p, p}; |
||||||
|
double[] columnSize = new double[]{p, f}; |
||||||
|
|
||||||
|
hostTextPane = new JTextField(); |
||||||
|
userNameTextPane = new JTextField(); |
||||||
|
Component[][] components = new Component[][]{ |
||||||
|
{new UILabel("host:"), hostTextPane}, |
||||||
|
{new UILabel("userName:"), userNameTextPane} |
||||||
|
}; |
||||||
|
JPanel centerPane = TableLayoutKit.createTableLayoutPane(components, rowSize, columnSize); |
||||||
|
panel.add(centerPane, BorderLayout.CENTER); |
||||||
|
return panel; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected boolean isFineBI() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void populateSubDatabaseConnectionBean(DemoConnection demoConnection) { |
||||||
|
hostTextPane.setText(demoConnection.getHost()); |
||||||
|
userNameTextPane.setText(demoConnection.getUsername()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected DemoConnection updateSubDatabaseConnectionBean() { |
||||||
|
DemoConnection connection = new DemoConnection(); |
||||||
|
connection.setHost(hostTextPane.getText()); |
||||||
|
connection.setUsername(userNameTextPane.getText()); |
||||||
|
return connection; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "demo"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,43 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fr.data.impl.Connection; |
||||||
|
import com.fr.decision.fun.impl.AbstractTransferConnectionManagerProvider; |
||||||
|
import com.fr.third.fasterxml.jackson.core.type.TypeReference; |
||||||
|
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author lidongy |
||||||
|
* @version 10.0 |
||||||
|
* Created by lidongy on 2021/3/4 |
||||||
|
*/ |
||||||
|
public class DemoConnectionTransferManager extends AbstractTransferConnectionManagerProvider<DemoConnection> { |
||||||
|
|
||||||
|
private static final String FIELD_HOST = "host"; |
||||||
|
private static final String FIELD_USERNAME = "username"; |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends Connection> getConnectionClass() { |
||||||
|
return DemoConnection.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String serialize(DemoConnection demoConnection) throws Exception { |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put(FIELD_HOST, demoConnection.getHost()); |
||||||
|
map.put(FIELD_USERNAME, demoConnection.getUsername()); |
||||||
|
return new ObjectMapper().writeValueAsString(map); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DemoConnection deserialize(String str) throws Exception { |
||||||
|
Map<String, Object> map = new ObjectMapper().readValue(str, new TypeReference<Map<String, Object>>() { |
||||||
|
}); |
||||||
|
DemoConnection demoConnection = new DemoConnection(); |
||||||
|
demoConnection.setHost((String) map.get(FIELD_HOST)); |
||||||
|
demoConnection.setUsername((String) map.get(FIELD_USERNAME)); |
||||||
|
return demoConnection; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fanruan.api.conf.HolderKit; |
||||||
|
import com.fanruan.api.data.open.BaseTableData; |
||||||
|
import com.fanruan.api.util.StringKit; |
||||||
|
import com.fr.config.holder.Conf; |
||||||
|
import com.fr.general.data.DataModel; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author lidongy |
||||||
|
* @version 10.0 |
||||||
|
* Created by lidongy on 2021/3/4 |
||||||
|
*/ |
||||||
|
public class DemoTableData extends BaseTableData { |
||||||
|
|
||||||
|
private Conf<String> query = HolderKit.simple(StringKit.EMPTY); |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public DataModel createDataModel(Calculator calculator) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DataModel createLimitDataModel(Calculator calculator, int i) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public String getQuery() { |
||||||
|
return query.get(); |
||||||
|
} |
||||||
|
|
||||||
|
public void setQuery(String query) { |
||||||
|
this.query.set(query); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||||
|
import com.fr.design.fun.impl.AbstractTableDataDefineProvider; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author lidongy |
||||||
|
* @version 10.0 |
||||||
|
* Created by lidongy on 2021/3/4 |
||||||
|
*/ |
||||||
|
public class DemoTableDataDefine extends AbstractTableDataDefineProvider { |
||||||
|
@Override |
||||||
|
public Class<? extends TableData> classForTableData() { |
||||||
|
return DemoTableData.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends TableData> classForInitTableData() { |
||||||
|
return DemoTableData.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends AbstractTableDataPane> appearanceForTableData() { |
||||||
|
return DemoTableDataPane.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String nameForTableData() { |
||||||
|
return "TransferableTableData"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String prefixForTableData() { |
||||||
|
return "demo"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String iconPathForTableData() { |
||||||
|
return "/com/fr/plugin/demo/dataset/transfer/images/demo.png"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fanruan.api.design.work.BaseTableDataPane; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author lidongy |
||||||
|
* @version 10.0 |
||||||
|
* Created by lidongy on 2021/3/4 |
||||||
|
*/ |
||||||
|
public class DemoTableDataPane extends BaseTableDataPane<DemoTableData> { |
||||||
|
|
||||||
|
private JTextArea queryTextPane; |
||||||
|
|
||||||
|
public DemoTableDataPane() { |
||||||
|
this.setLayout(new BorderLayout(4, 4)); |
||||||
|
queryTextPane = new JTextArea(); |
||||||
|
this.add(queryTextPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(DemoTableData demoTableData) { |
||||||
|
queryTextPane.setText(demoTableData.getQuery()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DemoTableData updateBean() { |
||||||
|
DemoTableData demoTableData = new DemoTableData(); |
||||||
|
demoTableData.setQuery(queryTextPane.getText()); |
||||||
|
return demoTableData; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "demo"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package com.fr.plugin.demo.dataset.transfer; |
||||||
|
|
||||||
|
import com.fr.base.TableData; |
||||||
|
import com.fr.decision.fun.impl.AbstractTransferDataSetManagerProvider; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author lidongy |
||||||
|
* @version 10.0 |
||||||
|
* Created by lidongy on 2021/3/4 |
||||||
|
*/ |
||||||
|
public class DemoTableDataTransferManager extends AbstractTransferDataSetManagerProvider<DemoTableData> { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends TableData> getDataSetClass() { |
||||||
|
return DemoTableData.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String serialize(DemoTableData demoTableData) throws Exception { |
||||||
|
return demoTableData.getQuery(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public DemoTableData deserialize(String str) throws Exception { |
||||||
|
DemoTableData demoTableData = new DemoTableData(); |
||||||
|
demoTableData.setQuery(str); |
||||||
|
return demoTableData; |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 361 B |
Loading…
Reference in new issue