Browse Source

Merge pull request #6621 in DESIGN/design from feature/10.0 to feature/big-screen

* commit 'ee78c20a998f2e7e4c2046756d38b8d7f428002a':
  REPORT-62437 安装大数据集导出excel插件后,远程和本地互相切换时保存失败问题
  REPORT-62142 fix 解密条件 关注内置的两种模板类型即可
  REPORT-62142 加密模板在json数据集插件禁用启用后的模板数据集无法正常显示
feature/big-screen
superman 3 years ago
parent
commit
9c6770e0d4
  1. 29
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  2. 5
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  3. 17
      designer-base/src/main/java/com/fr/file/StashedFILE.java

29
designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java

@ -12,7 +12,6 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate; import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.file.FileNodeFILE; import com.fr.file.FileNodeFILE;
@ -361,20 +360,28 @@ public class HistoryTemplateListCache implements CallbackEvent {
int size = historyList.size(); int size = historyList.size();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
JTemplate<?, ?> template = historyList.get(i); JTemplate<?, ?> template = historyList.get(i);
FILE file = templateToStashFile(template);
if (file != null) {
stashFILEMap.put(i, file);
}
}
FineLoggerFactory.getLogger().info("Env Change Template Stashed.");
}
private FILE templateToStashFile(JTemplate<?, ?> template) {
FILE file = template.getEditingFILE(); FILE file = template.getEditingFILE();
try { try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget(); BaseBook target = template.getTarget();
if (target != null) { if (target != null) {
target.export(outputStream); target.export(outputStream);
stashFILEMap.put(i, new StashedFILE(file, outputStream.toByteArray())); return new StashedFILE(file, outputStream.toByteArray(), template.suffix());
} }
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理 // 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} return null;
FineLoggerFactory.getLogger().info("Env Change Template Stashed.");
} }
private boolean checkStash() { private boolean checkStash() {
@ -458,18 +465,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
FILE file = template.getEditingFILE(); FILE file = template.getEditingFILE();
boolean needReload = context == null || needReloadTemplate(context, template); boolean needReload = context == null || needReloadTemplate(context, template);
if (needReload) { if (needReload) {
try { FILE stashFile = templateToStashFile(template);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); if (stashFile != null) {
BaseBook target = template.getTarget();
if (target != null) {
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName());
target.export(outputStream); template.refreshResource(stashFile);
FILE stashedFile = new StashedFILE(file, outputStream.toByteArray());
template.refreshResource(stashedFile);
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
} }
} }
} }

5
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -406,9 +406,12 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
} }
private void setTargetByFile(FILE file) { private void setTargetByFile(FILE file) {
this.template = JTemplateFactory.asIOFile(file, this.suffix()); T newTemplate = JTemplateFactory.asIOFile(file, this.suffix());
if (newTemplate != null) {
this.template = newTemplate;
setTarget(this.template); setTarget(this.template);
} }
}
private void addCenterPane() { private void addCenterPane() {

17
designer-base/src/main/java/com/fr/file/StashedFILE.java

@ -1,5 +1,9 @@
package com.fr.file; package com.fr.file;
import com.fr.base.io.XMLEncryptUtils;
import com.fr.io.EncryptUtils;
import com.fr.io.FineEncryptUtils;
import com.fr.stable.StringUtils;
import javax.swing.Icon; import javax.swing.Icon;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.InputStream; import java.io.InputStream;
@ -11,10 +15,16 @@ public class StashedFILE extends AbstractFILE {
private FILE file; private FILE file;
private byte[] content; private byte[] content;
private String suffix;
public StashedFILE(FILE file, byte[] content) { public StashedFILE(FILE file, byte[] content) {
this(file, content, null);
}
public StashedFILE(FILE file, byte[] content, String suffix) {
this.file = file; this.file = file;
this.content = content; this.content = content;
this.suffix = suffix;
} }
@Override @Override
@ -54,7 +64,12 @@ public class StashedFILE extends AbstractFILE {
@Override @Override
public InputStream asInputStream() throws Exception { public InputStream asInputStream() throws Exception {
return new ByteArrayInputStream(content); ByteArrayInputStream in = new ByteArrayInputStream(content);
return needDecode() ? XMLEncryptUtils.decodeInputStream(EncryptUtils.decodeInputStream(FineEncryptUtils.decode(in))) : in;
}
private boolean needDecode() {
return StringUtils.isNotEmpty(suffix) && (suffix.endsWith(".cpt") || suffix.endsWith(".frm"));
} }
@Override @Override

Loading…
Cancel
Save