commit 3b94d2cac6093cab7801073c880fa4a20bc1cd67 Author: pioneer Date: Fri Aug 5 16:15:52 2022 +0800 open diff --git a/README.md b/README.md new file mode 100644 index 0000000..ec739c9 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# open-JSD-9663 + +JSD-9663 在图表添加超链页面新增一个超链类型.该超链支持添加参数,并依赖postMessage实现跨域超链\ +免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ +仅作为开发者学习参考使用!禁止用于任何商业用途!\ +为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 \ 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..e5bcdf2 --- /dev/null +++ b/plugin.xml @@ -0,0 +1,25 @@ + + com.fr.plugin.xx.jsd9663 + + yes + 1.0.1 + 10.0 + fr.open + 2020-11-02 + + + + + + com.fr.plugin.xx + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/fr/plugin/xx/jsd9663/FuncRecorder.java b/src/main/java/com/fr/plugin/xx/jsd9663/FuncRecorder.java new file mode 100644 index 0000000..88d7ec7 --- /dev/null +++ b/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();//付费 + } +} diff --git a/src/main/java/com/fr/plugin/xx/jsd9663/JsFileHandler.java b/src/main/java/com/fr/plugin/xx/jsd9663/JsFileHandler.java new file mode 100644 index 0000000..fce02c0 --- /dev/null +++ b/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" + }; + } +} diff --git a/src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessage.java b/src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessage.java new file mode 100644 index 0000000..8409ef7 --- /dev/null +++ b/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; + } +} diff --git a/src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlink.java b/src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlink.java new file mode 100644 index 0000000..a9a4435 --- /dev/null +++ b/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()); + } +} diff --git a/src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlinkPane.java b/src/main/java/com/fr/plugin/xx/jsd9663/hyperlink/PostMessageHyperlinkPane.java new file mode 100644 index 0000000..3009ab3 --- /dev/null +++ b/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 { + 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); + } + } +} diff --git a/src/main/java/com/fr/plugin/xx/jsd9663/logger/PluginLoggerFactory.java b/src/main/java/com/fr/plugin/xx/jsd9663/logger/PluginLoggerFactory.java new file mode 100644 index 0000000..948defa --- /dev/null +++ b/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); + } + +} diff --git a/src/main/resources/com/fr/plugin/xx/jsd9663/locale/js/jsd9663.js b/src/main/resources/com/fr/plugin/xx/jsd9663/locale/js/jsd9663.js new file mode 100644 index 0000000..719e1ee --- /dev/null +++ b/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