commit
c9cbabe1f9
32 changed files with 1351 additions and 0 deletions
@ -0,0 +1,5 @@ |
|||||||
|
set JAVA_HOME=D:\FineReport\develop\java\jdk1.6u35 |
||||||
|
|
||||||
|
set ANT_OPTS=-Xmx512M -Xss100m |
||||||
|
|
||||||
|
D:\FineReport\develop\release\build\ant\bin\ant -f build.xml jar |
@ -0,0 +1,118 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||||
|
<project basedir="." default="jar" name="plugin"> |
||||||
|
<!-- JDK路径,根据自己机器上实际位置修改--> |
||||||
|
<property name="jdk.home" value="/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home"/> |
||||||
|
|
||||||
|
<property name="libs" value="${basedir}/lib"/> |
||||||
|
<property name="publicLibs" value=""/> |
||||||
|
<property name="destLoc" value="."/> |
||||||
|
<property name="classes" value="classes"/> |
||||||
|
|
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<property name="current-version" value="${plugin.version}"/> |
||||||
|
|
||||||
|
<!-- 插件版本--> |
||||||
|
<property name="plugin-version" value="${current-version}"/> |
||||||
|
<!-- 插件名字--> |
||||||
|
<property name="plugin-name" value="rh.iframe"/> |
||||||
|
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/> |
||||||
|
|
||||||
|
<target name="prepare"> |
||||||
|
<delete dir="${classes}"/> |
||||||
|
<delete dir="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<delete dir="${destLoc}/${plugin.name}"/> |
||||||
|
</target> |
||||||
|
<path id="compile.classpath"> |
||||||
|
<fileset dir="${libs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
<fileset dir="${publicLibs}"> |
||||||
|
<include name="**/*.jar"/> |
||||||
|
</fileset> |
||||||
|
</path> |
||||||
|
<patternset id="resources4Jar"> |
||||||
|
<exclude name="**/.settings/**"/> |
||||||
|
<exclude name=".classpath"/> |
||||||
|
<exclude name=".project"/> |
||||||
|
|
||||||
|
<exclude name="**/*.java"/> |
||||||
|
<exclude name="**/*.db"/> |
||||||
|
<exclude name="**/*.g"/> |
||||||
|
<exclude name="**/package.html"/> |
||||||
|
</patternset> |
||||||
|
<target name="copy_resources"> |
||||||
|
<echo message="从${resources_from}拷贝图片,JS,CSS等资源文件"/> |
||||||
|
<delete dir="tmp"/> |
||||||
|
<copy todir="tmp"> |
||||||
|
<fileset dir="${resources_from}\src"> |
||||||
|
<patternset refid="resources4Jar"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<copy todir="${classes}"> |
||||||
|
<fileset dir="tmp"/> |
||||||
|
</copy> |
||||||
|
<delete dir="tmp"/> |
||||||
|
</target> |
||||||
|
<target name="compile_javas"> |
||||||
|
<echo message="编译${compile_files}下的Java文件"/> |
||||||
|
<javac destdir="${classes}" debug="false" optimize="on" source="${source_jdk_version}" |
||||||
|
target="${target_jdk_version}" |
||||||
|
fork="true" memoryMaximumSize="512m" listfiles="false" srcdir="${basedir}" |
||||||
|
executable="${compile_jdk_version}/bin/javac"> |
||||||
|
<src path="${basedir}/src"/> |
||||||
|
<exclude name="**/.svn/**"/> |
||||||
|
<compilerarg line="-encoding UTF8 "/> |
||||||
|
<classpath refid="compile.classpath"/> |
||||||
|
</javac> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="jar_classes"> |
||||||
|
<echo message="打Jar包:${jar_name}"/> |
||||||
|
<delete file="${basedir}/${jar_name}"/> |
||||||
|
<jar jarfile="${basedir}/${jar_name}"> |
||||||
|
<fileset dir="${classes}"> |
||||||
|
</fileset> |
||||||
|
</jar> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="super_jar" depends="prepare"> |
||||||
|
<antcall target="copy_resources"> |
||||||
|
<param name="resources_from" value="${basedir}"/> |
||||||
|
</antcall> |
||||||
|
<antcall target="compile_javas"> |
||||||
|
<param name="source_jdk_version" value="1.6"/> |
||||||
|
<param name="target_jdk_version" value="1.6"/> |
||||||
|
<param name="compile_jdk_version" value="${jdk.home}"/> |
||||||
|
<param name="compile_files" value="${basedir}/src"/> |
||||||
|
</antcall> |
||||||
|
<echo message="compile plugin success!"/> |
||||||
|
|
||||||
|
<antcall target="jar_classes"> |
||||||
|
<param name="jar_name" value="${plugin-jar}"/> |
||||||
|
</antcall> |
||||||
|
<delete dir="${classes}"/> |
||||||
|
|
||||||
|
</target> |
||||||
|
<target name="jar" depends="super_jar"> |
||||||
|
<antcall target="zip"/> |
||||||
|
</target> |
||||||
|
|
||||||
|
<target name="zip"> |
||||||
|
<property name="plugin-folder" value="fr-plugin-${plugin-name}-${plugin-version}"/> |
||||||
|
<echo message="----------zip files----------"/> |
||||||
|
<mkdir dir="${plugin-folder}"/> |
||||||
|
<copy todir="${plugin-folder}"> |
||||||
|
<fileset dir="."> |
||||||
|
<include name="${plugin-jar}"/> |
||||||
|
<include name="plugin.xml"/> |
||||||
|
</fileset> |
||||||
|
</copy> |
||||||
|
<zip destfile="${basedir}/${plugin-folder}.zip" basedir="."> |
||||||
|
<include name="${plugin-folder}/*.jar"/> |
||||||
|
<include name="${plugin-folder}/plugin.xml"/> |
||||||
|
</zip> |
||||||
|
<xmlproperty file="${basedir}/plugin.xml"/> |
||||||
|
<move file="${plugin-folder}.zip" todir="${destLoc}/${plugin.name}"/> |
||||||
|
</target> |
||||||
|
</project> |
@ -0,0 +1,25 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||||
|
<id>com.fr.plugin.form.widget.rh.iframe</id> |
||||||
|
<name><![CDATA[网页框控件]]></name> |
||||||
|
<active>yes</active> |
||||||
|
<version>3.2</version> |
||||||
|
<env-version>8.0</env-version> |
||||||
|
<jartime>2016-01-15</jartime> |
||||||
|
<vendor>洪七公</vendor> |
||||||
|
<description><![CDATA[网页框控件,仅支持在表单中使用]]></description> |
||||||
|
<change-notes><![CDATA[ |
||||||
|
<p>[2015-12-03]修复再次打开地址设置界面时没有正确选择到选项的问题</p> |
||||||
|
<p>[2016-01-13]增加常用的API接口</p> |
||||||
|
<p>[2016-01-15]实现功能改进数据统计接口</p> |
||||||
|
]]></change-notes> |
||||||
|
<extra-core> |
||||||
|
<LocaleFinder class="com.fr.plugin.form.widget.locale.LocaleFinder"/> |
||||||
|
<JavaScriptFileHandler class="com.fr.plugin.form.widget.JavaScriptFileLoader"/> |
||||||
|
</extra-core> |
||||||
|
<extra-report> |
||||||
|
</extra-report> |
||||||
|
<extra-platform/> |
||||||
|
<extra-designer> |
||||||
|
<FormWidgetOptionProvider class="com.fr.plugin.form.widget.conf.RHIframeMarkInForm"/> |
||||||
|
</extra-designer> |
||||||
|
</plugin> |
@ -0,0 +1,30 @@ |
|||||||
|
# 表单网页框控件 |
||||||
|
|
||||||
|
该插件支持在FineReport V8.0的表单中使用网页框控件 |
||||||
|
|
||||||
|
## API接口 |
||||||
|
|
||||||
|
1. setValue:(String)v |
||||||
|
设置并刷新网页框控件的地址(保留原参数) |
||||||
|
2. getValue |
||||||
|
获取网页框控件的src地址 |
||||||
|
3. reset |
||||||
|
重置网页框控件并刷新 |
||||||
|
|
||||||
|
|
||||||
|
## 效果图 |
||||||
|
|
||||||
|
1. 选择控件界面 |
||||||
|
 |
||||||
|
|
||||||
|
2. 设置控件的地址和参数入口 |
||||||
|
 |
||||||
|
|
||||||
|
3. 设置控件的模板地址界面 |
||||||
|
 |
||||||
|
|
||||||
|
4. 设置控件的网络地址界面 |
||||||
|
 |
||||||
|
|
||||||
|
5. 预览效果 |
||||||
|
 |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 71 KiB |
After Width: | Height: | Size: 68 KiB |
After Width: | Height: | Size: 61 KiB |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.plugin.form.widget; |
||||||
|
|
||||||
|
import com.fr.stable.fun.impl.AbstractCssFileHandler; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class CSSFileLoader extends AbstractCssFileHandler { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String[] pathsForFiles() { |
||||||
|
return new String[0]; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,21 @@ |
|||||||
|
package com.fr.plugin.form.widget; |
||||||
|
|
||||||
|
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class JavaScriptFileLoader extends AbstractJavaScriptFileHandler { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String[] pathsForFiles() { |
||||||
|
return new String[]{ |
||||||
|
"/com/fr/plugin/form/widget/web/widget.rh.iframe.js" |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
package com.fr.plugin.form.widget.conf; |
||||||
|
|
||||||
|
import com.fr.design.fun.impl.AbstractFormWidgetOptionProvider; |
||||||
|
import com.fr.form.ui.Widget; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframe; |
||||||
|
import com.fr.plugin.form.widget.ui.XRHIframe; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframeMarkInForm extends AbstractFormWidgetOptionProvider { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<? extends Widget> classForWidget() { |
||||||
|
return RHIframe.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Class<?> appearanceForWidget() { |
||||||
|
return XRHIframe.class; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String iconPathForWidget() { |
||||||
|
return "/com/fr/plugin/form/widget/images/rh_iframe.png"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String nameForWidget() { |
||||||
|
return Inter.getLocText("Plugin-RH_Iframe_Name"); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,127 @@ |
|||||||
|
package com.fr.plugin.form.widget.core; |
||||||
|
|
||||||
|
import com.fr.form.ui.FieldEditor; |
||||||
|
import com.fr.general.xml.GeneralXMLTools; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONException; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.plugin.ExtraClassManager; |
||||||
|
import com.fr.plugin.form.widget.monitor.RHFunctionProcessor; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.core.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.web.core.SessionIDInfor; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframe extends FieldEditor { |
||||||
|
|
||||||
|
|
||||||
|
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; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
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; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public JSONArray createJSONData(SessionIDInfor 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) { |
||||||
|
return new String[0]; |
||||||
|
} |
||||||
|
|
||||||
|
@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) GeneralXMLTools.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) { |
||||||
|
GeneralXMLTools.writeXMLable(writer, attr, RHIframeAttr.XML_TAG); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,122 @@ |
|||||||
|
package com.fr.plugin.form.widget.core; |
||||||
|
|
||||||
|
import com.fr.base.Formula; |
||||||
|
import com.fr.base.ParameterMapNameSpace; |
||||||
|
import com.fr.general.FArray; |
||||||
|
import com.fr.general.xml.GeneralXMLTools; |
||||||
|
import com.fr.json.JSONArray; |
||||||
|
import com.fr.json.JSONException; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.CodeUtils; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
import com.fr.stable.UtilEvalError; |
||||||
|
import com.fr.stable.js.WidgetName; |
||||||
|
import com.fr.stable.script.NameSpace; |
||||||
|
import com.fr.stable.xml.*; |
||||||
|
import com.fr.web.core.SessionIDInfor; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframeAttr implements XMLable { |
||||||
|
public static final String XML_TAG = "RHIframeAttr"; |
||||||
|
|
||||||
|
private RHIframeSource source; |
||||||
|
|
||||||
|
private ParameterProvider[] parameters; |
||||||
|
|
||||||
|
public RHIframeSource getSource() { |
||||||
|
return source; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSource(RHIframeSource source) { |
||||||
|
this.source = source; |
||||||
|
} |
||||||
|
|
||||||
|
public ParameterProvider[] getParameters() { |
||||||
|
return parameters; |
||||||
|
} |
||||||
|
|
||||||
|
public void setParameters(ParameterProvider[] parameters) { |
||||||
|
this.parameters = parameters; |
||||||
|
} |
||||||
|
|
||||||
|
public void mixConfig(JSONObject jo, Calculator c, HttpServletRequest req) throws JSONException { |
||||||
|
if (source != null) { |
||||||
|
jo.put("src", source.getCalculatedUrl(c, req)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void mixJSONData(JSONArray ja, SessionIDInfor sessionIDInfor, Calculator c) throws JSONException, UtilEvalError { |
||||||
|
NameSpace ns = ParameterMapNameSpace.create(sessionIDInfor.getParameterMap4Execute()); |
||||||
|
c.pushNameSpace(ns); |
||||||
|
for (int i = 0; i < (parameters == null ? 0 : parameters.length); i++) { |
||||||
|
Object obj = parameters[i].getValue(); |
||||||
|
if (obj instanceof Formula) { |
||||||
|
String content = ((Formula) obj).getContent(); |
||||||
|
obj = c.evalValue(content); |
||||||
|
} |
||||||
|
JSONObject jo = new JSONObject(); |
||||||
|
if (obj instanceof String) { |
||||||
|
obj = CodeUtils.cjkEncode((String) obj); |
||||||
|
jo.put(parameters[i].getName(), obj); |
||||||
|
} else if (obj instanceof FArray) { |
||||||
|
obj = ((FArray) obj).cjkEncode(); |
||||||
|
jo.put(parameters[i].getName(), obj); |
||||||
|
} else if (obj instanceof WidgetName) { |
||||||
|
jo.put("widgetName", ((WidgetName) obj).getName()); |
||||||
|
} else { |
||||||
|
// 还可以是数字啊什么的
|
||||||
|
jo.put(parameters[i].getName(), obj); |
||||||
|
} |
||||||
|
|
||||||
|
ja.put(jo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String tmpName = reader.getTagName(); |
||||||
|
if (ParameterProvider.ARRAY_XML_TAG.equals(tmpName)) {//读取Parameters.
|
||||||
|
final List<ParameterProvider> tmpParameterList = new ArrayList<ParameterProvider>(); |
||||||
|
|
||||||
|
reader.readXMLObject(new XMLReadable() { |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
if (ParameterProvider.XML_TAG.equals(reader.getTagName())) { |
||||||
|
tmpParameterList.add(StableXMLUtils.readParameter(reader)); |
||||||
|
} |
||||||
|
} |
||||||
|
}); |
||||||
|
|
||||||
|
//转换数组.
|
||||||
|
if (!tmpParameterList.isEmpty()) { |
||||||
|
this.parameters = tmpParameterList.toArray(new ParameterProvider[tmpParameterList.size()]); |
||||||
|
} |
||||||
|
} else if (tmpName.equals(RHIframeSource.XML_TAG)) { |
||||||
|
this.source = (RHIframeSource) GeneralXMLTools.readXMLable(reader); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
if (source != null) { |
||||||
|
GeneralXMLTools.writeXMLable(writer, source, RHIframeSource.XML_TAG); |
||||||
|
} |
||||||
|
StableXMLUtils.writeParameters(writer, parameters); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
RHIframeAttr cloned = (RHIframeAttr)super.clone(); |
||||||
|
cloned.source = source; |
||||||
|
cloned.parameters = parameters; |
||||||
|
return cloned; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,40 @@ |
|||||||
|
package com.fr.plugin.form.widget.core; |
||||||
|
|
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLable; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframeSource implements XMLable { |
||||||
|
|
||||||
|
public static final String XML_TAG = "RHIframeSource"; |
||||||
|
|
||||||
|
|
||||||
|
public String toString() { |
||||||
|
return "source"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public String getCalculatedUrl(Calculator calculator, HttpServletRequest req) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object clone() throws CloneNotSupportedException { |
||||||
|
return super.clone(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,74 @@ |
|||||||
|
package com.fr.plugin.form.widget.core; |
||||||
|
|
||||||
|
import com.fr.base.TemplateUtils; |
||||||
|
import com.fr.data.NetworkHelper; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class TemplateSource extends RHIframeSource { |
||||||
|
|
||||||
|
|
||||||
|
private String path; |
||||||
|
|
||||||
|
public TemplateSource() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public TemplateSource(String path) { |
||||||
|
this.path = path; |
||||||
|
} |
||||||
|
|
||||||
|
public String getPath() { |
||||||
|
return path; |
||||||
|
} |
||||||
|
|
||||||
|
public void setPath(String path) { |
||||||
|
this.path = path; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getCalculatedUrl(Calculator calculator, HttpServletRequest req) { |
||||||
|
try { |
||||||
|
String realPath = TemplateUtils.render(path, calculator); |
||||||
|
if (realPath.contains(".cpt")) { |
||||||
|
return NetworkHelper.createServletURL(req) + "?reportlet=" + realPath; |
||||||
|
} else if (realPath.contains(".frm")) { |
||||||
|
return NetworkHelper.createServletURL(req) + "?formlet=" + realPath; |
||||||
|
} |
||||||
|
} catch (Exception e) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return Inter.getLocText("Plugin_RH_Iframe_Template_Path"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
super.readXML(reader); |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String nodeName = reader.getTagName(); |
||||||
|
if ("Attr".equals(nodeName)) { |
||||||
|
this.path = reader.getAttrAsString("path", null); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
super.writeXML(writer); |
||||||
|
writer.startTAG("Attr"); |
||||||
|
writer.attr("path", path); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
package com.fr.plugin.form.widget.core; |
||||||
|
|
||||||
|
import com.fr.base.TemplateUtils; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.script.Calculator; |
||||||
|
import com.fr.stable.xml.XMLPrintWriter; |
||||||
|
import com.fr.stable.xml.XMLableReader; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class URLSource extends RHIframeSource { |
||||||
|
private String url; |
||||||
|
|
||||||
|
public URLSource() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public URLSource(String url) { |
||||||
|
this.url = url; |
||||||
|
} |
||||||
|
|
||||||
|
public String getUrl() { |
||||||
|
return url; |
||||||
|
} |
||||||
|
|
||||||
|
public void setUrl(String url) { |
||||||
|
this.url = url; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getCalculatedUrl(Calculator calculator, HttpServletRequest req) { |
||||||
|
try { |
||||||
|
return TemplateUtils.render(url, calculator); |
||||||
|
} catch (Exception e) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String toString() { |
||||||
|
return Inter.getLocText("Plugin_RH_Iframe_Url"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void readXML(XMLableReader reader) { |
||||||
|
super.readXML(reader); |
||||||
|
if (reader.isChildNode()) { |
||||||
|
String nodeName = reader.getTagName(); |
||||||
|
if ("Attr".equals(nodeName)) { |
||||||
|
this.url = reader.getAttrAsString("url", null); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void writeXML(XMLPrintWriter writer) { |
||||||
|
super.writeXML(writer); |
||||||
|
writer.startTAG("Attr"); |
||||||
|
writer.attr("url", url); |
||||||
|
writer.end(); |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 357 B |
@ -0,0 +1,19 @@ |
|||||||
|
package com.fr.plugin.form.widget.locale; |
||||||
|
|
||||||
|
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class LocaleFinder extends AbstractLocaleFinder { |
||||||
|
|
||||||
|
@Override |
||||||
|
public int currentAPILevel() { |
||||||
|
return CURRENT_LEVEL; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String find() { |
||||||
|
return "com/fr/plugin/form/widget/locale/iframe"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,4 @@ |
|||||||
|
Plugin-RH_Iframe_Name=Iframe |
||||||
|
Plugin-RH_Iframe_Value=Address |
||||||
|
Plugin_RH_Iframe_Template_Path=Template Path |
||||||
|
Plugin_RH_Iframe_Url=URL |
@ -0,0 +1,4 @@ |
|||||||
|
Plugin-RH_Iframe_Name=\u7F51\u9875\u6846 |
||||||
|
Plugin-RH_Iframe_Value=\u5730\u5740\u548C\u53C2\u6570 |
||||||
|
Plugin_RH_Iframe_Template_Path=\u6A21\u677F\u8DEF\u5F84 |
||||||
|
Plugin_RH_Iframe_Url=\u7F51\u7EDC\u8DEF\u5F84 |
@ -0,0 +1,26 @@ |
|||||||
|
package com.fr.plugin.form.widget.monitor; |
||||||
|
|
||||||
|
import com.fr.stable.fun.FunctionHelper; |
||||||
|
import com.fr.stable.fun.impl.AbstractFunctionProcessor; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/3. |
||||||
|
*/ |
||||||
|
public class RHFunctionProcessor extends AbstractFunctionProcessor { |
||||||
|
|
||||||
|
private static RHFunctionProcessor instance = new RHFunctionProcessor(); |
||||||
|
|
||||||
|
public static RHFunctionProcessor getInstance() { |
||||||
|
return instance; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public int getId() { |
||||||
|
return FunctionHelper.generateFunctionID("com.fr.plugin.form.widget.rh.iframe"); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getLocaleKey() { |
||||||
|
return "Plugin-RH_Iframe_Name"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,52 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicPane; |
||||||
|
import com.fr.design.gui.frpane.UIRadioPane; |
||||||
|
import com.fr.design.gui.itableeditorpane.ParameterTableModel; |
||||||
|
import com.fr.design.gui.itableeditorpane.UITableEditorPane; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframeAttr; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframeSource; |
||||||
|
import com.fr.stable.ParameterProvider; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHFramePane extends BasicPane { |
||||||
|
|
||||||
|
private UIRadioPane<RHIframeSource> radioPane; |
||||||
|
private UITableEditorPane<ParameterProvider> editorPane; |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return Inter.getLocText("Plugin-RH_Iframe_Value"); |
||||||
|
} |
||||||
|
|
||||||
|
public RHFramePane() { |
||||||
|
setLayout(new BorderLayout()); |
||||||
|
radioPane = new SourceRadioPane(); |
||||||
|
radioPane.setPreferredSize(new Dimension(200, 60)); |
||||||
|
add(radioPane, BorderLayout.NORTH); |
||||||
|
ParameterTableModel model = new ParameterTableModel(); |
||||||
|
editorPane = new UITableEditorPane<ParameterProvider>(model); |
||||||
|
add(editorPane, BorderLayout.CENTER); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public RHIframeAttr update() { |
||||||
|
RHIframeAttr attr = new RHIframeAttr(); |
||||||
|
attr.setSource(radioPane.updateBean()); |
||||||
|
java.util.List<ParameterProvider> list = editorPane.update(); |
||||||
|
attr.setParameters(list.toArray(new ParameterProvider[list.size()])); |
||||||
|
return attr; |
||||||
|
} |
||||||
|
|
||||||
|
public void populate(RHIframeAttr attr) { |
||||||
|
if (attr != null) { |
||||||
|
radioPane.populateBean(attr.getSource()); |
||||||
|
editorPane.populate(attr.getParameters()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui; |
||||||
|
|
||||||
|
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
|
import com.fr.design.gui.frpane.UIRadioPane; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframeSource; |
||||||
|
|
||||||
|
import java.util.ArrayList; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class SourceRadioPane extends UIRadioPane<RHIframeSource>{ |
||||||
|
|
||||||
|
@Override |
||||||
|
protected List<FurtherBasicBeanPane<? extends RHIframeSource>> initPaneList() { |
||||||
|
List<FurtherBasicBeanPane<? extends RHIframeSource>> list = new ArrayList<FurtherBasicBeanPane<? extends RHIframeSource>>(); |
||||||
|
list.add(new TemplateSourcePane()); |
||||||
|
list.add(new URLSourcePane()); |
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected String title4PopupWindow() { |
||||||
|
return "Source"; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui; |
||||||
|
|
||||||
|
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.gui.ibutton.UIButton; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.gui.itree.filetree.ReportletPane; |
||||||
|
import com.fr.plugin.form.widget.core.TemplateSource; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.awt.event.ActionEvent; |
||||||
|
import java.awt.event.ActionListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class TemplateSourcePane extends FurtherBasicBeanPane<TemplateSource> { |
||||||
|
|
||||||
|
private UITextField textField; |
||||||
|
|
||||||
|
public TemplateSourcePane() { |
||||||
|
setLayout(new BorderLayout()); |
||||||
|
JPanel contentPane = new JPanel(new BorderLayout()); |
||||||
|
contentPane.setPreferredSize(new Dimension(30, 20)); |
||||||
|
add(contentPane, BorderLayout.NORTH); |
||||||
|
|
||||||
|
textField = new UITextField(); |
||||||
|
UIButton btn = new UIButton("..."); |
||||||
|
btn.setPreferredSize(new Dimension(30, 20)); |
||||||
|
contentPane.add(textField, BorderLayout.CENTER); |
||||||
|
contentPane.add(btn, BorderLayout.EAST); |
||||||
|
btn.addActionListener(new ActionListener() { |
||||||
|
@Override |
||||||
|
public void actionPerformed(ActionEvent e) { |
||||||
|
final ReportletPane reportletPane = new ReportletPane(); |
||||||
|
reportletPane.setSelectedReportletPath(textField.getText()); |
||||||
|
BasicDialog reportletDialog = reportletPane.showWindow(SwingUtilities.getWindowAncestor(TemplateSourcePane.this)); |
||||||
|
|
||||||
|
reportletDialog.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
public void doOk() { |
||||||
|
textField.setText(reportletPane.getSelectedReportletPath()); |
||||||
|
} |
||||||
|
}); |
||||||
|
reportletDialog.setVisible(true); |
||||||
|
} |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(Object ob) { |
||||||
|
return ob instanceof TemplateSource; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return "模板路径"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void reset() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(TemplateSource ob) { |
||||||
|
textField.setText(ob.getPath()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public TemplateSource updateBean() { |
||||||
|
return new TemplateSource(textField.getText()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,48 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui; |
||||||
|
|
||||||
|
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
|
import com.fr.design.formula.TinyFormulaPane; |
||||||
|
import com.fr.plugin.form.widget.core.URLSource; |
||||||
|
|
||||||
|
import java.awt.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class URLSourcePane extends FurtherBasicBeanPane<URLSource> { |
||||||
|
|
||||||
|
private TinyFormulaPane formulaPane; |
||||||
|
|
||||||
|
public URLSourcePane() { |
||||||
|
setLayout(new BorderLayout()); |
||||||
|
formulaPane = new TinyFormulaPane(); |
||||||
|
add(formulaPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public boolean accept(Object ob) { |
||||||
|
return ob instanceof URLSource; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String title4PopupWindow() { |
||||||
|
return "网络路径"; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void reset() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void populateBean(URLSource ob) { |
||||||
|
if (ob != null) { |
||||||
|
formulaPane.populateBean(ob.getUrl()); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public URLSource updateBean() { |
||||||
|
return new URLSource(formulaPane.updateBean()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,75 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui; |
||||||
|
|
||||||
|
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||||
|
import com.fr.design.designer.creator.XWidgetCreator; |
||||||
|
import com.fr.design.form.util.XCreatorConstants; |
||||||
|
import com.fr.design.gui.itextfield.UITextField; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; |
||||||
|
import com.fr.general.Inter; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframe; |
||||||
|
import com.fr.plugin.form.widget.ui.editor.RHIframeModelEditor; |
||||||
|
import com.fr.plugin.form.widget.ui.render.RHIframeModelRenderer; |
||||||
|
import com.fr.stable.ArrayUtils; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
import java.awt.*; |
||||||
|
import java.beans.IntrospectionException; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class XRHIframe extends XWidgetCreator { |
||||||
|
|
||||||
|
public XRHIframe(RHIframe widget, Dimension initSize) { |
||||||
|
super(widget, initSize); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
||||||
|
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), new CRPropertyDescriptor[]{ |
||||||
|
new CRPropertyDescriptor("attr", this.toData().getClass()) |
||||||
|
.setI18NName(Inter.getLocText("Plugin-RH_Iframe_Value")) |
||||||
|
.setEditorClass(RHIframeModelEditor.class) |
||||||
|
.setRendererClass(RHIframeModelRenderer.class), |
||||||
|
new CRPropertyDescriptor("overflowX", this.data.getClass()).setI18NName( |
||||||
|
Inter.getLocText("Preference-Horizontal_Scroll_Bar_Visible")).putKeyValue( |
||||||
|
XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), |
||||||
|
new CRPropertyDescriptor("overflowY", this.data.getClass()).setI18NName( |
||||||
|
Inter.getLocText("Preference-Vertical_Scroll_Bar_Visible")).putKeyValue( |
||||||
|
XCreatorConstants.PROPERTY_CATEGORY, "Advanced")}); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected JComponent initEditor() { |
||||||
|
if (editor == null) { |
||||||
|
editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); |
||||||
|
UITextField address = new UITextField(); |
||||||
|
editor.add(address, BorderLayout.NORTH); |
||||||
|
JPanel contentPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||||
|
contentPane.setBackground(Color.white); |
||||||
|
editor.add(contentPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
return editor; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Dimension initEditorSize() { |
||||||
|
return new Dimension(160, 80); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 该组件是否可以拖入参数面板 |
||||||
|
* 这里控制 网页预定义控件在工具栏不显示 |
||||||
|
* |
||||||
|
* @return 是则返回true |
||||||
|
*/ |
||||||
|
public boolean canEnterIntoParaPane() { |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getIconPath() { |
||||||
|
return "/com/fr/plugin/form/widget/images/rh_iframe.png"; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui.editor; |
||||||
|
|
||||||
|
import com.fr.design.dialog.BasicDialog; |
||||||
|
import com.fr.design.dialog.DialogActionAdapter; |
||||||
|
import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframeAttr; |
||||||
|
import com.fr.plugin.form.widget.ui.RHFramePane; |
||||||
|
|
||||||
|
import javax.swing.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class AccessibleRHIframeModelEditor extends UneditableAccessibleEditor { |
||||||
|
|
||||||
|
private RHFramePane rhFramePane; |
||||||
|
|
||||||
|
public AccessibleRHIframeModelEditor() { |
||||||
|
super(new RHIframeModelWrapper()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
protected void showEditorPane() { |
||||||
|
if (rhFramePane == null) { |
||||||
|
rhFramePane = new RHFramePane(); |
||||||
|
} |
||||||
|
BasicDialog dlg = rhFramePane.showWindow(SwingUtilities.getWindowAncestor(this)); |
||||||
|
rhFramePane.populate(getValue()); |
||||||
|
dlg.addDialogActionListener(new DialogActionAdapter() { |
||||||
|
@Override |
||||||
|
public void doOk() { |
||||||
|
RHIframeAttr zTreeNode = rhFramePane.update(); |
||||||
|
setValue(zTreeNode); |
||||||
|
fireStateChanged(); |
||||||
|
} |
||||||
|
}); |
||||||
|
dlg.setVisible(true); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public RHIframeAttr getValue() { |
||||||
|
return (RHIframeAttr) super.getValue(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui.editor; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframeModelEditor extends AccessiblePropertyEditor { |
||||||
|
public RHIframeModelEditor() { |
||||||
|
super(new AccessibleRHIframeModelEditor()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,33 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui.editor; |
||||||
|
|
||||||
|
import com.fr.design.Exception.ValidationException; |
||||||
|
import com.fr.design.designer.properties.Decoder; |
||||||
|
import com.fr.design.designer.properties.Encoder; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframeAttr; |
||||||
|
import com.fr.plugin.form.widget.core.RHIframeSource; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframeModelWrapper implements Encoder<RHIframeAttr>, Decoder<RHIframeAttr> { |
||||||
|
@Override |
||||||
|
public RHIframeAttr decode(String txt) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void validate(String txt) throws ValidationException { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public String encode(RHIframeAttr v) { |
||||||
|
if (v != null) { |
||||||
|
RHIframeSource source = v.getSource(); |
||||||
|
if (source != null) { |
||||||
|
return source.toString(); |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,13 @@ |
|||||||
|
package com.fr.plugin.form.widget.ui.render; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||||
|
import com.fr.plugin.form.widget.ui.editor.RHIframeModelWrapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by richie on 15/12/2. |
||||||
|
*/ |
||||||
|
public class RHIframeModelRenderer extends EncoderCellRenderer { |
||||||
|
public RHIframeModelRenderer() { |
||||||
|
super(new RHIframeModelWrapper()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,233 @@ |
|||||||
|
/** |
||||||
|
* @class FR.RHIframe |
||||||
|
* @extends FR.BaseEditor |
||||||
|
*/ |
||||||
|
(function($){ |
||||||
|
|
||||||
|
FR.RHIframe = FR.extend(FR.BaseEditor, { |
||||||
|
|
||||||
|
_defaultConfig: function () { |
||||||
|
return $.extend(FR.RHIframe.superclass._defaultConfig.apply(), { |
||||||
|
baseName: 'rh.iframe', |
||||||
|
baseClass: 'rh.iframe', |
||||||
|
widgetName: "", |
||||||
|
src: "", |
||||||
|
width: "100%", |
||||||
|
height: "100%", |
||||||
|
showOverFlowX: true, |
||||||
|
showOverFlowY: true |
||||||
|
}); |
||||||
|
}, |
||||||
|
_init: function () { |
||||||
|
FR.RHIframe.superclass._init.apply(this, arguments); |
||||||
|
this.initData(); |
||||||
|
// 控件属性
|
||||||
|
var o = this.options; |
||||||
|
|
||||||
|
this.editComp = this.element.css({ |
||||||
|
width: '100%', |
||||||
|
height: '100%' |
||||||
|
}); |
||||||
|
o.iframeName = o.widgetName || this.createNoRepeatName(); |
||||||
|
this.$iframe = $("<iframe name=" + o.iframeName + " id=" |
||||||
|
+ o.iframeName + ">").addClass(o.baseClass).attr({ |
||||||
|
width : '100%', |
||||||
|
height : '100%', |
||||||
|
frameborder: 0, |
||||||
|
scrolling: !o.showOverFlowX && !o.showOverFlowY |
||||||
|
? 'no' |
||||||
|
: 'yes' |
||||||
|
}).appendTo(this.editComp); |
||||||
|
// 这里滚动条的设置 跟子页面的设置有关
|
||||||
|
// 如果嵌入的是我们的报表或者表单 window的尺寸都是100%那就取了iframe的大小
|
||||||
|
// 如果报表或表单内容尺寸超过的话 就会出现滚动条 那么就改下子元素 这时一般不跨域
|
||||||
|
this.$iframe[0].onload = function () { |
||||||
|
if (!o.showOverFlowX || !o.showOverFlowY) { |
||||||
|
try { // 可能跨域 那就不用管了
|
||||||
|
if (this.contentWindow) { |
||||||
|
var doc = this.contentWindow.document; |
||||||
|
var cc = $('.content-container', $(doc)); |
||||||
|
|
||||||
|
if (cc.length > 0) { |
||||||
|
setOverflow(cc); |
||||||
|
} else { |
||||||
|
// 有可能是表单 html和body都要设置
|
||||||
|
setOverflow($(doc.documentElement)); |
||||||
|
setOverflow($(doc.body)); |
||||||
|
} |
||||||
|
function setOverflow(cc) { |
||||||
|
if (!o.showOverFlowX) { |
||||||
|
cc.css('overflow-x', 'hidden'); |
||||||
|
} |
||||||
|
if (!o.showOverFlowY) { |
||||||
|
cc.css('overflow-y', 'hidden'); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} catch (e) { |
||||||
|
console && console.log("error"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// IE里面需要设置rowspan为1才能正常显示....否则会跳过n行不显示,chrome应该是bug,一会儿好一会儿不好
|
||||||
|
if ($.browser.msie && (this.$iframe.parent()).is("div") |
||||||
|
&& (this.$iframe.parent().parent()).is("td") |
||||||
|
&& (this.$iframe.parent().parent().attr("widget")) != null |
||||||
|
&& (this.$iframe.parent().parent().parent()).is("tr")) { |
||||||
|
// this.$iframe.parent().parent().attr('rowspan', '1');
|
||||||
|
// 上面这么搞有问题的,IE7或IE8杂项下,合并单元格中的网页框控件会只显示在第一行的,改成下面
|
||||||
|
this.$iframe.parent().height(""); |
||||||
|
} else { |
||||||
|
this.$iframe.css('overflow-x', o.showOverFlowX ? 'auto' : 'hidden'); |
||||||
|
this.$iframe.css('overflow-y', o.showOverFlowY ? 'auto' : 'hidden'); |
||||||
|
} |
||||||
|
|
||||||
|
if (o.controlAttr) { |
||||||
|
this.setValue(o.controlAttr); |
||||||
|
} else if (o.src) { |
||||||
|
this._loadIframeByGet(); |
||||||
|
} |
||||||
|
if (o.disabled) { |
||||||
|
this._addDisableMask(); |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
createNoRepeatName: function () { |
||||||
|
var len = $('iframe' + this.options.baseClass).length; |
||||||
|
while ($('iframe[name=' + this.options.baseName + len + ']').length !== 0) { |
||||||
|
len++; |
||||||
|
} |
||||||
|
return this.options.baseName + len; |
||||||
|
}, |
||||||
|
|
||||||
|
// richer:以get的方式获取ifram的参数
|
||||||
|
_loadIframeByGet: function () { |
||||||
|
var src = this.options.src, self = this; |
||||||
|
// 获取参数组
|
||||||
|
if (this.options.data) { |
||||||
|
//bug:63869这个遍历没有必要下面都有ifelse了
|
||||||
|
//for (var i = 0, len = this.options.data.getLength(); i < len; i++) {
|
||||||
|
// var params = this.options.data.getRecord(i).getContent();
|
||||||
|
// src = src.appendQuery(params);
|
||||||
|
//}
|
||||||
|
|
||||||
|
var waitForInitComplete = []; |
||||||
|
|
||||||
|
for (var i = 0, len = this.options.data.getLength(); i < len; i++) { |
||||||
|
var params = this.options.data.getRecord(i).getContent(); |
||||||
|
if (typeof params == 'object' && params.widgetName && this.options.form) { |
||||||
|
var w = this.options.form.getWidgetByName(params.widgetName); |
||||||
|
if (w) { |
||||||
|
var para = {}; |
||||||
|
para[params.widgetName] = w.getValue(); |
||||||
|
src = src.appendQuery(para); |
||||||
|
} else { |
||||||
|
waitForInitComplete.push(params.widgetName); |
||||||
|
} |
||||||
|
} else { |
||||||
|
src = src.appendQuery(params); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
if (waitForInitComplete.length > 1) { |
||||||
|
var form = this.options.form; |
||||||
|
form.on(FR.Events.AFTERINIT, function () { |
||||||
|
for (var c = 0; c < waitForInitComplete.length; c++) { |
||||||
|
var name = waitForInitComplete[c]; |
||||||
|
var para = {}; |
||||||
|
para[name] = form.getWidgetByName(name).getValue(); |
||||||
|
src = src.appendQuery(para); |
||||||
|
} |
||||||
|
self._changeIframe(src); |
||||||
|
}); |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
this._changeIframe(src); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 添加一层遮罩层,用于屏蔽iframe内容的可用性 |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
_addDisableMask: function () { |
||||||
|
this.mask = $('<span/>').css({ |
||||||
|
backgroundColor : '#66B9FF', |
||||||
|
height: this.options.height, |
||||||
|
width: this.options.width, |
||||||
|
left: this.element.offset().left |
||||||
|
}).appendTo(this.element); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置网页框控件的地址并重新加载页面(保留原参数) |
||||||
|
* @param {String} v 新的地址 |
||||||
|
*/ |
||||||
|
setValue : function(v) { |
||||||
|
this.options.src = v; |
||||||
|
this._loadIframeByGet(); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取网页框的src地址 |
||||||
|
* @returns {String} 地址 |
||||||
|
*/ |
||||||
|
getValue: function () { |
||||||
|
return this.$iframe.attr("src"); |
||||||
|
}, |
||||||
|
|
||||||
|
_dealValueWithEvents: function (src) { |
||||||
|
this.options.src = src; |
||||||
|
this._changeIframe(src); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 改变iframe的src指向的地址 |
||||||
|
* @param src 新的地址 |
||||||
|
* @private |
||||||
|
*/ |
||||||
|
_changeIframe: function (src) { |
||||||
|
this.$iframe.attr("src", src); |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 加载指定的url |
||||||
|
* @param url 网页地址 |
||||||
|
*/ |
||||||
|
loadUrl : function(url) { |
||||||
|
this.$iframe.attr("src", url); |
||||||
|
}, |
||||||
|
|
||||||
|
setEnable: function (enable) { |
||||||
|
FR.RHIframe.superclass.setEnable.apply(this, arguments); |
||||||
|
if (enable) { |
||||||
|
if (this.mask) { |
||||||
|
this.mask.remove(); |
||||||
|
} |
||||||
|
} else { |
||||||
|
if (this.mask) { |
||||||
|
this.mask.show(); |
||||||
|
} else { |
||||||
|
this._addDisableMask(); |
||||||
|
} |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
doResize: function (give) { |
||||||
|
FR.RHIframe.superclass.doResize.apply(this, arguments); |
||||||
|
if (this.submitForm) { |
||||||
|
this.submitForm.submit(); |
||||||
|
} |
||||||
|
}, |
||||||
|
|
||||||
|
/** |
||||||
|
* 重置网页框控件 |
||||||
|
*/ |
||||||
|
reload: function () { |
||||||
|
this.options.data.clearData(); |
||||||
|
this._loadIframeByGet(); |
||||||
|
} |
||||||
|
}); |
||||||
|
$.shortcut('rh.iframe', FR.RHIframe); |
||||||
|
})(jQuery); |
Loading…
Reference in new issue