Browse Source

open

master
pioneer 2 years ago
commit
3b94d2cac6
  1. 6
      README.md
  2. BIN
      lib/finekit-10.0-20210309.jar
  3. 25
      plugin.xml
  4. 17
      src/main/java/com/fr/plugin/xx/jsd9663/FuncRecorder.java
  5. 17
      src/main/java/com/fr/plugin/xx/jsd9663/JsFileHandler.java
  6. 29
      src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessage.java
  7. 72
      src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlink.java
  8. 94
      src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlinkPane.java
  9. 32
      src/main/java/com/fr/plugin/xx/jsd9663/logger/PluginLoggerFactory.java
  10. 19
      src/main/resources/com/fr/plugin/xx/jsd9663/locale/js/jsd9663.js

6
README.md

@ -0,0 +1,6 @@
# open-JSD-9663
JSD-9663 在图表添加超链页面新增一个超链类型.该超链支持添加参数,并依赖postMessage实现跨域超链\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。

BIN
lib/finekit-10.0-20210309.jar

Binary file not shown.

25
plugin.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.fr.plugin.xx.jsd9663</id>
<name><![CDATA[ 超链向父窗口传参 ]]></name>
<active>yes</active>
<version>1.0.1</version>
<env-version>10.0</env-version>
<vendor>fr.open</vendor>
<jartime>2020-11-02</jartime>
<description><![CDATA[ postMessage ]]></description>
<change-notes>
<![CDATA[2022-03-03 初始化工程]]>
<![CDATA[2022-03-07 设计器页面增加超链选项]]>
</change-notes>
<main-package>com.fr.plugin.xx</main-package>
<!--功能点注册,这个类不能去掉-->
<function-recorder class="com.fr.plugin.xx.jsd9663.FuncRecorder"/>
<extra-report>
<JavaScriptFileHandler class="com.fr.plugin.xx.jsd9663.JsFileHandler"/>
</extra-report>
<extra-designer>
<HyperlinkProvider class="com.fr.plugin.xx.jsd9663.hyperlink.PostMessage"/>
</extra-designer>
</plugin>

17
src/main/java/com/fr/plugin/xx/jsd9663/FuncRecorder.java

@ -0,0 +1,17 @@
package com.fr.plugin.xx.jsd9663;
import com.fr.plugin.context.PluginContexts;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.stable.fun.Authorize;
//功能点注册
@FunctionRecorder
@Authorize(callSignKey = "com.fr.plugin.xx.jsd9663")
public class FuncRecorder {
@ExecuteFunctionRecord
public static boolean execute(){
return PluginContexts.currentContext().isAvailable();//付费
}
}

17
src/main/java/com/fr/plugin/xx/jsd9663/JsFileHandler.java

@ -0,0 +1,17 @@
package com.fr.plugin.xx.jsd9663;
import com.fr.plugin.transform.ExecuteFunctionRecord;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler;
@FunctionRecorder
public class JsFileHandler extends AbstractJavaScriptFileHandler{
@ExecuteFunctionRecord
@Override
public String[] pathsForFiles() {
return new String[]{
"com/fr/plugin/xx/jsd9663/locale/js/jsd9663.js"
};
}
}

29
src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessage.java

@ -0,0 +1,29 @@
package com.fr.plugin.xx.jsd9663.hyperlink;
import com.fr.design.fun.impl.AbstractHyperlinkProvider;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.general.ComparatorUtils;
public class PostMessage extends AbstractHyperlinkProvider {
private NameableCreator nameableCreator = new NameObjectCreator(
"\u4f20\u9012\u53c2\u6570\u7ed9\u7236\u7a97\u53e3",
PostMessageHyperlink.class, PostMessageHyperlinkPane.class);
@Override
public int hashCode() {
return nameableCreator.menuName().hashCode();
}
@Override
public boolean equals(Object obj) {
return (obj != null && obj instanceof PostMessage)
&& ComparatorUtils.equals(((PostMessage) obj).nameableCreator, nameableCreator);
}
@Override
public NameableCreator createHyperlinkCreator() {
return nameableCreator;
}
}

72
src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlink.java

@ -0,0 +1,72 @@
package com.fr.plugin.xx.jsd9663.hyperlink;
import com.fanruan.api.json.JSONKit;
import com.fr.base.Formula;
import com.fr.js.Hyperlink;
import com.fr.json.JSONObject;
import com.fr.stable.ParameterProvider;
import com.fr.stable.web.Repository;
import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
public class PostMessageHyperlink extends Hyperlink {
private Integer parentNode;
@Override
protected String actionJS(Repository repository) {
ParameterProvider[] parameters = this.getParameters();
JSONObject entries = JSONKit.create();
for (ParameterProvider parameter : parameters) {
Object value = parameter.getValue();
if(value instanceof Formula){
entries.put(parameter.getName(),((Formula)value).getResult());
}else{
entries.put(parameter.getName(),value);
}
}
if(parentNode == null){
parentNode = 1;
}
return "FR.postMessage("+entries.toString() +","+parentNode+");";
}
public Integer getParentNode() {
return parentNode;
}
public void setParentNode(Integer parentNode) {
if(parentNode == null || parentNode == 0){parentNode = 1;}
this.parentNode = parentNode;
}
private static final String XML_TAG = "PostMessageHyperlink";
@Override
public void writeXML( XMLPrintWriter writer ){
super.writeXML(writer);
writer.startTAG(XML_TAG)
.attr("parentNode", parentNode).end();
}
@Override
public void readXML(XMLableReader reader){
super.readXML(reader);
String tag = reader.getTagName();
if( XML_TAG.equals(tag) ){
parentNode = reader.getAttrAsInt("parentNode", 1);
}
}
@Override
public Object clone() throws CloneNotSupportedException {
PostMessageHyperlink rt = (PostMessageHyperlink)super.clone();
rt.setParentNode( this.getParentNode() );
return rt;
}
@Override
public boolean equals(Object obj){
return obj instanceof PostMessageHyperlink
&& (((PostMessageHyperlink)obj).getParentNode() == getParentNode());
}
}

94
src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlinkPane.java

@ -0,0 +1,94 @@
package com.fr.plugin.xx.jsd9663.hyperlink;
import com.fr.base.Parameter;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
import com.fr.design.gui.frpane.ReportletParameterViewPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.ParameterProvider;
import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
import java.util.List;
public class PostMessageHyperlinkPane extends BasicBeanPane<PostMessageHyperlink> {
private UINumberField parentNode;
protected ReportletParameterViewPane parameterViewPane;
private HashMap hyperLinkEditorMap;
public PostMessageHyperlinkPane() {
this.initComponents();
}
@Override
protected String title4PopupWindow() {
return "title4PopupWindow";
}
protected void initComponents() {
parentNode = new UINumberField();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pane = TableLayoutHelper.createTableLayoutPane(
new Component[][]{
{new UILabel("\u7236\u7a97\u53e3\u6240\u5c5e\u5c42\u6570:"), parentNode}
},
new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED},
new double[]{ TableLayout.PREFERRED,TableLayout.FILL}
);
this.add( pane, BorderLayout.NORTH );
this.parameterViewPane = new ReportletParameterViewPane( this.getChartParaType(), this.getValueEditorPane(), this.getValueEditorPane());
this.add(this.parameterViewPane, "Center");
this.parameterViewPane.setBorder(GUICoreUtils.createTitledBorder(Toolkit.i18nText("Fine-Design_Basic_Parameter"), (Color)null));
}
protected int getChartParaType() {
return this.hyperLinkEditorMap != null ? 1 : 0;
}
protected ValueEditorPane getValueEditorPane() {
return ValueEditorPaneFactory.createVallueEditorPaneWithUseType(this.getChartParaType(), this.hyperLinkEditorMap);
}
@Override
public void populateBean(PostMessageHyperlink demoHyperlink) {
List var2 = this.parameterViewPane.update();
var2.clear();
ParameterProvider[] var3 = demoHyperlink.getParameters();
this.parameterViewPane.populate(var3);
parentNode.setValue(demoHyperlink.getParentNode());
}
@Override
public PostMessageHyperlink updateBean() {
PostMessageHyperlink demoHyperlink = new PostMessageHyperlink();
this.updateBean(demoHyperlink);
demoHyperlink.setParentNode((int)parentNode.getValue());
return demoHyperlink;
}
public void updateBean(PostMessageHyperlink var1) {
List var2 = this.parameterViewPane.update();
if (!var2.isEmpty()) {
Parameter[] var3 = new Parameter[var2.size()];
var2.toArray(var3);
var1.setParameters(var3);
var1.setParentNode((int)parentNode.getValue());
} else {
var1.setParameters((ParameterProvider[])null);
}
}
}

32
src/main/java/com/fr/plugin/xx/jsd9663/logger/PluginLoggerFactory.java

@ -0,0 +1,32 @@
package com.fr.plugin.xx.jsd9663.logger;
import com.fr.log.FineLoggerFactory;
public class PluginLoggerFactory{
private static PluginLoggerFactory pluginLogger = null;
private static final String pluginId = "[com.fr.plugin.xx.demo] ";
private PluginLoggerFactory() {
}
public static PluginLoggerFactory getLogger(){
if(pluginLogger == null){
return new PluginLoggerFactory();
}
return pluginLogger;
}
public void info(String m){
FineLoggerFactory.getLogger().info(pluginId+m);
}
public void debug(String m){
FineLoggerFactory.getLogger().debug(pluginId+m);
}
public void error(String m){
FineLoggerFactory.getLogger().error(pluginId+m);
}
}

19
src/main/resources/com/fr/plugin/xx/jsd9663/locale/js/jsd9663.js

@ -0,0 +1,19 @@
!(function (){
FR.postMessage = function(msg,parentNode){
var target = window.parent;
if(typeof(parentNode) != 'number'){
parentNode = 1;
}else if (parentNode > 8){
parentNode = -1;
}
if(parentNode == -1){
target = window.top;
}else if(parentNode > 1){
for(i=1;i<parentNode;i++){
target = target.parent;
}
}
target.postMessage(msg,"*");
}
}())
Loading…
Cancel
Save