Browse Source

REPORT-92893 锁定的模板,重复另存副本,设计器页面模板内容不更新

release/11.0
roger 11 months ago
parent
commit
d5256c0193
  1. 32
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

32
designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.SwingWorker;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
@ -65,14 +66,7 @@ public class TemplateUtils {
if (file == null) {
return;
}
Runnable doAfterCreateTemplate;
//判断一下要保存的文件是否已打开
int index = HistoryTemplateListCache.getInstance().contains(file);
JTemplate template = null;
if (index != -1) {
template = HistoryTemplateListCache.getInstance().getHistoryList().get(index);
}
createAndOpenTemplate0(file, oldPath, createByEditingTemplate, openNewTemplate, template);
createAndOpenTemplate0(file, oldPath, createByEditingTemplate, openNewTemplate, null);
}
/**
@ -181,23 +175,29 @@ public class TemplateUtils {
* @param template 需要关闭的模板
*/
private static void openNewTemplateAndCloseOldTemplate(FILE file, boolean openNewTemplate, @Nullable JTemplate<?, ?> template) {
new SwingWorker<Boolean, Void>() {
new SwingWorker<List<JTemplate<?,?>>, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
protected List<JTemplate<?,?>> doInBackground() throws Exception {
List<JTemplate<?,?>> needCloseTemplate = new ArrayList<>();
//判断一下要保存的副本文件是否已打开
int index = HistoryTemplateListCache.getInstance().contains(file);
if (index != -1) {
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(file.getPath());
needCloseTemplate.add(HistoryTemplateListCache.getInstance().getHistoryList().get(index));
}
if (JTemplate.isValid(template)) {
//给要关闭的模板解锁
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(template.getPath());
return true;
needCloseTemplate.add(template);
}
return false;
return needCloseTemplate;
}
@Override
protected void done() {
try {
if (get()) {
//模板释放锁成功后关闭该模板
HistoryTemplateListCache.getInstance().closeSelectedReport(template);
}
//获取需要关闭的模板
List<JTemplate<?, ?>> jTemplates = get();
jTemplates.forEach(jTemplate -> HistoryTemplateListCache.getInstance().closeSelectedReport(jTemplate));
if (openNewTemplate) {
DesignerContext.getDesignerFrame().openTemplate(file);
}

Loading…
Cancel
Save