hugh
4 years ago
15 changed files with 946 additions and 2 deletions
@ -1,4 +1,5 @@
|
||||
# demo-table-data-define |
||||
|
||||
新增数据集类型集合demo |
||||
包括模板数据集、设计器操作服务器数据集、决策平台操作服务器数据集 |
||||
新增数据集类型集合demo\ |
||||
包括模板数据集、设计器操作服务器数据集、决策平台操作服务器数据集\ |
||||
demo生效后,预览TableData.cpt模板,显示Hello World!则成功 |
@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<WorkBook xmlVersion="20170720" releaseVersion="10.0.0"> |
||||
<TableDataMap> |
||||
<TableData name="dm1" class="com.tptj.demo.hg.table.data.DemoTableData" pluginID="com.tptj.demo.hg.table.data.define.v10"> |
||||
<Parameters/> |
||||
<Attributes> |
||||
<![CDATA[o17-Ja]AAbocRDI`"98~ |
||||
]]></Attributes> |
||||
</TableData> |
||||
</TableDataMap> |
||||
<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"> |
||||
<PrivilegeControl/> |
||||
<Expand/> |
||||
</C> |
||||
<C c="1" r="2"> |
||||
<O t="DSColumn"> |
||||
<Attributes dsName="dm1" columnName="config"/> |
||||
<Complex/> |
||||
<RG class="com.fr.report.cell.cellattr.core.group.FunctionGrouper"/> |
||||
<Parameters/> |
||||
</O> |
||||
<PrivilegeControl/> |
||||
<Expand dir="0"/> |
||||
</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/> |
||||
<DesignerVersion DesignerVersion="KAA"/> |
||||
<PreviewType PreviewType="0"/> |
||||
<TemplateIdAttMark class="com.fr.base.iofile.attr.TemplateIdAttrMark"> |
||||
<TemplateIdAttMark TemplateId="7ef8fc13-47b3-43f0-ab1c-a1d7d3687317"/> |
||||
</TemplateIdAttMark> |
||||
</WorkBook> |
@ -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') |
||||
} |
||||
|
||||
|
@ -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.
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.tptj.demo.hg.table.data.define.v10</id> |
||||
<name><![CDATA[ table data ]]></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.table.data</main-package> |
||||
<function-recorder class="com.tptj.demo.hg.table.data.DemoTableData"/> |
||||
<extra-designer> |
||||
<ServerTableDataDefineProvider class="com.tptj.demo.hg.table.data.server.Demo"/> |
||||
<TableDataDefineProvider class="com.tptj.demo.hg.table.data.Demo"/> |
||||
</extra-designer> |
||||
<extra-decision> |
||||
<UniversalServerTableDataProvider class="com.tptj.demo.hg.table.data.server.WebDemo"/> |
||||
</extra-decision> |
||||
</plugin> |
@ -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"; |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -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<String> 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(); |
||||
} |
||||
} |
@ -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<ParameterBean> parameters = new ArrayList(); |
||||
private String config; |
||||
|
||||
public List<ParameterBean> getParameters() { |
||||
return parameters; |
||||
} |
||||
|
||||
public void setParameters(List<ParameterBean> 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<ParameterBean> 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<len;i++){ |
||||
ParameterBean oItem = parameters.get(i); |
||||
ParameterBean sItem = this.parameters.get(i); |
||||
if( !StringUtils.equals(oItem.getName(),sItem.getName()) || |
||||
!StringUtils.equals(oItem.getValue(),sItem.getValue()) || |
||||
!StringUtils.equals(oItem.getType(),sItem.getType()) ){ |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
package com.tptj.demo.hg.table.data.server; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.design.data.tabledata.tabledatapane.AbstractTableDataPane; |
||||
import com.fr.design.fun.impl.AbstractServerTableDataDefineProvider; |
||||
import com.tptj.demo.hg.table.data.DemoTableData; |
||||
import com.tptj.demo.hg.table.data.ui.DemoTableDataPane; |
||||
|
||||
/** |
||||
* @author 秃破天际 |
||||
* @version 10.0 |
||||
* Created by 秃破天际 on 2021-03-29 |
||||
**/ |
||||
public class Demo extends AbstractServerTableDataDefineProvider { |
||||
@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"; |
||||
} |
||||
} |
@ -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<DemoTableData> { |
||||
@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<ParameterBean> 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<ParameterBean> 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); |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -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<DemoTableData> { |
||||
|
||||
private UITextArea config = new UITextArea(); |
||||
private UITableEditorPane<ParameterProvider> 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<ParameterProvider> model = new ParameterTableModel(); |
||||
parameterTableEditorPane = new UITableEditorPane<ParameterProvider>(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<ParameterProvider> parameterProviderList = parameterTableEditorPane.update(); |
||||
Parameter[] parameters = parameterProviderList.toArray(new Parameter[parameterProviderList.size()]); |
||||
data.setParameters(parameters); |
||||
return data; |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return "Demo Data"; |
||||
} |
||||
} |
After Width: | Height: | Size: 382 B |
@ -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" |
||||
}); |
||||
}); |
||||
})(); |
Loading…
Reference in new issue