You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
4.2 KiB
147 lines
4.2 KiB
package com.fr.plugin.form.widget.core; |
|
|
|
import com.fr.form.ui.FieldEditor; |
|
import com.fr.form.ui.Interactive; |
|
import com.fanruan.api.xml.XmlKit; |
|
import com.fr.intelli.record.Focus; |
|
import com.fr.intelli.record.Original; |
|
import com.fr.json.JSONArray; |
|
import com.fanruan.api.err.JSONException; |
|
import com.fr.json.JSONObject; |
|
import com.fr.plugin.ExtraClassManager; |
|
import com.fr.plugin.form.widget.monitor.RHFunctionProcessor; |
|
import com.fr.record.analyzer.EnableMetrics; |
|
import com.fr.script.Calculator; |
|
import com.fanruan.api.util.ArrayKit; |
|
import com.fanruan.api.report.analy.data.NodeVisitor; |
|
import com.fr.stable.fun.FunctionProcessor; |
|
import com.fr.stable.script.CalculatorProvider; |
|
import com.fr.stable.web.Repository; |
|
import com.fr.stable.xml.XMLPrintWriter; |
|
import com.fr.stable.xml.XMLableReader; |
|
import com.fr.stable.web.SessionProvider; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
/** |
|
* Created by richie on 15/12/2. |
|
*/ |
|
@EnableMetrics |
|
public class RHIframe extends FieldEditor implements Interactive { |
|
|
|
|
|
private boolean overflowX = true; |
|
private boolean overflowY = true; |
|
|
|
private RHIframeAttr attr = new RHIframeAttr(); |
|
|
|
|
|
public RHIframe() { |
|
|
|
} |
|
|
|
public RHIframeAttr getAttr() { |
|
return attr; |
|
} |
|
|
|
public void setAttr(RHIframeAttr attr) { |
|
this.attr = attr; |
|
} |
|
|
|
public boolean isOverflowX() { |
|
return overflowX; |
|
} |
|
|
|
public void setOverflowX(boolean overflowX) { |
|
this.overflowX = overflowX; |
|
} |
|
|
|
public boolean isOverflowY() { |
|
return overflowY; |
|
} |
|
|
|
public void setOverflowY(boolean overflowY) { |
|
this.overflowY = overflowY; |
|
} |
|
|
|
|
|
@Focus(id=Constants.PLUGIN_ID, text = "Plugin-RH_Iframe_Name", source = Original.PLUGIN) |
|
public JSONObject createJSONConfig(Repository repo, Calculator c, NodeVisitor nodeVisitor) throws JSONException { |
|
JSONObject jo = super.createJSONConfig(repo, c, nodeVisitor); |
|
attr.mixConfig(jo, c, repo.getHttpServletRequest()); |
|
jo.put("showOverFlowX", overflowX); |
|
jo.put("showOverFlowY", overflowY); |
|
FunctionProcessor processor = ExtraClassManager.getInstance().getFunctionProcessor(); |
|
if (processor != null){ |
|
processor.recordFunction(RHFunctionProcessor.getInstance()); |
|
} |
|
return jo; |
|
} |
|
|
|
|
|
public JSONArray createJSONData(SessionProvider sessionIDInfor, Calculator c, HttpServletRequest req) throws Exception { |
|
JSONArray ja = super.createJSONData(sessionIDInfor, c, req); |
|
attr.mixJSONData(ja,sessionIDInfor, c); |
|
return ja; |
|
} |
|
|
|
@Override |
|
public String getXType() { |
|
return "rh.iframe"; |
|
} |
|
|
|
@Override |
|
public boolean isEditor() { |
|
return false; |
|
} |
|
|
|
@Override |
|
public String[] supportedEvents() { |
|
return new String[0]; |
|
} |
|
|
|
@Override |
|
public String[] dependence(CalculatorProvider ca) { |
|
if (attr == null) { |
|
return ArrayKit.EMPTY_STRING_ARRAY; |
|
} |
|
return attr.dependence(ca); |
|
} |
|
|
|
@Override |
|
public void readXML( XMLableReader reader) { |
|
super.readXML(reader); |
|
if (reader.isChildNode()) { |
|
String nodeName = reader.getTagName(); |
|
if ("Attr".equals(nodeName)) { |
|
this.overflowX = reader.getAttrAsBoolean("scrollX", true); |
|
this.overflowY = reader.getAttrAsBoolean("scrollY", true); |
|
} else if (RHIframeAttr.XML_TAG.equals(nodeName)) { |
|
this.attr = (RHIframeAttr) XmlKit.readXMLable(reader); |
|
} |
|
} |
|
} |
|
|
|
@Override |
|
public void writeXML(XMLPrintWriter writer) { |
|
super.writeXML(writer); |
|
writer.startTAG("Attr"); |
|
writer.attr("scrollX", overflowX); |
|
writer.attr("scrollY", overflowY); |
|
writer.end(); |
|
if (attr != null) { |
|
XmlKit.writeXMLable(writer,attr, RHIframeAttr.XML_TAG); |
|
} |
|
} |
|
|
|
@Override |
|
public void mixinReturnData(HttpServletRequest req, Calculator ca, JSONObject jo) throws JSONException { |
|
if (widgetName != null) { |
|
RHIframeSource source = attr.getSource(); |
|
if (source != null) { |
|
String url = source.getCalculatedUrl(ca, req); |
|
jo.put(widgetName.toUpperCase(), url); |
|
} |
|
} |
|
} |
|
} |