|
|
|
@ -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,22 +360,30 @@ public class HistoryTemplateListCache implements CallbackEvent {
|
|
|
|
|
int size = historyList.size(); |
|
|
|
|
for (int i = 0; i < size; i++) { |
|
|
|
|
JTemplate<?, ?> template = historyList.get(i); |
|
|
|
|
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())); |
|
|
|
|
} |
|
|
|
|
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
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); |
|
|
|
|
return new StashedFILE(file, outputStream.toByteArray(), template.suffix()); |
|
|
|
|
} |
|
|
|
|
// 如果 target == null 那么这个模板是被模板内存优化功能处理过的,不用处理
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean checkStash() { |
|
|
|
|
try { |
|
|
|
|
return stashWorker.get(); |
|
|
|
@ -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) { |
|
|
|
|
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); |
|
|
|
|
FILE stashFile = templateToStashFile(template); |
|
|
|
|
if (stashFile != null) { |
|
|
|
|
FineLoggerFactory.getLogger().info("{} is being reloaded", file.getName()); |
|
|
|
|
template.refreshResource(stashFile); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|