diff --git a/README.md b/README.md
index 4977dcc..8c58c45 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,5 @@
# demo-table-data-define
-新增数据集类型集合demo
-包括模板数据集、设计器操作服务器数据集、决策平台操作服务器数据集
\ No newline at end of file
+新增数据集类型集合demo\
+包括模板数据集、设计器操作服务器数据集、决策平台操作服务器数据集\
+demo生效后,预览TableData.cpt模板,显示Hello World!则成功
\ No newline at end of file
diff --git a/TableData.cpt b/TableData.cpt
new file mode 100644
index 0000000..410dfd5
--- /dev/null
+++ b/TableData.cpt
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..57a1a52
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,126 @@
+
+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'])
+ implementation project(':kit-fine')
+ implementation project(':kit-common')
+}
+
+
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/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..ee80140
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,20 @@
+
+ com.tptj.demo.hg.table.data.define.v10
+
+ yes
+ 1.0
+ 10.0
+ tptj
+ 2019-07-18
+
+
+ com.tptj.demo.hg.table.data
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/tptj/demo/hg/table/data/Demo.java b/src/main/java/com/tptj/demo/hg/table/data/Demo.java
new file mode 100644
index 0000000..01c23b8
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/table/data/Demo.java
@@ -0,0 +1,43 @@
+package com.tptj.demo.hg.table.data;
+
+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.table.data.ui.DemoTableDataPane;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+public class Demo extends AbstractTableDataDefineProvider {
+ @Override
+ public Class extends TableData> classForTableData() {
+ return DemoTableData.class;
+ }
+
+ @Override
+ public Class extends TableData> classForInitTableData() {
+ return null;
+ }
+
+ @Override
+ public Class extends AbstractTableDataPane> appearanceForTableData() {
+ return DemoTableDataPane.class;
+ }
+
+ @Override
+ public String nameForTableData() {
+ return "Demo Data";
+ }
+
+ @Override
+ public String prefixForTableData() {
+ return "dm";
+ }
+
+ @Override
+ public String iconPathForTableData() {
+ return "com/tptj/demo/hg/table/data/images/icon.png";
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/table/data/DemoDataModel.java b/src/main/java/com/tptj/demo/hg/table/data/DemoDataModel.java
new file mode 100644
index 0000000..3d11ce7
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/table/data/DemoDataModel.java
@@ -0,0 +1,48 @@
+package com.tptj.demo.hg.table.data;
+
+import com.fanruan.api.data.open.BaseDataModel;
+import com.fanruan.api.err.TableDataException;
+import com.fr.script.Calculator;
+import com.fr.stable.ParameterProvider;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+public class DemoDataModel extends BaseDataModel {
+
+ private String config;
+ private ParameterProvider[] parameters;
+
+ public DemoDataModel(Calculator calculator,ParameterProvider[] parameters, String config){
+ this.parameters = parameters;
+ this.config = config;
+ }
+
+ @Override
+ public int getColumnCount() throws TableDataException {
+ return 1+parameters.length;
+ }
+
+ @Override
+ public String getColumnName(int colIdx) throws TableDataException {
+ return 0 == colIdx ? "config" : parameters[colIdx-1].getName();
+ }
+
+ @Override
+ public int getRowCount() throws TableDataException {
+ return 1;
+ }
+
+ @Override
+ public Object getValueAt(int rowIdx, int colIdx) throws TableDataException {
+ return 0==colIdx ? config : parameters[colIdx-1].getValue();
+ }
+
+ @Override
+ public void release() throws Exception {
+ parameters = null;
+ config = null;
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/table/data/DemoTableData.java b/src/main/java/com/tptj/demo/hg/table/data/DemoTableData.java
new file mode 100644
index 0000000..613f18c
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/table/data/DemoTableData.java
@@ -0,0 +1,68 @@
+package com.tptj.demo.hg.table.data;
+
+import com.fanruan.api.data.open.BaseTableData;
+import com.fr.config.holder.Conf;
+import com.fr.config.holder.factory.Holders;
+import com.fr.general.data.DataModel;
+import com.fr.general.xml.GeneralXMLTools;
+import com.fr.intelli.record.Focus;
+import com.fr.record.analyzer.EnableMetrics;
+import com.fr.script.Calculator;
+import com.fr.stable.EncodeConstants;
+import com.fr.stable.StringUtils;
+import com.fr.stable.xml.XMLPrintWriter;
+import com.fr.stable.xml.XMLableReader;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+@EnableMetrics
+public class DemoTableData extends BaseTableData {
+ /**
+ * 自定义一些配置
+ */
+ private Conf config = Holders.simple(StringUtils.EMPTY);
+
+ public String getConfig() {
+ return config.get();
+ }
+
+ public void setConfig( String config) {
+ this.config.set(config);
+ }
+
+ @Override
+ @Focus(id = "com.tptj.demo.hg.table.data.v10",text = "table data")
+ public DataModel createDataModel(Calculator calculator) {
+ return new DemoDataModel( calculator,
+ Calculator.processParameters(calculator,super.getParameters(calculator)),
+ getConfig() );
+ }
+
+ @Override
+ public void readXML(XMLableReader reader) {
+ super.readXML(reader);
+ if (reader.isChildNode()){
+ if ("Attributes".equals(reader.getTagName())) {
+ try{
+ String conf = new String(GeneralXMLTools.readByteArray(reader), EncodeConstants.ENCODING_UTF_8);
+ setConfig(conf);
+ }catch(Exception e){
+ setConfig(StringUtils.EMPTY);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void writeXML(XMLPrintWriter writer) {
+ super.writeXML(writer);
+ writer.startTAG("Attributes");
+ try{
+ GeneralXMLTools.writeByteArray(writer, getConfig().getBytes(EncodeConstants.ENCODING_UTF_8));
+ }catch(Exception e){}
+ writer.end();
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/table/data/DemoTableDataBean.java b/src/main/java/com/tptj/demo/hg/table/data/DemoTableDataBean.java
new file mode 100644
index 0000000..38d84b6
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/table/data/DemoTableDataBean.java
@@ -0,0 +1,63 @@
+package com.tptj.demo.hg.table.data;
+
+import com.fr.decision.webservice.bean.BaseBean;
+import com.fr.decision.webservice.bean.dataset.ParameterBean;
+import com.fr.stable.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+public class DemoTableDataBean extends BaseBean {
+ private List parameters = new ArrayList();
+ private String config;
+
+ public List getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(List parameters) {
+ this.parameters = parameters;
+ }
+
+ public String getConfig() {
+ return config;
+ }
+
+ public void setConfig(String config) {
+ this.config = config;
+ }
+
+ @Override
+ public boolean equals(Object o){
+ return o instanceof DemoTableDataBean
+ && StringUtils.equals(((DemoTableDataBean)o).config, config)
+ && isSameParameter(((DemoTableDataBean)o).parameters);
+ }
+
+ private boolean isSameParameter(List parameters){
+ if( null == parameters && null != this.parameters ){
+ return false;
+ }
+ if( null != parameters && null == this.parameters ){
+ return false;
+ }
+ if( parameters.size() != this.parameters.size() ){
+ return false;
+ }
+ for( int i=0,len= parameters.size();i classForTableData() {
+ return DemoTableData.class;
+ }
+
+ @Override
+ public Class extends TableData> classForInitTableData() {
+ return null;
+ }
+
+ @Override
+ public Class extends AbstractTableDataPane> appearanceForTableData() {
+ return DemoTableDataPane.class;
+ }
+
+ @Override
+ public String nameForTableData() {
+ return "Demo Data";
+ }
+
+ @Override
+ public String prefixForTableData() {
+ return "dm";
+ }
+
+ @Override
+ public String iconPathForTableData() {
+ return "com/tptj/demo/hg/table/data/images/icon.png";
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/table/data/server/WebDemo.java b/src/main/java/com/tptj/demo/hg/table/data/server/WebDemo.java
new file mode 100644
index 0000000..9acc59b
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/table/data/server/WebDemo.java
@@ -0,0 +1,74 @@
+package com.tptj.demo.hg.table.data.server;
+
+import com.fr.base.Parameter;
+import com.fr.decision.fun.impl.AbstractUniversalServerTableDataProvider;
+import com.fr.decision.webservice.bean.dataset.ParameterBean;
+import com.fr.json.JSONObject;
+import com.fr.script.Calculator;
+import com.fr.stable.ParameterProvider;
+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.ParserType;
+import com.fr.web.struct.category.ScriptPath;
+import com.tptj.demo.hg.table.data.DemoTableData;
+import com.tptj.demo.hg.table.data.DemoTableDataBean;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+public class WebDemo extends AbstractUniversalServerTableDataProvider {
+ @Override
+ public Class classForTableData() {
+ return DemoTableData.class;
+ }
+
+ @Override
+ public String nameForTableData() {
+ return "demo_data";
+ }
+
+ @Override
+ public JSONObject serialize(DemoTableData data) {
+ DemoTableDataBean bean = new DemoTableDataBean();
+ bean.setConfig(data.getConfig());
+ List parameterBeans = new ArrayList();
+ ParameterProvider[] parameters = data.getParameters(Calculator.createCalculator());
+ for(ParameterProvider parameter : parameters ) {
+ parameterBeans.add(new ParameterBean(parameter.getValue().getClass().getSimpleName(),
+ parameter.getName(),
+ parameter.valueToString()));
+ }
+ bean.setParameters(parameterBeans);
+ return JSONObject.mapFrom(bean);
+ }
+
+ @Override
+ public DemoTableData deserialize(DemoTableData data, JSONObject config ) {
+ DemoTableDataBean bean = config.mapTo(DemoTableDataBean.class);
+ DemoTableData dataSet = new DemoTableData();
+ dataSet.setConfig( bean.getConfig() );
+ List params = bean.getParameters();
+ Parameter[] parameters = new Parameter[params.size()];
+ for(int i = 0; i < parameters.length; ++i) {
+ parameters[i] = params.get(i).createParameter();
+ }
+ dataSet.setParameters(parameters);
+ return dataSet;
+ }
+
+ @Override
+ public Atom client() {
+ return new Component(){
+ @Override
+ public ScriptPath script(RequestClient client ) {
+ return ScriptPath.build("com/tptj/demo/hg/table/data/js/main.js", ParserType.DYNAMIC);
+ }
+ };
+ }
+}
diff --git a/src/main/java/com/tptj/demo/hg/table/data/ui/DemoTableDataPane.java b/src/main/java/com/tptj/demo/hg/table/data/ui/DemoTableDataPane.java
new file mode 100644
index 0000000..92418c2
--- /dev/null
+++ b/src/main/java/com/tptj/demo/hg/table/data/ui/DemoTableDataPane.java
@@ -0,0 +1,93 @@
+package com.tptj.demo.hg.table.data.ui;
+
+import com.fanruan.api.design.work.BaseTableDataPane;
+import com.fanruan.api.design.ui.component.UITextArea;
+import com.fanruan.api.design.ui.container.UIScrollPane;
+import com.fr.base.BaseUtils;
+import com.fr.base.Parameter;
+import com.fr.design.data.datapane.preview.PreviewTablePane;
+import com.fr.design.gui.ibutton.UIButton;
+import com.fr.design.gui.ilable.UILabel;
+import com.fr.design.gui.itableeditorpane.ParameterTableModel;
+import com.fr.design.gui.itableeditorpane.UITableEditorPane;
+import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
+import com.fr.design.layout.TableLayout;
+import com.fr.design.layout.TableLayoutHelper;
+import com.fr.script.Calculator;
+import com.fr.stable.ParameterProvider;
+import com.tptj.demo.hg.table.data.DemoTableData;
+
+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-29
+ **/
+public class DemoTableDataPane extends BaseTableDataPane {
+
+ private UITextArea config = new UITextArea();
+ private UITableEditorPane parameterTableEditorPane;
+
+ public DemoTableDataPane(){
+ setLayout(new BorderLayout());
+
+ 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(DemoTableDataPane.this.updateBean());
+ }
+ });
+ }
+ });
+
+ add(TableLayoutHelper.createTableLayoutPane(
+ new Component[][] {{
+ new UILabel("配置"),preview
+ }},
+ new double[] { TableLayout.PREFERRED },
+ new double[] { TableLayout.FILL,TableLayout.PREFERRED }
+ ),BorderLayout.NORTH);
+
+ UIScrollPane loadArea = new UIScrollPane(config);
+ add(loadArea, BorderLayout.CENTER);
+
+ UITableModelAdapter model = new ParameterTableModel();
+ parameterTableEditorPane = new UITableEditorPane(model);
+
+ add(parameterTableEditorPane,BorderLayout.SOUTH);
+ }
+
+ @Override
+ public void populateBean(DemoTableData data) {
+ if (data == null) {
+ return;
+ }
+ Calculator c = Calculator.createCalculator();
+ ParameterProvider[] parameters = data.getParameters(c);
+ parameterTableEditorPane.populate(parameters);
+ config.setText( data.getConfig() );
+ }
+
+ @Override
+ public DemoTableData updateBean() {
+ DemoTableData data = new DemoTableData();
+ data.setConfig( config.getText() );
+ java.util.List parameterProviderList = parameterTableEditorPane.update();
+ Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]);
+ data.setParameters(parameters);
+ return data;
+ }
+
+ @Override
+ protected String title4PopupWindow() {
+ return "Demo Data";
+ }
+}
diff --git a/src/main/resources/com/tptj/demo/hg/table/data/images/icon.png b/src/main/resources/com/tptj/demo/hg/table/data/images/icon.png
new file mode 100644
index 0000000..6e41b7e
Binary files /dev/null and b/src/main/resources/com/tptj/demo/hg/table/data/images/icon.png differ
diff --git a/src/main/resources/com/tptj/demo/hg/table/data/js/main.js b/src/main/resources/com/tptj/demo/hg/table/data/js/main.js
new file mode 100644
index 0000000..ebff0ae
--- /dev/null
+++ b/src/main/resources/com/tptj/demo/hg/table/data/js/main.js
@@ -0,0 +1,292 @@
+/**
+ * @author 秃破天际
+ * @version 10.0
+ * Created by 秃破天际 on 2021-03-29
+ **/
+!(function () {
+ var Model = BI.inherit(Fix.Model, {
+ _init: function () {
+ this.service = BI.Services.getService("dec.service.data.set");
+ },
+ context: ["dataSetName", "ableSave"],
+ state: function () {
+ var val = this.options.value.datasetData || {};
+ return {
+ config : val.config || "",
+ parameters: val.parameters || []
+ };
+ },
+ childContext: ["previewAble", "previewedDataSet"],
+ watch: {
+ previewAble: function (v) {
+ this.setAbleSave(v);
+ }
+ },
+ computed: {
+ paramHeader: function () {
+ //定义参数列表表头
+ var map = BI.map(BI.Constants.getConstant("dec.constants.data.set.sql.header"), function (i, v) {
+ return BI.extend({
+ textAlign: "left",
+ height: 30,
+ hgap: 10
+ }, v);
+ });
+ map.push({
+ textAlign: "left",
+ height: 30,
+ hgap: 10,
+ text: ""
+ });
+ return [map];
+ },
+ paramItems: function () {
+ var self = this;
+ return BI.map(this.model.parameters, function (i, param) {
+ return [{
+ type: "bi.text_editor",
+ value: param.name,
+ textAlign: "left",
+ height: 30,
+ lgap: 10,
+ listeners: [{
+ eventName: BI.TextEditor.EVENT_CHANGE,
+ action: function () {
+ self.setParamName(i, this.getValue());
+ }
+ }]
+ }, {
+ type: "bi.icon_text_value_combo",
+ cls: "field-type-change",
+ height: 30,
+ items: BI.Constants.getConstant("dec.constants.data.set.sql.field"),
+ value: param.type,
+ listeners: [{
+ eventName: BI.IconTextValueCombo.EVENT_CHANGE,
+ action: function () {
+ self.setParamType(i, this.getValue()[0]);
+ }
+ }]
+ }, self.service.createParameterValueItem(param, function (val) {
+ self.setParamValue(i, val);
+ }),{
+ type: "bi.icon_button",
+ cls: "default-delete-font",
+ height: 30,
+ lgap: 10,
+ title: BI.i18nText("Dec-Basic_Delete"),
+ handler: function () {
+ self.deleteParameter(i);
+ }
+ }];
+ });
+ },
+ previewAble: function () {
+ return BI.isNotEmptyString(this.model.config);
+ },
+ previewedDataSet: function () {
+ return {
+ datasetType: DecCst.DataSet.Type.DEMO_DATA,
+ datasetName: this.model.dataSetName,
+ datasetData: {
+ config: this.model.config,
+ parameters: this.model.parameters
+ }
+ };
+ }
+ },
+ actions: {
+ initPage: function (cb) {
+ var self = this;
+ cb();
+ },
+ setConfig: function(v){
+ this.model.config = v;
+ },
+ refreshParam: function () {
+ var self = this;
+ Dec.Utils.getDataSetParameters(this.model.previewedDataSet, function (res) {
+ self.model.parameters = self.service.getParameters(res.data, self.model.parameters);
+ });
+ },
+ addParamter:function(v){
+ this.model.parameters.push(v);
+ },
+ deleteParameter:function(index){
+ this.model.parameters.splice(index, 1);
+ },
+ setParamName: function (index, name) {
+ this.model.parameters[index].name = name;
+ },
+ setParamType: function (index, type) {
+ if (this.model.parameters[index].type !== type) {
+ this.model.parameters[index].type = type;
+ this.model.parameters[index].value = this.service.getDefaultValueByType(type);
+ this.model.parameters.splice(0, 0);
+ }
+ },
+ setParamValue: function (index, val) {
+ this.model.parameters[index].value = val;
+ },
+ setAbleSave: function (v) {
+ this.model.ableSave = v;
+ }
+ }
+ });
+ BI.model("dec.model.data.set.type.demo.data", Model);
+
+
+ var DemoData = BI.inherit(BI.Widget, {
+ props: {
+ baseCls: "dec-data-set-sql",
+ $testId: "dec-data-set-sql",
+ value: {
+ datasetData: {}
+ }
+ },
+ _store: function () {
+ return BI.Models.getModel("dec.model.data.set.type.demo.data", this.options);
+ },
+ watch: {
+ config: function (v) {
+ this.configEditor.setValue(v);
+ },
+ "config || parameters.**": function () {
+ this.previewPane.resetPreview();
+ },
+ parameters: function () {
+ this.paramSettingPane.populate(this.model.paramItems, this.model.paramHeader);
+ }
+ },
+ beforeInit: function (cb) {
+ this.store.initPage(cb);
+ },
+ render: function () {
+ var self = this;
+ return {
+ type: "bi.htape",
+ items: [
+ //左侧的配置界面
+ {
+ el: {
+ type: "bi.vtape",
+ items: [
+ {
+ height: 24,
+ type: "bi.label",
+ cls: "dec-font-weight-bold",
+ text: "Config",
+ title: "Config",
+ textAlign: "left",
+ },
+ {
+ height:220,
+ type: "bi.textarea_editor",
+ cls: "bi-border",
+ value: this.model.config,
+ ref: function (_ref) {
+ self.configEditor = _ref;
+ },
+ listeners: [{
+ eventName: BI.FormulaEditor.EVENT_CHANGE,
+ action: function () {
+ self.store.setConfig(this.getValue());
+ }
+ }]
+ },
+ //下面是参数面板
+ {
+ type: "bi.left_right_vertical_adapt",
+ height: 24,
+ items: {
+ left: [{
+ type: "bi.label",
+ cls: "dec-font-weight-bold",
+ text: BI.i18nText("Dec-Basic_Parameter_Setting")
+ }],
+ right: [{
+ type: "bi.icon_button",
+ cls: "add-keyword-font",
+ level: "ignore",
+ lgap: 10,
+ handler: function () {
+ self.store.addParamter({
+ type:"String",
+ name:"",
+ value:""});
+ }
+ },{
+ type: "bi.icon_button",
+ cls: "refresh-font",
+ lgap: 10,
+ level: "ignore",
+ handler: function () {
+ self.store.refreshParam();
+ }
+ }]
+ }
+ }, {
+ type: "bi.components.style_table",
+ cls: "param-table",
+ width: 420,
+ columnSize: [130, 120, 120,""],
+ items: this.model.paramItems,
+ header: this.model.paramHeader,
+ ref: function () {
+ self.paramSettingPane = this;
+ }
+ }
+ ],
+ lgap: 10,
+ vgap: 15
+ },
+ width: 410,
+ lgap: 10,
+ vgap: 15
+ },
+ //右侧的预览界面
+ {
+ el: {
+ type: "bi.absolute",
+ cls: "bi-sortable-holder",
+ items: [{
+ el: {
+ type: "dec.data.set.preview",
+ listeners: [{
+ eventName: "EVENT_CHANGE",
+ action: function () {
+ self.store.refreshParam();
+ self.previewPane.previewData();
+ }
+ }],
+ ref: function (_ref) {
+ self.previewPane = _ref;
+ }
+ }, top: 10, right: 10, bottom: 10, left: 10
+ }]
+ },
+ hgap: 10,
+ vgap: 15
+ }
+ ]
+ };
+ },
+ getValue: function () {
+ return {
+ config: this.model.config,
+ parameters: this.model.parameters
+ };
+ }
+ });
+ BI.shortcut("dec.data.set.type.demo.data", DemoData);
+
+ $.extend(DecCst.DataSet.Type,{DEMO_DATA:"demo_data"});
+ BI.config("dec.provider.data.set", function (provider) {
+ provider.registerDataSetType({
+ value: DecCst.DataSet.Type.DEMO_DATA,
+ text: "Demo Data",
+ cardType: "dec.data.set.type.demo.data",
+ iconCls: "management-maintenance-cloud-font"
+ });
+ });
+})();
\ No newline at end of file