diff --git a/README.md b/README.md
index 6676247..97e9750 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,7 @@
# demo-connection-provider
-创建数据源连接的demo
\ No newline at end of file
+创建数据源连接的demo\
+demo生效后在设计器/决策平台的数据源管理页面会增加一个名为Demo Conn的数据源类型。\
+添加后设置一个key值,注:只有key1 key2 key3这三个key值可以链接成功。\
+添加完数据源连接,在模板数据集【注意不是服务器数据集】处可添加Demo Conn Data数据集\
+可以选择对应的数据源后预览得到对应的数据结果。
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..3d3e2c4
--- /dev/null
+++ b/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'])
+}
+
+
diff --git a/encrypt.xml b/encrypt.xml
new file mode 100644
index 0000000..1401cd1
--- /dev/null
+++ b/encrypt.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/common-kit-10.0-20210309.jar b/lib/common-kit-10.0-20210309.jar
new file mode 100644
index 0000000..7027142
Binary files /dev/null and b/lib/common-kit-10.0-20210309.jar differ
diff --git a/lib/finekit-10.0-20210309.jar b/lib/finekit-10.0-20210309.jar
new file mode 100644
index 0000000..2d3b5b4
Binary files /dev/null and b/lib/finekit-10.0-20210309.jar differ
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..ace9146
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,20 @@
+
+ com.tptj.demo.hg.connection.v10
+
+ yes
+ 1.0
+ 10.0
+ tptj
+ 2019-07-18
+
+
+ com.tptj.demo.hg.connection
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/tptj/demo/hg/connection/Demo.java b/src/main/java/com/tptj/demo/hg/connection/Demo.java
new file mode 100644
index 0000000..e18789a
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/Demo.java
@@ -0,0 +1,34 @@
+package com.tptj.demo.hg.connection;
+
+import com.fr.data.impl.Connection;
+import com.fr.design.beans.BasicBeanPane;
+import com.fr.design.fun.impl.AbstractConnectionProvider;
+import com.tptj.demo.hg.connection.conn.DemoConnection;
+import com.tptj.demo.hg.connection.conn.DemoConnectionPane;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class Demo extends AbstractConnectionProvider {
+ @Override
+ public String nameForConnection() {
+ return "Demo Conn";
+ }
+
+ @Override
+ public String iconPathForConnection() {
+ return "com/tptj/demo/hg/connection/images/icon.png";
+ }
+
+ @Override
+ public Class extends Connection> classForConnection() {
+ return DemoConnection.class;
+ }
+
+ @Override
+ public Class extends BasicBeanPane extends Connection>> appearanceForConnection() {
+ return DemoConnectionPane.class;
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/DemoTableDataDefine.java b/src/main/java/com/tptj/demo/hg/connection/DemoTableDataDefine.java
new file mode 100644
index 0000000..0d822f1
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/DemoTableDataDefine.java
@@ -0,0 +1,44 @@
+package com.tptj.demo.hg.connection;
+
+import com.fr.base.TableData;
+import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane;
+import com.fr.design.fun.impl.AbstractTableDataDefineProvider;
+import com.tptj.demo.hg.connection.data.DemoData;
+import com.tptj.demo.hg.connection.data.DemoDataPane;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class DemoTableDataDefine extends AbstractTableDataDefineProvider {
+ @Override
+ public Class extends TableData> classForTableData() {
+ return DemoData.class;
+ }
+
+ @Override
+ public Class extends TableData> classForInitTableData() {
+ return null;
+ }
+
+ @Override
+ public Class extends AbstractTableDataPane> appearanceForTableData() {
+ return DemoDataPane.class;
+ }
+
+ @Override
+ public String nameForTableData() {
+ return "Demo Conn Data";
+ }
+
+ @Override
+ public String prefixForTableData() {
+ return "dcd";
+ }
+
+ @Override
+ public String iconPathForTableData() {
+ return "com/tptj/demo/hg/connection/images/icon.png";
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/conn/DemoConnection.java b/src/main/java/com/tptj/demo/hg/connection/conn/DemoConnection.java
new file mode 100644
index 0000000..00e8536
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/conn/DemoConnection.java
@@ -0,0 +1,69 @@
+package com.tptj.demo.hg.connection.conn;
+
+import com.fanruan.api.conf.HolderKit;
+import com.fanruan.api.data.open.BaseConnection;
+import com.fanruan.api.i18n.I18nKit;
+import com.fanruan.api.util.StringKit;
+import com.fr.config.holder.Conf;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+import com.fr.third.ibm.icu.impl.Assert;
+import com.tptj.demo.hg.connection.store.Store;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class DemoConnection extends BaseConnection {
+
+ private Conf key = HolderKit.simple(StringKit.EMPTY);
+
+ public String getKey() {
+ return key.get();
+ }
+
+ public void setKey(String key) {
+ this.key.set(key);
+ }
+
+ @Override
+ public void testConnection() throws Exception {
+ Assert.assrt( Store.getInstance().contains(getKey()) );
+ }
+
+ @Override
+ public String connectMessage(boolean status) {
+ return I18nKit.getLocText(status?"Fine-Core_Datasource_Connection_Successfully":"Fine-Design_Database_Connection_Failed");
+ }
+
+ @Override
+ public String getDriver() {
+ return null;
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ super.readXML(reader);
+ if (reader.isChildNode()) {
+ String tagName = reader.getTagName();
+ if ("Attr".equals(tagName)) {
+ setKey(reader.getAttrAsString("key", StringKit.EMPTY));
+ }
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ super.writeXML(writer);
+ writer.startTAG("Attr").attr("key", getKey()).end();
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ DemoConnection cloned = (DemoConnection) super.clone();
+ cloned.key = (Conf) key.clone();
+ return cloned;
+ }
+
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/conn/DemoConnectionPane.java b/src/main/java/com/tptj/demo/hg/connection/conn/DemoConnectionPane.java
new file mode 100644
index 0000000..12c270c
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/conn/DemoConnectionPane.java
@@ -0,0 +1,45 @@
+package com.tptj.demo.hg.connection.conn;
+
+import com.fanruan.api.design.ui.component.UITextField;
+import com.fanruan.api.design.work.DatabaseConnectionPane;
+
+import javax.swing.*;
+import java.awt.*;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class DemoConnectionPane extends DatabaseConnectionPane {
+ //hugh:因为mainPanel是在父类的构造中先调用的,所以我们定义的控件一定不要在这里赋值!切记
+ private UITextField w_key;
+
+ @Override
+ protected JPanel mainPanel() {
+ JPanel pane = new JPanel();
+ w_key = new UITextField();
+ pane.setLayout( new BorderLayout(4,4) );
+ pane.add(w_key,BorderLayout.NORTH);
+ return pane;
+ }
+
+ @Override
+ protected void populateSubDatabaseConnectionBean( DemoConnection conn ) {
+ if( null != conn ){
+ w_key.setText(conn.getKey());
+ }
+ }
+
+ @Override
+ protected DemoConnection updateSubDatabaseConnectionBean() {
+ DemoConnection conn = new DemoConnection();
+ conn.setKey( w_key.getText() );
+ return conn;
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return "Demo Conn";
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/data/DemoData.java b/src/main/java/com/tptj/demo/hg/connection/data/DemoData.java
new file mode 100644
index 0000000..8bbeb84
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/data/DemoData.java
@@ -0,0 +1,70 @@
+package com.tptj.demo.hg.connection.data;
+
+import com.fanruan.api.conf.HolderKit;
+import com.fanruan.api.data.ConnectionKit;
+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.intelli.record.Focus;
+import com.fr.log.FineLoggerFactory;
+import com.fr.record.analyzer.EnableMetrics;
+import com.fr.script.Calculator;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+import com.tptj.demo.hg.connection.conn.DemoConnection;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+@EnableMetrics
+public class DemoData extends BaseTableData {
+ private Conf database = HolderKit.simple(StringKit.EMPTY);
+
+ public String getDatabase() {
+ return database.get();
+ }
+
+ public void setDatabase( String database) {
+ this.database.set(database);
+ }
+
+ @Override
+ @Focus(id = "com.tptj.demo.hg.connection.v10",text = "connection demo")
+ public DataModel createDataModel(Calculator calculator) {
+ DemoConnection conn = ConnectionKit.getConnection(getDatabase(),DemoConnection.class);
+ try {
+ conn.testConnection();
+ }catch (Exception e){
+ FineLoggerFactory.getLogger().error(e.getMessage(),e);
+ return DataModel.EMPTY_DATAMODEL;
+ }
+ return new DemoModel(conn);
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ super.readXML(reader);
+ if (reader.isChildNode()) {
+ String tagName = reader.getTagName();
+ if ("Attr".equals(tagName)) {
+ setDatabase(reader.getAttrAsString("source", StringKit.EMPTY));
+ }
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ super.writeXML(writer);
+ writer.startTAG("Attr").attr("source", getDatabase()).end();
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ DemoData cloned = (DemoData) super.clone();
+ cloned.database = (Conf) database.clone();
+ return cloned;
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/data/DemoDataPane.java b/src/main/java/com/tptj/demo/hg/connection/data/DemoDataPane.java
new file mode 100644
index 0000000..5d462eb
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/data/DemoDataPane.java
@@ -0,0 +1,66 @@
+package com.tptj.demo.hg.connection.data;
+
+import com.fanruan.api.design.work.BaseTableDataPane;
+import com.fanruan.api.design.work.ConnectionComboBoxPanel;
+import com.fr.base.BaseUtils;
+import com.fr.design.data.datapane.preview.PreviewTablePane;
+import com.fr.design.gui.ibutton.UIButton;
+import com.fr.design.layout.TableLayout;
+import com.fr.design.layout.TableLayoutHelper;
+import com.tptj.demo.hg.connection.conn.DemoConnection;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class DemoDataPane extends BaseTableDataPane {
+ private ConnectionComboBoxPanel w_connections;
+ public DemoDataPane(){
+ setLayout(new BorderLayout(4, 4));
+ w_connections = new ConnectionComboBoxPanel(DemoConnection.class);
+ add(w_connections, BorderLayout.NORTH);
+ UIButton preview = new UIButton(BaseUtils.readIcon("/com/fr/design/images/m_file/preview.png"));
+ preview.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ PreviewTablePane.previewTableData(DemoDataPane.this.updateBean());
+ }
+ });
+ }
+ });
+ add(TableLayoutHelper.createTableLayoutPane(
+ new Component[][] {{
+ w_connections,preview
+ }},
+ new double[] { TableLayout.PREFERRED },
+ new double[] { TableLayout.FILL,TableLayout.PREFERRED }
+ ),BorderLayout.NORTH);
+ }
+ @Override
+ public void populateBean(DemoData data) {
+ if( null != data ){
+ w_connections.setSelectedItem( data.getDatabase() );
+ }
+ }
+
+ @Override
+ public DemoData updateBean() {
+ DemoData data = new DemoData();
+ data.setDatabase( w_connections.getSelectedItem() );
+ return data;
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return "Demo Conn Data";
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/data/DemoModel.java b/src/main/java/com/tptj/demo/hg/connection/data/DemoModel.java
new file mode 100644
index 0000000..1788f5e
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/data/DemoModel.java
@@ -0,0 +1,43 @@
+package com.tptj.demo.hg.connection.data;
+
+import com.fanruan.api.data.open.BaseDataModel;
+import com.fanruan.api.err.TableDataException;
+import com.tptj.demo.hg.connection.store.Data;
+import com.tptj.demo.hg.connection.conn.DemoConnection;
+import com.tptj.demo.hg.connection.store.Store;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class DemoModel extends BaseDataModel {
+ private Data data = Data.EMPTY;
+ public DemoModel( DemoConnection conn ){
+ data = Store.getInstance().get( conn.getKey() );
+ }
+ @Override
+ public int getColumnCount() throws TableDataException {
+ return data.getKey().length;
+ }
+
+ @Override
+ public String getColumnName(int cIdx) throws TableDataException {
+ return data.getKey()[cIdx];
+ }
+
+ @Override
+ public int getRowCount() throws TableDataException {
+ return data.getRow().length;
+ }
+
+ @Override
+ public Object getValueAt(int rIdx, int cIdx) throws TableDataException {
+ return data.getRow()[rIdx][cIdx];
+ }
+
+ @Override
+ public void release() throws Exception {
+ data = Data.EMPTY;
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/decision/WebDemo.java b/src/main/java/com/tptj/demo/hg/connection/decision/WebDemo.java
new file mode 100644
index 0000000..7b7cd2b
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/decision/WebDemo.java
@@ -0,0 +1,62 @@
+package com.tptj.demo.hg.connection.decision;
+
+import com.fanruan.api.util.StringKit;
+import com.fr.decision.fun.impl.AbstractUniversalConnectionProvider;
+import com.fr.json.JSONObject;
+import com.fr.web.struct.Atom;
+import com.fr.web.struct.Component;
+import com.fr.web.struct.browser.RequestClient;
+import com.fr.web.struct.category.ScriptPath;
+import com.tptj.demo.hg.connection.conn.DemoConnection;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class WebDemo extends AbstractUniversalConnectionProvider {
+
+ @Override
+ public String nameForConnection() {
+ return "demo_con";
+ }
+
+ @Override
+ public String iconPathForConnection() {
+ return "/com/tptj/demo/hg/connection/images/icon.png";
+ }
+
+ @Override
+ public Class classForConnection() {
+ return DemoConnection.class;
+ }
+
+ @Override
+ public Atom client() {
+ return new Component() {
+ @Override
+ public ScriptPath script(RequestClient client) {
+ return ScriptPath.build("com/tptj/demo/hg/connection/js/main.js");
+ }
+ };
+ }
+
+ @Override
+ public JSONObject serialize(DemoConnection connection) {
+ return JSONObject.create().put("key",connection.getKey());
+ }
+
+ @Override
+ public DemoConnection deserialize(DemoConnection old, JSONObject config ){
+ DemoConnection conn = new DemoConnection();
+ conn.setKey(config.optString("key", StringKit.EMPTY));
+ if( null != old ){
+ conn.setId( old.getId() );
+ conn.setCreator( old.getCreator() );
+ }
+ return conn;
+ }
+
+
+
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/store/Data.java b/src/main/java/com/tptj/demo/hg/connection/store/Data.java
new file mode 100644
index 0000000..5979da6
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/store/Data.java
@@ -0,0 +1,33 @@
+package com.tptj.demo.hg.connection.store;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ **/
+public class Data {
+ private String[] key = new String[0];
+ private String[][] row = new String[0][0];
+ public static final Data EMPTY = new Data();
+ private Data(){}
+ public Data(String[] key, String[][] row) {
+ this.key = key;
+ this.row = row;
+ }
+
+ public String[] getKey() {
+ return key;
+ }
+
+ public void setKey(String[] key) {
+ this.key = key;
+ }
+
+ public String[][] getRow() {
+ return row;
+ }
+
+ public void setRow(String[][] row) {
+ this.row = row;
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/connection/store/Store.java b/src/main/java/com/tptj/demo/hg/connection/store/Store.java
new file mode 100644
index 0000000..c921a39
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/connection/store/Store.java
@@ -0,0 +1,57 @@
+package com.tptj.demo.hg.connection.store;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-31
+ * 模拟数据源
+ **/
+public class Store {
+ private Map store = new HashMap(3);
+ private static Store instance = null;
+ private Store(){ }
+
+ public boolean contains(String key){
+ return store.containsKey(key);
+ }
+
+ public Data get(String key){
+ return store.get(key);
+ }
+
+ private void load(){
+ store.put("key1",new Data(new String[]{"k1","k2","k3"},
+ new String[][]{
+ {"v11","v12","v13"},
+ {"v21","v22","v23"},
+ {"v31","v32","v33"}
+ } ));
+ store.put("key2",new Data(new String[]{"k4","k5"},
+ new String[][]{
+ {"n11","n12"},
+ {"n21","n22"},
+ {"n31","n32"}
+ } ));
+ store.put("key3",new Data(new String[]{"k6","k7","k3","k8"},
+ new String[][]{
+ {"x11","x12","x13","x14"},
+ {"x21","x22","x23","x24"},
+ {"x31","x32","x33","x34"}
+ } ));
+ }
+
+ public static Store getInstance(){
+ if( null == instance ){
+ synchronized (Store.class){
+ if( null == instance ){
+ instance = new Store();
+ instance.load();
+ }
+ }
+ }
+ return instance;
+ }
+}
diff --git a/src/main/resources/com/tptj/demo/hg/connection/images/demo.jpg b/src/main/resources/com/tptj/demo/hg/connection/images/demo.jpg
new file mode 100644
index 0000000..f3ee332
Binary files /dev/null and b/src/main/resources/com/tptj/demo/hg/connection/images/demo.jpg differ
diff --git a/src/main/resources/com/tptj/demo/hg/connection/images/icon.png b/src/main/resources/com/tptj/demo/hg/connection/images/icon.png
new file mode 100644
index 0000000..6e41b7e
Binary files /dev/null and b/src/main/resources/com/tptj/demo/hg/connection/images/icon.png differ
diff --git a/src/main/resources/com/tptj/demo/hg/connection/js/main.js b/src/main/resources/com/tptj/demo/hg/connection/js/main.js
new file mode 100644
index 0000000..6b45ccd
--- /dev/null
+++ b/src/main/resources/com/tptj/demo/hg/connection/js/main.js
@@ -0,0 +1,133 @@
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+!(function () {
+
+ //编辑配置
+ var createEditLine = function(label,value,ref,action){
+ return {
+ type: 'bi.left',
+ items: [
+ {
+ type: 'bi.label',
+ cls: 'bi-font-bold',
+ width: 100,
+ textAlign: 'left',
+ text: label
+ },
+ {
+ type: 'bi.text_editor',
+ width: 300,
+ allowBlank: true,
+ ref: ref,
+ value:value,
+ listeners: [{
+ eventName: BI.FormulaEditor.EVENT_CHANGE,
+ action: action
+ }]
+ }
+ ]
+ };
+ }
+ var DemoEditName = 'dec.dcm.connection.plugin.demo.edit';
+ var DemoEdit = BI.inherit(BI.Widget, {
+ props: {
+ value:{
+ key: ''
+ },
+ connectionName:''
+ },
+ render() {
+ var self = this;
+ var o = this.options;
+ return {
+ type: 'bi.vertical',
+ hgap: 15,
+ vgap: 10,
+ items: [
+ createEditLine(
+ '数据源名称',
+ o.connectionName,//self._parent.options.formData.connectionName,
+ function(_ref) {
+ self.name = _ref;
+ },
+ //hugh:2021-04-02,截止目前的所有发布版本均不支持getName方法修改数据源连接名称,需要使用下面这种非常不友好的方式修改
+ function () {
+ self._parent.options.formData.connectionName = this.getValue();
+ }
+ ),
+ createEditLine(
+ 'key值',
+ o.value.key,
+ function(_ref) {
+ self.key = _ref;
+ },
+ function () {}
+ )
+ ]
+ };
+ },
+ getValue() {
+ return {
+ key: this.key.getValue()
+ };
+ },
+ //hugh:2021-04-02下个小版本应该就支持直接使用getName来返回要修改的数据源链接名称了
+ getName(){
+ return this.name.getValue();
+ }
+ });
+ BI.shortcut(DemoEditName, DemoEdit);
+ BI.constant('dec.constant.database.conf.connect.form.demo.edit', DemoEditName);
+
+ //显示配置
+ var DemoShowName = 'dec.dcm.connection.plugin.demo.show';
+ var DemoShow = BI.inherit(BI.Widget, {
+ props: {
+ value: {
+ key: ''
+ }
+ },
+ render() {
+ var o = this.options;
+ return {
+ type: 'bi.vertical',
+ hgap: 15,
+ vgap: 10,
+ items: [
+ {
+ type: 'bi.left',
+ items: [
+ {
+ type: 'bi.label',
+ cls: 'bi-font-bold',
+ width: 100,
+ textAlign: 'left',
+ text: 'Key值'
+ },
+ {
+ type: 'bi.label',
+ text: o.value.key
+ }
+ ]
+ }
+ ]
+ };
+ }
+ });
+
+ BI.shortcut(DemoShowName, DemoShow);
+ BI.constant('dec.constant.database.conf.connect.form.demo.show', DemoShowName);
+ //注册
+ BI.config('dec.connection.provider.datebase', function(provider){
+ provider.registerDatabaseType({
+ text: 'Demo Conn',
+ databaseType: 'demo_con',
+ iconUrl: 'com/tptj/demo/hg/connection/images/demo.jpg',
+ edit: 'dec.dcm.connection.plugin.demo.edit',
+ show: 'dec.dcm.connection.plugin.demo.show',
+ });
+ });
+})();
\ No newline at end of file