Browse Source

Merge pull request #6619 in DESIGN/design from bugfix/10.0 to feature/10.0

* commit 'cc3cc76047238d0227edfde22b5746c4be143045':
  REPORT-62437 安装大数据集导出excel插件后,远程和本地互相切换时保存失败问题
  REPORT-62142 fix 解密条件 关注内置的两种模板类型即可
  REPORT-62142 加密模板在json数据集插件禁用启用后的模板数据集无法正常显示
feature/10.0
superman 3 years ago
parent
commit
ee78c20a99
  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.JTemplate;
import com.fr.design.mainframe.JVirtualTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.ui.util.UIUtil;
import com.fr.file.FILE;
import com.fr.file.FileNodeFILE;
@ -361,20 +360,28 @@ public class HistoryTemplateListCache implements CallbackEvent {
int size = historyList.size();
for (int i = 0; i < size; 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();
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
target.export(outputStream);
stashFILEMap.put(i, new StashedFILE(file, outputStream.toByteArray()));
return new StashedFILE(file, outputStream.toByteArray(), template.suffix());
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
FineLoggerFactory.getLogger().info("Env Change Template Stashed.");
return null;
}
private boolean checkStash() {
@ -458,18 +465,10 @@ public class HistoryTemplateListCache implements CallbackEvent {
FILE file = template.getEditingFILE();
boolean needReload = context == null || needReloadTemplate(context, template);
if (needReload) {
try {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
BaseBook target = template.getTarget();
if (target != null) {
FILE stashFile = templateToStashFile(template);
if (stashFile != null) {
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName());
target.export(outputStream);
FILE stashedFile = new StashedFILE(file, outputStream.toByteArray());
template.refreshResource(stashedFile);
}
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
template.refreshResource(stashFile);
}
}
}

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) {
this.template = JTemplateFactory.asIOFile(file, this.suffix());
T newTemplate = JTemplateFactory.asIOFile(file, this.suffix());
if (newTemplate != null) {
this.template = newTemplate;
setTarget(this.template);
}
}
private void addCenterPane() {

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

@ -1,5 +1,9 @@
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 java.io.ByteArrayInputStream;
import java.io.InputStream;
@ -11,10 +15,16 @@ public class StashedFILE extends AbstractFILE {
private FILE file;
private byte[] content;
private String suffix;
public StashedFILE(FILE file, byte[] content) {
this(file, content, null);
}
public StashedFILE(FILE file, byte[] content, String suffix) {
this.file = file;
this.content = content;
this.suffix = suffix;
}
@Override
@ -54,7 +64,12 @@ public class StashedFILE extends AbstractFILE {
@Override
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

Loading…
Cancel
Save