Browse Source

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

release/11.0
John.Ying-应志浩 2 years ago
parent
commit
a042152f1b
  1. 69
      designer-base/src/main/java/com/fr/design/utils/TemplateUtils.java

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

@ -173,41 +173,48 @@ public class TemplateUtils {
});
}
private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, @Nullable JTemplate<?, ?> template) {
createTemplate(file, oldPath, createByEditingTemplate).thenApply((Function<Boolean, Void>) aBoolean -> {
if (!aBoolean) {
//备份失败直接返回
return null;
/**
*
* @param file 模板文件
* @param openNewTemplate 是否需要打开新模板
* @param template 需要关闭的模板
*/
private static void openNewTemplate(FILE file, boolean openNewTemplate, @Nullable JTemplate<?, ?> template) {
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
if (JTemplate.isValid(template)) {
//给要关闭的模板解锁
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(template.getPath());
return true;
}
return false;
}
new SwingWorker<Boolean, Void>() {
@Override
protected Boolean doInBackground() throws Exception {
if (JTemplate.isValid(template)) {
//给要关闭的模板解锁
WorkContext.getCurrent().get(TplOperator.class).closeAndFreeFile(template.getPath());
return true;
@Override
protected void done() {
try {
if (get()) {
// 创建备份成功后,关闭原模板
HistoryTemplateListCache.getInstance().closeSelectedReport(template);
}
return false;
}
@Override
protected void done() {
try {
if (get()) {
// 创建备份成功后,关闭原模板
HistoryTemplateListCache.getInstance().closeSelectedReport(template);
}
if (openNewTemplate) {
DesignerContext.getDesignerFrame().openTemplate(file);
}
// 备份成功刷新下目录树 展示出来备份的模板
TemplateTreePane.getInstance().refresh();
} catch (Exception e) {
SaveFailureHandler.getInstance().process(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
if (openNewTemplate) {
DesignerContext.getDesignerFrame().openTemplate(file);
}
// 备份成功刷新下目录树 展示出来备份的模板
TemplateTreePane.getInstance().refresh();
} catch (Exception e) {
SaveFailureHandler.getInstance().process(e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}.execute();
}
}.execute();
}
private static void createAndOpenTemplate0(FILE file, String oldPath, boolean createByEditingTemplate, boolean openNewTemplate, @Nullable JTemplate<?, ?> template) {
createTemplate(file, oldPath, createByEditingTemplate).thenApply((Function<Boolean, Void>) aBoolean -> {
if (aBoolean) {
openNewTemplate(file, openNewTemplate, template);
}
return null;
});
}

Loading…
Cancel
Save