commit
10c57fd261
25 changed files with 1349 additions and 0 deletions
@ -0,0 +1,6 @@
|
||||
*.iml |
||||
.idea/ |
||||
target/ |
||||
lib/report/*.jar |
||||
.DS_Store |
||||
.classpath |
@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> |
||||
<project basedir="." default="jar" name="plugin"> |
||||
<!-- JDK路径,根据自己机器上实际位置修改--> |
||||
<property name="jdk.home" value="D:\FineReport\develop\java\jdk1.7.0_55"/> |
||||
|
||||
<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="formReportRefresh"/> |
||||
<property name="plugin-jar" value="fr-plugin-${plugin-name}-${plugin-version}.jar"/> |
||||
|
||||
<target name="prepare"> |
||||
<delete dir="${classes}"/> |
||||
</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/main/resources"> |
||||
<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/main/java"/> |
||||
<exclude name="**/.svn/**"/> |
||||
<compilerarg line="-encoding UTF-8 "/> |
||||
<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="*.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,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin> |
||||
<id>com.fr.plugin.reportRefresh.v10</id> |
||||
<name><![CDATA[表单内报表块刷新]]></name> |
||||
<active>yes</active> |
||||
<hidden>no</hidden> |
||||
<version>1.5</version> |
||||
<env-version>10.0~</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>finereport</vendor> |
||||
<description><![CDATA[实现表单报表块内实现页面自动刷新]]></description> |
||||
<change-notes><![CDATA[ |
||||
<p><a>[2019-05-22]修复sessionidtimeout问题</a></p> |
||||
<p><a>[2019-04-19]修复tab块中报表块不刷新问题</a></p> |
||||
<p><a>[2019-03-22]修复与组件加载动画插件冲突的问题</a></p> |
||||
<p><a>[2019-02-18]修复区域监控一段时间后无法刷新问题</a></p> |
||||
<p><a>[2018-12-26]修复复杂表单下卡顿问题</a></p> |
||||
<p><a>[2018-11-06]增加对组件动画的支持</a></p> |
||||
<p><a>[2018-07-31]插件升级以支持10</a></p> |
||||
<p><a>[2018-7-17]修复安装性能插件后无法自动刷新的问题</a></p> |
||||
<p><a>[2017-10-27]支持自定义类刷新, 精简获取刷新配置的json</a></p> |
||||
<p><a>[2017-7-12]适配9.0热部署</a></p> |
||||
<p><a>[2017-05-24]加入联动刷新, 修改jartime</a></p> |
||||
<p><a>[2017-05-22]加入单报表块刷新功能, 隐藏刷新动画</a></p> |
||||
<p><a>[2017-05-17]加入监控区域刷新功能</a></p> |
||||
<p><a>[2017-02-10]区分表单和报表参数面板,非表单不刷新</a></p> |
||||
<p><a>[2017-02-07]前端新加接口,表单初始化时增加afterload事件</a></p> |
||||
<p><a>[2016-11-16]可以通过设置不同报表块的刷新频率</a></p> |
||||
]]></change-notes> |
||||
<function-recorder class="com.fr.plugin.reportRefresh.ReportExtraRefreshAttr"/> |
||||
<extra-core> |
||||
<WebService class="com.fr.plugin.reportRefresh.web.RefreshFormService"/> |
||||
<LocaleFinder class="com.fr.plugin.reportRefresh.locale.RefreshLocaleFinder"/> |
||||
<IOFileAttrMark class="com.fr.plugin.reportRefresh.ReportExtraRefreshAttr"/> |
||||
</extra-core> |
||||
<extra-report> |
||||
<JavaScriptFileHandler class="com.fr.plugin.reportRefresh.web.JavaScriptFile"/> |
||||
</extra-report> |
||||
<extra-designer> |
||||
<PropertyEditor class="com.fr.plugin.reportRefresh.designer.propertypane.RefreshPropertyEditor"/> |
||||
</extra-designer> |
||||
</plugin> |
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<parent> |
||||
<groupId>com.fr.plugin</groupId> |
||||
<artifactId>starter</artifactId> |
||||
<version>10.0</version> |
||||
</parent> |
||||
|
||||
<packaging>jar</packaging> |
||||
<artifactId>demo-form-property</artifactId> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>com.fanruan.api</groupId> |
||||
<artifactId>finekit</artifactId> |
||||
<version>10.0</version> |
||||
<scope>system</scope> |
||||
<systemPath>${project.basedir}/lib/finekit-10.0.jar</systemPath> |
||||
</dependency> |
||||
</dependencies> |
||||
<build> |
||||
<!---如果要更改调试插件,改这里的配置就可以了--> |
||||
<outputDirectory>${project.basedir}/../webroot/WEB-INF/plugins/plugin-com.fr.plugin.export.xml-1.0/classes</outputDirectory> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>org.apache.maven.plugins</groupId> |
||||
<artifactId>maven-compiler-plugin</artifactId> |
||||
<configuration> |
||||
<source>6</source> |
||||
<target>6</target> |
||||
</configuration> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -0,0 +1,60 @@
|
||||
package com.fr.plugin.reportRefresh; |
||||
|
||||
import com.fr.design.designer.properties.items.Item; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
/** |
||||
* Created by Administrator on 2016/4/13/0013. |
||||
*/ |
||||
public enum RefreshAttrState { |
||||
NO_REFRESH(0) { |
||||
@Override |
||||
public String description() { |
||||
return InterProviderFactory.getProvider().getLocText("FR-Plugin_Refresh-No-Refresh"); |
||||
} |
||||
|
||||
}, |
||||
TIMER_REFRESH(1) { |
||||
@Override |
||||
public String description() { |
||||
return InterProviderFactory.getProvider().getLocText("FR-Plugin_Refresh-Interval-Refresh"); |
||||
} |
||||
}, |
||||
MONITOR_REFRESH(2) { |
||||
@Override |
||||
public String description() { |
||||
return InterProviderFactory.getProvider().getLocText("FR-Plugin_Monitor-Refresh"); |
||||
} |
||||
}; |
||||
|
||||
private int state; |
||||
|
||||
|
||||
private RefreshAttrState(int state) { |
||||
this.state = state; |
||||
} |
||||
|
||||
public int getState() { |
||||
return this.state; |
||||
} |
||||
|
||||
public String description() { |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
public static RefreshAttrState parse(int state) { |
||||
for (RefreshAttrState attrState : values()) { |
||||
if (attrState.state == state) { |
||||
return attrState; |
||||
} |
||||
} |
||||
|
||||
return NO_REFRESH; |
||||
} |
||||
|
||||
public Item propertyItem() { |
||||
return new Item(this.description(), this.getState()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,140 @@
|
||||
package com.fr.plugin.reportRefresh; |
||||
|
||||
import com.fr.form.stable.RefreshAttrProvider; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.fun.impl.AbstractIOFileAttrMark; |
||||
import com.fr.stable.xml.XMLPrintWriter; |
||||
import com.fr.stable.xml.XMLableReader; |
||||
|
||||
/** |
||||
* Created by Slpire on 2016/10/21. |
||||
*/ |
||||
@EnableMetrics |
||||
public class ReportExtraRefreshAttr extends AbstractIOFileAttrMark implements RefreshAttrProvider { |
||||
|
||||
private RefreshAttrState attrState = RefreshAttrState.NO_REFRESH; |
||||
// 刷新间隔, 0表示不刷新
|
||||
private double interval = 0; |
||||
// 刷新区域, 空表示不刷新.
|
||||
private String refreshArea; |
||||
// 自定义类刷新
|
||||
private boolean customClass = false; |
||||
|
||||
private static final String PLUGIN_ID = "com.fr.plugin.reportRefresh"; |
||||
|
||||
|
||||
public ReportExtraRefreshAttr() { |
||||
} |
||||
|
||||
public ReportExtraRefreshAttr(RefreshAttrState attrState) { |
||||
this.attrState = attrState; |
||||
} |
||||
|
||||
public RefreshAttrState getAttrState() { |
||||
return attrState; |
||||
} |
||||
|
||||
public void setAttrState(RefreshAttrState attrState) { |
||||
this.attrState = attrState; |
||||
} |
||||
|
||||
public double getInterval() { |
||||
return interval; |
||||
} |
||||
|
||||
public void setInterval(double interval) { |
||||
this.interval = interval; |
||||
} |
||||
|
||||
public String getRefreshArea() { |
||||
return refreshArea; |
||||
} |
||||
|
||||
public void setRefreshArea(String refreshArea) { |
||||
this.refreshArea = refreshArea; |
||||
} |
||||
|
||||
public boolean isCustomClass() { |
||||
return customClass; |
||||
} |
||||
|
||||
public void setCustomClass(boolean customClass) { |
||||
this.customClass = customClass; |
||||
} |
||||
|
||||
@Override |
||||
public String xmlTag() { |
||||
return RefreshAttrProvider.XML_TAG; |
||||
} |
||||
|
||||
@Override |
||||
public ReportExtraRefreshAttr clone() { |
||||
ReportExtraRefreshAttr cloned = (ReportExtraRefreshAttr) super.clone(); |
||||
this.setAttrState(cloned.attrState); |
||||
this.setInterval(cloned.interval); |
||||
this.setRefreshArea(cloned.refreshArea); |
||||
this.setCustomClass(cloned.customClass); |
||||
return cloned; |
||||
} |
||||
|
||||
@Override |
||||
@Focus(id = PLUGIN_ID, source = Original.PLUGIN, text = "FR-Plugin_Refresh-Plugin") |
||||
public void readXML(XMLableReader reader) { |
||||
if (reader.isChildNode()) { |
||||
String tagName = reader.getTagName(); |
||||
if (this.xmlTag().equals(tagName)) { |
||||
// 兼容老的逻辑与xml
|
||||
if (reader.getAttrAsBoolean("IsExtraAttr", false)) { |
||||
this.setAttrState(RefreshAttrState.TIMER_REFRESH); |
||||
this.setInterval(reader.getAttrAsDouble("reportRefreshInPC", 0)); |
||||
} else { |
||||
int state = reader.getAttrAsInt("state", 0); |
||||
this.setAttrState(RefreshAttrState.parse(state)); |
||||
this.setInterval(reader.getAttrAsDouble("interval", 0)); |
||||
this.setRefreshArea(reader.getAttrAsString("refreshArea", StringUtils.EMPTY)); |
||||
this.setCustomClass(reader.getAttrAsBoolean("customClass", false)); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object obj) { |
||||
return obj instanceof ReportExtraRefreshAttr && super.equals(obj) |
||||
&& ComparatorUtils.equals(attrState, ((ReportExtraRefreshAttr) obj).attrState) |
||||
&& ComparatorUtils.equals(interval, ((ReportExtraRefreshAttr) obj).interval) |
||||
&& ComparatorUtils.equals(refreshArea, ((ReportExtraRefreshAttr) obj).refreshArea); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return attrState.description(); |
||||
} |
||||
|
||||
@Override |
||||
public void writeXML(XMLPrintWriter writer) { |
||||
writer.startTAG(this.xmlTag()) |
||||
.attr("state", attrState.getState()) |
||||
.attr("interval", this.getInterval()) |
||||
.attr("refreshArea", this.getRefreshArea()) |
||||
.attr("customClass", this.isCustomClass()) |
||||
.end(); |
||||
} |
||||
|
||||
@Override |
||||
public JSONObject createJSONConfig() throws JSONException { |
||||
JSONObject jo = JSONObject.create(); |
||||
jo.put("state", attrState.getState()); |
||||
jo.put("interval", this.getInterval()); |
||||
jo.put("refreshArea", this.getRefreshArea()); |
||||
jo.put("customClass", this.isCustomClass()); |
||||
return jo; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.mainframe.widget.accessibles.UneditableAccessibleEditor; |
||||
import com.fr.plugin.reportRefresh.ReportExtraRefreshAttr; |
||||
|
||||
import javax.swing.SwingUtilities; |
||||
|
||||
public class AccessibleRefreshEditor extends UneditableAccessibleEditor { |
||||
|
||||
private RefreshAttrPane refreshAttrPane; |
||||
|
||||
public AccessibleRefreshEditor() { |
||||
super(new RefreshWrapper()); |
||||
} |
||||
|
||||
@Override |
||||
protected void showEditorPane() { |
||||
if (refreshAttrPane == null) { |
||||
refreshAttrPane = new RefreshAttrPane(); |
||||
} |
||||
|
||||
BasicDialog dlg = refreshAttrPane.showSmallWindow(SwingUtilities.getWindowAncestor(this), new DialogActionAdapter() { |
||||
|
||||
@Override |
||||
public void doOk() { |
||||
ReportExtraRefreshAttr refreshAttr = refreshAttrPane.updateBean(); |
||||
setValue(refreshAttr); |
||||
fireStateChanged(); |
||||
} |
||||
}); |
||||
refreshAttrPane.populateBean((ReportExtraRefreshAttr) getValue()); |
||||
dlg.setVisible(true); |
||||
} |
||||
} |
@ -0,0 +1,180 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.general.Inter; |
||||
import com.fr.plugin.reportRefresh.RefreshAttrState; |
||||
import com.fr.plugin.reportRefresh.ReportExtraRefreshAttr; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* Created by Administrator on 2017/5/8/0008. |
||||
*/ |
||||
public class RefreshAttrPane extends BasicBeanPane<ReportExtraRefreshAttr> { |
||||
|
||||
private UIRadioButton noRefreshRadio; |
||||
private UIRadioButton intervalRadio; |
||||
private UIRadioButton monitorRadio; |
||||
private UISpinner intervalSpinner; |
||||
private UITextField areaTextField; |
||||
private RefreshRadioGroup radioGroup; |
||||
private UICheckBox customRefresh; |
||||
private UILabel areaLabel; |
||||
private UILabel tipLabel; |
||||
private UIButton tipButton; |
||||
private JPanel typePane; |
||||
private JPanel intervalPane; |
||||
private JPanel areaPane; |
||||
|
||||
public RefreshAttrPane() { |
||||
initComponents(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p}; |
||||
|
||||
// 刷新类型
|
||||
typePane = TableLayoutHelper.createTableLayoutPane(initTypeComponents(), rowSize, new double[]{p, p, p, p}); |
||||
// 刷新间隔
|
||||
intervalPane = TableLayoutHelper.createTableLayoutPane(initIntervalComponents(), rowSize, new double[]{p, p, p, p, p, p}); |
||||
// 刷新区域
|
||||
areaPane = TableLayoutHelper.createTableLayoutPane(initAreaComponents(), rowSize, new double[]{p, p, p}); |
||||
|
||||
JPanel contentPane = TableLayoutHelper.createTableLayoutPane(new Component[][]{ |
||||
new Component[]{typePane}, |
||||
new Component[]{intervalPane}, |
||||
new Component[]{areaPane} |
||||
}, new double[]{p, p, p}, new double[]{p}); |
||||
|
||||
intervalPane.setVisible(false); |
||||
areaPane.setVisible(false); |
||||
|
||||
this.add(contentPane); |
||||
} |
||||
|
||||
private Component[][] initTypeComponents() { |
||||
noRefreshRadio = new UIRadioButton(Inter.getLocText("FR-Plugin_Refresh-No-Refresh")); |
||||
intervalRadio = new UIRadioButton(Inter.getLocText("FR-Plugin_Refresh-Interval-Refresh")); |
||||
monitorRadio = new UIRadioButton(Inter.getLocText("FR-Plugin_Monitor-Refresh")); |
||||
|
||||
radioGroup = new RefreshRadioGroup(); |
||||
radioGroup.add(noRefreshRadio); |
||||
radioGroup.add(intervalRadio); |
||||
radioGroup.add(monitorRadio); |
||||
|
||||
radioGroup.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
populateIntervalArea(); |
||||
} |
||||
}); |
||||
radioGroup.selectIndexButton(0); |
||||
|
||||
return new Component[][]{ |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Plugin_Refresh-Type")), noRefreshRadio, intervalRadio, monitorRadio} |
||||
}; |
||||
} |
||||
|
||||
private void populateIntervalArea() { |
||||
boolean noRefresh = noRefreshRadio.isSelected(); |
||||
boolean interval = intervalRadio.isSelected(); |
||||
boolean monitor = monitorRadio.isSelected(); |
||||
|
||||
intervalPane.setVisible(interval || monitor); |
||||
areaPane.setVisible(monitor); |
||||
customRefresh.setVisible(monitor); |
||||
tipButton.setVisible(monitor); |
||||
if (noRefresh) { |
||||
intervalSpinner.setValue(0); |
||||
} |
||||
if (noRefresh || interval) { |
||||
areaTextField.setText(StringUtils.EMPTY); |
||||
} |
||||
} |
||||
|
||||
private Component[][] initIntervalComponents() { |
||||
intervalSpinner = new UISpinner(0, Integer.MAX_VALUE, 1, 0); |
||||
customRefresh = new UICheckBox(Inter.getLocText("FR-Plugin_Refresh-Class")); |
||||
initTipButton(); |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Inter.getLocText("FR-Plugin_Refresh-Interval")), intervalSpinner, |
||||
new UILabel(Inter.getLocText("FR-Plugin_Refresh-Second")), new UILabel(), customRefresh, tipButton} |
||||
}; |
||||
|
||||
customRefresh.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
populateClassLabel(); |
||||
} |
||||
}); |
||||
return components; |
||||
} |
||||
|
||||
private void initTipButton() { |
||||
tipButton = new UIButton(); |
||||
tipButton.set4ToolbarButton(); |
||||
tipButton.setIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/help.png")); |
||||
tipButton.setToolTipText(Inter.getLocText("FR-Plugin_Refresh-Tip")); |
||||
} |
||||
|
||||
private void populateClassLabel() { |
||||
if (customRefresh.isSelected()) { |
||||
areaLabel.setText(Inter.getLocText("FR-Plugin_Refresh-Label")); |
||||
tipLabel.setText(Inter.getLocText("FR-Plugin_Refresh-Example")); |
||||
} else { |
||||
areaLabel.setText(Inter.getLocText("FR-Plugin_Refresh-Area")); |
||||
tipLabel.setText(Inter.getLocText("FR-Plugin_Refresh-Sample")); |
||||
} |
||||
} |
||||
|
||||
private Component[][] initAreaComponents() { |
||||
areaTextField = new UITextField(7); |
||||
areaLabel = new UILabel(Inter.getLocText("FR-Plugin_Refresh-Area")); |
||||
tipLabel = new UILabel(Inter.getLocText("FR-Plugin_Refresh-Sample")); |
||||
return new Component[][]{ |
||||
new Component[]{areaLabel, areaTextField, tipLabel} |
||||
}; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return Inter.getLocText("FR-Plugin_Refresh"); |
||||
} |
||||
|
||||
@Override |
||||
public void populateBean(ReportExtraRefreshAttr refreshAttr) { |
||||
radioGroup.selectIndexButton(refreshAttr.getAttrState().getState()); |
||||
populateIntervalArea(); |
||||
intervalSpinner.setValue(refreshAttr.getInterval()); |
||||
areaTextField.setText(refreshAttr.getRefreshArea()); |
||||
customRefresh.setSelected(refreshAttr.isCustomClass()); |
||||
populateClassLabel(); |
||||
} |
||||
|
||||
@Override |
||||
public ReportExtraRefreshAttr updateBean() { |
||||
ReportExtraRefreshAttr newAttr = new ReportExtraRefreshAttr(); |
||||
int state = radioGroup.getSelectRadioIndex(); |
||||
newAttr.setAttrState(RefreshAttrState.parse(state)); |
||||
newAttr.setInterval(intervalSpinner.getValue()); |
||||
newAttr.setRefreshArea(areaTextField.getText()); |
||||
newAttr.setCustomClass(customRefresh.isSelected()); |
||||
return newAttr; |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; |
||||
|
||||
public class RefreshEditor extends AccessiblePropertyEditor { |
||||
|
||||
public RefreshEditor() { |
||||
super(new AccessibleRefreshEditor()); |
||||
} |
||||
|
||||
@Override |
||||
public boolean refreshInTime() { |
||||
return true; |
||||
} |
||||
} |
@ -0,0 +1,60 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.design.designer.beans.events.DesignerEvent; |
||||
import com.fr.design.designer.creator.CRPropertyDescriptor; |
||||
import com.fr.design.form.util.XCreatorConstants; |
||||
import com.fr.design.fun.impl.AbstractFormElementCaseEditorProvider; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.mainframe.WidgetPropertyPane; |
||||
import com.fr.form.FormProvider; |
||||
import com.fr.form.stable.RefreshAttrProvider; |
||||
import com.fr.form.ui.ElementCaseEditor; |
||||
import com.fr.form.ui.ElementCaseEditorProvider; |
||||
import com.fr.locale.InterProviderFactory; |
||||
import com.fr.plugin.reportRefresh.ReportExtraRefreshAttr; |
||||
import com.fr.stable.core.PropertyChangeAdapter; |
||||
|
||||
import java.beans.IntrospectionException; |
||||
import java.beans.PropertyDescriptor; |
||||
|
||||
/** |
||||
* Created by Slpire on 16/9/22. |
||||
*/ |
||||
public class RefreshPropertyEditor extends AbstractFormElementCaseEditorProvider { |
||||
|
||||
public static String Refresh = "refresh"; |
||||
|
||||
private FormDesigner designer; |
||||
|
||||
public PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, ReportExtraRefreshAttr refreshAttrProvider) { |
||||
try { |
||||
return new CRPropertyDescriptor[]{ |
||||
new CRPropertyDescriptor("refreshAttr", temp) |
||||
.setEditorClass(RefreshEditor.class) |
||||
.setI18NName(InterProviderFactory.getProvider().getLocText("FR-Plugin_Refresh")) |
||||
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") |
||||
.setPropertyChangeListener(new PropertyChangeAdapter() { |
||||
@Override |
||||
public void propertyChange() { |
||||
designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); |
||||
designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_EDITED); |
||||
} |
||||
}) |
||||
}; |
||||
} catch (IntrospectionException e) { |
||||
return new CRPropertyDescriptor[0]; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public PropertyDescriptor[] createPropertyDescriptor(Class<?> temp, FormProvider reportAttr, ElementCaseEditorProvider editor) { |
||||
ElementCaseEditor elementCaseEditor = (ElementCaseEditor) editor; |
||||
ReportExtraRefreshAttr refreshAttr = elementCaseEditor.getAttrMark(RefreshAttrProvider.XML_TAG); |
||||
if (refreshAttr == null) { |
||||
refreshAttr = new ReportExtraRefreshAttr(); |
||||
elementCaseEditor.addWidgetAttrMark(refreshAttr); |
||||
} |
||||
|
||||
return this.createPropertyDescriptor(editor.getClass(), refreshAttr); |
||||
} |
||||
} |
@ -0,0 +1,75 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.design.gui.ibutton.UIRadioButton; |
||||
|
||||
import javax.swing.AbstractButton; |
||||
import javax.swing.ButtonGroup; |
||||
import java.awt.event.ActionListener; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class RefreshRadioGroup extends ButtonGroup { |
||||
|
||||
private List<UIRadioButton> radioButtons = new ArrayList<UIRadioButton>(); |
||||
|
||||
@Override |
||||
public void add(AbstractButton button) { |
||||
super.add(button); |
||||
|
||||
UIRadioButton radioButton = (UIRadioButton) button; |
||||
radioButtons.add(radioButton); |
||||
} |
||||
|
||||
/** |
||||
* 设置按钮状态 |
||||
*/ |
||||
public void setEnabled(boolean enabled) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.setEnabled(enabled); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 设置按钮状态 |
||||
*/ |
||||
public boolean isEnabled() { |
||||
return radioButtons.get(0).isEnabled(); |
||||
} |
||||
|
||||
/** |
||||
* 获取当前选中的按钮index |
||||
* |
||||
* @return 按钮index |
||||
*/ |
||||
public int getSelectRadioIndex() { |
||||
for (int i = 0, len = radioButtons.size(); i < len; i++) { |
||||
if (radioButtons.get(i).isSelected()) { |
||||
return i; |
||||
} |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
/** |
||||
* 选中指定index的按钮 |
||||
*/ |
||||
public void selectIndexButton(int index) { |
||||
if (index < 0 || index > radioButtons.size() - 1) { |
||||
return; |
||||
} |
||||
|
||||
UIRadioButton button = radioButtons.get(index); |
||||
button.setSelected(true); |
||||
} |
||||
|
||||
/** |
||||
* 给所有的按钮加上监听 |
||||
*/ |
||||
public void addActionListener(ActionListener actionListener) { |
||||
for (UIRadioButton radioButton : radioButtons) { |
||||
radioButton.addActionListener(actionListener); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,10 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.design.mainframe.widget.renderer.EncoderCellRenderer; |
||||
|
||||
public class RefreshRender extends EncoderCellRenderer { |
||||
|
||||
public RefreshRender() { |
||||
super(new RefreshWrapper()); |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
package com.fr.plugin.reportRefresh.designer.propertypane; |
||||
|
||||
import com.fr.design.designer.properties.Encoder; |
||||
import com.fr.plugin.reportRefresh.ReportExtraRefreshAttr; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
public class RefreshWrapper implements Encoder<ReportExtraRefreshAttr> { |
||||
public RefreshWrapper() { |
||||
} |
||||
|
||||
@Override |
||||
public String encode(ReportExtraRefreshAttr source) { |
||||
return source == null ? StringUtils.EMPTY : source.toString(); |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.plugin.reportRefresh.locale; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
/** |
||||
* Created by Slpire on 16/9/22. |
||||
*/ |
||||
public class RefreshLocaleFinder extends AbstractLocaleFinder { |
||||
|
||||
/** |
||||
* 国际化文件路径 |
||||
* |
||||
* @return 路径 |
||||
*/ |
||||
public String find() { |
||||
return "com/fr/plugin/reportRefresh/locale/refresh"; |
||||
} |
||||
} |
@ -0,0 +1,116 @@
|
||||
package com.fr.plugin.reportRefresh.web; |
||||
|
||||
import com.fr.base.Painter; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.FArray; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.stable.web.ServletContext; |
||||
import com.fr.stable.web.ServletContextAdapter; |
||||
import com.fr.web.core.SessionPoolManager; |
||||
import com.fr.web.core.TemplateSessionIDInfo; |
||||
import com.fr.web.session.SessionIDInfo; |
||||
|
||||
import java.util.Iterator; |
||||
import java.util.Map; |
||||
import java.util.Timer; |
||||
import java.util.TimerTask; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* 缓存一些解析的单元格 |
||||
* 格式为 <SessionID, <Expression, Value>> |
||||
* { |
||||
* 123 { |
||||
* A1: aaa, |
||||
* B5:C5: farray |
||||
* }, |
||||
* 456 { |
||||
* C7: map |
||||
* } |
||||
* } |
||||
* <p> |
||||
* Created by Administrator on 2017/5/11/0011. |
||||
*/ |
||||
public class CachedExpressionControl { |
||||
private static CachedExpressionControl expressionControl; |
||||
private static final long RELEASE_TIMER = 5 * 60 * 1000L; |
||||
|
||||
private Map<String, Map<String, Object>> cachedValue = new ConcurrentHashMap<String, Map<String, Object>>(); |
||||
|
||||
private Timer timer = PluginContexts.currentContext().newTimer(); |
||||
|
||||
static { |
||||
ServletContext.addServletContextListener(new ServletContextAdapter() { |
||||
@Override |
||||
public void onServletStop() { |
||||
expressionControl.release(); |
||||
expressionControl = null; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public static CachedExpressionControl getInstance() { |
||||
if (expressionControl == null) { |
||||
expressionControl = new CachedExpressionControl(); |
||||
} |
||||
|
||||
return expressionControl; |
||||
} |
||||
|
||||
private void release() { |
||||
cachedValue.clear(); |
||||
timer.cancel(); |
||||
} |
||||
|
||||
private CachedExpressionControl() { |
||||
initReleaseTimer(); |
||||
} |
||||
|
||||
private void initReleaseTimer() { |
||||
timer.schedule(new TimerTask() { |
||||
@Override |
||||
public void run() { |
||||
try { |
||||
String[] cachedSessionIDs = cachedValue.keySet().toArray(new String[cachedValue.size()]); |
||||
for (String sessionID : cachedSessionIDs) { |
||||
SessionIDInfo info = SessionPoolManager.getSessionIDInfor(sessionID, TemplateSessionIDInfo.class); |
||||
|
||||
if (info == null || info.isTimeout()) { |
||||
cachedValue.remove(sessionID); |
||||
} |
||||
} |
||||
} catch (Throwable ignored) { |
||||
// do nth
|
||||
} |
||||
|
||||
} |
||||
}, RELEASE_TIMER, RELEASE_TIMER); |
||||
} |
||||
|
||||
public boolean whetherExpressionValueChange(String sessionID, String expression, Object newVal) { |
||||
Map<String, Object> sessionValueMap = cachedValue.get(sessionID); |
||||
if (sessionValueMap == null) { |
||||
sessionValueMap = new ConcurrentHashMap<String, Object>(); |
||||
cachedValue.put(sessionID, sessionValueMap); |
||||
} |
||||
|
||||
Object oldVal = sessionValueMap.get(expression); |
||||
// 缓存新的值
|
||||
sessionValueMap.put(expression, newVal); |
||||
// 如果之前没有值, 可能是刚预览.
|
||||
if (newVal instanceof Painter) { |
||||
return false; |
||||
} |
||||
|
||||
if (newVal instanceof FArray) { |
||||
Iterator iterator = ((FArray) newVal).iterator(); |
||||
while (iterator.hasNext()) { |
||||
if (iterator.next() instanceof Painter) { |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
return !ComparatorUtils.equals(newVal, oldVal); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,125 @@
|
||||
package com.fr.plugin.reportRefresh.web; |
||||
|
||||
import com.fr.base.Formula; |
||||
import com.fr.base.ParameterMapNameSpace; |
||||
import com.fr.data.NetworkHelper; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.form.FormElementCaseProvider; |
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.ui.ElementCaseEditor; |
||||
import com.fr.form.ui.Widget; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.schedule.util.ExecuteCondition; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.StringUtils; |
||||
import com.fr.stable.web.Repository; |
||||
import com.fr.web.RepositoryDeal; |
||||
import com.fr.web.core.ActionNoSessionCMD; |
||||
import com.fr.web.core.ErrorHandlerHelper; |
||||
import com.fr.web.core.FormSessionIDInfor; |
||||
import com.fr.web.core.SessionPoolManager; |
||||
import com.fr.web.session.SessionIDInfo; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.PrintWriter; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* Created by Slpire on 2016/10/29. |
||||
*/ |
||||
public class CheckRefreshAreaAction extends ActionNoSessionCMD { |
||||
|
||||
private static final String CMD = "area"; |
||||
|
||||
@Override |
||||
public String getCMD() { |
||||
return CMD; |
||||
} |
||||
|
||||
@Override |
||||
public void actionCMD(HttpServletRequest req, HttpServletResponse res, String sessionID) throws Exception { |
||||
FormSessionIDInfor sessionIDInfo = SessionPoolManager.getSessionIDInfor(sessionID, FormSessionIDInfor.class); |
||||
if (sessionIDInfo == null) { |
||||
ErrorHandlerHelper.getErrorHandler().error(req, res, "SessionID: \"" + sessionID + "\" time out."); |
||||
return; |
||||
} |
||||
|
||||
String refreshArea = NetworkHelper.getHTTPRequestParameter(req, "refreshArea"); |
||||
String reportName = NetworkHelper.getHTTPRequestParameter(req, "reportName"); |
||||
boolean valueChange = true; |
||||
|
||||
if (StringUtils.isNotEmpty(refreshArea)) { |
||||
if (NetworkHelper.getHTTPRequestBoolParameter(req, "customClass")) { |
||||
valueChange = exeCustomClass(refreshArea, sessionIDInfo, reportName); |
||||
} else { |
||||
valueChange = exeCellValue(req, sessionID, sessionIDInfo, refreshArea, reportName, true); |
||||
} |
||||
} |
||||
|
||||
PrintWriter writer = WebUtils.createPrintWriter(res); |
||||
writer.write(valueChange + ""); |
||||
writer.flush(); |
||||
writer.close(); |
||||
} |
||||
|
||||
private boolean exeCellValue(HttpServletRequest req, String sessionID, FormSessionIDInfor sessionIDInfor, String refreshArea, String reportName, boolean valueChange) { |
||||
Repository repo = new RepositoryDeal(req, sessionIDInfor, Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION); |
||||
Form form = sessionIDInfor.getForm2Show(); |
||||
sessionIDInfor.applySessionIDInforParameters(req); |
||||
Map<String, Object> para = sessionIDInfor.updatePara(); |
||||
Calculator ca = initExpressionCalculator(sessionID, form, para); |
||||
para.putAll(form.getWidgetDefaultValueMap(para, repo)); |
||||
|
||||
sessionIDInfor.clearResultElementCase(reportName.toUpperCase()); |
||||
// 计算下指定的报表块
|
||||
executeGivenElements(sessionIDInfor, reportName, form, para); |
||||
|
||||
try { |
||||
//用于解析报表块中的格子=reportBlock1~A1这种
|
||||
String formulaContent = "=" + reportName + "~" + refreshArea; |
||||
Object newVal = ca.eval(new Formula(formulaContent)); |
||||
valueChange = CachedExpressionControl.getInstance().whetherExpressionValueChange(sessionID, formulaContent, newVal); |
||||
} catch (Throwable e) { |
||||
// 传入非法的刷新区域, 直接强制刷新.
|
||||
} |
||||
return valueChange; |
||||
} |
||||
|
||||
private boolean exeCustomClass(String refreshArea, FormSessionIDInfor sessionIDInfor, String reportName) { |
||||
try { |
||||
ExecuteCondition executeClass = (ExecuteCondition) GeneralUtils.classForName(refreshArea).newInstance(); |
||||
boolean result = executeClass.execute(); |
||||
if (result) { |
||||
sessionIDInfor.clearResultElementCase(reportName.toUpperCase()); |
||||
} |
||||
FineLoggerFactory.getLogger().debug("Class Execute Result: " + result); |
||||
return result; |
||||
} catch (Throwable throwable) { |
||||
FineLoggerFactory.getLogger().debug("Class Execute Failed: " + throwable.getMessage()); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
private void executeGivenElements(FormSessionIDInfor sessionIDInfor, String reportName, Form form, Map<String, Object> para) { |
||||
Widget widget = form.getWidgetByName(reportName); |
||||
ElementCaseEditor table = (ElementCaseEditor) widget; |
||||
FormElementCaseProvider elementcase = table.getElementCase(); |
||||
elementcase.setName(reportName); |
||||
elementcase.setTabledataSource(form); |
||||
String[] elems = elementcase.dependenceBlocks(); |
||||
elementcase.executeGivenElements(elems, sessionIDInfor, para); |
||||
} |
||||
|
||||
private Calculator initExpressionCalculator(String sessionID, Form form, Map<String, Object> para) { |
||||
Calculator ca = Calculator.createCalculator(); |
||||
ca.pushNameSpace(ParameterMapNameSpace.create(para)); |
||||
ca.setAttribute(TableDataSource.KEY, form); |
||||
//用于解析报表块中的格子=reportBlock1~A1这种
|
||||
ca.pushNameSpace(SessionIDInfo.asNameSpace(sessionID)); |
||||
return ca; |
||||
} |
||||
} |
@ -0,0 +1,62 @@
|
||||
package com.fr.plugin.reportRefresh.web; |
||||
|
||||
import com.fr.form.main.Form; |
||||
import com.fr.form.stable.RefreshAttrProvider; |
||||
import com.fr.form.ui.ElementCaseEditor; |
||||
import com.fr.form.ui.ElementCaseEditorProvider; |
||||
import com.fr.json.JSONArray; |
||||
import com.fr.json.JSONObject; |
||||
import com.fr.plugin.reportRefresh.ReportExtraRefreshAttr; |
||||
import com.fr.web.core.ActionNoSessionCMD; |
||||
import com.fr.web.core.ErrorHandlerHelper; |
||||
import com.fr.web.core.FormSessionIDInfor; |
||||
import com.fr.web.core.SessionPoolManager; |
||||
import com.fr.web.utils.WebUtils; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* Created by Slpire on 2016/10/29. |
||||
*/ |
||||
public class FormGetRefreshConfigAction extends ActionNoSessionCMD { |
||||
|
||||
public static final String CMD = "config"; |
||||
|
||||
@Override |
||||
public String getCMD() { |
||||
return CMD; |
||||
} |
||||
|
||||
@Override |
||||
public void actionCMD(HttpServletRequest req, HttpServletResponse res, String sessionID) throws Exception { |
||||
FormSessionIDInfor sessionIDInfo; |
||||
try { |
||||
sessionIDInfo = SessionPoolManager.getSessionIDInfor(sessionID, FormSessionIDInfor.class); |
||||
} catch (Exception e) { |
||||
return; |
||||
} |
||||
if (sessionIDInfo == null) { |
||||
ErrorHandlerHelper.getErrorHandler().error(req, res, "SessionID: \"" + sessionID + "\" time out."); |
||||
return; |
||||
} |
||||
Form form = sessionIDInfo.getForm2Show(); |
||||
ElementCaseEditorProvider[] elems = form.getElementCases(); |
||||
JSONArray reports = JSONArray.create(); |
||||
for (ElementCaseEditorProvider elem : elems) { |
||||
JSONObject jo = JSONObject.create(); |
||||
String widgetName = elem.getWidgetName(); |
||||
String mark = RefreshAttrProvider.XML_TAG; |
||||
ReportExtraRefreshAttr attr = ((ElementCaseEditor) elem).getAttrMark(mark); |
||||
jo.put("widgetName", widgetName); |
||||
if (attr != null) { |
||||
jo.put(mark, attr.createJSONConfig()); |
||||
} |
||||
reports.put(jo); |
||||
} |
||||
JSONObject formJo = JSONObject.create(); |
||||
formJo.put("sessionID", sessionID); |
||||
formJo.put("reports", reports); |
||||
WebUtils.printAsJSON(res, formJo); |
||||
} |
||||
} |
@ -0,0 +1,16 @@
|
||||
package com.fr.plugin.reportRefresh.web; |
||||
|
||||
import com.fr.stable.fun.impl.AbstractJavaScriptFileHandler; |
||||
|
||||
/** |
||||
* Created by Slpire on 16/9/22. |
||||
*/ |
||||
public class JavaScriptFile extends AbstractJavaScriptFileHandler { |
||||
|
||||
@Override |
||||
public String[] pathsForFiles() { |
||||
return new String[] { |
||||
"/com/fr/plugin/reportRefresh/web/refresh.js" |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.plugin.reportRefresh.web; |
||||
|
||||
import com.fr.stable.fun.Service; |
||||
import com.fr.stable.web.RequestCMDReceiver; |
||||
import com.fr.web.core.WebActionsDispatcher; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
|
||||
/** |
||||
* Created by Slpire on 2016/10/29. |
||||
*/ |
||||
public class RefreshFormService implements Service { |
||||
|
||||
private RequestCMDReceiver[] actions = { |
||||
new FormGetRefreshConfigAction(), |
||||
new CheckRefreshAreaAction() |
||||
}; |
||||
|
||||
public RefreshFormService() { |
||||
} |
||||
|
||||
@Override |
||||
public String actionOP() { |
||||
return "form_refresh"; |
||||
} |
||||
|
||||
@Override |
||||
public void process(HttpServletRequest req, HttpServletResponse res, String op, String sessionID) throws Exception { |
||||
WebActionsDispatcher.dealForActionDefaultCmd(req, res, sessionID, actions, FormGetRefreshConfigAction.CMD); |
||||
} |
||||
} |
@ -0,0 +1,15 @@
|
||||
FR-Plugin_Refresh=Refresh |
||||
FR-Plugin_Refresh-Plugin=Refresh PLugin |
||||
FR-Plugin_Monitor-Refresh=Monitor Refresh |
||||
FR-Plugin_Refresh-Area=Refresh Area |
||||
FR-Plugin_Refresh-Interval=Interval: |
||||
FR-Plugin_Refresh-Interval-Refresh=Interval Refresh |
||||
FR-Plugin_Refresh-No-Refresh=No Refresh |
||||
FR-Plugin_Refresh-Sample=eg: A1, C2:C12, E3:J6 |
||||
FR-Plugin_Refresh-Second=Second |
||||
FR-Plugin_Refresh-Type=Refresh Type: |
||||
FR-Plugin_Class-Refresh= |
||||
FR-Plugin_Refresh-Class= |
||||
FR-Plugin_Refresh-Label= |
||||
FR-Plugin_Refresh-Example= |
||||
FR-Plugin_Refresh-Tip= |
@ -0,0 +1,15 @@
|
||||
FR-Plugin_Refresh=Refresh |
||||
FR-Plugin_Refresh-Plugin=Refresh PLugin |
||||
FR-Plugin_Monitor-Refresh=Monitor Refresh |
||||
FR-Plugin_Refresh-Area=Refresh Area |
||||
FR-Plugin_Refresh-Interval=Interval: |
||||
FR-Plugin_Refresh-Interval-Refresh=Interval Refresh |
||||
FR-Plugin_Refresh-No-Refresh=No Refresh |
||||
FR-Plugin_Refresh-Sample=eg: A1, C2:C12, E3:J6 |
||||
FR-Plugin_Refresh-Second=Second |
||||
FR-Plugin_Refresh-Type=Refresh Type: |
||||
FR-Plugin_Class-Refresh=Custom Refresh |
||||
FR-Plugin_Refresh-Class=Custom Class |
||||
FR-Plugin_Refresh-Label=Custom: |
||||
FR-Plugin_Refresh-Example=eg: com.fr.RefreshImpl |
||||
FR-Plugin_Refresh-Tip=you can implement ExecuteCondition to return wherher need refresh |
@ -0,0 +1,15 @@
|
||||
FR-Plugin_Refresh=\u5237\u65B0 |
||||
FR-Plugin_Refresh-Plugin=\u8868\u5355\u62A5\u8868\u5757\u5237\u65B0\u63D2\u4EF6 |
||||
FR-Plugin_Monitor-Refresh=\u76D1\u63A7\u5237\u65B0 |
||||
FR-Plugin_Refresh-Area=\u76D1\u63A7\u533A\u57DF: |
||||
FR-Plugin_Refresh-Interval=\u5237\u65B0\u95F4\u9694:\u3000 |
||||
FR-Plugin_Refresh-Interval-Refresh=\u5B9A\u671F\u5237\u65B0 |
||||
FR-Plugin_Refresh-No-Refresh=\u5173\u95ED |
||||
FR-Plugin_Refresh-Sample=\u683C\u5F0F: A1, C2:C123, E3:J6 |
||||
FR-Plugin_Refresh-Second=\u79D2 |
||||
FR-Plugin_Refresh-Type=\u5237\u65B0\u673A\u5236: \u3000 |
||||
FR-Plugin_Class-Refresh=\u81EA\u5B9A\u4E49\u7C7B\u5237\u65B0 |
||||
FR-Plugin_Refresh-Class=\u81EA\u5B9A\u4E49\u7C7B |
||||
FR-Plugin_Refresh-Label=\u81EA\u5B9A\u4E49\u7C7B: |
||||
FR-Plugin_Refresh-Example=\u683C\u5F0F: com.fr.RefreshImpl |
||||
FR-Plugin_Refresh-Tip=\u60A8\u53EF\u4EE5\u901A\u8FC7\u81EA\u5B9A\u4E49\u7C7B\u5B9E\u73B0ExecuteCondition\u63A5\u53E3\u6765\u8FD4\u56DE\u662F\u5426\u9700\u8981\u5237\u65B0\u7EC4\u4EF6. |
@ -0,0 +1,15 @@
|
||||
FR-Plugin_Refresh=\u5237\u65B0 |
||||
FR-Plugin_Refresh-Plugin=\u8868\u5355\u62A5\u8868\u5757\u5237\u65B0\u63D2\u4EF6 |
||||
FR-Plugin_Monitor-Refresh=\u76E3\u63A7\u5237\u65B0 |
||||
FR-Plugin_Refresh-Area=\u76E3\u63A7\u55AE\u5143\u683C: |
||||
FR-Plugin_Refresh-Interval=\u5237\u65B0\u9593\u9694: |
||||
FR-Plugin_Refresh-Interval-Refresh=\u5B9A\u671F\u5237\u65B0 |
||||
FR-Plugin_Refresh-No-Refresh=\u95DC\u9589 |
||||
FR-Plugin_Refresh-Sample=\u683C\u5F0F: A1, C2:C12, E3:J6 |
||||
FR-Plugin_Refresh-Second=\u79D2 |
||||
FR-Plugin_Refresh-Type=\u5237\u65B0\u6A5F\u5236: |
||||
FR-Plugin_Class-Refresh=\u81EA\u5B9A\u7FA9\u985E\u5237\u65B0 |
||||
FR-Plugin_Refresh-Class=\u81EA\u5B9A\u4E49\u7C7B |
||||
FR-Plugin_Refresh-Label=\u81EA\u5B9A\u4E49\u7C7B: |
||||
FR-Plugin_Refresh-Example=\u683C\u5F0F: com.fr.RefreshImpl |
||||
FR-Plugin_Refresh-Tip=\u60A8\u53EF\u4EE5\u901A\u8FC7\u81EA\u5B9A\u4E49\u7C7B\u5B9E\u73B0ExecuteCondition\u63A5\u53E3\u6765\u8FD4\u56DE\u662F\u5426\u9700\u8981\u5237\u65B0\u7EC4\u4EF6. |
@ -0,0 +1,130 @@
|
||||
; |
||||
(function ($) { |
||||
//防止重复设置
|
||||
var flag = false; |
||||
FR.Form.Plugin.Panel.Events.push({ |
||||
name: FR.Events.AFTERLOAD, |
||||
|
||||
action: function () { |
||||
if (isParameterPane(this.options.type) || flag) { |
||||
return; |
||||
} |
||||
flag = true; |
||||
var sessionID = this.sessionID; |
||||
FR.ajax({ |
||||
url: FR.servletURL, |
||||
data: { |
||||
op: 'form_refresh', |
||||
cmd: 'config', |
||||
sessionID: sessionID, |
||||
_: new Date().getTime() |
||||
}, |
||||
async: false, |
||||
complete: function (res, status) { |
||||
if (status == 'success' && res.responseText) { |
||||
contenConfig = FR.jsonDecode(res.responseText); |
||||
doSetRefresh(contenConfig); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
}); |
||||
|
||||
var isParameterPane = function(type){ |
||||
//参数面板的form的话不走这边的逻辑
|
||||
return type === "parameter"; |
||||
}; |
||||
|
||||
var doSetRefresh = function (contenConfig) { |
||||
var reportsConfig = contenConfig.reports; |
||||
if (FR.isEmpty(reportsConfig)) { |
||||
return; |
||||
} |
||||
|
||||
for (var j = 0, length = reportsConfig.length; j < length; j++) { |
||||
var opts = reportsConfig[j]; |
||||
if (FR.isEmpty(opts.Refresh)) { |
||||
continue; |
||||
} |
||||
|
||||
var state = opts.Refresh.state; |
||||
var interval = opts.Refresh.interval; |
||||
|
||||
if (state === 0 || interval === 0) { |
||||
continue; |
||||
} |
||||
opts.sessionID = contenConfig.sessionID; |
||||
var refreshFunc = function (opts) { |
||||
return function () { |
||||
refreshReport(opts); |
||||
} |
||||
}; |
||||
window.setTimeout(refreshFunc(opts), interval * 1000); |
||||
} |
||||
}; |
||||
|
||||
var refreshReport = function (opts) { |
||||
var currentTime = new Date().getTime(); |
||||
var widget = _g().getWidgetByName(opts.widgetName); |
||||
if (FR.isEmpty(widget)) { |
||||
//有些控件会在某些操作之后创建,所以这边也要添加定时器
|
||||
window.setTimeout(function() { |
||||
refreshReport(opts); |
||||
}, opts.Refresh.interval * 1000); |
||||
return; |
||||
} |
||||
FR.ajax({ |
||||
url: FR.servletURL, |
||||
data: { |
||||
op: 'clear_pdl', |
||||
sessionID: opts.sessionID, |
||||
_: new Date().getTime() |
||||
} |
||||
}); |
||||
function fun(needRefresh) { |
||||
if(needRefresh){ |
||||
var animateProcessor = FR.Report.Plugin.AnimateProcessor; |
||||
var item = animateProcessor.item; |
||||
if (item && FR.Plugin.validLevel(animateProcessor, item) && item.refresh) { |
||||
item.refresh.call(this, widget, function () { |
||||
widget.gotoPage(1, "{}", 'lazy', false, false, true); |
||||
}); |
||||
resetTimer(); |
||||
return; |
||||
} |
||||
widget.gotoPage(1, "{}", 'lazy', false, false, true); |
||||
} |
||||
resetTimer(); |
||||
} |
||||
|
||||
function resetTimer() { |
||||
var proccessTime = opts.Refresh.interval * 1000 - new Date().getTime() + currentTime; |
||||
var timeout = proccessTime ? proccessTime : 0; |
||||
window.setTimeout(function () { |
||||
refreshReport(opts); |
||||
}, timeout); |
||||
} |
||||
|
||||
refreshByArea(opts, fun); |
||||
}; |
||||
|
||||
var refreshByArea = function (opts, callback) { |
||||
FR.ajax({ |
||||
url: FR.servletURL, |
||||
data: { |
||||
op: 'form_refresh', |
||||
cmd: 'area', |
||||
sessionID: opts.sessionID, |
||||
refreshArea: opts.Refresh.refreshArea, |
||||
customClass: opts.Refresh.customClass, |
||||
reportName: opts.widgetName, |
||||
_: new Date().getTime() |
||||
}, |
||||
complete: function (res, status) { |
||||
if (status == 'success') { |
||||
callback(res.responseText === 'true' || FR.isEmpty(opts.Refresh.refreshArea)); |
||||
} |
||||
} |
||||
}); |
||||
}; |
||||
})(jQuery); |
Loading…
Reference in new issue