From ccdadb03ba87310e9699e5db77826157dbb3514d Mon Sep 17 00:00:00 2001 From: WeiYanglu Date: Mon, 1 Aug 2022 12:55:33 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-74376=20=E6=94=AF=E6=8C=81=E5=AD=98?= =?UTF-8?q?=E5=82=A8FVS=E8=AE=BE=E8=AE=A1=E5=99=A8=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/DesignerEnvManager.java | 18 +++++ .../simple/SimpleDesignerConfig.java | 70 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java diff --git a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java index 823a551ffe..cec7b921da 100644 --- a/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java +++ b/designer-base/src/main/java/com/fr/design/DesignerEnvManager.java @@ -20,6 +20,7 @@ import com.fr.design.locale.impl.ProductImproveMark; import com.fr.design.login.DesignerLoginType; import com.fr.design.login.config.DesignerLoginConfigManager; import com.fr.design.mainframe.ComponentReuseNotifyUtil; +import com.fr.design.mainframe.simple.SimpleDesignerConfig; import com.fr.design.mainframe.reuse.ComponentReuseNotificationInfo; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.notification.SnapChatConfig; @@ -226,6 +227,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { private boolean propertiesUsable; + private SimpleDesignerConfig fvsDesignerConfig = SimpleDesignerConfig.getInstance("FvsDesignerConfig"); + /** * DesignerEnvManager. */ @@ -1012,6 +1015,10 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerStartupConfig.setEnabled(enabled); } + public SimpleDesignerConfig getFvsDesignerConfig() { + return fvsDesignerConfig; + } + /** * 返回环境名称迭代器 */ @@ -1863,6 +1870,8 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { readSnapChatConfig(reader); } else if (name.equals(DesignerLoginConfigManager.XML_TAG)) { readDesignerLoginAttr(reader); + } else if (name.equals(fvsDesignerConfig.getName())) { + readFvsDesignerConfig(reader); } else { readLayout(reader, name); } @@ -2113,6 +2122,7 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { writeSnapChatConfig(writer); writeComponentReuseNotificationInfo(writer); writeDesignerLoginAttr(writer); + writeFvsDesignerConfig(writer); writer.end(); } @@ -2419,6 +2429,14 @@ public class DesignerEnvManager implements XMLReadable, XMLWriter { this.designerLoginConfigManager.writeXML(writer); } + private void readFvsDesignerConfig(XMLableReader reader) { + reader.readXMLObject(fvsDesignerConfig); + } + + private void writeFvsDesignerConfig(XMLPrintWriter writer) { + this.fvsDesignerConfig.writeXML(writer); + } + enum XmlHandler { Self; diff --git a/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java new file mode 100644 index 0000000000..b6e58b9965 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/simple/SimpleDesignerConfig.java @@ -0,0 +1,70 @@ +package com.fr.design.mainframe.simple; + +import com.fr.stable.xml.XMLPrintWriter; +import com.fr.stable.xml.XMLable; +import com.fr.stable.xml.XMLableReader; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Wei + * 一个简单属性(字符串)存储类,用于自定义简单属性的存储 + * 如:getInstance("FVSDesignerConfig")可在FineReportEnv.xml中定义一个存储FVS相关配置 + */ +public class SimpleDesignerConfig implements XMLable { + + private static final HashMap configs = new HashMap<>(); + + private SimpleDesignerConfig(String name) { + this.name = name; + } + + public static SimpleDesignerConfig getInstance(String name) { + SimpleDesignerConfig config = configs.get(name); + if(config == null) { + config = new SimpleDesignerConfig(name); + configs.put(name, config); + } + return config; + } + + private String name = ""; + + private final Map content = new HashMap<>(); + + public void addAttr(String key, String value) { + content.put(key, value); + } + + public Map getContent() { + return content; + } + + @Override + public void readXML(XMLableReader reader) { + if (reader.isAttr()) { + content.putAll(reader.getAttrs()); + } + } + + @Override + public void writeXML(XMLPrintWriter writer) { + writer.startTAG(name); + content.forEach(writer::attr); + writer.end(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +}