Browse Source

first commit

master
unknown 4 years ago
commit
bd4105be88
  1. 129
      build.gradle
  2. BIN
      doc/插件开发成长计划系列教程-第十章.pptx
  3. 13
      encrypt.xml
  4. BIN
      lib/gson-2.3.1.jar
  5. 0
      lib/report/.gitkeep
  6. 25
      plugin.xml
  7. 3
      readme.md
  8. 60
      src/main/java/com/fr/plugin/WaterChartConfig.java
  9. 15
      src/main/java/com/fr/plugin/WaterChartProvider.java
  10. 46
      src/main/java/com/fr/plugin/WaterChartUI.java
  11. 67
      src/main/java/com/fr/plugin/WaterChat.java
  12. 52
      src/main/java/com/fr/plugin/pane/WaterChartTableDataPane.java
  13. 54
      src/main/java/com/fr/plugin/pane/WaterChatReportDataContentPane.java
  14. BIN
      src/main/resources/com/fr/plugin/web/icon/icon.png
  15. BIN
      src/main/resources/com/fr/plugin/web/icon/preview.PNG
  16. 991
      src/main/resources/com/fr/plugin/web/js/echarts-liquidfill.js
  17. 2
      src/main/resources/com/fr/plugin/web/js/echarts-liquidfill.min.js
  18. 92839
      src/main/resources/com/fr/plugin/web/js/echarts.js
  19. 15
      src/main/resources/com/fr/plugin/web/js/water.js

129
build.gradle

@ -0,0 +1,129 @@
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
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")
classes.dependsOn("copyPluginXML")
task copyPluginXML(type: Copy) {
print "copyed plugin.xml file"
from "$projectDir/plugin.xml"
into file("$projectDir/../webroot/WEB-INF/plugins/plugin-" + pluginName + "-1.0/")
}
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'])
}

BIN
doc/插件开发成长计划系列教程-第十章.pptx

Binary file not shown.

13
encrypt.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<target name="compile_encrypt_javas" depends="copyFiles">
<echo message="加密文件"/>
<echo message="${projectDir}"/>
<taskdef name="pretreatment" classname="com.fr.plugin.pack.PluginPretreatmentTask">
<classpath refid="compile.classpath"/>
</taskdef>
<pretreatment baseDir="${projectDir}"/>
</target>
<target name="compile_plain_javas" depends="copyFiles">
</target>
</project>

BIN
lib/gson-2.3.1.jar

Binary file not shown.

0
lib/report/.gitkeep

25
plugin.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<plugin>
<id>com.fr.plugin.water.plugin</id>
<name><![CDATA[水球图图表]]></name>
<active>yes</active>
<version>1.0</version>
<env-version>10.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>author</vendor>
<description><![CDATA[水球图图表]]></description>
<change-notes><![CDATA[
]]></change-notes>
<!--注册图表-后台模型-->
<extra-chart>
<IndependentChartProvider class="com.fr.plugin.WaterChartProvider" plotID="echart.water.chart"/>
</extra-chart>
<!--图表开发-设计器部分-->
<extra-chart-designer>
<IndependentChartUIProvider class="com.fr.plugin.WaterChartUI" plotID="echart.water.chart"/>
</extra-chart-designer>
<function-recorder class="com.fr.plugin.WaterChartProvider"/>
</plugin>

3
readme.md

@ -0,0 +1,3 @@
# 控件开发

60
src/main/java/com/fr/plugin/WaterChartConfig.java

@ -0,0 +1,60 @@
package com.fr.plugin;
import com.fr.extended.chart.AbstractDataConfig;
import com.fr.extended.chart.ExtendedField;
import com.fr.stable.AssistUtils;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
/**
* 后台图表对象用于数据保存和界面交换数据的model
*/
public class WaterChartConfig extends AbstractDataConfig {
/**
* 数据字段有一个字段保存一个
*/
private ExtendedField value = new ExtendedField();
public ExtendedField getValue() {
return value;
}
public void setValue(ExtendedField value) {
this.value = value;
}
@Override
protected void readAttr(XMLableReader xmLableReader) {
readExtendedField(value,"value",xmLableReader);
}
@Override
protected void writeAttr(XMLPrintWriter xmlPrintWriter) {
writeExtendedField(value,"value",xmlPrintWriter);
}
@Override
public ExtendedField[] dataSetFields() {
return new ExtendedField[]{
value
};
}
@Override
public WaterChartConfig clone() throws CloneNotSupportedException {
WaterChartConfig result = new WaterChartConfig();
result.setValue(this.getValue().clone());
return result;
}
@Override
public int hashCode() {
return super.hashCode() + AssistUtils.hashCode(this.getValue());
}
@Override
public boolean equals(Object obj) {
return obj instanceof WaterChartConfig && AssistUtils.equals(this.getValue(), ((WaterChartConfig) obj).getValue());
}
}

15
src/main/java/com/fr/plugin/WaterChartProvider.java

@ -0,0 +1,15 @@
package com.fr.plugin;
import com.fr.extended.chart.AbstractChart;
import com.fr.extended.chart.AbstractExtentChartProvider;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
@FunctionRecorder
public class WaterChartProvider extends AbstractExtentChartProvider {
@Override
@ExecuteFunctionRecord
protected AbstractChart createChart() {
return new WaterChat();
}
}

46
src/main/java/com/fr/plugin/WaterChartUI.java

@ -0,0 +1,46 @@
package com.fr.plugin;
import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane;
import com.fr.extended.chart.AbstractExtendedChartTableDataPane;
import com.fr.extended.chart.AbstractExtendedChartUIProvider;
import com.fr.plugin.pane.WaterChartTableDataPane;
import com.fr.plugin.pane.WaterChatReportDataContentPane;
/**
* 写这写按照plugin顺序写按照文档写按照idea提示写不要自己硬
*/
public class WaterChartUI extends AbstractExtendedChartUIProvider {
/**
* 数据来选为数据集数据时使用的界面
*/
@Override
protected AbstractExtendedChartTableDataPane getTableDataSourcePane() {
return new WaterChartTableDataPane();
}
/**
* 数据来选为单元格时下方的数据
*/
@Override
protected AbstractReportDataContentPane getReportDataSourcePane() {
return new WaterChatReportDataContentPane();
}
/**
* 预览图
*/
@Override
public String[] getDemoImagePath() {
return new String[]{
"com/fr/plugin/web/icon/preview.PNG"
};
}
/*
32*32
*/
@Override
public String getIconPath() {
return "com/fr/plugin/web/icon/icon.png";
}
}

67
src/main/java/com/fr/plugin/WaterChat.java

@ -0,0 +1,67 @@
package com.fr.plugin;
import com.fr.extended.chart.AbstractChart;
import com.fr.extended.chart.HyperLinkPara;
import com.fr.extended.chart.StringFormula;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.stable.web.Repository;
import java.util.List;
public class WaterChat extends AbstractChart<WaterChartConfig> {
@Override
@ExecuteFunctionRecord
/**
* plotID 对应
*/
protected String getChartID() {
return "echart.water.chart";
}
@Override
public String getChartName() {
return "水球图";
}
/**
* 数据源获取并解析成对应类型
*/
@Override
protected void addJSON(WaterChartConfig waterChartConfig, JSONObject jsonObject, Repository repository, JSONPara jsonPara) throws JSONException {
List<Object> values = waterChartConfig.getValue().getValues();
jsonObject.put("value", values);
}
@Override
protected String[] requiredJS() {
return new String[]{
"com/fr/plugin/web/js/echarts.js",
"com/fr/plugin/web/js/echarts-liquidfill.js",
"com/fr/plugin/web/js/water.js"
};
}
@Override
protected String wrapperName() {
return "demoWrapper";
}
@Override
protected String demoImagePath() {
return "com/fr/plugin/web/icon/preview.PNG";
}
@Override
protected HyperLinkPara[] hyperLinkParas() {
return new HyperLinkPara[0];
}
@Override
protected List<StringFormula> formulas() {
return null;
}
}

52
src/main/java/com/fr/plugin/pane/WaterChartTableDataPane.java

@ -0,0 +1,52 @@
package com.fr.plugin.pane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.extended.chart.AbstractExtendedChartTableDataPane;
import com.fr.plugin.WaterChartConfig;
/**
* 使用这个界面时fr会自动生成一个数据集选择器意味着只能单一数据源
* 然后根据我们有多少个字段编写多少个12然后渲染出来就自动生成
*/
public class WaterChartTableDataPane extends AbstractExtendedChartTableDataPane<WaterChartConfig> {
private UIComboBox xComboBox;
private UIComboBox xComboBox1;
/**
* 1 说明标签
* @return
*/
@Override
protected String[] fieldLabels() {
return new String[]{
"百分比数据集选择",
"第二个字段"
};
}
/**
* 2
* 字段选择器
*/
@Override
protected UIComboBox[] filedComboBoxes() {
if (xComboBox == null) {
xComboBox=new UIComboBox();
xComboBox1=new UIComboBox();
}
return new UIComboBox[]{
xComboBox,
xComboBox1
};
}
@Override
protected void populate(WaterChartConfig waterChartConfig) {
populateField(xComboBox, waterChartConfig.getValue());
}
@Override
protected WaterChartConfig update() {
WaterChartConfig waterChartConfig = new WaterChartConfig();
updateField(xComboBox, waterChartConfig.getValue());
return waterChartConfig;
}
}

54
src/main/java/com/fr/plugin/pane/WaterChatReportDataContentPane.java

@ -0,0 +1,54 @@
package com.fr.plugin.pane;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.extended.chart.AbstractExtendedChartReportDataPane;
import com.fr.plugin.WaterChartConfig;
/**
* 选中单元格数据集时使用本类来执行
*/
public class WaterChatReportDataContentPane extends AbstractExtendedChartReportDataPane<WaterChartConfig> {
private TinyFormulaPane xPane;
/**
* 返回标签数量
*/
@Override
protected String[] fieldLabel() {
return new String[]{
"百分比:(小数)"
};
}
/**
* 返回公式选择器
*/
@Override
protected TinyFormulaPane[] formulaPanes() {
if (xPane == null) {
xPane = new TinyFormulaPane();
}
return new TinyFormulaPane[]{
xPane
};
}
/**
* 更新界面
*/
@Override
protected void populate(WaterChartConfig waterChartConfig) {
populateField(xPane, waterChartConfig.getValue());
}
@Override
/**
* 更新图表模型
*/
protected WaterChartConfig update() {
WaterChartConfig waterChartConfig = new WaterChartConfig();
updateField(xPane, waterChartConfig.getValue());
return waterChartConfig;
}
}

BIN
src/main/resources/com/fr/plugin/web/icon/icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

BIN
src/main/resources/com/fr/plugin/web/icon/preview.PNG

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

991
src/main/resources/com/fr/plugin/web/js/echarts-liquidfill.js

File diff suppressed because one or more lines are too long

2
src/main/resources/com/fr/plugin/web/js/echarts-liquidfill.min.js vendored

File diff suppressed because one or more lines are too long

92839
src/main/resources/com/fr/plugin/web/js/echarts.js

File diff suppressed because it is too large Load Diff

15
src/main/resources/com/fr/plugin/web/js/water.js

@ -0,0 +1,15 @@
// 前端图表对象
demoWrapper = ExtendedChart.extend({
_init:function (dom, option) {
debugger
var chart = echarts.init(dom);
var option1 = {
series: [{
type: 'liquidFill',
data: option.value
}]
};
chart.setOption(option1);
return chart;
}
});
Loading…
Cancel
Save